fix(runtime): disable size debounce on emulator path so term.resize() reflows synchronously (14764)#6
Merged
Merged
Conversation
… reflows synchronously (14764) The autoTerm created inside createApp wraps the caller's stdout with `createSize` which applies a 200ms trailing-edge debounce on `resize` events. That coalescing is correct for real terminals receiving SIGWINCH bursts from tmux/cmux/Ghostty multiplexer resizes, but in emulator-backed runs (`run(<App />, createTermless())`) the resize is driven explicitly via `term.resize(cols, rows)` — no burst possible. The 200ms delay just pushes the resize event past the test's 100ms settle window, leaving the layout frozen on the pre-resize geometry. Surface symptom: km-silvery.termless-resize-reflow-4-fails — 4 tests in termless-coverage.test.tsx that resize the terminal and assert post-resize content all failed because the runtime never re-laid-out: top borders stay at the old width, columns clipped to the old narrow viewport never reflow, taller terminals show stale buffer content instead of the new full-height layout. Fix: thread a `resizeCoalesceMs` option from run.tsx emulator branch through app.run → autoTerm → createNodeTerm → createSize. The emulator branch passes 0 (no debouncing); the options-path with a fake real-stream still uses the 200ms default so existing burst-coalescing regression tests (run-writable.test.tsx "Screen sees only final coalesced width") keep their contract. Real-PTY callers go through run.tsx's Term branch where the caller injects their own Term — autoTerm path isn't used at all, so the default debounce is preserved end-to-end. Tests: - vendor/silvery/tests/features/termless-coverage.test.tsx — 4 resize tests flipped from test.fails → test, all passing - 2441 features tests pass | 1 expected fail (unrelated termless test.fails) - run-writable.test.tsx burst-coalescing assertions still pass (options path retains 200ms default) Touched files (+25 LOC of code, ~50 LOC of doc comments): - packages/ag-term/src/ansi/types.ts — CreateTermOptions.resizeCoalesceMs - packages/ag-term/src/ansi/term.ts — propagate option to createSize - packages/ag-term/src/runtime/create-app.tsx — AppRunOptions.resizeCoalesceMs; thread to autoTerm - packages/ag-term/src/runtime/run.tsx — emulator branch passes 0 - tests/features/termless-coverage.test.tsx — flip test.fails to test, update comments to "regression guard"
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
tests/features/termless-coverage.test.tsx(red→green) — termlessterm.resize(cols, rows)now propagates to layout within the test's 100ms settle windowcreateSizewhich applies a 200ms trailing-edge debounce. That coalescing is right for real terminals (tmux/cmux/Ghostty SIGWINCH bursts) but in emulator paths the resize is driven explicitly viaterm.resize(...)— no burst possible. The 200ms delay just pushes the resize event past the test's settle.resizeCoalesceMsoption from run.tsx emulator branch throughapp.run→ autoTerm →createNodeTerm→createSize. Emulator branch passes 0; options-path with fake real-stream keeps the 200ms default (run-writable.test.tsxburst-coalescing tests still green). Real-PTY callers go through run.tsx's Term branch wheretermis injected as a provider — autoTerm path isn't used, debounce contract preserved end-to-end.Files (+25 LOC of code, ~50 LOC of doc comments)
packages/ag-term/src/ansi/types.ts— newCreateTermOptions.resizeCoalesceMspackages/ag-term/src/ansi/term.ts— propagate option tocreateSizepackages/ag-term/src/runtime/create-app.tsx— newAppRunOptions.resizeCoalesceMs; thread to autoTerm creationpackages/ag-term/src/runtime/run.tsx— emulator branch passesresizeCoalesceMs: 0tests/features/termless-coverage.test.tsx— flip 4test.fails→test, update comments to "regression guard"Test plan
bun vitest run --project vendor vendor/silvery/tests/features/termless-coverage.test.tsx(15/15)bun vitest run --project vendor vendor/silvery/tests/features/(2441 pass | 1 expected fail | 4 skipped)test.failsflipped showed 4 distinct failures (border-width unchanged, Right Column missing at narrow width, top border missing after shrink, Row 9 missing after grow)