Repository navigation
fix(mobile): stop held accessory keys after release under latency - #14219
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe terminal raw-send helper now returns a boolean status for accepted, unavailable, and failed sends. Input commit paths await mirror and control-byte results and return Merge Risk: 🟡 Moderate · up to The PR improves held-key repeat pacing and release handling, but a rejected mirrored input can leave the client baseline ahead of the terminal; a later edit may send incorrect erase or delta bytes and mutate the user's command. This bounded correctness issue should be fixed or explicitly accepted before merge. 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
Full details: Linked Issues checkExplanation The changes directly address issue Full details: Out of Scope Changes checkExplanation The implementation and tests stay within terminal accessory repeat delivery, stale-target protection, send-result propagation, and related regression coverage. No unrelated product, persistence, protocol, dependency, or platform changes are present. Full details: Description checkExplanation The description provides a clear ELI5 explanation, change summary, rationale, scope, reliability contract, linked issue reference, visual evidence, and detailed validation results. It is sufficiently complete despite not reproducing every template heading or checklist item.
✨ 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: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 8548b08e-f4ba-4942-9b7d-12854271bade
📒 Files selected for processing (5)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/terminal/terminal-accessory-repeat.test.tsmobile/src/terminal/terminal-accessory-repeat.tsmobile/src/terminal/terminal-live-accessory-raw-send.test.tsmobile/src/terminal/terminal-live-accessory-raw-send.ts
|
Addressed both review findings on the latest |
…-mobile-picker-lag
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 06a830f0-80d2-4225-9250-30509ff75c53
📒 Files selected for processing (5)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/terminal/terminal-accessory-repeat.test.tsmobile/src/terminal/terminal-accessory-repeat.tsmobile/src/terminal/terminal-live-accessory-raw-send.test.tsmobile/src/terminal/terminal-live-accessory-raw-send.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- mobile/src/terminal/terminal-live-accessory-raw-send.ts
- mobile/app/h/[hostId]/session/[worktreeId].tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
…-mobile-picker-lag
…-mobile-picker-lag
…-mobile-picker-lag
|
Final review status for ELI5: what changes for the user?Before: If a user pressed and held an on-screen arrow, mobile could generate repeat commands faster than the host handled them. The commands could pile up, make a picker overshoot, and keep moving briefly after the finger was lifted. After: A held arrow waits for each repeat to finish before generating the next one. Releasing it prevents future repeats from being scheduled, so the picker should stop instead of draining a backlog. Ordinary quick taps: Each separate tap now dispatches immediately and is not held behind an earlier network acknowledgement. This prevents this PR from making ordinary tap latency worse, but it does not identify or fix the original single-tap lag reported in STA-3919 / #13845. That issue remains open. Final status
Recommendation: mergeable as the separate held-repeat reliability fix described above; do not treat this merge as resolving STA-3919 / #13845. |
…-mobile-picker-lag
…-mobile-picker-lag
…-mobile-picker-lag
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9ec2d2b7-28fa-4d93-9738-1f2a6063afb9
📒 Files selected for processing (10)
mobile/app/h/[hostId]/session/[worktreeId].tsxmobile/src/terminal/terminal-accessory-repeat.test.tsmobile/src/terminal/terminal-accessory-repeat.tsmobile/src/terminal/terminal-live-accessory-raw-send.test.tsmobile/src/terminal/terminal-live-accessory-raw-send.tsmobile/src/terminal/use-terminal-live-accessory-input-commit.test.tsmobile/src/terminal/use-terminal-live-accessory-input-commit.tsmobile/src/terminal/use-terminal-live-input-commit.test.tsmobile/src/terminal/use-terminal-live-input-commit.tsmobile/src/terminal/use-terminal-live-pending-input-flush.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- mobile/src/terminal/terminal-live-accessory-raw-send.ts
- mobile/src/terminal/terminal-accessory-repeat.ts
- mobile/src/terminal/terminal-live-accessory-raw-send.test.ts
- mobile/app/h/[hostId]/session/[worktreeId].tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 0 remain after this review.
| (handle: string, fieldText: string, composing?: boolean): Promise<boolean> => | ||
| runMirrorStep(handle, fieldText, false, composing), |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | 🏗️ Heavy lift
🔎 Supported by static analysis
🏁 Script executed:
#!/bin/bash
set -euo pipefail
rg -n -C 12 'queueTerminalLiveMirrorSend|handleLiveInputAccessoryBytes|suppress-raw' mobile/src mobile/appRepository: stablyai/orca
Length of output: 49033
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- review conventions ---'
find /tmp/coderabbit-repo-knowledge/stablyai-orca-89dc44e4 -maxdepth 2 -type f -name '*.md' -print \
| while read -r f; do
case "$f" in
*/learnings/*) ;;
*) printf '%s\n' "--- $f"; cat "$f" ;;
esac
done
printf '%s\n' '--- changed hook and directly bound helpers ---'
cat -n mobile/src/terminal/use-terminal-live-pending-input-flush.ts | sed -n '24,170p'
cat -n mobile/src/terminal/terminal-live-pending-flush-state.ts | sed -n '1,145p'Repository: stablyai/orca
Length of output: 17107
🏁 Script executed:
#!/bin/bash
set -euo pipefail
printf '%s\n' '--- remaining flush paths and mirror computation ---'
cat -n mobile/src/terminal/use-terminal-live-pending-input-flush.ts | sed -n '159,245p'
cat -n mobile/src/terminal/terminal-live-preedit-mirror.ts | sed -n '1,220p'
printf '%s\n' '--- sender binding and failure handling ---'
rg -n -C 10 'sendLiveTerminalInputRef|sendLiveTerminalInput|sendQueuedMirrorPayload|sendTerminalLiveAccessoryRawBytes' mobile/src mobile/appRepository: stablyai/orca
Length of output: 50369
Rebase the mirror baseline when a send fails.
When queueTerminalLiveMirrorSend returns false, sentLiveInputTextRef still contains the optimistic text. The suppress-raw branch does not reset it. A failed Backspace followed by new input can therefore leave stale text in the PTY, such as a, failed DEL, then b producing ab. Invalidate the baseline and force resynchronization before accepting later edits. Add a regression for this sequence.
|
Follow-up after the final rereview and fresh QA attempt at exact head df9a4a2: Scope clarificationThis is not an up/down-only special case. The same controller covers all six built-in repeatable accessory keys: Backspace, Delete, Up, Down, Left, and Right. Non-repeatable/custom keys cannot create the timer-generated held-repeat backlog, and any future built-in marked repeatable automatically uses this path. Separate taps dispatch immediately and independently. Only repeats generated during one continuous hold are acknowledgement-paced, which prevents backlog, overshoot, and movement after release under latency. Relationship to #13845A second code-path review found that ordinary taps were already dispatched concurrently before this PR. The terminal.send acknowledgement is also not on the tap-to-first-visible-output critical path: the host writes to the PTY before replying, while terminal output returns independently. So this PR fixes a real held-repeat reliability problem, but it does not establish the root cause of #13845's reported one-tap lag. That report is currently not reproducible, and host load, network/relay latency, TUI redraw time, or phone rendering are all still plausible without enough evidence to rank them. The senior next step for #13845 is one native reproduction with content-free timestamps across press, socket send, host PTY write, first PTY output, phone receive, WebView post, and xterm paint—not another speculative production patch. Current validation status
One integration guardrail for follow-up work: any future fire-and-forget accessory transport must keep timer-generated repeats acknowledgement-paced, or it will recreate the open-loop backlog fixed here. Status: mergeable as the separate held-repeat reliability fix above. Do not close #13845 based on this PR. |
|
Fresh Grok retry addendum at exact head What the clean retry verified
Before: After two rapid Tab taps: What remains unverifiedFresh native held-repeat proof is still blocked. Backspace was present in AX at Therefore this retry does not claim a fresh on-device pass for acknowledgement-paced repeats or the two-second post-release freeze. The deterministic repeat-controller tests and earlier paired-iOS evidence remain the support for that behavior. No source or PR code changed during this retry. The pre-existing Status remains: review-clean and required checks green; merge only as the separate held-accessory-repeat reliability fix. Do not treat it as resolving the unreproduced ordinary-tap lag in #13845. |
…ablyai#14219) * fix(mobile): backpressure accessory key repeats * fix(mobile): keep accessory repeats on the pressed terminal * fix(mobile): serialize accessory key presses * fix(mobile): preserve queued accessory taps * fix(mobile): fence queued taps across reconnects * fix(mobile): recheck queued tap delivery context * fix(mobile): stop accessory repeats after IME send failure * fix(mobile): pace repeated live-input edits * fix(mobile): dispatch accessory taps without ack delay (cherry picked from commit 4f14d6d)
Rebuild app/h/[hostId]/session/[worktreeId].tsx as a 10-line route over MobileSessionSurface + useMobileSessionController, restoring the 44 split modules main deleted on this branch and re-applying the hybrid operations-injection delta onto them. Three behaviors main's own split had silently dropped are kept from the branch instead: the accessory hold-to-repeat controller (#14219), the relay-recovery input to classifyConnection, and the live MobileMarkdownReader / MobileDiffCommentLineRow components (main's split forked stale copies). Claude-Session: https://claude.ai/code/session_01JNnE9qzUZMMnqpZWCqM3nb
…ablyai#14219) * fix(mobile): backpressure accessory key repeats * fix(mobile): keep accessory repeats on the pressed terminal * fix(mobile): serialize accessory key presses * fix(mobile): preserve queued accessory taps * fix(mobile): fence queued taps across reconnects * fix(mobile): recheck queued tap delivery context * fix(mobile): stop accessory repeats after IME send failure * fix(mobile): pace repeated live-input edits * fix(mobile): dispatch accessory taps without ack delay


Summary
terminal.sendwire contractELI5: user-facing before and after
Before: If a user pressed and held an on-screen arrow, mobile could send repeat commands faster than the host processed them. Those commands could pile up, make a picker overshoot, and keep moving briefly after the finger was lifted.
After: A held arrow waits for each repeat to finish before generating the next repeat, and releasing the arrow prevents any future repeat from being scheduled. Separate quick taps still fire immediately; they are not queued behind earlier network acknowledgements.
Scope
This is a held-button reliability fix. It does not establish or fix the root cause of the ordinary single-tap lag reported in STA-3919 / #13845, so that issue remains open for separate investigation.
Reliability contract
Validation
df9a4a236ee16bfef264f80a5d8a690965122e75git diff --checkpassedBefore: open-loop held repeats
sta3919-before-clean.mp4
After: response-paced held repeats and release fence
sta3919-after-proof.mp4
Earlier paired iOS rerun
pr14219-current-main.mp4
Related: STA-3919 / #13845 remains open.