Repository navigation
fix(terminal): mark captured shortcut input interactive - #13800
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:
📝 WalkthroughWalkthroughCaptured terminal input now uses the shared 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
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 |
be1b32c to
ffe4475
Compare
|
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. |
ffe4475 to
bb9b318
Compare
|
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. |
Refresh the interactive-redraw timestamp after a captured shortcut send succeeds, so the composer redraw that follows takes the low-latency foreground path instead of waiting out the 1s coalesce fallback. Orca's captured shortcut path sends directly through the captured pane transport to preserve pane, PTY and transport identity, and so bypasses xterm's onData -- the only place that previously stamped the timestamp. An idle pane therefore scheduled the post-Shift+Enter redraw as ordinary throughput. Measured in a real Pi pane on Windows: ~1029ms before, ~16-20ms after, at an identical ~2.3KB redraw. Stale pane bindings and rejected transport sends cannot refresh it. Fixes stablyai#10203 Refs stablyai#13598
lastTerminalInputAt has two readers, and the previous commit only meant to change one of them. onExit reads it as "the user never typed into this pane" to keep a newborn pane mounted when its shell dies on startup (the failing-.envrc direnv case, pty-connection.ts onExit) so the error stays visible and the worktree stays active. Stamping it from a captured shortcut therefore made a single Shift+Enter before that exit close the tab and bounce the user to Landing -- on every platform, since captured shortcuts are not Windows-only. Split the redraw window onto its own timestamp so captured shortcuts open the fast path without arming the teardown, and leave onExit's behaviour byte-identical to main.
bb9b318 to
8d5dc41
Compare
Deleting the onAccepted block, or replacing its binding-identity check with true, both left the whole suite green — so nothing pinned the part of this PR that actually ships. Cover both against the existing IME keyboard harness.
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/renderer/src/components/terminal-pane/keyboard-handlers-ime.test.tsx (1)
199-202: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winUse a real binding replacement in the stale-binding test.
The test changes
Map.getbased on a read counter instead of replacing the map entry. An additional lookup before the send can change the scenario and make the test fail for the wrong reason. Mutate the binding at the send boundary, then use the normalMap.getimplementation for the identity check.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 603bb61a-b247-4a2b-be8b-ac3938c2e430
📒 Files selected for processing (1)
src/renderer/src/components/terminal-pane/keyboard-handlers-ime.test.tsx
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review.
* fix(terminal): mark captured shortcut input interactive Refresh the interactive-redraw timestamp after a captured shortcut send succeeds, so the composer redraw that follows takes the low-latency foreground path instead of waiting out the 1s coalesce fallback. Orca's captured shortcut path sends directly through the captured pane transport to preserve pane, PTY and transport identity, and so bypasses xterm's onData -- the only place that previously stamped the timestamp. An idle pane therefore scheduled the post-Shift+Enter redraw as ordinary throughput. Measured in a real Pi pane on Windows: ~1029ms before, ~16-20ms after, at an identical ~2.3KB redraw. Stale pane bindings and rejected transport sends cannot refresh it. Fixes stablyai#10203 Refs stablyai#13598 * fix(terminal): keep captured shortcuts out of the pane-teardown signal lastTerminalInputAt has two readers, and the previous commit only meant to change one of them. onExit reads it as "the user never typed into this pane" to keep a newborn pane mounted when its shell dies on startup (the failing-.envrc direnv case, pty-connection.ts onExit) so the error stays visible and the worktree stays active. Stamping it from a captured shortcut therefore made a single Shift+Enter before that exit close the tab and bounce the user to Landing -- on every platform, since captured shortcuts are not Windows-only. Split the redraw window onto its own timestamp so captured shortcuts open the fast path without arming the teardown, and leave onExit's behaviour byte-identical to main. * test(terminal): pin the captured-shortcut wiring and its staleness guard Deleting the onAccepted block, or replacing its binding-identity check with true, both left the whole suite green — so nothing pinned the part of this PR that actually ships. Cover both against the existing IME keyboard harness. --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com> (cherry picked from commit a0cc9f3)
* fix(terminal): mark captured shortcut input interactive Refresh the interactive-redraw timestamp after a captured shortcut send succeeds, so the composer redraw that follows takes the low-latency foreground path instead of waiting out the 1s coalesce fallback. Orca's captured shortcut path sends directly through the captured pane transport to preserve pane, PTY and transport identity, and so bypasses xterm's onData -- the only place that previously stamped the timestamp. An idle pane therefore scheduled the post-Shift+Enter redraw as ordinary throughput. Measured in a real Pi pane on Windows: ~1029ms before, ~16-20ms after, at an identical ~2.3KB redraw. Stale pane bindings and rejected transport sends cannot refresh it. Fixes stablyai#10203 Refs stablyai#13598 * fix(terminal): keep captured shortcuts out of the pane-teardown signal lastTerminalInputAt has two readers, and the previous commit only meant to change one of them. onExit reads it as "the user never typed into this pane" to keep a newborn pane mounted when its shell dies on startup (the failing-.envrc direnv case, pty-connection.ts onExit) so the error stays visible and the worktree stays active. Stamping it from a captured shortcut therefore made a single Shift+Enter before that exit close the tab and bounce the user to Landing -- on every platform, since captured shortcuts are not Windows-only. Split the redraw window onto its own timestamp so captured shortcuts open the fast path without arming the teardown, and leave onExit's behaviour byte-identical to main. * test(terminal): pin the captured-shortcut wiring and its staleness guard Deleting the onAccepted block, or replacing its binding-identity check with true, both left the whole suite green — so nothing pinned the part of this PR that actually ships. Cover both against the existing IME keyboard harness. --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
* fix(terminal): mark captured shortcut input interactive Refresh the interactive-redraw timestamp after a captured shortcut send succeeds, so the composer redraw that follows takes the low-latency foreground path instead of waiting out the 1s coalesce fallback. Orca's captured shortcut path sends directly through the captured pane transport to preserve pane, PTY and transport identity, and so bypasses xterm's onData -- the only place that previously stamped the timestamp. An idle pane therefore scheduled the post-Shift+Enter redraw as ordinary throughput. Measured in a real Pi pane on Windows: ~1029ms before, ~16-20ms after, at an identical ~2.3KB redraw. Stale pane bindings and rejected transport sends cannot refresh it. Fixes stablyai#10203 Refs stablyai#13598 * fix(terminal): keep captured shortcuts out of the pane-teardown signal lastTerminalInputAt has two readers, and the previous commit only meant to change one of them. onExit reads it as "the user never typed into this pane" to keep a newborn pane mounted when its shell dies on startup (the failing-.envrc direnv case, pty-connection.ts onExit) so the error stays visible and the worktree stays active. Stamping it from a captured shortcut therefore made a single Shift+Enter before that exit close the tab and bounce the user to Landing -- on every platform, since captured shortcuts are not Windows-only. Split the redraw window onto its own timestamp so captured shortcuts open the fast path without arming the teardown, and leave onExit's behaviour byte-identical to main. * test(terminal): pin the captured-shortcut wiring and its staleness guard Deleting the onAccepted block, or replacing its binding-identity check with true, both left the whole suite green — so nothing pinned the part of this PR that actually ships. Cover both against the existing IME keyboard harness. --------- Co-authored-by: OrcaWin <293788423+OrcaWin@users.noreply.github.com>
Summary
A captured terminal shortcut (Shift+Enter and friends) now refreshes the interactive-redraw timestamp once its transport accepts the bytes, so the agent's composer redraw that follows renders promptly instead of waiting out the 1s coalesce fallback.
Fixes #10203. Independent of #13598, which decides which bytes Shift+Enter sends; this PR decides how fast Orca paints what those bytes produce.
Root cause
Ordinary typing reaches xterm's
onData, which callsmarkAcceptedTerminalInputSent()and stampslastTerminalInputAt. Orca's captured-shortcut path deliberately sends straight through the captured pane transport to preserve pane, PTY and transport identity — so it bypassesonDataand never stamped anything.That timestamp gates
latencySensitiveoutput. Without it, an idle pane treats the post-Shift+Enter redraw as ordinary throughput:pane-terminal-output-scheduler.tskeepsFOREGROUND_COALESCE_DELAY_MS(1000 ms) instead of clamping toLATENCY_SENSITIVE_FOREGROUND_COALESCE_DELAY_MS(16 ms). Redraws at or below 2048 chars take an unconditional immediate path, which is why a smallpi-starlinecomposer masks the bug and a default Pi composer (~2.3–3.3 KB) does not.Measured, in the real app
Windows, real Pi 0.84.2 pane, same pane and same redraw size across both arms, 8 samples each, measured with the repo's own
window.__orcaTypingDiagnosticecho probe:mainThat matches the two constants almost exactly (1000 ms coalesce vs the 16 ms clamp), which is the independent check that the mechanism is understood correctly and not merely correlated.
Implementation
sendCapturedTerminalInput()takes an optionalonAcceptedcallback, invoked only aftersendInput()returns true.PanePtyBinding.markShortcutTerminalInputSent()stamps the redraw window.No input bytes and no routing decisions change.
Second commit: a regression the first commit introduced
lastTerminalInputAthad two readers, and only one of them was meant to change.onExitreads!Number.isFinite(lastTerminalInputAt)as "the user never typed into this pane" to keep a newborn pane mounted when its shell dies during startup — the failing-.envrcdirenv case — so the error stays visible and the worktree stays active.Stamping it from a captured shortcut meant one Shift+Enter before such an exit closed the tab and dropped the user on Landing. On every platform, since captured shortcuts are not Windows-only.
The second commit splits the redraw window onto its own
lastInteractiveRedrawInputAt, leavingonExitbyte-identical tomain, with a regression test that fails if the two are merged again.Scope and risk
consumeForegroundImmediateBudgetas the pre-existing ≤2048-char branch: 128 KB per 500 ms per pane, and a 150 ms window. Holding Shift+Enter is bounded exactly as holding any character key already was, because ordinary keystrokes have always refreshed the same timestamp. The OpenTUI small-burst fairness path is untouched (those frames are ≤2048 chars and never consult the timestamp).Testing
src/renderer/src/components/terminal-pane+store/slices+lib/pane-manager: 7094 passed, 2 skipped, 0 failed.pnpm typecheckclean; oxlint and oxfmt clean on changed files; max-lines ratchet clean.onAcceptedwiring entirely, or replacing its binding-identity check withtrue, both left the whole suite green — nothing pinned the part of this PR that actually ships. A third commit covers both against the existing IME keyboard harness; each mutation now kills exactly one test.Takeover notes
Rebased onto current
mainand taken over.pty-connection.test.tsno longer exists onmain(it was split into per-topic files), so the scheduler regression moved intopty-connection-foreground-write-path.test.ts. Original authorship preserved on the first commit.