test(terminal): follow the existing suites to the one geometry owner

The gate caught fourteen failures the focused tests could not: every harness
that builds a partial app out of cherry-picked mixin methods, and every source
guard that named `fitAddon.fit()` by hand.

Most are wiring — `syncTerminalGeometry`, `_refitAfterCellSizeChange` and
`_resizeTerminalTo` added to the fakes so the real chain runs rather than a
stub of it. `file-browser-search` is the one that shows why it matters: without
the method on the fake, selectSession's unconditional call threw into its own
catch and every later assertion in the file measured a load that never
happened.

Two are not wiring.

`detached-session-pane-sizing` pinned the behaviour this change deliberately
reverses. It asserted the LOCAL fit still runs for a session owned by its own
window — "withhold the send, never the reflow" — so the assertion is restated
rather than patched, with the reason beside it and in the file's docblock: a
reflow the PTY is never told about leaves this xterm rendering a CLI's frames
against a shape that does not exist, and the popup that owns the pane is
drawing for its own width regardless. The old rule bought a garbled frame, not
a correct one.

`mobile-prompt-composer` sliced `_cleanupSessionData` as a fixed 1200-character
window, so the assertion depended on how much unrelated code sat above the line
it cared about. It reads the whole method now.

`terminal-scroll-intent` records `syncTerminalGeometry` rather than `fit`,
under its own name: recording a bare fit there would name the very thing the
subject was changed to stop doing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Rounak Datta
2026-09-22 13:22:28 +05:30
co-authored by Claude Opus 5
parent abf1d1f1ca
commit d9fa9ba1eb
6 changed files with 58 additions and 7 deletions
+9 -1
View File
@@ -40,6 +40,14 @@ function loadKeyboardHandler(opts: { viewportY: number; baseY: number }) {
const app: any = {
terminal,
fitAddon: { fit: () => calls.push('fit') },
// The settle refits through the one function that also applies the floor
// it reports (#464), so that is what the fake has to offer. Recorded under
// its own name rather than 'fit': a bare fit here would be the divergence
// this test's subject was changed to avoid.
syncTerminalGeometry: () => {
calls.push('syncTerminalGeometry');
return { cols: 80, rows: 24 };
},
// The real predicate (terminal-ui.js isTerminalAtBottom), reproduced so the
// test exercises the same tolerance the runtime uses.
isTerminalAtBottom: () => terminal.buffer.active.viewportY >= terminal.buffer.active.baseY - 2,
@@ -131,7 +139,7 @@ describe('keyboard settle preserves scroll intent (issue #259)', () => {
kh._scheduleViewportSettle({});
settle();
expect(calls).toContain('fit');
expect(calls).toContain('syncTerminalGeometry');
expect(calls).not.toContain('scrollToBottom');
expect(calls.some((c) => c.startsWith('scrollToLine'))).toBe(false);
});