Repository navigation
fix(mobile): make OMP terminal momentum refresh-rate independent - #21687
Conversation
dc12419 to
dfd4f12
Compare
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe momentum scrolling callback now uses elapsed time between animation frames to calculate friction and scroll displacement. The scroll-routing tests capture the updated function signature and verify the timing calculations. The golden terminal output reflects the same changes. The payload hash test updates its expected digest and document length. Priority: ➖ Normal 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 4 files. (1 skipped: 1 unsupported.)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Momentum integrates by real frame time:
momentumStepnow receives therequestAnimationFrametimestamp and deriveselapsed(16 ms on the first frame, clamped to[1, 50]ms), then scales both friction (Math.pow(FRICTION, elapsed / 16)) and displacement (vel * elapsed) by it. A fling now covers the same distance over the same wall-clock time at 60/90/120/144 Hz, while the 60 Hz baseline is preserved. - Regression assertions updated: the momentum
sliceBetweenboundaries now matchmomentumStep(frameTime), and new assertions pin the elapsed expression, the friction exponent, andvel * elapsed.
I verified the units (ts.velY is px/ms from Date.now() deltas, rAF timestamps are ms, so vel * elapsed is px), the closure scoping of lastMomentumTime (fresh per touchend, so launches don't share state), and that the total fling distance is unchanged (16·v0/(1−FRICTION)) — only the completion time was refresh-rate dependent. The focused suite passes 14/14 locally.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- First-frame elapsed now measured from touch release:
lastMomentumTimeis seeded withperformance.now()attouchendinstead of the=== 0sentinel with a hardcoded 16 ms default, so the first momentum frame integrates the real touch-release-to-first-frame delay (sameDOMHighResTimeStamptime origin, clamped to[1, 50]ms). The test now pinsperformance.now()and the simplified elapsed expression.
This is an improvement over the previous revision — the first frame is now accurate rather than assumed, and the sentinel is gone. The focused suite still passes 14/14 locally.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to GitHub limitations.
🟡 Minor · Honor the native reduced-motion preference in terminal momentum. · surface-touch-gestures.ts:220
mobile/src/terminal/terminal-webview-html/surface-touch-gestures.ts:220
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick winHonor the native reduced-motion preference in terminal momentum.
When
touchendleaves no touches and velocity exceedsMIN_VEL, this WebView startsmomentumStep, which keeps requesting frames.TerminalWebViewpassesXTERM_WEBVIEW_SOURCEwithout reduced-motion handling. The existinguseReducedMotionEnabledhook is used only by onboarding. Pass the native preference into the terminal HTML and skip both momentum scheduling calls when it is enabled.Source: Learnings
🧹 Nitpick comments (1)
mobile/src/terminal/terminal-webview-scroll-routing.test.ts (1)
181-186: 📐 Maintainability & Code Quality | 🔵 Trivial | 🏗️ Heavy liftTest momentum outcomes instead of source text.
These assertions only confirm implementation strings. They can pass while browser-level momentum behavior regresses. Add a browser-level test that drives animation frames at 60 Hz, 90 Hz, and 144 Hz and compares displacement and velocity decay.
Based on learnings: animation behavior requires browser validation, and tests should assert observable behavior instead of implementation details.
Source: Learnings
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: eb0ba0de-db65-47f4-bac8-171075c7d2de
📥 Commits
Reviewing files that changed from the base of the PR and between e8a7be4 and dfd4f12c03b9b4b3e7b5ea33979b390cd7182ffe.
📒 Files selected for processing (2)
mobile/src/terminal/terminal-webview-html/surface-touch-gestures.tsmobile/src/terminal/terminal-webview-scroll-routing.test.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.
dfd4f12 to
7bbd338
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This increment (delta against the prior pullfrog review at dfd4f12) completes the generated WebView payload contract for the momentum change; the momentum physics itself was reviewed in the two prior runs.
- Synced the WebView payload contract:
terminal-webview-payload-hash.test.tsnow pinsEXPECTED_SHA256to8ca3804…andEXPECTED_LENGTHto730681, matching the deliberate change to the emittedXTERM_HTML. The length delta (+209) reconciles exactly with the added momentum lines (lastMomentumTime,elapsed, theMath.powfriction, andvel * elapsed). - Regression assertions unchanged: the scroll-routing suite still pins the
momentumStep(frameTime)boundary and the elapsed/friction/displacement expressions.
Both focused suites pass locally (15/15). No new issues and no open pullfrog threads.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Verification update: the new mobile bundle, static analysis, payload/scroll verification, and Pullfrog checks pass. The required |
Visual proofI ran a browser-level visual harness against the exact PR source and recorded the momentum paths at synthetic 60 Hz and 144 Hz frame intervals. The harness asserts:
Measured final distances in the passing run:
This is a browser-level proof of the physics change, not physical Android hardware evidence. The linked Android 144 Hz issue should remain open until a real device frame trace is captured. |
6585eea to
de87571
Compare
Visual proof (rebased head)I reran the browser-level visual harness against the rebased implementation in Passing measurements:
The video is browser-level proof of the physics change, not physical Android hardware evidence. Issue #14573 remains open pending a real Android 144 Hz frame trace. |
There was a problem hiding this comment.
Important
terminal-document-identity.test.ts fails on this branch — the committed golden fixture still holds the pre-change momentum code.
Reviewed changes
This increment is a rebase onto a newer main (which moved the hand-written document script into src/terminal/document/ modules) plus a re-derived payload contract. The momentum physics is unchanged from the previously reviewed revision.
- Momentum edit relocated to
document/:momentumStepnow takes the rAFframeTimeand integrates friction (FRICTION ** (elapsed / 16)) and displacement (vel * elapsed) by clamped elapsed wall-clock time inmobile/src/terminal/document/surface-touch-gestures.ts. - Payload contract re-derived:
EXPECTED_SHA256/EXPECTED_LENGTHupdated to775a1294…/726574; the payload-hash and scroll-routing suites pass 15/15 locally. - Regression assertions updated to the new
momentumStep(frameTime)boundary and the elapsed/friction/displacement source strings.
⚠️ The committed golden document fixture was not regenerated
terminal-document-identity.test.ts compares the emitted document byte-for-byte against mobile/src/terminal/terminal-document-golden.txt, and that fixture still carries the old momentum code (let momentumStep = function() { vel *= FRICTION; … const delta = vel * 16; }, no lastMomentumTime/elapsed). The suite fails 2/3 on this branch, so pnpm --dir mobile test and CI go red. The payload-hash digest was updated, but the fixture that shows where the bytes moved was not — the test file itself calls an un-updated golden a blocking finding.
Technical details
# Regenerate the terminal document golden fixture
## Affected sites
- `mobile/src/terminal/terminal-document-golden.txt:3264` — still has `let momentumStep = function() {`, `vel *= FRICTION;`, `const delta = vel * 16;`, and no `lastMomentumTime`/`elapsed`
- `mobile/src/terminal/terminal-document-identity.test.ts:39` — byte-for-byte comparison against that fixture (also fails the placeholder round-trip at line 58)
## Required outcome
- `pnpm --dir mobile test src/terminal/terminal-document-identity.test.ts` passes 3/3.
- The fixture diff contains only the momentum lines, with no unrelated drift.
## Suggested approach
- From `mobile/`, run `node scripts/build-terminal-document-fixture.mjs` and commit the regenerated `terminal-document-golden.txt`. Verified locally on this branch: it produces a 6-insert/3-delete diff that is exactly the momentum change, and restores the suite.
- Per the test's own rule, note the fixture update in the commit message so the golden move is reviewable.DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Use elapsed animation-frame time for OMP terminal momentum and update the generated payload contract.
de87571 to
e22ecea
Compare
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This increment (delta against the prior pullfrog review at de87571) resolves that review's blocking finding and completes the generated payload contract; the momentum physics is unchanged from the already-reviewed revision.
- Regenerated the golden fixture:
terminal-document-golden.txtnow carries the momentum change (momentumStep(frameTime),elapsed,FRICTION ** (elapsed / 16),vel * elapsed,lastMomentumTime). The diff is exactly the momentum lines with no unrelated drift, andterminal-document-identity.test.tspasses 3/3 byte-for-byte. - Payload contract re-derived:
EXPECTED_SHA256/EXPECTED_LENGTHset to775a1294…/726574; the payload-hash suite passes. - Regression assertions aligned: the momentum
sliceBetweenboundaries now matchmomentumStep(frameTime)and pinperformance.now(), the clamped elapsed expression, the friction exponent, andvel * elapsed.
The full mobile/src/terminal suite passes locally (67 files, 630 tests) and pnpm --dir mobile typecheck passes. No prior pullfrog threads were open, and the golden fixture's absence was the only outstanding concern.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
`bd860f34c1` (#21687, OMP terminal momentum normalised across refresh rates) landed on main and moved the same three files this branch does. Document modules #21687 changed: `surface-touch-gestures.ts` only, and only inside the momentum loop of its touchend handler — `momentumStep` takes the animation frame's timestamp, holds `lastMomentumTime`, decays by `FRICTION ** (elapsed / 16)` and scales the delta by `elapsed` instead of a fixed 16 ms. It auto-merged with this branch's change to the line above it (`touches.length === 0`, fold 5), so the module carries both: the loop is main's and the count is this branch's. No other document module was touched by either side in the same file, and there was no module-level conflict to resolve. `terminal-document-golden.txt` and `terminal-webview-payload-hash.test.ts` conflicted because both sides re-pinned them. Resolved by regenerating from the merged modules (`node scripts/build-terminal-document-script.mjs`, then `build-terminal-document-fixture.mjs`), never by taking a side: the golden now carries main's six momentum lines and this branch's seven `touchesInRoot` lines, which is the only reading of the merge that is true of the modules. Golden byte length: 729,152 on this branch and 726,574 on main, 729,363 merged. Fixture 111,329 bytes. sha256 0263338994... (ours) and 775a129414... (main's) -> 0be398e4d7... Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

ELI5
A 144 Hz screen asks for animation frames more often than a 60 Hz screen. OMP terminal momentum used to move a fixed 16 ms on every frame, so the same swipe could travel a different distance depending on the display. This PR measures the real time between frames and keeps the physical scrolling behavior consistent.
What Changed
requestAnimationFrametimestamp andperformance.now()release anchor for momentum.Why
The fixed per-frame step was refresh-rate dependent. The elapsed-time integration is the smallest change that preserves the existing 60 Hz tuning while making 90/120/144 Hz behavior deterministic. It avoids introducing a new animation library, timer, native dependency, or mobile wire change.
Linked Issue
Relates to #14573 (keep the issue open until physical Android 144 Hz frame evidence is captured).
Visual Proof
N/A — this is WebView gesture physics; the available hosts have no Android 144 Hz device or frame-time capture. The interaction path is covered by the focused scroll-routing tests.
Testing
Commands and results:
pnpm --dir mobile test src/terminal/terminal-webview-scroll-routing.test.ts— 14/14 passed.pnpm --dir mobile typecheck— passed.pnpm --dir mobile exec oxlint src/terminal/terminal-webview-html/surface-touch-gestures.ts src/terminal/terminal-webview-scroll-routing.test.ts— passed.pnpm --dir mobile exec oxfmt --check src/terminal/terminal-webview-html/surface-touch-gestures.ts src/terminal/terminal-webview-scroll-routing.test.ts— passed.AI Disclosure
Internal StablyAI contributor; no external AI disclosure required.
Review
Reviewed the changed momentum path for frame timing, friction scaling, edge termination, terminal-input routing, and payload contract updates. The branch contains one focused commit and three files only.
Agent skill upstream boundary
Notes
Math.powper momentum frame; no new timer or listener.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass (or CI will cover; local preferred)