Skip to content

Fix blank/unclosable mobile emulator tab in floating workspace - #6042

Merged
Jinwoo-H merged 4 commits into
stablyai:mainfrom
wolfiesch:wolfiesch/popup-window-can-t-close-mobile-emulator
Jun 22, 2026
Merged

Jinwoo-H merged 4 commits into
stablyai:mainfrom
wolfiesch:wolfiesch/popup-window-can-t-close-mobile-emulator

Conversation

@wolfiesch

@wolfiesch wolfiesch commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes the floating-workspace Mobile Emulator (simulator) tab, which rendered a blank pane and could not be closed (the X and right-click "Close" did nothing).

FloatingTerminalPanel only handled three tab content types — terminal, browser, and editor. Simulator tabs appeared in the floating tab strip but were implicitly treated as editor tabs:

  • Blank pane: there was no render branch for simulator tabs, and they have no backing OpenFile, so nothing was drawn.
  • Close did nothing: the close handler fell through to the editor branch and called closeFile(entityId), which no-ops for a simulator tab (no backing file).

Changes

src/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsx

  • Treat simulator as its own content type — excluded from the editor predicates (activeEditorUnifiedId, activeEditorFileId, and the editorItems filter).
  • Add simulatorItems plus a render branch that mounts EmulatorPane for the active simulator tab (mirrors the existing browser branch).
  • Add 'simulator' to activeTabType resolution and pass activeSimulatorTabId into TabBar.
  • Route simulator-tab closes through closeUnifiedTab(tab.id) instead of closeFile.
  • Exclude simulator from floating Close All Files (closeAllFiles) — simulator tabs are not files, so this leaves the Mobile Emulator open like terminal/browser tabs.

src/renderer/src/components/floating-terminal/FloatingTerminalPanel.test.tsx

  • Add setFloatingSimulatorTab helper and an EmulatorPane mock.
  • Add a case asserting a simulator tab renders EmulatorPane and that closing routes through closeUnifiedTab.
  • Add a case asserting Close All Files closes a clean editor tab but leaves a simulator tab open.

E2E automation (added in this PR)

tests/e2e/floating-mobile-emulator-tab.spec.ts — a deterministic Electron/Playwright smoke test that guards exactly this fix:

  • Seeds a simulator unified tab in the floating workspace via the store, opens the real floating panel, and asserts the emulator pane renders ([data-emulator-pane]).
  • Closes the tab through the real tab-strip X ([data-tab-close-button="true"]) and asserts the simulator tab is gone from both the DOM and the store.
  • No live iOS Simulator, Orca Computer, or AX clicking — runs headless in CI. Run with pnpm run test:e2e:floating-mobile-emulator.

Supporting hooks: stable data-emulator-pane on the emulator pane roots and data-tab-close-button on the simulator tab chrome.

Screenshots

Demo (screen recording) — opening the floating Mobile Emulator tab and closing it via the tab-strip X: the pane renders and the close path works.

Floating Mobile Emulator open/close demo

Testing

  • pnpm test (focused: FloatingTerminalPanel.test.tsx, 46 passed)
  • pnpm typecheck (focused: typecheck:web passed)
  • oxlint on the changed files (passed; lint-staged hook also passed on commit)
  • pnpm lint (full)
  • pnpm build
  • Added a regression test that fails without the simulator render/close wiring
  • pnpm run test:e2e:floating-mobile-emulator (headless + headful, 1 passed) — exercises real renderer DOM and the tab-strip close path

AI Review Report

Ran a maintainability review (code-simplifier) over the diff: no simplifications recommended — the additions mirror the established terminal/browser/editor patterns with consistent naming. The duplicated contentType !== predicate predates this change and matches file style; extracting a helper would broaden scope. No cross-platform-specific code paths (shortcuts, paths, shell, Electron platform branches) are touched — this is renderer tab-routing logic shared across macOS/Linux/Windows.

Security Audit

No input handling, command execution, path handling, auth, secrets, dependency, or IPC surface changes. The fix only re-routes an existing in-renderer store action (closeUnifiedTab) and mounts an existing component (EmulatorPane). No new external data flows.

