Skip to content

refactor: split the viewer out of the Claude artifact host - #35

Merged
mindsocket merged 1 commit into
mainfrom
claude/project-thread-tmn7yk
Nov 13, 2026
Merged

mindsocket merged 1 commit into
mainfrom
claude/project-thread-tmn7yk

Conversation

@mindsocket

Copy link
Copy Markdown
Owner

Requested by Rog · project thread

First step toward a self-contained HTML render of a space's map views. The artifact host's UI moves into a host-neutral viewer, so a second host (an inline HTML page) can reuse it without picking up Claude artifact concepts.

Changes

  • src/viewer/Viewer.tsx and viewer.css: the space and view switcher, parameter controls, map view and side panel. These come from src/artifact/main.tsx and page.css, with the art- classes renamed to viewer-.
  • cardLabel option: the viewer applies an accessible name to each card when a host passes one. The artifact host passes the comment-mode label ([<index>] <title> · <view>), so its behaviour is unchanged.
  • src/core/snapshot.ts: SpaceSnapshot now lives here as a type, so browser hosts can use it. The artifact loader returns it, and the duplicate LoadedSpace type is gone (name is now space). There is no public API change.
  • Module boundary tests: the viewer may import only core, layouts, React and structured-context/browser, and no module may import the artifact host.
  • docs/architecture.md and AGENTS.md are updated to match.

Verification

  • bun test, bun run typecheck and bun run lint pass.
  • I bundled the artifact host with a mocked artifact database holding the launch-playbook fixture and loaded it in Playwright. Cards carried [1] 04 Sustain · strategy-tree-style labels, 44 edges were drawn, selecting a node opened the panel with a warning, and the console showed no errors.
  • bun run build builds the library, but this sandbox couldn't run the final build-artifact-page step because its network blocks jsDelivr. That step only changed the CSS path it reads.

Generated by Claude Code

The artifact host's UI (space and view switcher, parameter controls, map
view, side panel) moves to src/viewer as a host-neutral Viewer, so other
hosts, such as a self-contained HTML page, can reuse it. The snapshot type
moves to core, and the artifact's loader returns it instead of restating
it. Card labels for the artifact's comment mode become a cardLabel option
the artifact host passes. Module boundary tests keep the viewer free of
host code and keep hosts unimported.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019XphpeFwEYm8K11SoT9ewz
@mindsocket
mindsocket merged commit 5825459 into main Nov 13, 2026
1 check passed
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.

2 participants