Skip to content

fix(terminal): defer metric option writes to unmeasurable panes - #12944

Merged
brennanb2025 merged 7 commits into
mainfrom
brennanb2025/terminal-deferred-hidden-appearance
Aug 7, 2026
Merged

brennanb2025 merged 7 commits into
mainfrom
brennanb2025/terminal-deferred-hidden-appearance

Conversation

@brennanb2025

@brennanb2025 brennanb2025 commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Terminal metric options — fontSize / fontFamily / fontWeight / fontWeightBold / lineHeight — now land only on panes that can actually be measured. On an unmeasurable pane the latest values park per-pane (WeakMap keyed on the terminal, latest-wins) and flush at the next safe fit or reveal, before the fit reads dimensions so cols/rows are computed from the new metrics.

Why: writing any of these makes xterm's renderer clear() + handleResize(cols, rows) + _fullRefresh() (RenderService). On a pane with no usable box that repaint is wasted — with WebGL suspended it lands in the DOM-renderer fallback — and the cols/rows re-fit that has to follow the write cannot run there. Deferring keeps that churn off hidden panes across every tab and keeps the metric write coupled to the fit that must follow it.

Non-metric options (theme, cursor, scroll sensitivity) are untouched — they are safe while hidden. Measurability helpers moved from pane-fit.ts to pane-fit-measurability.ts to stay under the max-lines cap (no behavior change in the move). A metric-options-deferred-flush diagnostic breadcrumb records each flush for crash-report forensics.

Correction to the original rationale

This PR was originally described as fixing the P0 "terminal stuck on bold/blurry font until resize" reports, on the theory that writing a metric option to a hidden pane re-measures cell size against a wrong box, latches it via hasValidSize, and mis-keys the shared WebGL glyph atlas. That mechanism was investigated and disproved — noting it here so reviewers don't build on it:

  • CharSizeService constructs TextMetricsMeasureStrategy (an OffscreenCanvas + measureText) and only falls back to DomMeasureStrategy if that constructor throws. Chromium supports both OffscreenCanvas and fontBoundingBoxAscent/Descent, so the TextMetrics path is what runs in Electron. It reads no DOM, no layout, and no visibility state — a hidden pane measures identically to a visible one.
  • The DOM fallback already guards the hidden case: BaseMeasureStategy._validateAndSet discards a 0-width/height result and retains the previous value rather than latching it.
  • hasValidSize is just width > 0 && height > 0. It can be false; it cannot be wrongly true from a bad box, because the box is never an input.
  • CharAtlasUtils.generateConfig keys the atlas on dpr, cell/char metrics, font and colors — not cols/rows or canvas size — so a hidden-pane atlas is keyed identically to a visible-pane one.
  • CharSizeService re-measures only on ['fontFamily', 'fontSize']. Three of the five options deferred here (fontWeight, fontWeightBold, lineHeight) never trigger a cell-size measure at all.

Upstream has no issue matching the described bug; the closest, xterm.js #3029 "FitAddon and display:none", was closed as designed with the position that only cols/rows need a real box — which Orca already gates via canMeasurePaneForFit.

So this PR is a repaint/perf improvement plus the correctness fixes below, not a fix for the bold/blurry-font P0. That P0's DOM-fallback-frame route is handled by the separate per-pane WebGL attach latch + fit-anchored reattach PR. The two are independent and land in either order; both touch the pane-fit.ts import block, so whichever lands second needs a trivial rebase.

