Skip to content

feat!: replace snapshots with element replay - #171

Merged
cowboyd merged 1 commit into
mainfrom
feat/element-replay
Dec 1, 2026
Merged

cowboyd merged 1 commit into
mainfrom
feat/element-replay

Conversation

@cowboyd

@cowboyd cowboyd commented Oct 27, 2026

Copy link
Copy Markdown
Collaborator

What does this PR do?

Adds result.info.get(id).replay as a substitute for an entire rendered element, including its descendants. Hosts can reuse its packed directives without rebuilding or repacking the subtree. Layout, pointer handling, caret placement, and transitions still run in the new render context.

let sidebar = previous.info.get("sidebar")!;
let next = term.render([
  open("root", rootProps),
  sidebar.replay,
  close(),
]);

Removes snapshot(). Obtain a fresh replay after each completed render; update() and rejected renders preserve existing replays. The optional validated(term) wrapper rejects expired replays and unbalanced open/close directives.

Assembly walks the incoming buffer once, copying fresh spans and referenced spans from the previous frame into the current runlist before execution. Element metadata remains lazy.

The renderer spec (§8.3.4) defines this feature's scope and behavior, so no separate issue is needed.

Type of change

  • Bug fix
  • Feature
  • Refactor (no behavior change)
  • Documentation
  • Performance improvement
  • Tests
  • Chore (dependencies, CI, tooling)

Validation

  • WASM build passes; deno task test passes all 29 suites / 417 test steps.
  • deno task verify, deno lint, and deno task build:npm 0.0.0-verify.0 pass.
  • Tests cover replay equivalence, descendant renewal, resizing, pointer/caret behavior, transitions, capacity failures, and optional validation.
  • Local 80×24 dashboard benchmark, three interleaved rounds including replay renewal: steady replay takes 22.48 µs/frame versus 29.76 µs for fresh directives; replaying the body with a changing footer takes 23.67 µs versus 30.08 µs. Output and bounds match. Fresh rendering measured roughly 2% slower than the pre-replay branch in this run.

Checklist

  • All tests pass (deno task test)
  • Files are formatted (deno task fmt)
  • I have added/updated tests for my changes (if applicable)
  • I have added a changeset

AI-generated code disclosure

  • This PR includes AI-generated code

@bombshell-cooper

This comment was marked as duplicate.

Comment thread .changeset/element-replay.md Resolved
@pkg-pr-new

pkg-pr-new Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Open in StackBlitz

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

commit: 9672e33

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Size Increased — +0.2 KB

132.6 KB unpacked

@codspeed

codspeed Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

1 warning

⚠️ Upgrade your CodSpeed plugin for Node.js 24

@codspeed/* 5.4.0 is only tested on Node.js 18, 20, and 22, so your Node.js 24 measurements may be inaccurate. Upgrade your @codspeed/* packages to 6.0.0 or later.

See affected benchmarks

✅ 10 untouched benchmarks
🆕 1 new benchmark

Performance Changes

Benchmark BASE HEAD Efficiency
🆕 render steady replay N/A 27 ms N/A

Comparing feat/element-replay (9672e33) with main (326f86e)

Open in CodSpeed

@cowboyd
cowboyd force-pushed the feat/element-replay branch 2 times, most recently from 4fabb9f to b44bd3f Compare December 1, 2026 02:30
@cowboyd
cowboyd force-pushed the feat/element-replay branch from b44bd3f to 4ef220f Compare December 1, 2026 02:34
Comment thread .changeset/css-color-strings.md Resolved
@cowboyd
cowboyd force-pushed the feat/element-replay branch from 4ef220f to b5baf57 Compare December 1, 2026 02:37
Comment thread .changeset/css-color-strings.md Resolved
Base automatically changed from spike/frame-ownership to main December 1, 2026 02:45
@cowboyd
cowboyd force-pushed the feat/element-replay branch from b5baf57 to 9672e33 Compare December 1, 2026 02:45
Comment thread .changeset/css-color-strings.md Resolved
@cowboyd
cowboyd marked this pull request as ready for review December 1, 2026 02:46
@cowboyd
cowboyd merged commit 869521b into main Dec 1, 2026
13 checks passed
@cowboyd
cowboyd deleted the feat/element-replay branch December 1, 2026 05:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants