Repository navigation
fix(mobile): harden terminal height refit (follow-up to #8647) - #8707
Merged
Merged
Conversation
Addresses review feedback on #8647: - Defer height refits while the keyboard is visible and coalesce every skipped layout change into one correction after the keyboard closes, via a pure reducer. Prevents an over-fit that settles with the keyboard up from surviving (on iOS the edge-to-edge keyboard doesn't change the frame height on close, so there was no later event to re-trigger it). - Drive height layout callbacks imperatively (notifyTerminalFrameHeight) instead of setState, so height-only layout bursts no longer re-render SessionScreen. - Cache the updateViewport capability (method_not_found -> unsupported): old desktops now get one unsupported probe then legacy resubscribe, instead of one probe per refit. Reconnect resets the cache so an upgraded desktop is re-detected. No server schema or subscription-protocol changes; desktop-first stays compatible. Tests: 703 mobile terminal/session pass; tsc, oxlint, formatting clean.
Contributor
📝 WalkthroughWalkthroughThe terminal viewport refit flow now uses imperative frame-height and keyboard-visibility notifications instead of local session state and refs. A reducer tracks keyboard-aware refit state and coalesces deferred frame-height changes. Window resize handling skips height-only refits while the keyboard is visible. The hook caches 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 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 |
Close a race in the keyboard-deferral: a height refit deferred at keyboard-close arms a 150ms debounce timer, and if the keyboard reopens inside that window the timer still fired and reflowed the PTY mid-keystroke. The timer callback now re-consults the reducer (new `refit-committed` event) when the armed refit is height-originated: if the keyboard is visible again it re-defers (pending) instead of reflowing, and runs on the next keyboard close. Scoped via a height-originated flag so width/rotation and the forced reconnect/foreground re-asserts stay unguarded and always run. Tests: reducer coverage for the reopen-during-debounce re-defer + a wiring assertion; 705 mobile terminal/session pass; tsc, oxlint clean.
8 of 9 tasks
enrick-dev
pushed a commit
to enrick-dev/orca
that referenced
this pull request
Oct 15, 2026
stablyai#8707) * fix(mobile): harden terminal height refit (follow-up to stablyai#8647) Addresses review feedback on stablyai#8647: - Defer height refits while the keyboard is visible and coalesce every skipped layout change into one correction after the keyboard closes, via a pure reducer. Prevents an over-fit that settles with the keyboard up from surviving (on iOS the edge-to-edge keyboard doesn't change the frame height on close, so there was no later event to re-trigger it). - Drive height layout callbacks imperatively (notifyTerminalFrameHeight) instead of setState, so height-only layout bursts no longer re-render SessionScreen. - Cache the updateViewport capability (method_not_found -> unsupported): old desktops now get one unsupported probe then legacy resubscribe, instead of one probe per refit. Reconnect resets the cache so an upgraded desktop is re-detected. No server schema or subscription-protocol changes; desktop-first stays compatible. Tests: 703 mobile terminal/session pass; tsc, oxlint, formatting clean. * fix(mobile): re-check keyboard when a deferred height refit fires Close a race in the keyboard-deferral: a height refit deferred at keyboard-close arms a 150ms debounce timer, and if the keyboard reopens inside that window the timer still fired and reflowed the PTY mid-keystroke. The timer callback now re-consults the reducer (new `refit-committed` event) when the armed refit is height-originated: if the keyboard is visible again it re-defers (pending) instead of reflowing, and runs on the next keyboard close. Scoped via a height-originated flag so width/rotation and the forced reconnect/foreground re-asserts stay unguarded and always run. Tests: reducer coverage for the reopen-during-debounce re-defer + a wiring assertion; 705 mobile terminal/session pass; tsc, oxlint clean.
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.
Follow-up to #8647 (already merged) addressing two concrete risks + a perf issue raised in review. Client-only — no server schema or subscription-protocol changes, so desktop-first stays compatible.
Changes
1. Defer keyboard-visible height refits, and re-check at fire time (correctness). #8647 skipped a height change while the keyboard was visible and never re-fired it — on iOS the edge-to-edge keyboard doesn't change the frame height on close, so an over-fit that settled with the keyboard up could survive. A pure reducer (
reduceTerminalFrameHeightRefit) now marks such changespendingand applies one correction when the keyboard closes. That correction is debounced 150 ms, so the reducer is re-consulted when the timer actually fires (refit-committed): if the keyboard reopened inside the debounce window it re-defers instead of reflowing mid-keystroke, and runs on the next close. Scoped via a height-originated flag so width/rotation and the forced reconnect/foreground re-asserts stay unguarded and always run.2. Height layout callbacks no longer re-render SessionScreen (perf). Height now dispatches imperatively via
notifyTerminalFrameHeight(...)instead ofsetTerminalFrameHeightstate, so height-only layout bursts stay off React's render path for the ~5k-line SessionScreen. (Width stays on state — it changes rarely.)3. Cache the updateViewport capability (efficiency + desktop-first compat). #8647 increased refit frequency; on an old desktop that returns
method_not_found, each refit meant another failed probe before the legacy-resubscribe fallback.updateViewportCapabilityRefnow recordsunsupported(narrowmethod_not_found-only predicate) so an old desktop probes once then goes straight to legacy resubscribe. Reconnect resets it so an in-place desktop upgrade is re-detected — mirroring the repo'sGitCapabilityCachepattern. The cache is a hook-local ref, so "one probe" is per mounted session / reconnect epoch, not process-global.Testing
vitest run src/terminal src/session→ 705 passed;tsc --noEmitclean; oxlint + formatting clean.react-native, which is why this whole suite avoids mounting). The reducer tests exercise the keyboard-visible coalescing and the reopen-during-debounce re-defer (refit-committed); source assertions verify the imperative notify path, the fire-time re-check scoped to height refits, and that height no longer routes throughsetState. The "zero refits while typing / zero re-render / one probe per epoch" behavior follows from those decisions — it is not proven by an end-to-end timer/RPC test.Ref #7350 — the base fix (#8647) targets this and is still pending on-device confirmation; this PR hardens the same path.