Repository navigation
fix(mobile): an accessory Enter ends the field's editing session, and the page's Enter survives a composition - #22300
Conversation
…sition The emulator's page-only defect, in a browser: an Android soft keyboard keeps a composition open over the word being typed, so the Enter keydown carries `isComposing: true`, which is the condition react-native-web reads to skip `onSubmitEditing` entirely. Nothing reaches the terminal and the field keeps the text. The probe route now mounts `useTerminalLiveInputCommit` and the command dock's own field props, so keys enter through the browser rather than through a handle that calls the hook directly. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
react-native-web's keydown handler withholds `onSubmitEditing` whenever the Enter keydown reports a composition — `nativeEvent.isComposing`, or the Android `keyCode` 229 that stands for it — which is a soft keyboard's normal state mid-word. Nothing reached the terminal and the field kept the text. Native Android's editor action has no such suppression, which is why only the page showed it. The field now also claims `beforeinput`/`insertLineBreak`, the browser's own end-of-line signal. react-native-web cancels every keydown it does submit on, so that event exists only in the cases it dropped, never twice; an IME still choosing a candidate reports `insertCompositionText` and is left alone. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…on closure The `.web.ts` sibling needed its row in `web-overrides.json`, whose check lists exactly the overrides on disk. The session route's page closure moves with it: the callback ref and the binding it resolves to are both local, and the native sibling stays out, which is what the pair is for. modules 4207 -> 4209 (+2) local modules 1021 -> 1023 (+2) Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ve field The device trace's variant (a), which is what shots/23 was: the chip emits no DOM key event, so react-native-web's submit handling never runs and the accessory hook is the only thing that could end the field's editing session. With nothing held it takes the send-now branch, which flushes nothing and writes neither the capture state nor the field, so the text the PTY already echoed stays put and the next keystrokes append to it. Not a page defect: the held-text fallback only holds a trailing non-ASCII run, so ASCII leaves nothing held on native either. The unit case is on the shared hook for that reason. The probe route now models what the send actions do with 'allow-raw', so the check can see a control sent twice or not at all. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ate too Three cases, one red. A plain Enter sends the draft and empties the field, which is `beginBufferedTerminalDraftSend`'s doing and stays a guard. The key bar's Enter chip in buffered mode is a plain terminal key: the accessory hook declines at its live-handle guard, one carriage return goes out and the draft is untouched, also a guard. The red one is Enter under an open composition. This field reaches its send through `onSubmitEditing` alone, so react-native-web's keydown gate swallows it exactly as it did for the live field, and the draft neither goes out nor leaves the field. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…both fields Two defects, one rule: after a control that ends the line, the terminal owns the echoed text and the field's editing session is over. The key bar's Enter chip (device trace, variant (a)) emits no DOM key event, so only the accessory hook could end that session. Its held-text branch does, through the flush; with nothing held it took `send-now`, which flushed nothing and wrote neither the capture state nor the field. Not page-only: the held-text fallback holds a trailing non-ASCII run, so ASCII leaves nothing held on native either. `send-now` now takes the same flush when the bytes end the line, and still defers the send to its caller so exactly one return goes out. The buffered command field had the live field's composition gate, because it also reaches its send through `onSubmitEditing` alone. It binds the page's line-break signal now too, which is why the seam is named for a terminal text field rather than for the live input. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. 📝 WalkthroughWalkthroughThe change adds cross-platform terminal text-field submission. Web fields submit on line-break Priority: ⬇️ Low Merge Risk: 🔵 Low · up to The feature behavior is covered, but the new regression test can miss the stale handler case it targets and can retain test listeners. Stabilize the fixture and clean up the binding before merging. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the defects, user impact, implementation, and test coverage, but it omits most required template sections, including ELI5, What Changed, Why, Linked Issue with Resolution Rewrite the description using the repository template. Add the required section headings and content, include a
✨ 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.
Important
The buffered command field's new web Enter-under-composition path does not run the production handler: submitBufferedDraft is memoized with [] over a handleSend closure that is frozen at the hook's first render, so the path is a permanent no-op. The live field's equivalent path is wired correctly.
Reviewed changes
- Accessory Enter ends the live field session —
send-nowon a line-ending control now takes the held-text flush (terminalLiveAccessoryInputEndsLine), clearing capture state and the field through the existing seam while still deferring the raw\rto the caller. Ordering is preserved becauseflushPendingLiveInputTextawaits the in-flight mirror flush first. - Web submit binding pair — new
terminal-text-field-submit-binding(native no-op) plus a.web.tssibling that bindsbeforeinputinsertLineBreak/insertParagraph;useTerminalTextFieldSubmitBindingis a callback-ref hook; both dock fields rebind through it. - Rigs and censuses — render rig probe route rewritten to mount the real commit hook plus a buffered field (plain, composition, and accessory-chip cases); session-route closure
4207→4209; route-parity hook/callback hashes re-recorded; aweb-overrides.jsonentry added.
ℹ️ Nitpicks
use-terminal-text-field-submit-binding.tsnames its ref parameterliveInputRef, but it now also binds the buffered command field (commandInputRef), and its JSDoc still says "the field mounts and unmounts withliveInputEnabled" — true only for the live field. A neutral name and doc would read better.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…as given Found by pullfrog on #22300. The binding refreshed its handler ref only when the callback identity changed, so a caller memoizing on an empty dependency list was bound once and never again. The buffered command field does exactly that: its submit closes over handleSend, a per-render function whose guard reads client and activeHandle, both null until effects supply them, so the page's line-break submit could never pass that guard. The probe route now carries the same two paths the dock has — a fresh per-render function on the field's onSubmitEditing prop, and the memoized closure on the binding — because the working prop path is what hid this. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
Found by pullfrog on #22300. `submitBufferedDraft` was memoized on an empty dependency list, which froze the per-render `handleSend` it calls. That guard reads `client`, `activeHandle` and `canSend`, none of which the first render has, so the page's line-break submit could never pass it. The field's own `onSubmitEditing` prop kept working, which is what hid it. The handler is per-render now, and the binding refreshes its handler ref on every commit rather than when the callback identity changes — the ref exists so the listener always reaches the newest handler, and it should not rest on a caller's memoization. That second half fixes nothing on its own: a `useCallback` with `[]` returns one function object for the life of the component, so no ref can find a newer closure behind it. The source census is what catches that, and it is red against the frozen handler. The probe route is back on the dock's shape, per-render on both submit paths, with a note saying why a route that writes its own submit cannot catch this. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…n send The census beside this reads one spelling of a frozen handler. This reads the behaviour: the send-actions hook is rendered first as a session is before its effects land, with no client and no handle, then again as it is after, and the listener the page's binding attached has to reach the second one. Asserted on the params that reach the client, not on a call count. Red with the `useCallback` restored, and red with a `useMemo` in its place, which is the point of testing the behaviour rather than the spelling. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
`[] as Array<T>` inside the hoisted factory was a type assertion with nothing to explain: the arrays are built here, so a checked declaration says the same thing and the quality gate has nothing to flag. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 4578e8ef-9693-4ffd-ad05-0d7eea0841e9
📒 Files selected for processing (7)
config/scripts/mobile-web-app-live-input-probe-route.mjsmobile/src/session/mobile-session-route-parity.test.tsmobile/src/session/terminal-field-submit-binding-send.test.tsxmobile/src/session/terminal-field-submit-binding-wiring.test.tsmobile/src/session/use-mobile-session-terminal-send-actions.tsmobile/src/terminal/use-terminal-text-field-submit-binding.test.tsxmobile/src/terminal/use-terminal-text-field-submit-binding.ts
🚧 Files skipped from review as they are similar to previous changes (1)
- mobile/src/session/use-mobile-session-terminal-send-actions.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
| clientRef: { current: session.client }, | ||
| connStateRef: { current: 'connected' }, | ||
| liveInputRef: { current: null }, | ||
| commandInputRef: { current: null }, |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,170p' mobile/src/session/terminal-field-submit-binding-send.test.tsx
sed -n '60,100p' mobile/src/session/use-mobile-session-terminal-send-actions.ts
sed -n '1,80p' mobile/src/terminal/use-terminal-text-field-submit-binding.tsRepository: stablyai/orca
Length of output: 9023
🏁 Script executed:
sed -n '1,180p' mobile/src/terminal/terminal-text-field-submit-binding.web.ts
sed -n '90,190p' mobile/src/session/use-mobile-session-terminal-send-actions.ts
rg -n "bindTerminalTextFieldSubmit|beforeinput|insertLineBreak" mobile/src/terminal mobile/src/session/terminal-field-submit-binding-send.test.tsxRepository: stablyai/orca
Length of output: 7703
Keep commandInputRef stable across renders.
buildScope() creates a new commandInputRef for READY. This changes bindCommandField, so the test effect removes the original listener and installs a new one. The test can therefore pass if the binding regresses to capture the OFFLINE submit callback directly, because the new listener captures the READY callback.
With the original listener and OFFLINE callback retained, handleSend() returns before sending because OFFLINE has no client, active handle, or send capability. Reuse one ref so the test protects this regression.
Proposed fix
const field = document.createElement('input')
+const commandInputRef = { current: null }
let restoredDrafts: string[] = []
function buildScope(session: Session): MobileSessionTerminalWebviewModel {
@@
- commandInputRef: { current: null },
+ commandInputRef,| useEffect(() => { | ||
| bindCommandField(fieldAsTextInput) | ||
| }, [bindCommandField]) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟡 Minor | ⚡ Quick win
🔎 Supported by static analysis
🏁 Script executed:
sed -n '1,170p' mobile/src/session/terminal-field-submit-binding-send.test.tsx
sed -n '1,80p' mobile/src/terminal/use-terminal-text-field-submit-binding.ts
sed -n '1,90p' mobile/src/terminal/terminal-text-field-submit-binding.web.tsRepository: stablyai/orca
Length of output: 8868
Release the listener when Harness unmounts.
The effect binds fieldAsTextInput, but it does not call bindCommandField(null) on unmount. The binding hook invokes its stored listener cleanup only when its callback receives another node or null. Because field is module-scoped, the beforeinput listener and its render callback can remain attached for later tests.
Suggested fix
useEffect(() => {
bindCommandField(fieldAsTextInput)
+ return () => {
+ bindCommandField(null)
+ }
}, [bindCommandField])📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| useEffect(() => { | |
| bindCommandField(fieldAsTextInput) | |
| }, [bindCommandField]) | |
| useEffect(() => { | |
| bindCommandField(fieldAsTextInput) | |
| return () => { | |
| bindCommandField(null) | |
| } | |
| }, [bindCommandField]) |
There was a problem hiding this comment.
ℹ️ No critical issues — the prior finding is fixed; one minor note inline.
Reviewed changes
Re-reviewed the four commits since the prior pullfrog review (eed2cc12, base a8786c04):
- De-memoized the buffered field's submit —
submitBufferedDraftis no longeruseCallback(…, []), so the page'sbeforeinputpath reaches the currenthandleSendinstead of the first-render closure; the buffered field's Enter-under-composition path is live again. - Added red-first coverage — a source census refuses a
[]-frozen handler on either bound field, and a behavioral test rendersuseMobileSessionTerminalSendActionsoffline→ready and dispatchesinsertLineBreakon the bound DOM field, asserting the params that reach the client. Both fail withuseCallback(…, [])restored. - Refreshed the binding hook and rig —
useTerminalTextFieldSubmitBindingrefreshes its handler ref every commit and renames its ref parameter tofieldRef; the probe route'ssendBufferedDraftis per-render too; route-parity counts/hashes re-recorded (281hooks /79callbacks).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…t have The handler ref refreshed on every commit rather than on the callback identity, and the docblock called that the reason the seam exists. It is not: a caller that freezes its closure hands this hook one function object for the life of the component, so no ref finds a newer one, and a caller that does not freeze it changes identity every render and refreshes the dependency anyway. Measured both ways. The dependency is back, and the prose says only what the code does. The rule that does hold — a bound handler must not be frozen on an empty dependency list — is stated where it is enforced, in the wiring census, with the behavioural check named beside it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…y list React Doctor flags the dependency twice, once per bound field: both of the dock's field submits are rebuilt every render, because the handleSend they read is, so `[onSubmit]` is a new value every time and there is nothing to compare. The tree's other latest-refs are written without a list for the same reason — use-mobile-web-shell-bridge.ts:148 is the one this follows. The comment says what the ref does, which is mirror the newest closure after each commit so callers may pass per-render handlers. It claims nothing about a caller that freezes one; that rule is still the wiring census's. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…l it cannot make (#22326) * fix(mobile): a Retry that can only re-dial is not offered where nothing dials Six failed-load screens share one Retry shape: re-dial a host that is not connected, otherwise re-read. On the page the re-dial is inert (`client-context.web.tsx:55`) and each screen's load already re-runs when the shell's client reconnects, so in the disconnected state that Retry did nothing at all. `connectionRetryAction` makes the decision once and answers null when a re-dial is needed and none exists; agent history, the file explorer root, the file preview, git history, the source-control status gate and the diff review render no Retry for null. The explorer's per-folder Retry keeps its control: it queues the folder, and the queue drains on the next `connected` whoever brought it back. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * fix(mobile): the page offers no re-dial, so no header offers one `forceReconnect` on the page was `() => Promise.resolve()`: the shell owns the connection and nothing in the document can re-dial it. The host header's Reconnect and the session header's "tap to retry" were wired to it and did nothing there. The context member is now nullable and the page's provider hands out null, so the compiler found every caller: both headers render no reconnect affordance for null, and the session status keeps the verdict label without promising a tap. Native providers and the recording adapters still pass a function, so nothing a phone renders changes. The session route's host-JSX parity hash moves for the header's extra null check; the page test doubles that stubbed the old inert re-dial now stub null. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * docs(mobile): the auth-failed banner cites the page's re-dial as null Three comments and the banner's override reason still said the page's `forceReconnect` was an inert `() => Promise.resolve()`, and cited `client-context.web.tsx` lines the previous commit moved. They now say null and point at the lines that hold it. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): the session closure gains the page's Retry decision `connection-retry-action.ts` is the one module the Retry fix adds to the session route's page closure, reached through the explorer, source control and git history it docks. Measured on this head with all five generators run first, and diffed against the pre-change closure: one local module added, none removed. Session route closure 4207 -> 4208 modules, local 1021 -> 1022. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * docs(mobile): the capability probe belongs on the page, and says why The push fence excluded `runtime-capability-probe.ts` because the session route and the host screen run it. The session half holds, and the probe works there: `status.get` carries no client identity and makes no write, the shell forwards it like any non-`native.` request, and the desktop's mobile allowlist admits it. The host-screen half no longer does: `codex-reset-credit-capability.ts` is reached only from `accounts.tsx`, which the bundle carries and the page hands to the native screen. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): keep the session retry test's cast under its disable line The formatter wrapped the cast onto the line after the disable comment, which left it uncovered. The cast now sits on its own line directly below the SAFETY note. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): the agent-history Retry test mocks the pathname the handoff reads Main's page route handoff now subscribes to `usePathname` (#22300), and the Retry suite this branch added mounts that handoff with an `expo-router` mock that lacked it. Same one-line addition main made to the back-handoff suite. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): pin the reload each hidden page Retry relies on Hiding a Retry on the page rests on the screen's load re-running when the shell's client reconnects, because nothing on the page re-dials. Only the explorer's folder drain pinned that. Each other site now has a case that starts unreachable with no Retry and asserts the load goes out on the client and state the reconnect delivers: agent history (status.get), file preview (the preview read), diff review (the snapshot load), git history (git.history) and source-control status (git.status, in the loaders suite because the panel test mocks the state hook). Each goes red when the `client`/`connState` dependencies it guards are removed; for source control that is both `loadStatus` and the `loadBranchCompare` it depends on. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb * test(mobile): one import of the transport types in the source-control loaders test CI's native code-quality audit denies the duplicate-import warning the reload pin added. Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb

Two defects in the terminal's text fields, both found on the emulator with the page shell (inert today:
EXPO_PUBLIC_MOBILE_SHELL=otaonly), one of them shared with native.The key bar's Enter chip left the sent text in the live field. Device trace (raw CDP against a debuggable OTA build,
adbinput): keyboard Enter submits and clears synchronously on the page; the chip runs the command and never clears, no composition involved. The next keystrokes then appended to the stale text (lslsin the field while the PTY gotls). Cause in the shared accessory commit hook: the chip's\rcarries no held text, so the decision issend-now, which only waits for an in-flight mirror flush and returnsallow-raw; nothing ended the field's editing session. The same branch is taken on native Android for ASCII typing, so this is not page-only. Fix: a control that ends the line takes the same flush the held-text branch takes (terminalLiveAccessoryInputEndsLine), clearing capture state and field through the existing seam, and still defers the send to its caller so exactly one\rreaches the wire. Escape with no held text keeps its pinned behaviour. Red-first in the render rig by tapping the chip and in unit cases on the shared hook.react-native-web dropped Enter under an open IME composition. Its
TextInputwithholdsonSubmitEditingwhen the Enter keydown reportsisComposing(or Android'skeyCode229), the normal mid-word state of a soft keyboard. Measured on the real bundle: nothing sent, field kept the draft. Fix: a sibling pairterminal-text-field-submit-binding(native binds nothing; web bindsbeforeinputand acts oninsertLineBreak/insertParagraphonly). react-native-web cancels every keydown it does submit on, so the browser signal fires in exactly the cases it dropped and never twice; a candidate-selecting IME reportsinsertCompositionTextand is left alone. Applied to both the live field and the buffered command field.Per mode, in the rig: live + chip (field empty, one
\r), buffered + plain Enter and buffered + chip (already correct, now guarded), buffered + Enter under composition (draft sent, field empty).Session-route closure pin 4,207→4,209 (the submit-binding pair). Route parity hashes re-recorded for the two new hooks.