Repository navigation
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Narrow the queued Windows foreground repair — the span the immediate repair used now travels with the pending next-frame refresh.
pendingRepairRowSpanre-validates it against a fresh viewport snapshot (buffertype, gridrows,baseY,viewportY) and unions in the rows parsed since the write plus the current caret row, falling back to0..rows-1on any mismatch or a flipped sync-render path. - Tests — a deterministic
requestAnimationFramequeue, a controllable terminal double, an extension of the existing convergence oracle over the existingCASES, the Issue #19622 one-row fixture, and explicit full-grid fallbacks for scroll, resize, buffer flip, renderer swap, whole-viewport parse, and disposal.
I traced the superset invariant: pendingRepairRowSpan seeds its union with repair.span and readParsedDirtyRowSpan only resets on forceViewportRefresh, so the delayed span is always a superset of the immediate repair (or falls back whole-grid). I also confirmed the new oracle has teeth by reverting only the production file to 87bc51d and watching the suite fail (14 failures, including { start: 0, end: 59 } vs { start: 55, end: 55 }); with the change it passes 54/54, and pane-manager/ + replay-guard.test.ts pass 988/988.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Navigate logical layers of code changes, visualize relationships, and explore their blast radius. Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
📥 CommitsReviewing files that changed from the base of the PR and between e9e88d151ff700de4541c13d29aac1b477ba10fd and 952a71b. You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configuration
📥 CommitsReviewing files that changed from the base of the PR and between 748012127206f5cd22d7c5d97ef83cd74f68bcfb and e9e88d151ff700de4541c13d29aac1b477ba10fd. 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review. 📝 WalkthroughWalkthroughThe foreground render path now records the original repair span, viewport state, and synchronous-render choice for queued follow-up work. Before the delayed refresh, it checks for changes to buffer type, terminal size, scroll position, dirty rows, cursor row, and renderer path. It uses a narrow combined span when possible and otherwise refreshes the full viewport. Tests cover delayed repairs, fallback conditions, multiple writes, and pane discard. Priority: ➖ Normal Severity of issue fixed: Medium Merge Risk: ⚪ Minimal · up to The change narrows delayed terminal repaints when it is safe and falls back to a full refresh otherwise. No concrete merge-blocking risk was identified. Electron visual validation was not run, so a manual visual check is worthwhile. Security Architecture ReviewSecurity architecture risk: 🔵 Low · up to The impact is limited to terminal display repair. Overlapping writes can lose part of the delayed repaint coverage, but both writes still receive immediate repairs. No expanded permissions or cross-service exposure was identified. Retained concerns
Security review detailsSecurity Blast Radius
Trust Boundaries and Controls
Resilience and Maintainability Implications
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Linked Issues checkExplanation [ Resolution Track column geometry or equivalent reflow state in the pending repair validation, and add a regression test that verifies a column-only resize or reflow selects the full grid. Add or run automated Electron pixel-convergence validation for the delayed narrowed repair.
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: 1
ℹ️ Review info
⚙️ Run configuration
- Configuration used: Repository UI
- Review profile: CHILL
- Plan: Advanced
- Run ID:
b8221cf5-2500-4915-b67a-674ed230185a
📥 Commits
Reviewing files that changed from the base of the PR and between 87bc51d and 6fd313b4ef7e1cdee951672c8cfb2d5758e61aee.
📒 Files selected for processing (2)
src/renderer/src/lib/pane-manager/pane-terminal-foreground-render-settle.tssrc/renderer/src/lib/pane-manager/terminal-foreground-repair-convergence.test.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed only the commit added since the prior Pullfrog review (7480121, perf(terminal): keep dirtied rows across a parse-span reset).
- Carried dirtied rows across a tracker reset —
writeForegroundTerminalChunknow reads the accumulated parse span beforeresetParsedDirtyRowsand threads it ascarriedDirtySpan. A forced write that resets the shared tracker can no longer drop rows an intervening ordinary write dirtied.carryRowsIntoPendingRepairwidens the already-queued repair record in place (the queued frame closes over that record), andsettleForegroundRenderunions the same span into any repair the write schedules itself. - Carry cannot narrow a fallback — it is skipped when the carried span is
nullor the queued repair is already whole-grid (span: null), so a scroll / resize / buffer flip / renderer-swap / unobservable-parse repair still repaints the whole viewport. Geometry is re-validated at frame time regardless. - Regression test — forced write queues a repair, an ordinary write dirties another row, then a later forced write resets the tracker without queueing its own repair; the pending repeat must include the intervening row. It asserts the exact widened span (
{ start: 3, end: 20 }), so it would fail if the carry were removed.
Verified on 7480121: the convergence file passes 55/55 (up from 54) and pane-terminal-foreground-render-settle.test.ts passes 3/3. The added test is behavioural rather than theatre — the author's own report shows it failing without the fix. No specialist dispatch was warranted: the incremental delta is one self-contained carry helper plus its test, and the superset/fallback reasoning traces cleanly.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
|
Thanks — both bot findings here were worth acting on, and the second one found a case I had wrongly dismissed at design time. Analysis of the two findings
What changed
One implementation detail worth recording for review: the queued frame closes over the repair record it was scheduled with, so the widened span is applied to that record in place. My first attempt replaced the queued map entry instead, which was a complete no-op — the test caught it immediately. Results
Both cases were confirmed to fail on the preceding commit with exactly those values, and pass now. Full state after both commits: 56/56 in On the reproduced baseline — thank you for reverting only the production file to Still not validated: pixel convergence in Electron ( |
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
This run re-reviewed only the commit added since the prior Pullfrog review (e9e88d1, perf(terminal): carry a superseded repair's span into its replacement), reading it against the full PR.
- Carry a superseded repair's span into its replacement — when a forced write queues its own repeat,
scheduleViewportSettleRefreshcancels the previously queued repair. That repair'sspancan hold caret rows the parse tracker never saw.writeForegroundTerminalChunknow unionsqueuedRepairRowSpan(terminal)intocarriedDirtySpanbefore the tracker reset, so the replacement repair seed (span ? unionRowSpans(span, carriedDirtySpan) : null) retains those rows instead of dropping them. - Still cannot narrow a fallback — the union only runs on a proven span; a
nullqueued span ornullcarried span leaves the replacement whole-grid, and frame-time geometry validation is unchanged. - Regression test — a first forced write queues a narrow repair with a caret row outside the parse span; a second forced write supersedes it; the flushed repeat must be
{ start: 5, end: 20 }. I confirmed it fails ({ start: 10, end: 20 }) when only this commit's production hunk is reverted, and passes with it.
I traced the superset invariant for the new path: carriedDirtySpan seeds from repair.span as well as the parse tracker, and pendingRepairRowSpan still unions repair.span with rows parsed since and the caret. Over-coverage is safe by design — only narrowing would be a defect — and the added width is discarded whenever the frame-time type/rows/baseY/viewportY check or the synchronous path check fails. No specialist dispatch was warranted: the delta is one self-contained helper plus one union site and its test. No open Pullfrog threads to retire; the two CodeRabbit threads on the PR are already resolved.
deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏
A native-Windows in-place rewrite repairs the rows it dirtied immediately, then repeats the repair on the next frame as `0..rows-1`. The repeat exists to repaint content Chromium paints a frame late, but requesting the whole grid turns every such frame into a full-viewport cell walk (stablyai#19622): xterm's render debouncer unions ranges, so one whole-grid request widens the frame it merges into. The queued repeat now carries the span the immediate repair used and, when the frame runs, unions in the rows parsed since plus the caret row. It falls back to the whole grid whenever that span cannot be proven to still apply: a scroll, a resize, a buffer flip, a renderer swap, an unobservable parse (including xterm's own whole-viewport request), or an immediate repair that was itself whole-grid. The repeat therefore never covers less than the repair it repeats. Fixes stablyai#19622
Review follow-up (CodeRabbit on the first commit). A forced write resets
the shared parse-span tracker before it parses, so rows an earlier
ordinary write had dirtied were dropped from a repair that was still
queued, and the repeated repair then covered less than the whole-grid
request it replaced.
Read the accumulated span before the reset and widen the queued repair
with it, and carry it into a repair this write schedules for itself. The
carry only ever widens a repair that already had a proven span: `null`
still means the whole viewport, which covers the carried rows anyway.
The queued frame closes over the repair record it was scheduled with, so
the widened span is applied to that record in place; replacing the queued
entry would leave the frame on the old span.
The new case fails on the previous commit with
`expected { start: 10, end: 20 } to deeply equal { start: 3, end: 20 }`.
Second review follow-up on the same thread. The previous commit preserved
rows the parse tracker had accumulated, but a replacement repair is built
from the tracker plus its own parse, and a queued repair's span can hold
rows the tracker never saw: `repairRowSpan` widens the parse span with the
caret rows on both sides of the write, and a caret that moved without a
line update never reaches the tracker. Superseding such a repair dropped
those rows.
The carry now unions the queued repair's own span with the tracker's, so
whichever repair ends up running still owes the same rows. A `null` span
is untouched and still means the whole viewport.
The new case fails on the previous commit with
`expected { start: 10, end: 20 } to deeply equal { start: 5, end: 20 }`.
e9e88d1 to
952a71b
Compare
|
Rebased onto current Nothing else changed beyond the rebase. Ready for review whenever there is a slot — @nwparker. |
|
Closing to keep my queue honest: the repository merges within about a day and this has sat six with no review, so it is not being picked up. #19622 stays open for anyone who wants to take it, and the branch stays in my fork. |

Author: @paolovalletta_
ELI5
When an agent redraws one line in a Windows terminal pane, Orca fixes that line straight away — then, one frame later, fixes it again but asks the terminal to redo the entire screen, even though nothing else changed. This repeats the immediate fix over just the rows that actually changed, and keeps asking for the whole screen whenever it cannot prove that is still safe.
What Changed
Before: a forced foreground repair on a native-Windows ConPTY pane computed a narrow row span, applied it immediately, then repeated the repaint on the next frame as
0..rows-1. In a 120×60 pane a one-row status rewrite therefore ended up walking 7,200 cells on the following frame instead of 120.After: the queued repeat carries the span the immediate repair used. When the frame runs it unions in the rows parsed since the write plus the caret row, and requests that. Anything it cannot prove still applies falls back to the whole grid.
Mechanism. The delayed
refreshVisibleRowscall inscheduleViewportSettleRefreshpassed no span, and a missing span means0..rows-1(pane-terminal-foreground-render-settle.ts). The span now travels with the pending refresh, andpendingRepairRowSpanre-validates it against a geometry snapshot before it is used: same buffer type, same grid height, andbaseY/viewportYprovably unchanged, plus a still-observable parse span. The repeat is a superset of the immediate repair by construction, because the immediate span is the union's seed.Two details that follow from the existing code rather than from this change:
readParsedDirtyRowSpanreturns the union of every parse since the last reset, so rows written by an intervening non-forced chunk are included; a parse that xterm answers with a whole-viewport request (undefined) yieldsnull, so the whole grid is repainted.shouldRefreshViewportSynchronouslyis re-resolved when the frame runs, and its producers read the attached renderer (() => !manager.hasWebglRenderer(pane.id)). A flipped value therefore means a renderer was swapped mid-frame, where only the whole viewport can be proven converged for the replacement — so the span is dropped in that case too.Why
Issue #19622 is a bounded finding in the delayed repair after #18169: the immediate repair was already narrowed, and the remaining whole-grid request turns every in-place redraw into a full-viewport
_updateModelwalk one frame later. The module already documents this cost as the reason the immediate repair was narrowed at all ("xterm's render debouncer unions ranges, so a0..rows-1repair request turns every frame into a full-viewport cell walk"), so this finishes the narrowing the surrounding code intends rather than introducing a new strategy.Alternatives considered:
Linked Issue
Fixes #19622
Visual Proof
N/ANo visual change is intended or expected: the same rows are repainted, one frame later, and content coverage can only grow relative to the immediate repair. The difference is how many rows Orca asks xterm to walk. Confirming pixel convergence needs the Electron visual gate (
terminal-render.pixel-refresh-repair), which this machine cannot build — see Limitations.Testing
Measurement. Deterministic operation counts on the real
@xterm/headlessparser, driving the productionwriteForegroundTerminalChunkimplementation with real escape bytes. The instrument is the test file itself, so the baseline is reproducible by reversing the production file only.origin/main)0..59)55..55)(−98.3% for both.)
terminal-foreground-repair-convergence.test.tsBaseline command:
Fails with
expected { start: +0, end: 59 } to deeply equal { start: 55, end: 55 }for the fixture andexpected { start: +0, end: 23 } to not deeply equal { start: +0, end: 23 }for each corpus shape. The new cases extend the file's existing convergence oracle to the delayed repair; that oracle is the losslessness check (every changed row and both caret rows must be inside the requested span).Also run, all green:
vitest run --config config/vitest.config.ts src/renderer/src/lib/pane-manager/ src/renderer/src/components/terminal-pane/replay-guard.test.ts src/renderer/src/components/terminal-pane/xterm-write-buffer-stall.repro.test.tsvitest run --config config/vitest.performance.config.tsnode config/scripts/run-typecheck-projects-in-parallel.mjsnode config/scripts/check-changed-code-quality.mjsoxlint --config config/oxlint-anti-slop.json <2 files>.oxlintrc.jsonmax-linesFull lint (
pnpm lint) constituent gates, run individually because pnpm'sverify-deps-before-runrefuses to run any script until the native modules compile (no MSVC on the measuring machine):oxlint(repo-wide)audit:anti-slop(repo-wide)audit:code-quality:native,audit:code-quality:type-awarecheck:dead-classescheck:max-lines-ratchet,check:ts-nocheck-ratchet,check:runtime-electron-ratchetcheck:reliability-gates,check:readme-local-links,check:node-runtime-pinverify:rpc-params-catalog,verify:bundled-skill-guides,verify:localization-coverageverify:skill-bundle-manifestorigin/maintoo — see belowverify:skill-bundle-manifestreportsresources/skills/{current-manifest,snapshot-registry,release-mapping}.jsonas stale. This is pre-existing and unrelated to this change: it reproduces identically in a pristine detached worktree oforigin/main(87bc51d371) with no local modifications, and the two files in this PR are not inputs to that generator. Flagging it rather than silently excluding it.Platforms: the tests above ran on Windows in Node. No Electron, DOM, WebGL or live-PTY validation was performed — see Limitations. Nothing was validated on macOS or Linux at runtime; the logic is platform-neutral and non-Windows reaches the changed path only through the replay producers.
AI Disclosure
Written with an AI coding agent. Session model:
deepseek-v4.1-flash(provideropencode-go), with research sub-agents on the same model. All measurements in this description were produced by the commands shown above on this machine; the agent could not build Electron or run the visual gate.Review
AI code-review summary over the full diff, per the checklist in
CONTRIBUTING.md:process.platformor path assumptions. The only producer offollowupViewportRefreshisnativeWindowsRewriteNeedsFollowupRenderRefresh(native Windows ConPTY, foreground, in-place rewrite), so macOS and Linux see no change on that path; SSH/WSL/remote panes do not set it at all (it requiresexecutionHostId === 'local', no connection, and a non-WSL cwd). The replay producers set it on every platform, but there the repeat stays full-grid whenever the parse span is unobservable or xterm asks for a whole viewport, which is what snapshot restores do.components/ui/primitive touched.Self-review of the diff specifically looked for: leaked or duplicated pending refreshes (the schedule path still cancels first, and the fire path deletes before refreshing), duplicated listeners (
onRequestRefreshRowssubscriptions are unchanged), cleanup on discard (covered by a new test), and the timer-cancellation path (clearTimeoutunchanged,cancelAnimationFramestill guarded).Agent skill upstream boundary
docs/reference/agent-skill-sharing-upstream-boundary.mdand copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.Notes
config/performance-audit.md.pane-terminal-foreground-render-settle.ts, but only in its import andwriteForegroundTerminalChunkwrite-callback hunks (the guarded write pipeline). This change is confined to the scheduling helpers below it, so the two do not overlap semantically; whichever lands second should expect at most a trivial rebase.Limitations
@xterm/headlessparser but without the DOM or WebGL renderer. They are not painted-pixel counts and not wall-clock: [Bug]: Native-Windows follow-up terminal repaint expands a one-row update to the full grid #19622 itself notes the finding "establishes additional rendered row coverage, not a wall-clock speedup".terminal-render.pixel-refresh-repair(Electron visual golden) andpnpm buildwere not run. Pixel convergence for the narrowed repeat is argued from the coverage oracle, not observed.pnpm testfirst runsensure-native-runtime, which compiles native modules); the affected directory and the whole performance-contract set were run instead, plus typecheck and the changed-code gate.Checklist
N/Awith reasonpnpm lint,pnpm typecheck,pnpm test, andpnpm buildpass —typecheckpasses and everypnpm lintgate passes except the pre-existingverify:skill-bundle-manifestfailure shown above;test/buildcould not run locally (no MSVC); CI will cover