Notes

Draft PR. Remaining before marking ready: manual UI verification of open/close in a dev profile with an active emulator session, plus full pnpm lint / pnpm build.


Open in Stage

FloatingTerminalPanel only handled terminal/browser/editor content types, so simulator tabs rendered no pane and routed close through closeFile (a no-op for simulator tabs). Treat simulator as its own content type: render EmulatorPane for the active simulator tab, wire activeSimulatorTabId into TabBar, and close via closeUnifiedTab.
@ghost

ghost commented Jun 22, 2026 •

Copy link
Copy Markdown

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

Title
1 Include simulator tabs in floating workspace counts
2 Add stable test hooks to emulator components
3 Wire simulator tabs into FloatingTerminalPanel
4 Verify floating simulator behavior with unit tests
5 Add E2E regression test for mobile emulator
Open in Stage

Chapters generated by Stage for commit 48a315d on Jun 22, 2026 11:24pm UTC.

@AmethystLiang

Copy link
Copy Markdown
Contributor

thx for the PR! will get it landed once its ready

Adds a deterministic Electron/Playwright spec that seeds a simulator unified tab in the floating workspace, asserts the emulator pane renders, and closes it through the real tab-strip X. Adds stable data-emulator-pane selectors and a data-tab-close-button hook on the simulator tab chrome, plus a targeted package script. No live iOS Simulator or Orca Computer/AX dependency.
@wolfiesch

Copy link
Copy Markdown
Contributor Author

ofc! I'm making a few final tweaks - will push the PR out of draft when ready!

Close All Files filtered out only terminal/browser tabs, so after the simulator render/close fix it would also close the Mobile Emulator. Simulator tabs are not files; exclude contentType 'simulator' to match terminal/browser behavior, and add a regression test asserting Close All Files closes the editor tab but leaves the simulator open.
@wolfiesch

Copy link
Copy Markdown
Contributor Author

Pushed 1891e6fba: excluded simulator tabs from floating Close All Files. closeAllFiles previously filtered out only terminal/browser tabs, so after the simulator render/close fix it would also close the Mobile Emulator. Simulator tabs aren't files, so they're now excluded alongside terminal/browser, matching that behavior. Added a regression test: Close All Files closes a clean editor tab but leaves a simulator tab open.

Focused vitest (47 passed), typecheck:web, and oxlint on the changed files all pass.

@wolfiesch
wolfiesch marked this pull request as ready for review June 22, 2026 11:46
Copilot AI review requested due to automatic review settings June 22, 2026 11:47
@coderabbitai

coderabbitai Bot commented Jun 22, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 0bda4276-8828-4984-8c03-8c29aa3a8c9c

📥 Commits

Reviewing files that changed from the base of the PR and between 1891e6f and 48a315d.

📒 Files selected for processing (3)
  • src/renderer/src/store/selectors.test.ts
  • src/renderer/src/store/selectors.ts
  • tests/e2e/floating-mobile-emulator-tab.spec.ts

📝 Walkthrough

Walkthrough

The pull request adds a "simulator" tab type to FloatingTerminalPanel. EmulatorPane is imported and rendered for active simulator tabs, with inactive ones hidden via absolute positioning. Active editor state derivation is updated to exclude simulator tabs, a new simulatorItems list is derived separately from editorItems, and closeUnifiedTab is wired to handle simulator tab close while "Close All Files" preserves them. The tab visibility selector is updated to count simulator tabs as always-visible floating tabs. EmulatorPane's root div gains a data-emulator-pane attribute and EditorFileTab's close button gains data-tab-close-button="true" for test targeting. Unit tests and a new Playwright E2E spec covering tab render and close are added, along with a corresponding npm script.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main fix: restoring functionality (rendering and closing) to the previously blank and unclosable mobile emulator tab in the floating workspace.
Description check ✅ Passed The description includes all required sections: a detailed summary of the fix, screenshots with a demo recording, testing status (focused tests and E2E passed; full lint/build pending), AI review report, security audit, and notes acknowledging draft status and pending work.
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.


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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Fixes floating-workspace “Mobile Emulator” unified tabs by treating simulator as a first-class tab content type (rendering EmulatorPane and closing via closeUnifiedTab), and adds regression coverage to prevent blank/unclosable simulator tabs from returning.

