Repository navigation
perf(terminal): skip ordinary output in preview control scans - #19400
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:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📥 CommitsReviewing files that changed from the base of the PR and between 7253013 and f6e24d09af21dfd6de2629283a6a3f2d29851ee6. 📒 Files selected for processing (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 5 remain after this review. 📝 WalkthroughWalkthroughThe terminal vertical-control scanner now jumps between ESC characters instead of scanning every code unit. New tests cover bounded inspections, CSI variants, embedded control strings, incomplete sequences, scan resumption, and redraw tail preservation. A new experimental reliability gate records coverage, test evidence, performance measurements, promotion criteria, and known gaps. Priority: ⬇️ Low Merge Risk: ⚪ Minimal · up to This change improves terminal control scanning performance while retaining parser behavior and adding focused regression coverage. The reliability-gate metadata now consistently reflects its supported coverage, so no merge-blocking current-head risk remains. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description provides a useful ELI5 summary, implementation details, performance data, and validation results. However, it omits most required template sections, including What Changed, Why, Linked Issue, Visual Proof, Testing checkboxes, AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Resolution Complete the required template sections. Add the linked issue after "Fixes #"; add Visual Proof with attachments or write "N/A" and explain why; move testing details into Testing and mark the applicable checkboxes; complete AI Disclosure, Review, Agent skill upstream boundary, Notes, and Checklist. Include clear What Changed and Why sections. Full details: Docstring CoverageExplanation Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 2 files. (1 skipped: 1 unsupported.) 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.
✅ No new issues found.
Reviewed changes
Replaces the per-code-unit charCodeAt walk in containsTerminalVerticalLineControl with forward indexOf('\x1b') searches, adds a fidelity/work-budget test suite, and registers an experimental reliability gate.
containsTerminalVerticalLineControl: ESC detection now usesindexOf('\x1b', index + 1)instead of walking every code unit. TheparseAnsiControlSequencecall and theindex = parsed.endIndexskip are unchanged, so recognition results are identical — each iteration still advances past the parsed control before searching for the next ESC.- New test file: 22 tests bound ordinary-text code-unit inspections (
< 16vs the ~90k baseline), pin CSI-Arecognition across canonical/private/malformed forms, cover OSC/DCS/SOS/PM/APC embedding and incomplete controls, and exercise the tail redraw path end to end. - Reliability gate:
terminal-performance.vertical-control-scanregistered as experimental/partial with a work/fidelity oracle and recorded budget; schema-valid perconfig/scripts/check-reliability-gates.mjs.
I traced the indexOf rewrite against the original walk — including consecutive-ESC and OSC-terminator edge cases — and confirmed the search and skip semantics are equivalent. ESC is a single BMP code unit, so indexOf('\x1b') finds exactly the positions the charCodeAt scan did, and the loop still resumes at endIndex + 1 in both versions. The inspection-bound tests would fail loudly on a revert to the full walk, so they genuinely pin the optimization rather than absorbing it.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
Re-reviewed the incremental delta (test-only plus gate metadata) on top of the previously approved optimization.
- Scan-resumption tests: added 7 cases under
resumes scanning after a parsed controlthat pin theindex = parsed.endIndexskip interacting withindexOf('\x1b', index + 1)— an ESC inside CSI parameter bytes is consumed by that control, back-to-back controls resume correctly, an OSC (\x1b]0;t\x07) terminator is skipped before the next control, and a trailing lone ESC is reported false rather than looping. - Reliability gate metadata: oracle and assertion refs now include ESC-inside-params and back-to-back controls, and the evidence-run summary reflects the 29-test total.
I traced each new case against parseAnsiControlSequence and the indexOf loop and confirmed every expectation matches the implementation, and the full suite passes locally (29 tests). No production code changed, so no behavioral risk was introduced.
DeepSeek Pro (free via Pullfrog for OSS) | 𝕏
957b0d9 to
37b6c58
Compare
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
config/reliability-gates.jsonc (1)
22-25: 🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick winFix the self-contradictory
coveredProvidersclaim for SSH/remote-runtime.
coveredProviderslistssshandremote-runtimeas covered.coverageNoteson the next line states the opposite: "live SSH transport and Linux/Windows runtime execution are not exercised."knownGapslater in the same gate repeats this: "Linux and Windows execution and live SSH transport have not been exercised." Removesshandremote-runtimefromcoveredProviders, or updatecoverageNotes/knownGapsto match the real test coverage. A stalecoveredProvidersvalue can mislead anyone using this manifest to judge whether the SSH/remote-runtime path is actually exercised.Separately, this gate (
agent-session.history-forward-read-budget) and the other scattered edits elsewhere in this diff are not mentioned in the PR summary or the AI-generated summary, which describe only one new gate forterminal-performance.vertical-control-scan. Confirm this gate is intentionally part of this change and not carried over from an unrelated branch state.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 01cb274f-c5b5-464e-8281-b4f428792143
📒 Files selected for processing (1)
config/reliability-gates.jsonc
Included review availability: Your plan provides up to 10 included reviews per hour; 1 remains after this review.
37b6c58 to
7253013
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. |
f6e24d0 to
389725f
Compare
389725f to
7c5e0ff
Compare
…s, and two hot-path walks (#371) * fix(terminal): keep restored OSC-8 ranges across a no-op resize (#17759) Cold restore seeded a checkpoint's OSC-8 link ranges and then replayed records that resize, so any resize record after the checkpoint dropped them and restored hyperlinks in scrollback lost clickability. Same-size resize records reach the durable log routinely, because every attach re-asserts the pane's dimensions and session-output-plane records each one without a same-size dedupe — so an ordinary reattach was enough to lose the links. Restored ranges are row-indexed, so clearing them on a reflow is right; a resize to the size already applied is not a reflow. Gate on the dimensions actually changing. Introduced in d46349c ("fix: improve mobile link modifier handling", #5597), which added setRestoredOscLinks along with unconditional clearing in both resize() and clearScrollback(). clearScrollback's clearing is correct and is unchanged, with a test pinning it. Found during adversarial review of #17752 and filed as #17756. Not a regression from that PR: #17667 had incidentally masked it by gating no-op resizes to protect a snapshot cache, and removing the cache removed the gate. The same gate returns here on its own terms — as a correctness fix with tests, rather than as a side effect of a cache. (cherry picked from commit ae35e04) * fix(mobile): stop double-scaling commit timestamps in history rows (#17731) Co-authored-by: Claude <[email protected]> Co-authored-by: Jinwoo-H <[email protected]> (cherry picked from commit c300913) * perf(terminal): usar el trim que ya camina, no la regex cuadratica (upstream #19214) Port de la idea de stablyai/orca#19214. Dos call sites del redraw seguian con `line.replace(/[ \t]+$/g, '')`: el `+` anclado hace que el motor retroceda sobre la corrida de padding por cada posicion de inicio que prueba, o sea tiempo cuadratico en una fila que un TUI rellena hasta el ancho de la ventana. Y un redraw a pantalla completa trimea CADA fila retenida en cada frame. No hace falta traer nada: nuestro `trimTerminalLineRight` (orca-runtime.ts:39163) ya camina la cadena y es identico al de upstream, solo que esos dos sitios nunca lo usaron. El diff son dos lineas. El test de upstream no se trae: importa `terminal-tail-buffer` y `terminal-tail-line-controls`, dos modulos que extrajo despues de nuestra divergencia, y nuestro helper es privado del monolito. Sin cambio de comportamiento —las dos implementaciones son equivalentes, leidas lado a lado— y los 4554 tests de `src/main/runtime` que cubren ese camino siguen verdes. La medicion de la mejora es de upstream, no mia. * perf(terminal): saltar a cada ESC en vez de caminar cada chunk (upstream #19400) Port de stablyai/orca#19400 a nuestro monolito. `containsTerminalVerticalLineControl` corre una vez por chunk de PTY, en el main thread, para CADA terminal —visible, oculta o aparcada— y caminaba la cadena posicion por posicion. Solo un ESC puede introducir un control vertical, asi que para salida ordinaria (logs de build, `cat`, texto por pipe) el walk entero es trabajo tirado. Nuestra version era incluso mas lenta que la de upstream ANTES de su fix: leia `value[index]`, que crea un string de un caracter por posicion. Ahora salta con `indexOf` de ESC en ESC, conservando el skip de `parsed.endIndex` en el cuerpo. 4554 tests de `src/main/runtime` en verde, sin cambio de comportamiento. --------- Co-authored-by: Neil <[email protected]> Co-authored-by: blade035 <[email protected]> Co-authored-by: Claude <[email protected]> Co-authored-by: Jinwoo-H <[email protected]>

ELI5
To decide how to draw a terminal's preview, Orca had to look at every single character of output just to find the rare "move the cursor up" marker. Now it jumps straight to those markers and skips the ordinary text in between, so the same preview is produced using noticeably less CPU on busy terminals. Nothing about what you see changes — only how much work the app does to figure it out.
Main terminal preview/read-tail updates scanned every ordinary output code unit to detect cursor-up controls. Use forward native ESC searches for the outer scan and retain the existing control parser, complete-payload skipping, incomplete-control stop and canonical CSI A recognition.
The production normalization → tail append → transcript → preview pipeline uses 13–22% less CPU across 4 MiB log fixtures: plain logs 43.418 → 37.932 ms, colored logs 49.321 → 42.570 ms, and no-newline output 32.009 → 25.100 ms. Ten thousand one-character writes into a growing partial line improve 190.374 → 126.820 ms. Rotated equal-bundle tiny-echo and redraw controls found no material regression; these are processing measurements, not end-to-end typing latency.
Validation: 22 new tests bound ordinary-text code-unit inspections (90k–98k → 0–5) and cover numeric/private/malformed CSI, embedded controls, incomplete payloads and exact redraw rows. Baseline comparison matched 204,925 predicates and 3,000 complete tail transitions. The exact original-base normalizer with only this change passed 1,298 tests with one existing skip across five suites; the integrated version passed 1,308 with that same skip. Full typecheck, changed-code quality and reliability-manifest validation passed.
Experimental gate:
terminal-performance.vertical-control-scan, with a deterministic work/fidelity oracle and recorded performance budget. No new state, timers, IO, backpressure, published content or remote protocol changes. Folder workspaces and all hosts use the same string semantics. Live Electron/native input, SSH/WSL/Linux/Windows and many-pane frame measurements remain gaps. The PR starts from the original base and does not include or require the separate pending-storage optimization.