Skip to content

feat(viz): shared stack-and-heap snapshot and a light/dark palette - #202

Merged
mnaimfaizy merged 1 commit into
mainfrom
feat/shared-snapshot
Oct 11, 2026
Merged

mnaimfaizy merged 1 commit into
mainfrom
feat/shared-snapshot

Conversation

@mnaimfaizy

Copy link
Copy Markdown
Owner

Summary

PR 3 of the ADR 0004 build plan: the shared foundation. No behaviour or visual change.

  • src/shared/snapshot/ — Slot, StackFrame, HeapObject, Snapshot, Reference, slotKey, getReferences, getReachable, moved out of the Stack ↔ Heap story so a Playground trace step can hold the same shape.
    • Adds the heap kinds function and scope that a trace needs (a closure and the popped frame it keeps alive). No story uses them yet.
    • cell is optional, because a trace has no authored cells; Placed<T> marks authored placement.
    • Reachability stays derived from references, never stored.
    • The story narrows the generic types and re-exports every name it exported, so no other file changes. stackHeapStory.test.ts passes unedited and the beat data is untouched.
  • src/shared/viz/palette.ts — one palette organised by role, with a light and a dark variant. Light reproduces today's colours exactly. Dark is defined and contrast-tested for the Playground and is not used yet. New roles: function and scope.
  • StackHeap2D / StackHeap3D read their colours from the light palette; no raw hex remains in either file.
  • beat-model skill — stack-and-heap stories take the snapshot from src/shared/snapshot; other domains (Git commits and refs) keep their own typed snapshots.

Checks

  • npx tsc -b, npm run lint, npm run test:run (35 files, 364 tests; 24 new) and npm run build pass. npm run agents:check passes.
  • Every hex removed from the two views exists with the same value in the light palette.
  • The built entry bundle contains no WebGLRenderer; StackHeap3D is still its own lazy chunk.
  • In a browser, the Stack ↔ Heap story at beat 7 renders in 2D and 3D with the original colours and no console errors. The other beats and the label-overlap script were not re-run.

Notes for review

  • Light contrast. Three of today's light colours are below 3:1 against the light background: object stroke 2.42, array stroke 2.65, focus 2.05. The values are kept, and the test asserts the measured value for light only. Fixing them would change the published look.
  • Behaviour edge. getReachable now ignores a refId that matches no heap object, and a slot may reference a frame id. No story has either case.
  • Unused for now. frameActive fill and stroke, and the text / label entries (hex approximations of the current Tailwind classes) are used when the views are generalised in PR 4.
  • The Git views keep their own palettes until then.

🤖 Generated with Claude Code

First step of ADR 0004's shared foundation. No behaviour or visual change.

- src/shared/snapshot: Slot, StackFrame, HeapObject, Snapshot, Reference
  and the reference helpers, moved out of the Stack <-> Heap story so a
  Playground trace step can hold the same shape. Adds the `function` and
  `scope` kinds a trace needs and makes `cell` optional (`Placed<T>` for
  authored placement). The story re-exports every name it exported.
- src/shared/viz/palette: one palette by role with a light and a dark
  variant. Light reproduces today's colours exactly; dark is defined and
  contrast-tested for the Playground, not used yet.
- StackHeap2D and StackHeap3D read their colours from the light palette.
- beat-model skill: stack-and-heap stories take the snapshot from
  src/shared/snapshot; other domains keep their own typed snapshots.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@mnaimfaizy mnaimfaizy self-assigned this Oct 11, 2026
@mnaimfaizy
mnaimfaizy merged commit 74622c2 into main Oct 11, 2026
9 checks passed
@mnaimfaizy
mnaimfaizy deleted the feat/shared-snapshot branch October 11, 2026 10:17
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