Skip to content

feat: in-place resize via term.update() - #113

Draft
natemoo-re wants to merge 9 commits into
feat/terminfofrom
nm/feat/resize
Draft

feat: in-place resize via term.update()#113
natemoo-re wants to merge 9 commits into
feat/terminfofrom
nm/feat/resize

Conversation

@natemoo-re

Copy link
Copy Markdown
Member
  • resizing no longer means throwing the whole Term away — term.update({ width, height }) resizes it in place, synchronously
  • you can also pass input events straight through: term.update({ events }) picks out the resize events (last one wins, everything else ignored), so it folds right into a render loop next to input.scan()
  • no new wasm module is ever created: the existing instance grows its memory if needed and re-inits the renderer state where it stands, so a terminfo attachment survives the resize
  • the first frame after a resize is a full repaint, reusing the same mechanism capability changes already use
  • memory only grows: shrinking the terminal keeps the high-water mark until the Term is discarded (spec'd as accepted behavior)
  • resizing to the same size is a no-op, and bad dimensions (zero, negative, fractional) throw
  • spec'd first in renderer-spec §7.7/§8.6; no C changes needed — init() was already re-entrant
  • 9 new tests: layout at new dims, full repaint, no-op, event coalescing, pointer-state reset, truecolor surviving resize while attached, downsize-then-upsize

Builds on #106 (based on feat/terminfo).

Replaces the create-a-new-Term resize story (old 7.4) with a synchronous
update transaction: reallocate renderer state in place within the existing
wasm instance and linear memory, never re-instantiating over shared memory,
so a TermInfo attachment survives resize.

Accepts a discriminated options bag: explicit dimensions or an event array
(resize events coalesce last-wins; non-resize events ignored). The event
shape is structural, deliberately assignable from input's ResizeEvent
without introducing a renderer->input dependency (11.4).

After a non-no-op update the next render is a complete redraw, reusing the
7.6 generation-invalidation mechanism. Growth-only memory (high-water mark
on downsize) is documented as accepted behavior. Output views are
invalidated by update() since memory.grow detaches buffers; 7.3's validity
window is widened accordingly.
…guard

Review follow-up: 'let opsBuf!: number' plus a runtime '=== undefined'
check sent conflicting signals. Allocating the fixed-size attached
buffer once at declaration makes opsBuf always a number and removes
the guard from layout().
Clay__RootContainer leaks into pointer-over ids (pre-existing, elastic
per renderer-spec 12.4); the pointer suite matches with filters and
toContainEqual rather than encoding the internal id, so do the same.
@github-actions

Copy link
Copy Markdown

Size Increased — +3.0 KB

142.7 KB unpacked

@pkg-pr-new

pkg-pr-new Bot commented Aug 22, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@bomb.sh/tty@113

commit: 92a8ef5

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