Audible confirmation for explicit phone timer controls, with distinct round-completion feedback.
Successful saved start/resume plays one 0.18-second tone; pause/end plays that tone and a short impact haptic.
The same service covers both the circle and labelled controls. It does not observe redraws, restoration or remote changes.
Existing two-tone/two-pulse round completion and Watch behavior remain unchanged. PR #5 circular photos stays separate.
Ready to push
Four source reviews completed; the clock-interruption pause finding is fixed and independently confirmed. 18 focused timer domain tests and 2 affected phone UI journeys passed, plus strict lint and whitespace. Physical sound/haptic perception remains unverified. No install or merge.
A short single sound confirms that your phone timer started or resumed. Pausing or ending it also gives a short buzz.
You can tell a tap worked without watching the screen. The existing double completion sound still means a round finished.
Feedback follows the saved action, so a failed or repeated action does not sound successful.
TimerRunView routes both explicit controls through a retained PhoneTimerInteractionService. It reuses RoutineSessionService.changeTimer, then classifies the saved before/after checkpoints. A false result or thrown error emits nothing. The default callback retains a lazy AVAudioPlayer and UIImpactFeedbackGenerator; isolated tests inject a cue recorder instead.
The 0.18-second bundled mono 880 Hz tone is phone-only. Small audio playback duplication avoids widening the shared completion code or changing Watch behavior. Ambient playback respects silent mode and volume.
The coordinator emits only after the durable routine transaction returns true. Start/resume must result in running; pause must stop a previously running checkpoint into paused or interrupted. End must result in ended without increasing completedRounds. This makes boundary completion take precedence over the single cue. Reopen/advance remain silent, and feedback is not registered with MutationEffects or TimelineView.
The SwiftUI State-held coordinator retains the audio player between actions so playback survives the action closure. Sound failures do not roll back saved actions or suppress the pause/end haptic. Notification authorization remains separately governed. Hardware/system audio and haptic delivery cannot be established by simulator tests.
Phone timer start/resume/pause/end, replay silence, boundary precedence and clock-interrupted pauses are implemented. Existing ordered-session controls, Watch feedback and completion delivery are preserved. The focused synthetic checks pass; physical perception and deployment are deliberately pending.
Meddy/Meddy/Features/RoutineRunView.swift
Why it matters. One entry point covers the circle and primary labelled control without sounds during redraw or restoration.
What to look at. TimerRunView.transition
Meddy/Meddy/Services/PhoneTimerInteractionService.swift
Why it matters. A boundary pause can finish a round, while clock uncertainty can interrupt it. The cue follows the actual result.
What to look at. changeTimer
Meddy/MeddyTests/MeddyPhoneTimerInteractionTests.swift
Why it matters. Injected cue recording verifies order, replay silence, boundary precedence and clock mismatch without pretending to verify physical perception.
What to look at. MeddyPhoneTimerInteractionTests
Keep completion resources and shared/Watch source byte-identical; a short phone-only resource expresses the distinct interaction cue.
A pause/end tap that increments completedRounds emits no single-tone cue. Existing completion service owns the two-tone feedback.
The request concerns timer controls. Opening a child or pausing an ordered session retains existing behavior.
| Severity | Area | Finding | Resolution |
|---|---|---|---|
| minor | New synthetic fixture lifetime | The initial targeted run crashed because five tests dropped their ModelContainer before using its models. The owned run was stopped; its failed receipt is retained separately. | Retain the isolated container through test completion with the existing withExtendedLifetime pattern, then rerun the same focused checks. No production adjustment was needed. |
| minor | Clock uncertainty during pause | A running-to-interrupted pause stopped timing but originally had no interaction cue. | Include saved interrupted pauses, add continuity-mismatch regression, and independently recheck the final source. |
| minor | Design paragraph placement | Interaction feedback was inside the round-completion-only list. | Move the paragraph into the preceding timer-control section. |
| minor | Audio helper reuse | Ambient session and cached playback duplicate the private shared completion helper. | Retain the short phone-only implementation to avoid widening this change into shared/Watch refactoring. |
Source: local run at 2026-10-08T22:49:16.058956+00:00 · snapshot cae9798b5554f3c8bfaa0551336abd706fa56118
Baseline: none
Execution: passed · JUnit: 2 files · Coverage: none · Baseline: absent
Coverage scope: as the project configures it
Totals: 20 passed · 0 failed · 0 skipped · 0 errored · 0 flaky
Derived by declaration name, from the diff (no baseline run).
Files that import a changed file on the left, changed files in the centre, files a changed file imports on the right. Snapshot working-tree against base 100e77b01ea794ed8b35c59445bc56f6ade5f4e0.
7 files: 4 code · 3 docs. Click to expand.
diff --git a/Meddy/Meddy/Features/RoutineRunView.swift b/Meddy/Meddy/Features/RoutineRunView.swiftindex 6c1a36a..b81e6e6 100644--- a/Meddy/Meddy/Features/RoutineRunView.swift+++ b/Meddy/Meddy/Features/RoutineRunView.swift@@ -387,6 +387,7 @@ struct TimerRunView: View { @ScaledMetric(relativeTo: .largeTitle) private var timerTitleSize = 28 @State private var actionID = UUID() @State private var error: String?+ @State private var interactions = PhoneTimerInteractionService() private var service: RoutineSessionService { RoutineSessionService(context: context) } private var checkpoint: TimerCheckpoint? { try? service.timer(run) } private var definition: FrozenRoutineDefinition? { try? service.definition(run) }@@ -538,11 +539,12 @@ struct TimerRunView: View { } private func transition(_ operation: TimerOperation) { do {- try service.changeTimer(- run, actionID: actionID, clock: ExecutionClock.sample(), operation: operation)+ let changed = try interactions.changeTimer(+ run, service: service, actionID: actionID, clock: ExecutionClock.sample(),+ operation: operation) actionID = UUID() error = nil- if operation == .start || operation == .resume {+ if changed && (operation == .start || operation == .resume) { Task { guard !AppEnvironment.isTesting else { return } let center = UNUserNotificationCenter.current()
diff --git a/Meddy/Meddy/Services/PhoneTimerInteractionService.swift b/Meddy/Meddy/Services/PhoneTimerInteractionService.swiftnew file mode 100644index 0000000..87d71d2--- /dev/null+++ b/Meddy/Meddy/Services/PhoneTimerInteractionService.swift@@ -0,0 +1,69 @@+import AVFAudio+import Foundation+import UIKit++/// Feedback belongs to explicit phone controls, after their checkpoint has been saved.+/// Restoration, remote updates and round-boundary reconciliation never call this service.+@MainActor+final class PhoneTimerInteractionService {+ enum Cue { case started, stopped }++ private let feedback: (Cue) -> Void++ init(feedback: ((Cue) -> Void)? = nil) {+ let player = PhoneTimerInteractionFeedback()+ self.feedback = feedback ?? { cue in+ guard !AppEnvironment.isTesting else { return }+ player.play(cue)+ }+ }++ @discardableResult+ func changeTimer(+ _ run: RoutineRun, service: RoutineSessionService, actionID: UUID,+ clock: ClockSample, operation: TimerOperation+ ) throws -> Bool {+ let before = try service.timer(run)+ let changed = try service.changeTimer(+ run, actionID: actionID, clock: clock, operation: operation)+ guard changed else { return false }+ let after = try service.timer(run)+ switch operation {+ case .start, .resume:+ if after.phase == .running { feedback(.started) }+ case .pause:+ if before.phase == .running && [.paused, .interrupted].contains(after.phase) {+ feedback(.stopped)+ }+ case .end:+ if after.phase == .ended && after.completedRounds == before.completedRounds {+ feedback(.stopped)+ }+ case .reopen, .advance:+ break+ }+ return true+ }+}++@MainActor+private final class PhoneTimerInteractionFeedback {+ private var audioPlayer: AVAudioPlayer?+ private let haptic = UIImpactFeedbackGenerator(style: .medium)++ func play(_ cue: PhoneTimerInteractionService.Cue) {+ do {+ // The single tone, like completion audio, respects silent mode and system volume.+ try AVAudioSession.sharedInstance().setCategory(.ambient)+ if audioPlayer == nil {+ let url = Bundle.main.url(forResource: "TimerInteraction", withExtension: "wav")+ if let url { audioPlayer = try AVAudioPlayer(contentsOf: url) }+ }+ audioPlayer?.currentTime = 0+ audioPlayer?.play()+ } catch {+ // An unavailable sound must not suppress the pause/end haptic or saved action.+ }+ if cue == .stopped { haptic.impactOccurred() }+ }+}
diff --git a/Meddy/Meddy/Services/TimerInteraction.wav b/Meddy/Meddy/Services/TimerInteraction.wavnew file mode 100644index 0000000..e2eb159Binary files /dev/null and b/Meddy/Meddy/Services/TimerInteraction.wav differ
diff --git a/Meddy/MeddyTests/MeddyPhoneTimerInteractionTests.swift b/Meddy/MeddyTests/MeddyPhoneTimerInteractionTests.swiftnew file mode 100644index 0000000..4d9b917--- /dev/null+++ b/Meddy/MeddyTests/MeddyPhoneTimerInteractionTests.swift@@ -0,0 +1,141 @@+import AVFAudio+import Foundation+import SwiftData+import Testing++@testable import Meddy++@MainActor+struct MeddyPhoneTimerInteractionTests {+ private func fixture() throws -> (ModelContainer, RoutineRun, RoutineSessionService) {+ let store = try AppEnvironment.makeContainer(isolated: true)+ let routine = try RoutineService(context: store.mainContext).createTimed(+ name: "Synthetic interaction timer", rounds: 2, durationSeconds: 10)+ let service = RoutineSessionService(context: store.mainContext)+ return (store, try service.start(routine), service)+ }++ private func clock(_ time: Double) -> ClockSample {+ .init(wall: Date(timeIntervalSince1970: time), monotonic: time, continuityID: "synthetic")+ }++ @Test func interactionToneIsBundledAndShorterThanDistinctCompletionChime() throws {+ let single = try #require(Bundle.main.url(forResource: "TimerInteraction", withExtension: "wav"))+ let completion = try #require(Bundle.main.url(forResource: "RoundComplete", withExtension: "wav"))+ let singlePlayer = try AVAudioPlayer(contentsOf: single)+ let completionPlayer = try AVAudioPlayer(contentsOf: completion)+ #expect(singlePlayer.duration >= 0.1 && singlePlayer.duration <= 0.25)+ #expect(completionPlayer.duration > 0.5)+ }++ @Test func successfulControlsEmitOnceAfterSavingAndReplayedActionsStaySilent() throws {+ let (store, run, service) = try fixture()+ var cues: [PhoneTimerInteractionService.Cue] = []+ var savedPhases: [TimerPhase] = []+ let interactions = PhoneTimerInteractionService { cue in+ #expect(!store.mainContext.hasChanges)+ cues.append(cue)+ if let timer = try? service.timer(run) { savedPhases.append(timer.phase) }+ }+ let startID = UUID()+ #expect(try interactions.changeTimer(+ run, service: service, actionID: startID, clock: clock(100), operation: .start))+ #expect(try !interactions.changeTimer(+ run, service: service, actionID: startID, clock: clock(101), operation: .start))+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(102), operation: .pause)+ #expect(try service.timer(run).remaining(at: clock(500)) == 8)+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(500), operation: .resume)+ let endID = UUID()+ try interactions.changeTimer(+ run, service: service, actionID: endID, clock: clock(501), operation: .end)+ #expect(try !interactions.changeTimer(+ run, service: service, actionID: endID, clock: clock(502), operation: .end))+ #expect(cues == [.started, .stopped, .started, .stopped])+ #expect(savedPhases == [.running, .paused, .running, .ended])+ }++ @Test func boundaryCompletionAndExplicitNextRoundHaveDifferentFeedback() throws {+ let (store, run, service) = try fixture()+ defer { withExtendedLifetime(store) {} }+ var cues: [PhoneTimerInteractionService.Cue] = []+ let interactions = PhoneTimerInteractionService { cues.append($0) }+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(100), operation: .start)+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(110), operation: .pause)+ #expect(try service.timer(run).phase == .waiting)+ #expect(cues == [.started])+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(200), operation: .start)+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(210), operation: .end)+ #expect(try service.timer(run).phase == .completed)+ #expect(cues == [.started, .started])+ }++ @Test func endingExactlyAtAnIntermediateBoundaryDoesNotOverlapCompletion() throws {+ let (store, run, service) = try fixture()+ defer { withExtendedLifetime(store) {} }+ var cues: [PhoneTimerInteractionService.Cue] = []+ let interactions = PhoneTimerInteractionService { cues.append($0) }+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(100), operation: .start)+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(110), operation: .end)+ #expect(try service.timer(run).phase == .ended)+ #expect(try service.timer(run).completedRounds == 1)+ #expect(cues == [.started])+ }++ @Test func reopeningRestoringAndUnchangedAdvanceDoNotEmitInteractionFeedback() throws {+ let (store, run, service) = try fixture()+ defer { withExtendedLifetime(store) {} }+ try service.changeTimer(run, actionID: UUID(), clock: clock(100), operation: .start)+ try service.changeTimer(run, actionID: UUID(), clock: clock(102), operation: .end)+ var cues: [PhoneTimerInteractionService.Cue] = []+ let interactions = PhoneTimerInteractionService { cues.append($0) }+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(500), operation: .reopen)+ #expect(try service.timer(run).phase == .paused)+ #expect(try !interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(501), operation: .advance))+ _ = PhoneTimerControl(checkpoint: try service.timer(run), clock: clock(502))+ #expect(cues.isEmpty)+ }++ @Test func pauseThatReconcilesAClockMismatchStillConfirmsTheStoppedTimer() throws {+ let (store, run, service) = try fixture()+ defer { withExtendedLifetime(store) {} }+ var cues: [PhoneTimerInteractionService.Cue] = []+ let interactions = PhoneTimerInteractionService { cues.append($0) }+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(100), operation: .start)+ let mismatch = ClockSample(+ wall: clock(102).wall, monotonic: 102, continuityID: "changed-continuity")+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: mismatch, operation: .pause)+ #expect(try service.timer(run).phase == .interrupted)+ #expect(try service.timer(run).deadline == nil)+ #expect(try service.timer(run).completedRounds == 0)+ #expect(cues == [.started, .stopped])+ }++ @Test func rejectedAndDeletedRunActionsStaySilent() throws {+ let (store, run, service) = try fixture()+ defer { withExtendedLifetime(store) {} }+ var cues: [PhoneTimerInteractionService.Cue] = []+ let interactions = PhoneTimerInteractionService { cues.append($0) }+ #expect(throws: ExecutionError.invalidTransition) {+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(100), operation: .resume)+ }+ run.isDeleted = true+ #expect(throws: ExecutionError.unknownRun) {+ try interactions.changeTimer(+ run, service: service, actionID: UUID(), clock: clock(100), operation: .start)+ }+ #expect(cues.isEmpty)+ }+}
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 40538d3..dee61d6 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -15,6 +15,7 @@ - T2413: Keep notification snoozes at their chosen 15-minute deadline, cancel queued originals, suppress elapsed replay and await background scheduling completion. ### Added+- Short single-tone feedback for saved iPhone timer start/resume, and the same tone plus a short haptic for pause/end. Round completion retains its distinct two-tone/two-pulse feedback. - `make install` and `make install-release` for signed, in-place Debug/Release iPhone updates, with explicit device overrides and phone-only packaging. - Optional medication prescription date, doctor/clinic, user-entered supply-duration days and repeats left; profile-scoped editor/detail/export with explicit decrement and guarded Undo. - T2426: Short completion chime and longer per-round feedback: a two-pulse iPhone haptic pattern and two Watch notification pulses, subject to device sound/haptic settings.
diff --git a/docs/meddy-design.md b/docs/meddy-design.mdindex f6091b5..f02dc39 100644--- a/docs/meddy-design.md+++ b/docs/meddy-design.md@@ -1093,6 +1093,8 @@ Round 1 of 4 The timer must derive remaining time from a persisted deadline and accumulated active time, not by decrementing an integer every second. Paused time is excluded; resuming records a new start/deadline for the remaining time. This avoids UI drift and preserves progress across foreground changes. Use a monotonic clock while running where available; if clock changes/relaunch make elapsed time uncertain, show interrupted state for explicit resume/review rather than claiming completion. +Explicit iPhone timer start/resume plays one short single tone after the changed checkpoint is saved. Explicit pause/end plays that single tone plus a short haptic. Both the timer circle and labelled controls use this feedback. Opening a ready/saved timer, reopening without starting, repeated action IDs, rejected/failed actions, redraws, restoration and remote/background reconciliation do not emit it. If a pause/end tap reaches a round boundary, completion feedback takes precedence rather than overlapping the single tone. This changes phone timer controls only; ordered-session controls and Watch feedback retain their existing behavior. Ambient audio respects silent mode/volume; physical sound and haptic delivery remain subject to hardware and system settings.+ ### 12.5 Round completion At exactly the configured round duration:
diff --git a/docs/meddy-implementation-plan.md b/docs/meddy-implementation-plan.mdindex 60c852b..d5c902f 100644--- a/docs/meddy-implementation-plan.md+++ b/docs/meddy-implementation-plan.md@@ -1,6 +1,14 @@ # Meddy — Implementation task plan **Status:** Phone and companion source implemented and tested in isolation; live CloudKit and physical Watch acceptance remain unverified/deferred.++## Phone timer interaction feedback++Owner request: make accidental timer start/pause transitions audible. Both phone timer controls now route through `PhoneTimerInteractionService`: one 0.18-second synthetic tone for saved start/resume, and that tone plus a short impact haptic for saved pause/end. The existing completion sound/pattern, notification permission flow and Watch behavior remain separate. Ready-child navigation and Reopen do not start a timer or emit feedback. Replayed/no-op/rejected actions remain silent; round-boundary completion takes precedence. Audio respects silent mode and volume. No signing, entitlement, schema, account or deployment change is required.++Acceptance uses isolated saved timer transitions, duplicate action identities, boundary precedence, reopening/restoration and rejected actions, plus existing completion and phone control journeys. Simulator results establish state transitions and bundled audio availability; actual sound/haptic perception requires a physical iPhone check. Circular-photo PR #5 remains separate. Track this request locally while Transit writes are paused.++Focused validation on `cae9798`: 18 timer domain tests across interaction, completion-alert and control suites passed; both the large-circle start/pause/resume/next-round and saved-child return journeys passed (exit 0). Whitespace and strict SwiftLint passed, with zero violations in 113 files. The initial run exposed a new test-fixture container-lifetime bug; its failed receipt was retained and the fixture corrected before the passing rerun. No production workaround was needed. Owned test processes drained and assigned simulators returned to their original Shutdown states. No broad suite, physical install or merge ran; physical sound/haptic perception remains pending. **Date:** 6 October 2026 **Sources:** [Design including 6 October profile/wake amendments](meddy-design.md), [Implementation preflight v4](meddy-implementation-preflight.md). These remain authoritative. **Baseline:** `ecbc247` — First commit; existing project `Meddy/Meddy.xcodeproj`. The authoritative source documents are tracked repository copies; later user-approved amendments are recorded in place. Preserve their filenames and existing scope; the preflight's illustrative DESIGN.md/SETUP.md names do not require duplicate copies or renaming.
18 focused phone timer tests and 2 affected routine UI journeys passed on clean cae9798. The Xcode test actions built the app and test targets. Strict lint passed 113 files with zero violations. No broad suite, live CloudKit, personal health fixture, physical Watch or device install ran.
Bundled WAV decoding/duration and emitted cue intent are checked. Actual sound/haptic perception, silent-mode behavior and physical delivery still need an owner iPhone check.