Changes:

  • Add explicit simulator-tab handling in FloatingTerminalPanel (tab classification, rendering, and close/close-all routing).
  • Add unit tests + a dedicated Electron/Playwright E2E smoke test for floating simulator tab render + close behavior.
  • Add stable test selectors for the emulator pane root and the real tab-strip close button.

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
tests/e2e/floating-mobile-emulator-tab.spec.ts New E2E regression test that seeds a floating simulator tab, asserts pane renders, and closes via the tab-strip X.
src/renderer/src/components/tab-bar/EditorFileTab.tsx Adds a stable data-tab-close-button attribute to the close button for E2E targeting (used by simulator tabs too).
src/renderer/src/components/floating-terminal/FloatingTerminalPanel.tsx Implements simulator tab type handling: excluded from editor predicates, rendered via EmulatorPane, and closed via closeUnifiedTab.
src/renderer/src/components/floating-terminal/FloatingTerminalPanel.test.tsx Adds simulator-focused unit tests and store helpers validating render + close-all-files behavior.
src/renderer/src/components/emulator-pane/EmulatorPane.tsx Adds data-emulator-pane to the emulator pane root for stable E2E selection.
src/renderer/src/components/emulator-pane/emulator-unavailable-pane.tsx Adds data-emulator-pane to the unavailable state root so E2E can assert rendering on non-macOS too.
package.json Adds test:e2e:floating-mobile-emulator script to run the new E2E spec deterministically.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +70 to +77
async function openFloatingPanelIfNeeded(page: Page): Promise<void> {
if ((await page.locator(OPEN_PANEL_SELECTOR).count()) === 0) {
await page.evaluate((eventName) => {
window.dispatchEvent(new Event(eventName))
}, TOGGLE_EVENT)
}
await expect(page.locator(OPEN_PANEL_SELECTOR)).toBeVisible()
}

@Jinwoo-H Jinwoo-H 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.

Thanks, this is the right direction. I added one follow-up fix while validating:

  • Count simulator tabs in the floating visible-tab selector so a closed floating workspace with only Mobile Emulator content still mounts and can be reopened.
  • Made the new e2e wait for the floating panel mount before dispatching the toggle event.
  • Verified the real Electron flow: simulator pane renders in the floating workspace, and the tab-strip close button removes the simulator tab from both DOM and store state.

Validation passed: focused unit tests, typecheck, changed-file lint, and pnpm run test:e2e:floating-mobile-emulator.

@Jinwoo-H
Jinwoo-H merged commit e46d4a9 into stablyai:main Jun 22, 2026
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
…yai#6042)

* Fix blank/unclosable mobile emulator tab in floating workspace

FloatingTerminalPanel only handled terminal/browser/editor content types, so simulator tabs rendered no pane and routed close through closeFile (a no-op for simulator tabs). Treat simulator as its own content type: render EmulatorPane for the active simulator tab, wire activeSimulatorTabId into TabBar, and close via closeUnifiedTab.

* Add floating Mobile Emulator tab E2E smoke test

Adds a deterministic Electron/Playwright spec that seeds a simulator unified tab in the floating workspace, asserts the emulator pane renders, and closes it through the real tab-strip X. Adds stable data-emulator-pane selectors and a data-tab-close-button hook on the simulator tab chrome, plus a targeted package script. No live iOS Simulator or Orca Computer/AX dependency.

* Exclude simulator tabs from floating Close All Files

Close All Files filtered out only terminal/browser tabs, so after the simulator render/close fix it would also close the Mobile Emulator. Simulator tabs are not files; exclude contentType 'simulator' to match terminal/browser behavior, and add a regression test asserting Close All Files closes the editor tab but leaves the simulator open.

* Keep floating simulator tabs mounted

---------

Co-authored-by: Wolfgang Schoenberger <[email protected]>
Co-authored-by: Jinwoo-H <[email protected]>
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.

4 participants