Haptics in the study loop, on both platforms - #233
Merged
Conversation
A `StudySessionEffect.Haptic(StudyHaptic)` on the ordinary effect flow, emitted where the loop actually turns: the flip, a grade, a checked or given-up answer, the microphone opening, a spoken attempt, a failed listen, the daily goal and the end of the session. Emitted here rather than fired on tap by the screens because whether a tap *did* anything is known here and nowhere else — a grade arriving while the previous one is still writing, a Check on an untypable card and a second reveal are all ignored, and buzzing for one of those tells the reader something happened when nothing did. Four patterns, sized to what both platforms can distinguish. The last card's grade deliberately does not tick: it and the completion's Success would land a few milliseconds apart and read as one smeared buzz rather than two events. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
Maps `StudyHaptic` onto `HapticFeedbackType` and performs it from the route's effect collector. Android offers one "that did not work" pattern, so Warning and Failure both land on Reject; the distinction between them is iOS's to make. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
The same effect through UIKit's generators — a light impact for a tick, and the notification generator's success/warning/error for the other three. The Taptic Engine is warmed on appear so the session's first buzz lands with the tap. Compared rather than pattern-matched: a Kotlin enum crosses as an object with class properties, not as a Swift enum. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
Adds the "decided in the ViewModel, never on tap" rule to CLAUDE.md, and the `dumpsys vibrator_manager` steps that are the only way to assert on a buzz from an emulator — including the one that catches a regression: tapping an already-flipped card must produce no entry at all. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The study loop had no haptics at all. It now buzzes where the loop actually turns — and, just as importantly, does not buzz where a tap changed nothing.
Where it fires
TickSuccessWarningFailureThe one design decision worth reviewing
The buzz is decided in
StudySessionViewModel, never fired on tap by a screen. Whether a tap did anything is known there and nowhere else: a grade arriving while the previous one is still writing, a Check on an untypable card and a second reveal are all ignored, and buzzing for one of those tells the reader something happened when nothing did. So it rides the ordinary effect flow asStudySessionEffect.Haptic(StudyHaptic), and the platforms only map it.Three consequences:
WarningandFailureare.warningand.erroron iOS; Android has one "that did not work" pattern and both land onReject.Successwould land a few milliseconds apart and read as one smeared buzz rather than two events.tryEmited, not emitted from a launched coroutine — one that has to queue for buffer space is better dropped than fired late against the next card. (Which is why the new testsrunCurrent()before the first tap.)Verified
An emulator has no actuator, so "did it buzz" was read back from
adb shell dumpsys vibrator_manager, which names the calling package, the constant and the pattern the framework played. Journeys 03 and 09 re-run onemulator-5554; full table injourneys/RESULTS.md.constant=6(ContextClick) →Prebaked=TICK, attributed tocom.github.jvsena42.loopkyconstant=16(Confirm), not 16 ticksconstant=17(Reject)Plus
:shared:jvmTest(a newStudySessionHapticsTest),detektAlland:composeApp:assembleDebug.iOS is written but unrun. There is no macOS on this machine — no
xcodebuildmcp, no simulator — soHaptics.swifthas not been compiled, let alone felt. It owes a run, andRESULTS.mdsays so.🤖 Generated with Claude Code
https://claude.ai/code/session_0116NZ92Pe7aGQpqtiRkP4Ye