Repository navigation
fix(mobile): native desktop-mode keyboard lift stays on screen; metrics carry the row pitch - #23070
Conversation
…rics Carried from 2eab7633013 and 62113b7ac30 with the `rowPitch` metric they need (from f7d78405c7d, without its page-only lift). The document reports the drawn row pitch, cell height times fit scale, and reports again when a fit commits a new scale. The metrics handler compared four fields and dropped an update that moved only the pitch, so desktop display mode kept the phone's 15 px pitch; it now compares every field. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
… hides of the grid Carried from 097f5d8d33f, native rule only. Desktop display mode draws 40 rows about 270 dp tall, and a lift by the covered strip (312 on Pixel_API_37) moved the whole grid under the header. The lift is now also capped by the hidden strip of the drawn grid. A sweep shows it equals base's arithmetic whenever the drawn grid fills the frame, which phone mode always does. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…t by behaviour A caret mid-grid in desktop display mode lifts only enough to clear its row, which the anchor term decides; without it the lift was the whole hidden strip and no test noticed. The fit commit's re-emit is now asserted by committing a fit and reading the pitch it reports, rather than by the order of two lines in the source. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
The tests typecheck ratchet refused the double: the seam's rect carries `left` and `top` too. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 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 (4)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review. 📝 WalkthroughWalkthroughKeyboard-avoidance metrics now include an optional row pitch calculated from measured cell height and total scale. Fit commits emit metrics after repositioning, and text scaling applies a fit when the requested font size already matches. Lift calculations use row pitch to bound lifts for grids drawn smaller than their terminal frames. Tests cover metrics parsing and equality, fit and pinch behavior, and lift calculations. The callback-body hash pin is updated. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to A changed-preset pinch on a narrow grid can leave keyboard-lift metrics stale until a later refit. This is a bounded edge case, but it warrants owner awareness or a fix before merging. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The change affects terminal display positioning, not terminal permissions or command authority. The new measurement is validated before use. Delayed display updates during terminal replacement remain an uncertainty. Retained concerns Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description gives detailed user impact, implementation details, rationale, evidence, and test coverage. However, it does not complete required template items, including the linked issue, visual proof or an explicit N/A explanation, the Testing section and checkboxes, and the remaining checklist sections. Resolution Add a valid issue reference after “Fixes #”. Add before-and-after visual proof, or state N/A with a reason if no visual or interaction change applies. Complete the Testing section with manual-test status and platforms, and complete or explicitly address the required checklist and other template sections.
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 96020489-b6d9-443e-acd1-7d0ef9404101
📒 Files selected for processing (10)
mobile/src/session/mobile-session-route-parity.test.tsmobile/src/session/use-mobile-session-accessory-selection.tsmobile/src/terminal/document/fit-scale.tsmobile/src/terminal/document/keyboard-avoidance-metrics.tsmobile/src/terminal/document/viewport-transform.tsmobile/src/terminal/terminal-keyboard-avoidance-lift.test.tsmobile/src/terminal/terminal-keyboard-avoidance-lift.tsmobile/src/terminal/terminal-keyboard-avoidance-webview.test.tsmobile/src/terminal/terminal-webview-contract.test.tsmobile/src/terminal/terminal-webview-contract.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Picks up #23073 (mobile typecheck fix on main) so CI runs on a current merge ref. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Desktop-mode lift capped by the drawn grid —
computeActiveTerminalKeyboardLiftnow detects a grid drawn short of the frame (rows * pitch < frame - pitch) and lifts only what the keyboard hides of it, clearing the caret row plus one row; base arithmetic is untouched wherever the grid fills the frame. rowPitchadded to the keyboard-avoidance metrics — emitted ascellHeight * totalScale(via the newgetMeasuredCellHeight), re-emitted on every fit commit, and parsed only when a finite value > 0 so absent/zero/malformed payloads fall back to the previous arithmetic.- Session dedupe compares every field —
sameTerminalKeyboardAvoidanceMetricsreplaces the four-field inline check, so a fit-scale change that moves only the pitch is no longer dropped (route-parity body pin refreshed accordingly). - Tests — lift cap/anchor, a >500-case sweep against a copy of the base arithmetic, pitch reporting/parsing, the fit-commit re-emit, and the field-by-field comparison.
Verified locally: the four touched mobile vitest files pass (terminal-keyboard-avoidance-lift, terminal-keyboard-avoidance-webview, terminal-webview-contract, mobile-session-route-parity). The new optional field survives the WebView→RN bridge unmodified, and the document uses width=device-width, initial-scale=1 with a top-left transform-origin, so the CSS-px pitch and the RN frame height share a coordinate space.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
A pinch moves the drawn row pitch through userScale. A release onto the same text-size preset skipped the refit, so no metrics were emitted and a write made mid-gesture left the lift reading the transient pitch. applyTextScale now says whether it scheduled the refit, and the release emits when it did not. The text-scale frame also emitted a transient pitch after its resize, before the fit it schedules commits and emits the final one. Drop that emit so a preset change reports once. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: adb05763-f928-4432-aa7f-8c2e262a5d5a
📒 Files selected for processing (4)
mobile/src/terminal/document/document-host-root.test.tsmobile/src/terminal/document/surface-touch-gestures.tsmobile/src/terminal/document/text-scaling.tsmobile/src/terminal/terminal-keyboard-avoidance-webview.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.
| } | ||
| const rows = Math.max(8, Math.floor(scope.viewportRect().height / cellH)) | ||
| scope.term.resize(cols, rows) | ||
| emitKeyboardAvoidanceMetrics(scope) | ||
| } | ||
| applyFitScale(scope, 'text-scale') | ||
| }) | ||
| return true | ||
| } | ||
|
|
||
| export function startTextScaling(scope: TerminalDocumentScope) { |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '50,105p' mobile/src/terminal/document/text-scaling.ts
sed -n '215,250p' mobile/src/terminal/document/surface-touch-gestures.ts
sed -n '75,175p' mobile/src/terminal/document/fit-scale.tsRepository: stablyai/orca
Length of output: 6973
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- changed diff ---'
git diff --no-ext-diff aed59a797ad5632080aa4b306c7c0508d9e0b951 1e39a2a7d77fc6a854ec5fc72c9ba2ab2e0efc34 -- mobile/src/terminal/document/text-scaling.ts mobile/src/terminal/document/surface-touch-gestures.ts
printf '%s\n' '--- text-scaling bindings ---'
rg -n -C 4 'MIN_FIT_COLS|emitKeyboardAvoidanceMetrics|applyTextScale|applyFitScale' mobile/src/terminal/document
printf '%s\n' '--- metric definitions and consumers ---'
rg -n -C 5 'keyboard.?avoidance|keyboardAvoidance|avoidanceMetrics|rowPitch|host.*metric|metrics' mobile/src mobile --glob '!**/node_modules/**' | head -240Repository: stablyai/orca
Length of output: 41363
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- changed diff ---'
git diff --no-ext-diff aed59a797ad5632080aa4b306c7c0508d9e0b951 1e39a2a7d77fc6a854ec5fc72c9ba2ab2e0efc34 -- mobile/src/terminal/document/text-scaling.ts mobile/src/terminal/document/surface-touch-gestures.ts
printf '%s\n' '--- relevant bindings ---'
rg -n -C 4 'MIN_FIT_COLS|emitKeyboardAvoidanceMetrics|applyTextScale|applyFitScale' mobile/src/terminal/document
printf '%s\n' '--- metric consumers ---'
rg -n -C 5 'keyboard.?avoidance|keyboardAvoidance|avoidanceMetrics|rowPitch' mobile/src --glob '!**/node_modules/**'Repository: stablyai/orca
Length of output: 41975
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- fit-scale continuation ---'
sed -n '170,230p' mobile/src/terminal/document/fit-scale.ts
printf '%s\n' '--- fittedBox and viewport refit bindings ---'
rg -n -C 6 'fittedBox|observeViewport|viewportRect|applyFitScale\\(' mobile/src/terminal/document --glob '*.ts'
printf '%s\n' '--- keyboard metrics emitter and host consumer ---'
sed -n '1,130p' mobile/src/terminal/document/keyboard-avoidance-metrics.ts
rg -n -C 8 'onKeyboardAvoidanceMetrics|computeActiveTerminalKeyboardLift|keyboardAvoidanceMetrics' mobile/src --glob '*.ts'
printf '%s\n' '--- pinch handler registration and guards ---'
rg -n -C 8 'attachSurfaceEventHandlers|isPinching|touchstart|touchmove|touchend|touches' mobile/src/terminal/document --glob '*.ts'Repository: stablyai/orca
Length of output: 1741
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- fit-scale continuation ---'
sed -n '170,230p' mobile/src/terminal/document/fit-scale.ts
printf '%s\n' '--- fittedBox and viewport refit bindings ---'
rg -n -C 6 'fittedBox|observeViewport|viewportRect|applyFitScale\(' mobile/src/terminal/document --glob '*.ts'
printf '%s\n' '--- keyboard metrics emitter and host consumer ---'
sed -n '1,130p' mobile/src/terminal/document/keyboard-avoidance-metrics.ts
rg -n -C 8 'onKeyboardAvoidanceMetrics|computeActiveTerminalKeyboardLift|keyboardAvoidanceMetrics' mobile/src --glob '*.ts'
printf '%s\n' '--- pinch handler registration and guards ---'
rg -n -C 8 'attachSurfaceEventHandlers|isPinching|touchstart|touchmove|touchend|touches' mobile/src/terminal/document --glob '*.ts'Repository: stablyai/orca
Length of output: 42536
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- metric emitter ---'
cat -n mobile/src/terminal/document/keyboard-avoidance-metrics.ts | sed -n '1,115p'
printf '%s\n' '--- viewport observer implementations ---'
rg -n -F 'observeViewport' mobile/src
printf '%s\n' '--- host metric route and lift consumer ---'
rg -n -F 'onKeyboardAvoidanceMetrics' mobile/src
rg -n -F 'computeActiveTerminalKeyboardLift' mobile/src
printf '%s\n' '--- exact lift fallback ---'
sed -n '1,180p' mobile/src/terminal/terminal-keyboard-avoidance-lift.tsRepository: stablyai/orca
Length of output: 10457
🏁 Script executed:
#!/bin/bash
set -e
printf '%s\n' '--- mounted viewport observer ---'
sed -n '175,220p' mobile/src/terminal/terminal-web-document-mount.ts
printf '%s\n' '--- window viewport observer ---'
sed -n '320,365p' mobile/src/terminal/document/document-scope.ts
printf '%s\n' '--- session metric state update ---'
sed -n '130,210p' mobile/src/terminal/use-terminal-webview-controller.ts
rg -n -C 8 'handleKeyboardAvoidanceMetrics|keyboardAvoidanceMetrics' mobile/src/session --glob '*.ts*'Repository: stablyai/orca
Length of output: 11984
Emit keyboard-avoidance metrics before the narrow-grid return.
When a changed pinch release computes fewer than MIN_FIT_COLS columns, applyTextScale returns true, so the pinch handler skips its direct emission. The deferred callback then returns after clearing fittedBox, before applyFitScale emits metrics. A later ResizeObserver callback may refit, but until then the host retains the old row pitch and can calculate keyboard lift from stale metrics.
Suggested fix
+import { emitKeyboardAvoidanceMetrics } from './keyboard-avoidance-metrics'
if (cols < MIN_FIT_COLS) {
// Why: hidden (0 wide) or too narrow; the next box must refit at the new cell size.
scope.fittedBox = null
+ emitKeyboardAvoidanceMetrics(scope)
return
}There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed the one commit since the prior pullfrog review at 2da942f0 — 1e39a2a ("report keyboard-avoidance pitch after a pinch release"), which addresses CodeRabbit's finding about a pinch release onto an unchanged text size.
- A same-size pinch release re-reports the at-rest pitch —
applyTextScalenow reports whether it scheduled a refit, and the surfacetouchendhandler emitskeyboard-avoidance-metricsdirectly when it did not, so the lift no longer keeps reading the transient pitch a mid-gesture write left behind. - A preset-changing release reports once — the direct emit inside the
text-scaleframe (afterresize, before the fit) is removed; the metrics now reach the session only throughcommitFitScale, so a reflow reports a single final pitch instead of a transient followed by the final. - Tests —
document-host-root.test.tsgains a measured-grid pinch harness with one case pinning the same-preset release restoring the at-rest pitch and one pinning the preset-changing release reporting exactly once; the geometry-site contract test now pointstext-scalingat itsapplyFitScalecall, whose commit emit is pinned separately.
I traced the emission coverage: the same-preset release emits synchronously at rest, the changed-preset release emits via commitFitScale, and onWriteParsed still emits on every parsed write. The return true/false contract holds on every path the caller can reach.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
The pinch release emitted metrics itself whenever applyTextScale said no refit was scheduled. A release onto a preset a settings change had just applied saw an unchanged font size and emitted the pre-refit pitch, one frame before the refit reported the real one. A same-size applyTextScale now schedules the fit too, so every text-scale change reports through commitFitScale. A pending refit supersedes that fit by token. applyTextScale returns nothing and the release emits nothing. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This increment re-reviewed the two commits since the prior pullfrog review at 1e39a2a — 7c62f41 ("report text-scale pitch only through the fit commit") and the origin/main merge.
- Text-scale pitch is reported only through the fit commit —
applyTextScaleno longer returns a refit flag and the surfacetouchendhandler no longer emits; a same-font-size change now callsapplyFitScale(scope, 'text-scale'), andcommitFitScaleunconditionally emitskeyboard-avoidance-metricsafter it writes the new scale into the transform. A pinch release onto a preset a settings change just applied can no longer report the transient pre-refit pitch. - The changed-size frame's direct emit was removed — metrics now reach the session through the refit the frame schedules, so a text-scale change has one emission site instead of two.
- Tests —
document-host-root.test.tsgains a same-preset-release-at-rest-pitch pin, a preset-changing release "reports once through the refit" pin, and a "release lands while a refit is pending" pin asserting exactly one post-refit pitch; the webview contract test asserts from source thatapplyTextScalecarries no boolean return and thatsurface-touch-gesturesholds no emit.
I traced emission coverage for the new design: the emitted rowPitch is read from the same live cell height and total scale that commitFitScale just applied, the same-size branch cannot take the narrow-grid early return, and a superseding refit invalidates an in-flight one by fitRetryToken. The remaining non-commit exits are a 0-width/hidden host or an unopened terminal, neither of which has a drawn grid to mismatch. The five touched mobile vitest files pass at this head.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
Carries #23070 (row pitch emitted once, at the fit commit) and #23079 (the page pushes its frame box; one contentFrame View holds onLayout). The frame's onLayout keeps this branch's unrounded width and frame-layout subscribe; the scope keeps hostFrame beside fitPending (fittedBox left with main's fit rewrite); a text-scale change fits through the one fitDimensionsFromCell, over the viewport until a measure gives the frame, and a too-narrow fit still commits through applyFitScale. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

What
Two native keyboard-lift fixes found while working on the page's keyboard handling. They change native behaviour, so they ship on their own, separate from the OTA-only redesign.
Native desktop display mode with the keyboard up was blank. The lift used the covered strip of the frame (312 px on a Pixel-class phone) even when the drawn grid was much shorter than the frame, so the whole grid moved off screen. The lift is now also capped by what the keyboard hides of the drawn grid:
min(covered strip, hidden strip of the drawn grid), anchored on the caret row as before. Whenever the drawn grid fills the frame the result is identical to before (phone mode: 312, unchanged). In desktop mode the caret stays visible above the dock; when the hidden strip is the binding limit the caret row sits flush on the dock, with no one-row margin.A metrics change in row pitch alone was dropped. The session's keyboard-metrics dedupe compared cursor, rows and alt-screen only. The metrics now carry the drawn row pitch (cell height × fit scale, re-emitted on every fit commit), and every field is compared.
A pinch that released onto the same text size left the pitch stale (CodeRabbit's finding).
applyTextScalereturned early when the font size was unchanged, so nothing re-emitted after the pinch scale reset. Now a same-size text-scale change schedules the fit too, so the fit commit is the only place row pitch is reported: no boolean hand-off between the release and the refit, and no transient pitch. That also fixes a settings change followed by a same-preset release before the refit ran, which reported the pre-refit pitch.No wire change: the metrics message is document → session inside the app; the new field is optional and an absent, zero or malformed value falls back to the previous arithmetic.
Evidence
Emulator (Pixel_API_37, native): phone mode lift 312 unchanged; desktop mode lift 0 with the caret above the dock (previously blank). Reviewer's 200k-case random property check: every case where the drawn grid fills the frame equals the previous arithmetic exactly; the cap path never puts the caret under the dock.
Tests (red first)
terminal-keyboard-avoidance-lift.test.ts: desktop-mode cap, >500-case sweep against the previous arithmetic, mid-grid anchor (caret row 46 lifts 6.3, row 45 lifts 0; the mutant without the anchor term lifts 23.3).terminal-keyboard-avoidance-webview.test.ts,terminal-webview-contract.test.ts: pitch carried and parsed; a change in pitch alone is no longer dropped; a fit commit at scale 0.5 over 15 px cells reports pitch 7.5.document-host-root.test.ts: a pinch releasing onto the same preset reports the at-rest pitch (expected 10.815 to be 10.3before); a release that changes the preset reports once, through the refit (expected 5 to be 4before); a release while a refit is pending never reports the pre-refit pitch (expected [15.846…, …] to deeply equal [23.076…]before).