Review fixes (commit 2)

  • The deferral never flushed. The WeakMap was keyed on ManagedPane, but PaneManager.getPanes() returns a fresh toPublicPane() wrapper on every call, so the writer and every reader used different keys. The net effect was dropping metric writes on hidden panes rather than deferring them — change the font with a tab hidden and that tab kept the old font indefinitely. Now keyed on pane.terminal, which is carried by reference through the wrapper and dies with the pane.
  • Forced layout on the tab-switch hot path. flushDeferredPaneMetricOptionsIfMeasurable probed measurability (a getComputedStyle ancestor walk + getBoundingClientRect + proposeDimensions) before checking whether anything was parked, per pane on every resume. The O(1) WeakMap check now comes first, so the common no-deferral case costs zero DOM reads — this matters because the light tab-resume path is built to do no layout work at all.
  • Second forced measurement per pane per settings write. Any settings write re-runs the appearance pass over every mounted pane. paneMetricOptionsAlreadySettled now short-circuits when all five values are already live and nothing is parked, which also stops a no-op deferral arming a pointless refit on the next reveal.
  • Reveal could strand parked options. fitRevealedPane's pixel and grid checks can both say "nothing to do" and return without fitting. It now flushes first and fits when a flush lands.
  • Font zoom could be clobbered. useTerminalFontZoom writes fontSize directly then calls safeFit, which flushes — overwriting the user's zoom with the parked value. The zoom now folds its value into any pending deferral, so other parked keys still apply.
  • The fit floor was evaluated with pre-flush metrics. performSafeFit checked the minimum cols/rows gate at the old cell size, then flushed and fit unconditionally. A large font jump on a narrow pane passes at the old size and lands under the floor at the new one, so fit() pinned the PTY to exactly the sliver grid that floor exists to reject. It now re-checks after a flush that actually landed; the parked values still apply, only the fit is skipped.
  • The reveal flush did a raw synchronous fit. fitRevealedPane's flush branch called safeFit directly, which its own contract forbids on reveal: resumeRendering has just re-attached WebGL, whose cell metrics transiently differ from the DOM renderer's, and xterm's wrap→unwrap is not a perfect inverse — so a raw fit there can leave a diff-painting inline TUI corrupted. A landed flush leaves pixels unchanged with a diverged grid, the same shape as a snapshot resize, so it now takes the same steady-grid repair. Reachable via window wake, which calls fitAllRevealedPanes with no pre-flush loop.
  • Narrow panes were stranded on a stale font. canApplyPaneMetricOptions reused canMeasurePaneForFit, but the divider clamp is 50px — over the 48px pixel floor, yet only ~5 cols, under the ≥8 cols fit floor. Such a pane deferred every font change and never flushed: it never hides, and its box never changes, so no reveal and no ResizeObserver entry arrives. Metric writes now gate on display plus the pixel box only. Hidden panes and the transient worktree-switch overlay are near-zero, so they still defer; the cols/rows floor stays on the fit. Apply and flush share one predicate, so no "applies but never flushes" state can open up.

Testing

  • pnpm typecheck
  • oxlint + audit:code-quality:native + audit:code-quality:type-aware
  • src/renderer/src/lib/pane-manager/ and src/renderer/src/components/terminal-pane/ — 304 files / 3803 tests green
  • full pnpm test and pnpm build — left to CI
  • Added or updated high-quality tests that would catch regressions

Test notes: the keying bug survived round 1 because the fixtures were identity-blind — getPanes returned the same objects every call, unlike production. makeManager now allocates a fresh pane view per call, and there are direct regression tests that defer through one toPublicPane() view and flush through another and through the internal pane. Both fail if the key is reverted to the pane object. Also covered: the settled gate (including that a parked deferral is never "settled", so an equal-valued apply can't strand it), the zoom fold-in, and fitRevealedPane fitting when a flush lands on a pane the size checks would otherwise skip.

Security Audit

Renderer-internal state only. No input handling, command execution, path handling, auth, secrets, dependency, or IPC changes. The diagnostics breadcrumb carries only a numeric pane id through the existing terminal_webgl_diagnostic sink.

Notes

  • Cross-platform: renderer-only logic, identical on macOS/Linux/Windows. No shortcuts, labels, paths, shell, or Electron platform-specific behavior touched. SSH and folder-workspace panes go through the same pane-manager paths and the same gates.
  • Deliberately NOT changed: reveal-time atlas resets, and the parking/unmount architecture (design discussion pending).
  • Follow-up worth a ticket: the real mis-measure vector for font rendering is font-load timing — measureText resolves against whatever face is loaded at that instant, so a late-arriving @font-face leaves cached metrics diverged until a resize. Unrelated to visibility and untouched here.

Writing fontSize/fontFamily/fontWeight/lineHeight makes xterm re-measure
cell size against the pane's current box. A hidden or mid-layout pane can
measure a wrong-but-nonzero size, which latches (hasValidSize) and mis-keys
the shared WebGL glyph atlas until a manual resize — the stuck variant of
the P0 bold/blurry-font reports.

Metric writes now land only on measurable panes; otherwise the latest
values park per-pane and flush on the next safe fit or reveal (with a refit
on the light tab-resume path, which otherwise skips fitting). Measurability
helpers move to pane-fit-measurability.ts to stay under the pane-fit.ts
line cap.
@coderabbitai

coderabbitai Bot commented Aug 6, 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
📝 Walkthrough

Walkthrough

Terminal metric options now defer when pane dimensions cannot be measured. Latest deferred values replace earlier values and flush after measurement succeeds. Safe fitting validates pane dimensions before fitting. Appearance updates route font and line-height options through the deferred path. Visibility resume flushes measurable panes and refits revealed panes when deferred metrics are applied. Tests cover deferral, replacement, fitting, and light tab reveal behavior.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 45.45% 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
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.
Title check ✅ Passed The title clearly and concisely describes the main change: deferring terminal metric option writes for unmeasurable panes.
Description check ✅ Passed The description is detailed and covers the change, testing, security, notes, and cross-platform impact, but omits the Screenshots and AI Review Report sections.
✨ Finishing Touches 💡 1
📝 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.

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 021ec59c-311a-4690-aefe-728c73dc80db

📥 Commits

Reviewing files that changed from the base of the PR and between f6d0bde and e681157.

📒 Files selected for processing (8)
  • src/renderer/src/components/terminal-pane/terminal-appearance.test.ts
  • src/renderer/src/components/terminal-pane/terminal-appearance.ts
  • src/renderer/src/components/terminal-pane/terminal-visibility-resume.test.ts
  • src/renderer/src/components/terminal-pane/terminal-visibility-resume.ts
  • src/renderer/src/lib/pane-manager/pane-fit-measurability.ts
  • src/renderer/src/lib/pane-manager/pane-fit.ts
  • src/renderer/src/lib/pane-manager/pane-metric-options-deferral.test.ts
  • src/renderer/src/lib/pane-manager/pane-metric-options-deferral.ts

Comment on lines +83 to +85
// Why here: metric options deferred while the pane was unmeasurable must land
// before this fit reads dimensions, or the fit pins cols/rows to stale metrics.
flushDeferredPaneMetricOptions(pane)

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.

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

Keep deferred metrics deferred for display-none panes.

Line 80 validates dimensions but not display visibility. A hidden pane with cached nonzero dimensions can reach Line 85 and apply xterm metrics against an invalid layout. Use canApplyPaneMetricOptions for this safe-fit gate. Add a display-none fixture that reports nonzero dimensions.

Proposed fix
-import { canMeasurePaneForFit, getProposedPaneDimensions } from './pane-fit-measurability'
+import { canApplyPaneMetricOptions, getProposedPaneDimensions } from './pane-fit-measurability'
@@
-  if (!canMeasurePaneForFit(pane)) {
+  if (!canApplyPaneMetricOptions(pane)) {
     return false
   }

Based on PR objectives, safe fitting must validate pane visibility before a deferred flush.

getPanes() returns a fresh toPublicPane() wrapper per call, so a
WeakMap keyed on ManagedPane never matched across call sites: deferred
metric options were dropped, not deferred. Key on pane.terminal, which
is carried by reference and dies with the pane.

Also from review:
- flushDeferredPaneMetricOptionsIfMeasurable checks the pending WeakMap
  before the measurability probe, so the common no-deferral case costs
  zero forced style/layout on every reveal.
- applyTerminalAppearance skips the apply (and the probe) when all five
  values are already live and nothing is parked; any settings write
  re-runs the pass over every mounted pane, and arming a no-op deferral
  would trigger a refit on the next reveal.
- fitRevealedPane flushes first: its pixel/grid checks can both no-op
  and return without fitting, stranding parked options.
- Font zoom folds its direct fontSize write into any pending deferral so
  the flush inside safeFit cannot clobber the user's zoom.

Corrects comments that asserted a cell-size re-measure mechanism xterm
does not have: CharSizeService measures via OffscreenCanvas TextMetrics,
independent of the pane box, and only fontSize/fontFamily re-measure.

Test fixtures now allocate a fresh pane view per getPanes() call, which
is what production does and what hid the keying bug.
performSafeFit evaluated the min cols/rows gate with the pre-flush cell
size, then flushed and fit unconditionally. A large font jump on a
narrow pane passes the gate at the old size and lands under it at the
new one, so fit() pinned the PTY to the tiny grid the floor exists to
reject. Re-check after a flush that actually landed.

The parked values still apply, so the pane is never stuck on stale
metrics; only the fit is skipped.
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron manual validation — 4/4 PASS

Isolated Orca dev instance (dedicated ORCA_DEV_USER_DATA_PATH, CDP 9335), identity verified via window.api.app.getIdentity() as brennanb2025/terminal-deferred-hidden-appearance. All verdicts below are backed by screenshots of rendered pixels, not store or DOM inspection.

Scenario Result Pixel proof
A — font 14→22 changed while a tab is hidden PASS Hidden tab measured 0×0 at change time, so the deferred path was genuinely exercised. On reveal it rendered at the new size immediately, no manual resize. Glyph weight and sharpness matched the always-visible tab — no bold doubling, blur, or ghosted second layer.
B — font family + line height while hidden PASS SF Mono→Menlo and line height 1→2 both landed on reveal; leading visibly ~2× vs scenario A.
C — font zoom not clobbered PASS Global size set to 16 while the tab was hidden, tab revealed, then ⌘= — zoom enlarged and stayed after 2s rather than snapping back to the parked value.
D — normal path, no regression PASS Visible-pane font change applied immediately; split, uneven divider drag, and rapid tab switching all left readable text with no stuck grid, clipping, or overlapping canvases.

Scenario A is the direct on-screen disproof of the keying regression fixed in 529a3b3403: before that commit the parked metrics were stored against a throwaway toPublicPane() wrapper, so a font change made while a tab was hidden was dropped permanently, not deferred.

Gaps — stated explicitly rather than implied

  • Validated against 529a3b3403. The later ea0233513c (re-check the fit floor after a flush) is not covered by these scenarios; it targets a narrow-pane edge case that needs a pane at the ~50px divider clamp.
  • Multi-worktree switching was not exercised (single worktree in the test profile). That path matters here, so it's an open gap.
  • Playwright's Meta+= does not reach Electron's main-process zoom routing; scenario C used real OS keystrokes to the verified Electron PID.
  • Mid-run, a default playwright session briefly attached to a different Orca instance (other worktrees were also running with remote debugging). Every scenario screenshot was re-verified against the correct identity through a named session afterwards.

Screenshots are saved locally at ~/orca-qa/pr-12944/ (26 PNGs) with a full write-up in REPORT.md. Say the word if you want them uploaded to the PR itself — that needs an assets branch or the web UI, since the CLI can't attach images to a comment.

fitRevealedPane's new flush branch called safeFit directly, which is
exactly what the function's contract forbids on reveal: resumeRendering
has just re-attached WebGL, whose cell metrics transiently differ from
the DOM renderer's, so a raw fit can propose a one-column-off grid and
reflow — and xterm's wrap/unwrap is not a perfect inverse, leaving a
diff-painting inline TUI corrupted.

A landed flush leaves pixels unchanged with a diverged grid, the same
shape as a snapshot resize, so it takes the same steady-grid repair.
A real resize still fits synchronously, after the flush.

Reachable via window wake, which calls fitAllRevealedPanes with no
pre-flush loop.

@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: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d1d0bad0-28d8-48f0-98a9-90e89d03f1b1

📥 Commits

Reviewing files that changed from the base of the PR and between ea02335 and 2be1c12.

📒 Files selected for processing (2)
  • src/renderer/src/lib/pane-manager/pane-reveal-fit.test.ts
  • src/renderer/src/lib/pane-manager/pane-reveal-fit.ts

Comment on lines +79 to +92
it('still flushes parked metric options when the pane also resized while hidden', () => {
mocks.flushDeferredPaneMetricOptionsIfMeasurable.mockReturnValue(true)
const pane = createPane({
lastFitClientSize: { width: 800, height: 600 },
currentSize: { width: 640, height: 480 },
terminal: { cols: 80, rows: 24 },
proposed: { cols: 64, rows: 20 }
})

fitRevealedPane(pane)

expect(mocks.flushDeferredPaneMetricOptionsIfMeasurable).toHaveBeenCalledWith(pane)
// A real resize still takes the synchronous path, and the flush already landed.
expect(mocks.safeFit).toHaveBeenCalledWith(pane)

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.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Assert the resize routing in this test.

This test verifies only that deferred options are flushed. It does not verify that a client-size change calls safeFit and avoids requestStablePaneFit. Add both assertions so a regression to stable routing does not pass.

Proposed assertions
     expect(mocks.flushDeferredPaneMetricOptionsIfMeasurable).toHaveBeenCalledWith(pane)
+    expect(mocks.safeFit).toHaveBeenCalledWith(pane)
+    expect(mocks.requestStablePaneFit).not.toHaveBeenCalled()
     // A real resize still takes the synchronous path, and the flush already landed.

canApplyPaneMetricOptions reused canMeasurePaneForFit, whose >=8 cols /
>=4 rows floor exists to stop a fit pinning the PTY to a sliver. But the
divider clamp is 50px, which clears the 48px pixel floor and proposes
~5 cols — so a pane dragged to the clamp deferred every font change and
never flushed: it never hides, and its box never changes, so no reveal
and no ResizeObserver entry ever arrives. It rendered a stale font until
widened, where pre-PR the write was unconditional.

Gate metric writes on display plus the pixel box only. Hidden panes and
the transient worktree-switch overlay are near-zero, so they still
defer — the deferral's purpose is unchanged. The cols/rows floor stays
on the fit, including the post-flush re-check in performSafeFit.

Apply and flush share the same predicate, so no "applies but never
flushes" state can open up.
Conflict was the predicted one in pane-fit.ts: #12945 and this branch
each split the file differently to stay under the max-lines cap.

Resolution keeps both splits:
- main's pane-fit-client-size.ts extraction (readFitClientSize is now
  re-exported from there; the local copies are dropped)
- this branch's pane-fit-measurability.ts extraction (canMeasurePaneForFit
  and getProposedPaneDimensions), so main's local getProposedDimensions
  and duplicate min-size constants are dropped
- main's notifyPaneFitSucceeded in safeFit, alongside the deferred metric
  flush and post-flush fit-floor re-check in performSafeFit
@brennanb2025

Copy link
Copy Markdown
Contributor Author

Electron UI QA — PASS

Branch/HEAD: brennanb2025/terminal-deferred-hidden-appearance @ 25bf0f8fc7
Method: Isolated Electron dev instance (CDP :9335, dedicated ORCA_DEV_USER_DATA_PATH, VITE_EXPOSE_STORE=true) via playwright-cli; no Computer Use / input injection.

Scenario

  1. Two terminal tabs in the pinniped worktree; seed content on Terminal 1.
  2. Switch to Terminal 2 (hide Tab1).
  3. Change metrics while Tab1 hidden: fontSize 14→22, fontFamily SF Mono→Menlo, fontWeight 500→700, lineHeight 1→1.4.
  4. Light reveal: tab-switch back to Terminal 1.
  5. Heavy reveal: setActiveWorktree(null) → change metrics again (22→18, Menlo→Monaco, 700→400, 1.4→1.2) → re-activate worktree + Terminal 1.
  6. Light-switch Terminal 2 to confirm its parked heavy-path metrics flush.

Outcome

Checkpoint Result
Hidden pane keeps old live options (deferral) Pass — Tab1 stayed 14/SF Mono/500/1 while Tab2 applied 22/Menlo/700/1.4
Light reveal flushes + re-fits Pass — Tab1 → 22/Menlo/700/1.4, 83×26, screen fitted to pane
Heavy reveal flushes + re-fits Pass — Tab1 → 18/Monaco/400/1.2, 103×33, fitted
WebGL restored (no stretched DOM fallback) Pass — canvasCount 4, domRows 0 after both reveals
No garbled/corrupted TUI on first paint Pass — buffer + screenshots readable

Screenshots

Light reveal (Tab1 @ 22px Menlo 700 / 1.4):
02-tab1-light-reveal-new-metrics.png

Heavy reveal (Tab1 @ 18px Monaco 400 / 1.2):
03-tab1-heavy-reveal-monaco-18.png

Tab2 after metrics while Tab1 hidden:
01-tab2-visible-after-metrics.png

Tab2 after parked heavy-path flush:
04-tab2-after-parked-flush.png

Limitations

  • Driven via store/CDP (setActiveTab / setActiveWorktree / updateSettings), not Settings UI clicks.
  • Single pane per tab (no split layout); no SSH/folder-workspace host variant.
  • Glyph crispness judged visually from screenshots (no atlas pixel-diff automation).

Local evidence: /tmp/orca-qa-12944-screenshots/, /tmp/orca-qa-12944-report.md

@brennanb2025
brennanb2025 merged commit bc1e049 into main Aug 7, 2026
90 of 92 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…lyai#12944)

* fix(terminal): defer metric option writes to unmeasurable panes

Writing fontSize/fontFamily/fontWeight/lineHeight makes xterm re-measure
cell size against the pane's current box. A hidden or mid-layout pane can
measure a wrong-but-nonzero size, which latches (hasValidSize) and mis-keys
the shared WebGL glyph atlas until a manual resize — the stuck variant of
the P0 bold/blurry-font reports.

Metric writes now land only on measurable panes; otherwise the latest
values park per-pane and flush on the next safe fit or reveal (with a refit
on the light tab-resume path, which otherwise skips fitting). Measurability
helpers move to pane-fit-measurability.ts to stay under the pane-fit.ts
line cap.

* fix(terminal): key metric deferral by terminal, not pane view

getPanes() returns a fresh toPublicPane() wrapper per call, so a
WeakMap keyed on ManagedPane never matched across call sites: deferred
metric options were dropped, not deferred. Key on pane.terminal, which
is carried by reference and dies with the pane.

Also from review:
- flushDeferredPaneMetricOptionsIfMeasurable checks the pending WeakMap
  before the measurability probe, so the common no-deferral case costs
  zero forced style/layout on every reveal.
- applyTerminalAppearance skips the apply (and the probe) when all five
  values are already live and nothing is parked; any settings write
  re-runs the pass over every mounted pane, and arming a no-op deferral
  would trigger a refit on the next reveal.
- fitRevealedPane flushes first: its pixel/grid checks can both no-op
  and return without fitting, stranding parked options.
- Font zoom folds its direct fontSize write into any pending deferral so
  the flush inside safeFit cannot clobber the user's zoom.

Corrects comments that asserted a cell-size re-measure mechanism xterm
does not have: CharSizeService measures via OffscreenCanvas TextMetrics,
independent of the pane box, and only fontSize/fontFamily re-measure.

Test fixtures now allocate a fresh pane view per getPanes() call, which
is what production does and what hid the keying bug.

* fix(terminal): re-check the fit floor after a metric flush

performSafeFit evaluated the min cols/rows gate with the pre-flush cell
size, then flushed and fit unconditionally. A large font jump on a
narrow pane passes the gate at the old size and lands under it at the
new one, so fit() pinned the PTY to the tiny grid the floor exists to
reject. Re-check after a flush that actually landed.

The parked values still apply, so the pane is never stuck on stale
metrics; only the fit is skipped.

* fix(terminal): route a reveal metric flush through the stable fit

fitRevealedPane's new flush branch called safeFit directly, which is
exactly what the function's contract forbids on reveal: resumeRendering
has just re-attached WebGL, whose cell metrics transiently differ from
the DOM renderer's, so a raw fit can propose a one-column-off grid and
reflow — and xterm's wrap/unwrap is not a perfect inverse, leaving a
diff-painting inline TUI corrupted.

A landed flush leaves pixels unchanged with a diverged grid, the same
shape as a snapshot resize, so it takes the same steady-grid repair.
A real resize still fits synchronously, after the flush.

Reachable via window wake, which calls fitAllRevealedPanes with no
pre-flush loop.

* fix(terminal): gate metric writes on the pixel box, not the fit floor

canApplyPaneMetricOptions reused canMeasurePaneForFit, whose >=8 cols /
>=4 rows floor exists to stop a fit pinning the PTY to a sliver. But the
divider clamp is 50px, which clears the 48px pixel floor and proposes
~5 cols — so a pane dragged to the clamp deferred every font change and
never flushed: it never hides, and its box never changes, so no reveal
and no ResizeObserver entry ever arrives. It rendered a stale font until
widened, where pre-PR the write was unconditional.

Gate metric writes on display plus the pixel box only. Hidden panes and
the transient worktree-switch overlay are near-zero, so they still
defer — the deferral's purpose is unchanged. The cols/rows floor stays
on the fit, including the post-flush re-check in performSafeFit.

Apply and flush share the same predicate, so no "applies but never
flushes" state can open up.

* fix(terminal): flush heavy reveal metrics after WebGL resume
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