Skip to content

feat!: replace snapshots with element replay - #171

Draft
cowboyd wants to merge 1 commit into
spike/frame-ownershipfrom
feat/element-replay
Draft

cowboyd wants to merge 1 commit into
spike/frame-ownershipfrom
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

Copy link
Copy Markdown
Contributor

Changeset suggestion

The current changeset no longer matches this PR. This review contains a corrected replacement.

Why: Changeset package scope does not match the affected packages confidently. Changeset bump does not match the consumer-visible impact.

View the proposed changeset
---
'@bomb.sh/tty': minor
---

TODO: Write changeset message (inference failed: HTTP 401: {"error":{"message":"User not found.","code":401}})

Review this changeset manually

If this draft is correct, react with 🚀 and Cooper will commit it to this branch.

@@ -0,0 +1,10 @@
---

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.

Changeset needs revision.

Changeset package scope does not match the affected packages confidently. Changeset bump does not match the consumer-visible impact.

View the proposed replacement
---
'@bomb.sh/tty': minor
---

TODO: Write changeset message (inference failed: HTTP 401: {"error":{"message":"User not found.","code":401}})

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

@github-actions

Copy link
Copy Markdown

Size Reduced — -0.7 KB

129.7 KB unpacked

@codspeed

codspeed Bot commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Merging this PR will not alter performance

✅ 10 untouched benchmarks
🆕 1 new benchmark

Performance Changes

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

Comparing feat/element-replay (bb380f3) with spike/frame-ownership (6269f98)1

Open in CodSpeed

Footnotes

  1. No successful run was found on spike/frame-ownership (201083e) during the generation of this report, so b5d7d13 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report. ↩

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.

1 participant