Skip to content

Fix SSH terminal replay artifacts - #6043

Merged
Jinwoo-H merged 6 commits into
mainfrom
Jinwoo-H/bug-remote-over-ssh-codex-often-has-these-displa
Jun 22, 2026
Merged

Jinwoo-H merged 6 commits into
mainfrom
Jinwoo-H/bug-remote-over-ssh-codex-often-has-these-displa

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • route SSH reconnect replay through a single reconnect-owned attach path
  • suppress relay replay notifications during reconnect attach and drop identical burst duplicates
  • serialize/coalesce renderer replay writes before rebuilding the terminal WebGL renderer
  • add a Docker-backed SSH Codex-style repro harness that forces reconnect and captures raster/text evidence

Validation

  • pnpm exec vitest run src/main/providers/ssh-pty-provider.test.ts src/main/ssh/ssh-relay-session.test.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts src/renderer/src/components/terminal-pane/use-terminal-pane-global-effects.test.ts src/renderer/src/lib/pane-manager/pane-terminal-output-scheduler.test.ts --config config/vitest.config.ts
  • pnpm exec oxlint package.json src/main/providers/ssh-pty-provider.ts src/main/providers/ssh-pty-provider.test.ts src/main/ssh/ssh-relay-session.ts src/main/ssh/ssh-relay-session.test.ts src/renderer/src/components/terminal-pane/pty-connection.ts src/renderer/src/components/terminal-pane/pty-connection.test.ts tests/e2e/ssh-codex-display-artifacts-repro.spec.ts tests/e2e/ssh-codex-reconnect-replay-driver.ts tests/e2e/ssh-codex-repro-remote-fixtures.ts tests/e2e/ssh-codex-terminal-observers.ts tests/e2e/ssh-codex-real-remote.ts tests/e2e/terminal-raster-artifact-analysis.ts tests/e2e/terminal-repro-evidence.ts config/scripts/run-ssh-codex-artifacts-repro-e2e.mjs
  • SKIP_BUILD=1 ORCA_E2E_FORCE_SSH_RECONNECT_DURING_TUI=1 ORCA_E2E_EXPECT_NO_CODEX_ARTIFACTS=1 ORCA_E2E_CODEX_FIXTURE_FRAMES=160 ORCA_E2E_CODEX_FIXTURE_FRAME_DELAY_MS=20 pnpm run test:e2e:ssh-codex-artifacts-repro

Evidence

The forced-reconnect repro delivered replay payloads for the same SSH PTY, then finished with no duplicated status rows and no stale gray raster rows in the final screen analysis.

Made with Orca 🐋


Open in Stage

@ghost

ghost commented Jun 22, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 4 individual chapters for you:

Title
1 Add attachForReconnect to SSH PTY provider
2 Filter duplicate replay payloads during reconnect
3 Coalesce terminal replay writes in renderer
4 Add Docker-backed SSH artifact repro harness
Open in Stage

Chapters generated by Stage for commit dc35d9f on Jun 22, 2026 7:40pm UTC.

@coderabbitai

coderabbitai Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Note

Reviews paused

It 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 reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 24a04f9d-6a5f-4991-ac40-b3b948ea3f6a

📥 Commits

Reviewing files that changed from the base of the PR and between 8ffca8e and dc35d9f.

📒 Files selected for processing (2)
  • package.json
  • src/renderer/src/components/terminal-pane/pty-connection.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • package.json
  • src/renderer/src/components/terminal-pane/pty-connection.ts

📝 Walkthrough

Walkthrough

The changes introduce a PTY reconnect replay deduplication pipeline spanning the main process and renderer. SshPtyProvider gains attachForReconnect, which issues pty.attach with suppressReplayNotification: true. SshRelaySession uses this new method during reattachment and suppresses duplicate replay payloads via a per-PTY content fingerprint map with a time-window guard. On the renderer side, replayDataCallback is rewritten with a promise-chain drain queue that coalesces overlapping replay events and triggers rebuildPaneWebgl exactly once per burst. A new E2E suite adds Docker exec utilities, remote TUI fixture scripts that deliberately produce gray background bands, a Playwright reconnect/replay driver, pixel-level raster gray-slab analysis, evidence persistence, and a spec that validates artifact absence after SSH reconnect, with a dedicated npm script and runner.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description covers the summary of changes, validation steps, and evidence, but lacks screenshots/visual changes section, AI review report, security audit, and platform-specific notes as specified in the template. Add missing sections: Screenshots (or 'No visual change'), AI Review Report with cross-platform checks, Security Audit summary, and Notes on platform-specific behavior and risks.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Fix SSH terminal replay artifacts' directly and clearly describes the main purpose of the PR: fixing SSH terminal replay artifacts during reconnect.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (3)
tests/e2e/ssh-codex-display-artifacts-repro.spec.ts (1)

177-183: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Document the env-driven assertion mode at the artifact check.

This branch is non-obvious (default repro-vs-strict mode), so a 1–2 line rationale comment here would prevent misinterpretation.

💡 Suggested comment
+      // Why: this spec supports both repro mode (expect artifacts) and strict
+      // regression mode (expect none), controlled by ORCA_E2E_EXPECT_NO_CODEX_ARTIFACTS.
       if (EXPECT_NO_ARTIFACTS) {
         expect(analysis.slabCount).toBeLessThanOrEqual(MAX_FINAL_GRAY_SLABS)
         expect(analysis.staleStatusGlyphRowCount).toBe(0)
         expect(analysis.duplicateStatusRows ?? []).toEqual([])
As per coding guidelines: “When writing or modifying code driven by a design doc or non-obvious constraint, add a comment explaining why the code behaves the way it does.”

Source: Coding guidelines

tests/e2e/terminal-raster-artifact-analysis.ts (2)

157-158: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Document the heuristic thresholds driving slab/status detection.

These hard-coded thresholds are non-obvious and design-driven; please add short rationale comments near the constants so future updates don’t accidentally invalidate artifact detection behavior.

Proposed fix
-  const minRunWidth = Math.max(32, Math.round(target.cellWidth * scaleX * 14))
-  const minRunHeight = Math.max(4, Math.round(target.cellHeight * scaleY * 0.35))
+  // Tuned to ignore short gray fragments while still catching replay slab bands.
+  const minRunWidth = Math.max(32, Math.round(target.cellWidth * scaleX * 14))
+  // Require multi-pixel vertical continuity to avoid one-line anti-alias noise.
+  const minRunHeight = Math.max(4, Math.round(target.cellHeight * scaleY * 0.35))
@@
-      cyanPixelCount >= Math.max(12, Math.round(target.cellWidth * scaleX * 3)) &&
-      greenPixelCount >= Math.max(24, Math.round(target.cellWidth * scaleX * 8)) &&
+      // Thresholds tuned to classify stale codex status glyph rows in screenshots.
+      cyanPixelCount >= Math.max(12, Math.round(target.cellWidth * scaleX * 3)) &&
+      greenPixelCount >= Math.max(24, Math.round(target.cellWidth * scaleX * 8)) &&

As per coding guidelines, **/*.{ts,tsx,js,jsx} changes with non-obvious constraints should include short comments explaining why the behavior exists.

Also applies to: 237-241

Source: Coding guidelines


297-297: 🧹 Nitpick | 🔵 Trivial | ⚡ Quick win

Replace fixed post-reset sleep with a deterministic paint wait.

Line [297] uses a fixed 250ms delay, which is prone to CI timing variance and can still capture before the reset is visually settled. Prefer a deterministic wait (e.g., two RAF ticks in-page) before recapturing.

Proposed fix
-  await page.waitForTimeout(250)
+  await page.evaluate(
+    () =>
+      new Promise<void>((resolve) =>
+        requestAnimationFrame(() => requestAnimationFrame(() => resolve()))
+      )
+  )
   return captureGraySlabAnalysis(page)

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: c53044b8-1b0b-4e34-acae-27e90cd50be6

📥 Commits

Reviewing files that changed from the base of the PR and between c1e0718 and 09d1d3e.

📒 Files selected for processing (15)
  • config/scripts/run-ssh-codex-artifacts-repro-e2e.mjs
  • package.json
  • src/main/providers/ssh-pty-provider.test.ts
  • src/main/providers/ssh-pty-provider.ts
  • src/main/ssh/ssh-relay-session.test.ts
  • src/main/ssh/ssh-relay-session.ts
  • src/renderer/src/components/terminal-pane/pty-connection.test.ts
  • src/renderer/src/components/terminal-pane/pty-connection.ts
  • tests/e2e/ssh-codex-display-artifacts-repro.spec.ts
  • tests/e2e/ssh-codex-real-remote.ts
  • tests/e2e/ssh-codex-reconnect-replay-driver.ts
  • tests/e2e/ssh-codex-repro-remote-fixtures.ts
  • tests/e2e/ssh-codex-terminal-observers.ts
  • tests/e2e/terminal-raster-artifact-analysis.ts
  • tests/e2e/terminal-repro-evidence.ts

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
tests/e2e/terminal-webgl-reset-capture.ts (1)

9-22: 🧹 Nitpick | 🔵 Trivial | 💤 Low value

Consider extracting shared pane lookup logic.

The tab/pane resolution code (lines 10-18) duplicates the logic in readActiveTerminalRasterTarget. If either changes—for example, if a new worktree-resolution edge case is added—they could drift apart.

Since this is test infrastructure and captureGraySlabAnalysis already handles the missing-pane error path, this is low risk. An optional improvement would be exporting a reusable pane-finding helper or passing pane identifiers explicitly.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 5c40f205-6a75-4dcf-bf38-1544cb5bedc3

📥 Commits

Reviewing files that changed from the base of the PR and between 2883576 and 8ffca8e.

📒 Files selected for processing (6)
  • config/scripts/run-ssh-codex-artifacts-repro-e2e.mjs
  • tests/e2e/ssh-codex-display-artifacts-repro.spec.ts
  • tests/e2e/ssh-codex-reconnect-replay-driver.ts
  • tests/e2e/ssh-codex-repro-remote-fixtures.ts
  • tests/e2e/terminal-raster-artifact-analysis.ts
  • tests/e2e/terminal-webgl-reset-capture.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • config/scripts/run-ssh-codex-artifacts-repro-e2e.mjs
  • tests/e2e/ssh-codex-repro-remote-fixtures.ts
  • tests/e2e/ssh-codex-reconnect-replay-driver.ts
  • tests/e2e/ssh-codex-display-artifacts-repro.spec.ts

…ver-ssh-codex-often-has-these-displa

# Conflicts:
#	src/cli/handlers/agent-hooks.test.ts
@Jinwoo-H
Jinwoo-H merged commit a0d9505 into main Jun 22, 2026
3 checks passed
@Jinwoo-H
Jinwoo-H deleted the Jinwoo-H/bug-remote-over-ssh-codex-often-has-these-displa branch June 22, 2026 23:42
nwparker added a commit that referenced this pull request Aug 30, 2026
Takes the current xterm beta line: xterm 287 -> 303, addon-webgl 286 -> 299,
addon-serialize 287 -> 300, headless 302, the remaining addons -> 300, and the
same set on mobile. All four packages stamp upstream commit d3e32b3.

The reasons are upstream #6042/#6043/#6055 (a shared glyph atlas no longer
garbles sibling panes on a page merge, clear, or sampler-budget overflow) and
Note that core 303 is not image-addon-only over 302: it carries the buffer perf
work, including the new BufferLineStringCache.

addon-webgl and addon-serialize move into the patch generator
--------------------------------------------------------------
Both were hand-edited minified bundles, which is what the Known Gaps section of
docs/reference/xterm-patch-regeneration.md described. Both reproduce byte for
byte from the pinned commit, so they are now manifest entries generated from a
source patch like @xterm/xterm already was. Their sourcemaps now move with their
bundles; before this they shipped maps whose offsets did not match the code
beside them.

The webgl patch shrinks from a 1.06 MB hand-edited bundle to a 6.6 KB source
patch, because upstream took the invalidation half Orca had backported. What is
left is only what upstream still lacks: the fragment-shader else branch for a
v_texpage past the sampler budget, the clearTexture guard that no-ops once a
merged page holds index 0, spending the merge retry budget before beginFrame
latches the version it saw, and Orca's font-weight probe.

The serialize source patch is byte-for-byte the same fixes as before; upstream
changed nothing in that addon between 287 and 300.

Generator fixes, each of which failed silently
----------------------------------------------
- `--relative` was appended after the `--` separator in CHECKOUT_DIFF_FLAGS, so
  git read it as a pathspec and kept repo-root-relative paths, dropping every
  source hunk from an addon's patch.
- `git apply` run from a package subdirectory still resolves patch paths from
  the repo root, skips every hunk and exits 0. It now runs from the root with
  `--directory=<packageDir>`, and a source patch that leaves the checkout
  unchanged is a hard failure rather than an empty patch.
- An addon's own `tsgo -p .` has empty files/include and only project
  references, so it emits nothing and the addon webpack then fails on a missing
  ./out/. The root build now runs first.
- versionStampFile is optional; publish.js stamps an addon's package.json, which
  overlayBuildOutput never patches.
- On a version bump the lockfile has no entry under the new key yet, so --write
  reports the gap instead of aborting mid-run. --check still fails on it.

Adding the two addons pushed the generator and the Electron packaging contract
test over max-lines, so the patch-text helpers move to xterm-patch-text.mjs
(pure text: no checkout, no build) and the vendored-xterm assertions move out of
the packaging contract into xterm-webgl-runtime-contract.test.mjs.

Tests
-----
Four tests asserted upstream bugs that are now fixed, not Orca behaviour:

- xterm-user-scrolling-contract pinned headless and core by version string.
  Upstream bumps each package only when its own output changes, so headless 302
  and core 303 are the same source. It now asserts they share a commit.
- Five CSI 3 J assertions expected a reader stranded at the top after an erase.
  Upstream #6081 clears isUserScrolling there, so the erase releases them to the
  bottom instead. Orca's pin still lands them correctly, because its parser
  handler observes the erase before xterm's own handler runs.
- The IME transaction test hard-coded the xterm version; it now reads the
  installed package, since the point is that bundle, map and version agree.
- The Electron runtime contract asserted Orca's old clearModelGeneration. Shared
  atlas invalidation is upstream's now, so it asserts pageLayoutVersion on the
  resolved dependency, plus the Orca-only hunks on the patch.

Verified: 66,008 unit tests, mobile's 3,863, the four WebGL atlas e2e specs, and
`regenerate-xterm-patches.mjs --check` in sync on all three packages.

Left alone deliberately: resetAllTerminalWebglAtlases still fans out globally
even though clearTexture now self-heals siblings, and upstream #6068
(WebglAddon.dispose leaks the GL context) is still open.
nwparker added a commit that referenced this pull request Aug 30, 2026
* Upgrade xterm to 6.1.0-beta.303 and generate the addon patches

Takes the current xterm beta line: xterm 287 -> 303, addon-webgl 286 -> 299,
addon-serialize 287 -> 300, headless 302, the remaining addons -> 300, and the
same set on mobile. All four packages stamp upstream commit d3e32b3.

The reasons are upstream #6042/#6043/#6055 (a shared glyph atlas no longer
garbles sibling panes on a page merge, clear, or sampler-budget overflow) and
Note that core 303 is not image-addon-only over 302: it carries the buffer perf
work, including the new BufferLineStringCache.

addon-webgl and addon-serialize move into the patch generator
--------------------------------------------------------------
Both were hand-edited minified bundles, which is what the Known Gaps section of
docs/reference/xterm-patch-regeneration.md described. Both reproduce byte for
byte from the pinned commit, so they are now manifest entries generated from a
source patch like @xterm/xterm already was. Their sourcemaps now move with their
bundles; before this they shipped maps whose offsets did not match the code
beside them.

The webgl patch shrinks from a 1.06 MB hand-edited bundle to a 6.6 KB source
patch, because upstream took the invalidation half Orca had backported. What is
left is only what upstream still lacks: the fragment-shader else branch for a
v_texpage past the sampler budget, the clearTexture guard that no-ops once a
merged page holds index 0, spending the merge retry budget before beginFrame
latches the version it saw, and Orca's font-weight probe.

The serialize source patch is byte-for-byte the same fixes as before; upstream
changed nothing in that addon between 287 and 300.

Generator fixes, each of which failed silently
----------------------------------------------
- `--relative` was appended after the `--` separator in CHECKOUT_DIFF_FLAGS, so
  git read it as a pathspec and kept repo-root-relative paths, dropping every
  source hunk from an addon's patch.
- `git apply` run from a package subdirectory still resolves patch paths from
  the repo root, skips every hunk and exits 0. It now runs from the root with
  `--directory=<packageDir>`, and a source patch that leaves the checkout
  unchanged is a hard failure rather than an empty patch.
- An addon's own `tsgo -p .` has empty files/include and only project
  references, so it emits nothing and the addon webpack then fails on a missing
  ./out/. The root build now runs first.
- versionStampFile is optional; publish.js stamps an addon's package.json, which
  overlayBuildOutput never patches.
- On a version bump the lockfile has no entry under the new key yet, so --write
  reports the gap instead of aborting mid-run. --check still fails on it.

Adding the two addons pushed the generator and the Electron packaging contract
test over max-lines, so the patch-text helpers move to xterm-patch-text.mjs
(pure text: no checkout, no build) and the vendored-xterm assertions move out of
the packaging contract into xterm-webgl-runtime-contract.test.mjs.

Tests
-----
Four tests asserted upstream bugs that are now fixed, not Orca behaviour:

- xterm-user-scrolling-contract pinned headless and core by version string.
  Upstream bumps each package only when its own output changes, so headless 302
  and core 303 are the same source. It now asserts they share a commit.
- Five CSI 3 J assertions expected a reader stranded at the top after an erase.
  Upstream #6081 clears isUserScrolling there, so the erase releases them to the
  bottom instead. Orca's pin still lands them correctly, because its parser
  handler observes the erase before xterm's own handler runs.
- The IME transaction test hard-coded the xterm version; it now reads the
  installed package, since the point is that bundle, map and version agree.
- The Electron runtime contract asserted Orca's old clearModelGeneration. Shared
  atlas invalidation is upstream's now, so it asserts pageLayoutVersion on the
  resolved dependency, plus the Orca-only hunks on the patch.

Verified: 66,008 unit tests, mobile's 3,863, the four WebGL atlas e2e specs, and
`regenerate-xterm-patches.mjs --check` in sync on all three packages.

Left alone deliberately: resetAllTerminalWebglAtlases still fans out globally
even though clearTexture now self-heals siblings, and upstream #6068
(WebglAddon.dispose leaks the GL context) is still open.

* Drop the two unused WebGL atlas fan-out exports

resetAllTerminalWebglAtlases and presentAllTerminalPanesWithoutAtlasClear have
no callers, and had none at cadfc55 either — the last call site went in
#6949, which routed reveal recovery through
resetAndRefreshAllTerminalWebglAtlases instead. Only a comment in
pane-manager.ts still named the first one; it now points at the live entry
point. scheduleRevealPresent leaves the registry's structural type with them,
though the manager method stays: terminal-visibility-resume.ts calls it
directly.

This is dead-code removal, not a consequence of the xterm bump. The live
recovery path is unchanged.

resetAndRefreshAllTerminalWebglAtlases stays, and so does the reveal-time
escalation in pane-reveal-repaint.ts. Upstream 299 does make a pane-local
clearTexture bump pageLayoutVersion so siblings rebuild on their next frame,
which is the bug the escalation was written for, but I could not demonstrate
that removing it is safe: with the escalation removed,
floating-workspace-shared-glyph-atlas.spec.ts still passed headful, and it also
passed with upstream's mechanism deliberately disabled (pageLayoutVersion
pinned to 0 in the installed bundle, verified present in the built renderer).
A guard that passes with the fix disabled cannot license removing the
workaround, so the escalation stays until that spec can reproduce the garbling.

Verified: pane-manager and terminal-pane suites (4,713 tests), typecheck, the
headful shared-atlas spec, and the three headless WebGL specs.

* Give the shared glyph atlas spec a trigger that can fail

floating-workspace-shared-glyph-atlas.spec.ts guards the corruption where one
terminal wiping the module-global atlas leaves sibling terminals drawing from
stale texture coordinates. Both of its tests drive that through a floating
panel reveal, and Orca's reveal paths escalate to a registry-wide atlas reset
that repaints every pane — so the recovery under test heals the damage before
the assertion runs, and the tests pass whether or not xterm propagates the
invalidation at all.

The new test clears the shared atlas straight through the floating manager with
the panel closed, so nothing else repaints the workspace terminal, then repaints
it with terminal.refresh(). That is the load-bearing detail: _updateModel skips
cells whose content is unchanged, so the refresh reuses vertices baked against
the pages that were just wiped, which is exactly the state the fix has to
recover from.

Verified as a discriminator rather than assumed. Pinning ITextureAtlas's
pageLayoutVersion getter to 0 in the installed bundle, which disables the
per-renderer invalidation upstream added in addon-webgl 0.20.0-beta.299, and
confirming that reached the built renderer:

  fix intact:   siblingClearIntact=true   1 passed
  fix disabled: siblingClearIntact=false  1 failed

The failure renders the workspace terminal completely blank — stale coordinates
into a wiped atlas sample nothing. The two reveal tests pass unchanged in both
configurations, which is the gap this closes.

* Compare shared-atlas screenshots with tolerance instead of byte equality

Byte equality fails on sub-pixel antialiasing noise that leaves every glyph
legible, so the headful spec flaked under xterm 303. Reuse the existing
compareTerminalScreenshots helper: real stale-model corruption blanks the
terminal at ~3% of pixels, twice the helper's 1.5% threshold, so the looser
oracle keeps its teeth. Log the ratio so failures are diagnosable.

* fix(xterm): cancel empty deferred IME compositions

* test(xterm): strengthen runtime patch contracts
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
* Upgrade xterm to 6.1.0-beta.303 and generate the addon patches

Takes the current xterm beta line: xterm 287 -> 303, addon-webgl 286 -> 299,
addon-serialize 287 -> 300, headless 302, the remaining addons -> 300, and the
same set on mobile. All four packages stamp upstream commit d3e32b3.

The reasons are upstream stablyai#6042/stablyai#6043/stablyai#6055 (a shared glyph atlas no longer
garbles sibling panes on a page merge, clear, or sampler-budget overflow) and
Note that core 303 is not image-addon-only over 302: it carries the buffer perf
work, including the new BufferLineStringCache.

addon-webgl and addon-serialize move into the patch generator
--------------------------------------------------------------
Both were hand-edited minified bundles, which is what the Known Gaps section of
docs/reference/xterm-patch-regeneration.md described. Both reproduce byte for
byte from the pinned commit, so they are now manifest entries generated from a
source patch like @xterm/xterm already was. Their sourcemaps now move with their
bundles; before this they shipped maps whose offsets did not match the code
beside them.

The webgl patch shrinks from a 1.06 MB hand-edited bundle to a 6.6 KB source
patch, because upstream took the invalidation half Orca had backported. What is
left is only what upstream still lacks: the fragment-shader else branch for a
v_texpage past the sampler budget, the clearTexture guard that no-ops once a
merged page holds index 0, spending the merge retry budget before beginFrame
latches the version it saw, and Orca's font-weight probe.

The serialize source patch is byte-for-byte the same fixes as before; upstream
changed nothing in that addon between 287 and 300.

Generator fixes, each of which failed silently
----------------------------------------------
- `--relative` was appended after the `--` separator in CHECKOUT_DIFF_FLAGS, so
  git read it as a pathspec and kept repo-root-relative paths, dropping every
  source hunk from an addon's patch.
- `git apply` run from a package subdirectory still resolves patch paths from
  the repo root, skips every hunk and exits 0. It now runs from the root with
  `--directory=<packageDir>`, and a source patch that leaves the checkout
  unchanged is a hard failure rather than an empty patch.
- An addon's own `tsgo -p .` has empty files/include and only project
  references, so it emits nothing and the addon webpack then fails on a missing
  ./out/. The root build now runs first.
- versionStampFile is optional; publish.js stamps an addon's package.json, which
  overlayBuildOutput never patches.
- On a version bump the lockfile has no entry under the new key yet, so --write
  reports the gap instead of aborting mid-run. --check still fails on it.

Adding the two addons pushed the generator and the Electron packaging contract
test over max-lines, so the patch-text helpers move to xterm-patch-text.mjs
(pure text: no checkout, no build) and the vendored-xterm assertions move out of
the packaging contract into xterm-webgl-runtime-contract.test.mjs.

Tests
-----
Four tests asserted upstream bugs that are now fixed, not Orca behaviour:

- xterm-user-scrolling-contract pinned headless and core by version string.
  Upstream bumps each package only when its own output changes, so headless 302
  and core 303 are the same source. It now asserts they share a commit.
- Five CSI 3 J assertions expected a reader stranded at the top after an erase.
  Upstream stablyai#6081 clears isUserScrolling there, so the erase releases them to the
  bottom instead. Orca's pin still lands them correctly, because its parser
  handler observes the erase before xterm's own handler runs.
- The IME transaction test hard-coded the xterm version; it now reads the
  installed package, since the point is that bundle, map and version agree.
- The Electron runtime contract asserted Orca's old clearModelGeneration. Shared
  atlas invalidation is upstream's now, so it asserts pageLayoutVersion on the
  resolved dependency, plus the Orca-only hunks on the patch.

Verified: 66,008 unit tests, mobile's 3,863, the four WebGL atlas e2e specs, and
`regenerate-xterm-patches.mjs --check` in sync on all three packages.

Left alone deliberately: resetAllTerminalWebglAtlases still fans out globally
even though clearTexture now self-heals siblings, and upstream stablyai#6068
(WebglAddon.dispose leaks the GL context) is still open.

* Drop the two unused WebGL atlas fan-out exports

resetAllTerminalWebglAtlases and presentAllTerminalPanesWithoutAtlasClear have
no callers, and had none at 45233ef either — the last call site went in
stablyai#6949, which routed reveal recovery through
resetAndRefreshAllTerminalWebglAtlases instead. Only a comment in
pane-manager.ts still named the first one; it now points at the live entry
point. scheduleRevealPresent leaves the registry's structural type with them,
though the manager method stays: terminal-visibility-resume.ts calls it
directly.

This is dead-code removal, not a consequence of the xterm bump. The live
recovery path is unchanged.

resetAndRefreshAllTerminalWebglAtlases stays, and so does the reveal-time
escalation in pane-reveal-repaint.ts. Upstream 299 does make a pane-local
clearTexture bump pageLayoutVersion so siblings rebuild on their next frame,
which is the bug the escalation was written for, but I could not demonstrate
that removing it is safe: with the escalation removed,
floating-workspace-shared-glyph-atlas.spec.ts still passed headful, and it also
passed with upstream's mechanism deliberately disabled (pageLayoutVersion
pinned to 0 in the installed bundle, verified present in the built renderer).
A guard that passes with the fix disabled cannot license removing the
workaround, so the escalation stays until that spec can reproduce the garbling.

Verified: pane-manager and terminal-pane suites (4,713 tests), typecheck, the
headful shared-atlas spec, and the three headless WebGL specs.

* Give the shared glyph atlas spec a trigger that can fail

floating-workspace-shared-glyph-atlas.spec.ts guards the corruption where one
terminal wiping the module-global atlas leaves sibling terminals drawing from
stale texture coordinates. Both of its tests drive that through a floating
panel reveal, and Orca's reveal paths escalate to a registry-wide atlas reset
that repaints every pane — so the recovery under test heals the damage before
the assertion runs, and the tests pass whether or not xterm propagates the
invalidation at all.

The new test clears the shared atlas straight through the floating manager with
the panel closed, so nothing else repaints the workspace terminal, then repaints
it with terminal.refresh(). That is the load-bearing detail: _updateModel skips
cells whose content is unchanged, so the refresh reuses vertices baked against
the pages that were just wiped, which is exactly the state the fix has to
recover from.

Verified as a discriminator rather than assumed. Pinning ITextureAtlas's
pageLayoutVersion getter to 0 in the installed bundle, which disables the
per-renderer invalidation upstream added in addon-webgl 0.20.0-beta.299, and
confirming that reached the built renderer:

  fix intact:   siblingClearIntact=true   1 passed
  fix disabled: siblingClearIntact=false  1 failed

The failure renders the workspace terminal completely blank — stale coordinates
into a wiped atlas sample nothing. The two reveal tests pass unchanged in both
configurations, which is the gap this closes.

* Compare shared-atlas screenshots with tolerance instead of byte equality

Byte equality fails on sub-pixel antialiasing noise that leaves every glyph
legible, so the headful spec flaked under xterm 303. Reuse the existing
compareTerminalScreenshots helper: real stale-model corruption blanks the
terminal at ~3% of pixels, twice the helper's 1.5% threshold, so the looser
oracle keeps its teeth. Log the ratio so failures are diagnosable.

* fix(xterm): cancel empty deferred IME compositions

* test(xterm): strengthen runtime patch contracts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant