feat: surfaces — a diff part, generic publish, snippet→surface rename#26
Merged
Conversation
Introduce the surface model: a surface is an ordered list of parts, each with its own kind (html | diff). A snippet becomes a surface with one html part; a diagram-with-its-diff is [html, diff] in one card. - types: Surface/SurfacePart/DiffPart, Comment.surfaceId; Store renamed to *Surface methods - storage + sqlStore: surfaces table/array, in-place migration from legacy snippets + comments.snippetId (deployed DOs can't reset) - app: publishSurface/reviseSurface flows; /api/surfaces (+ /api/snippets html-sugar aliases); /s/:id?part=N renders one html part; surface-* events - mcp (http + stdio): publish_surface/update_surface + snippet aliases - cli: sideshow diff, publish --diff, comment --surface - diff parts are data rendered by the trusted viewer, never via the iframe Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- viewer: Card iterates surface.parts — html parts keep the sandboxed iframe (one per part), diff parts render via a new <DiffPart> using @pierre/diffs' CodeView (shiki-js engine, no wasm). Full snippet->surface rename in api/ state/App; feedback-loop behavior preserved verbatim. - @pierre/diffs bundled into the single-file viewer. - docs: DESIGN_GUIDE/AGENT_SETUP/SKILL teach surfaces, parts, and diff examples. - CHANGELOG [Unreleased]; AGENTS.md map (surfacePage, surfaces/parts). - api.test: combined html+diff surface, part rendering, publish_surface MCP. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- write responses (POST/PUT /api/surfaces + aliases) return identifiers and part kinds only, not the parts the agent just sent — a large diff patch is never echoed back. Reads (GET, session list) still carry full parts. - tool schemas + design guide recommend the compact `patch` form for diffs and mark before/after `files` as the heavier fallback. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
396ddf2 to
4ebc396
Compare
|
Review the following changes in direct dependencies. Learn more about Socket for GitHub.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Surfaces + a diff surface
Generalizes "snippets" into surfaces: a published card is now an ordered list of parts, each with its own kind. Two kinds today:
html— arbitrary agent markup, rendered sandboxed in an iframe (exactly today's snippet).diff— a unified/git patch, rendered natively in the viewer by@pierre/diffs(CodeView,shiki-jsengine) as a syntax-highlighted split/unified code review.A surface can combine parts, so
[html, diff]is a diagram with its code review in one versioned, commentable card.Why diffs render outside the iframe
A diff is data (a patch), not arbitrary code — the agent sends a patch and we own the rendering. So diff parts render in the trusted viewer, not the sandbox: less injected-content risk, the viewer controls the theme, and
@pierre/diffsgets its real CSS + layout managers (bundled via Vite). The snippet sandbox invariant —allow-scripts, noallow-same-origin— is untouched; it still governs everyhtmlpart.Generic publishing, all three tiers
publish_surface/update_surface(parts);publish_snippet/update_snippetremain as html-sugar aliases.POST/PUT/GET/DELETE /api/surfaces; legacy/api/snippetsroutes alias through.sideshow diff <patch>,sideshow publish --diff <patch>,sideshow comment --surface.What changed
server/types.ts):Surface/SurfacePart/DiffPart;Comment.surfaceId;Store*Surfacemethods.htmlPart/firstHtmlbridge the legacy shape.storage.ts,workers/sqlStore.ts): surfaces table/array; in-place migration of legacysnippetsandcomments.snippetIdon load (deployed DOs can't reset). Both still passtest/storeContract.ts.publishSurface/reviseSurfaceflows;surface-*SSE events;/s/:id?part=Nrenders one html part.Carditeratessurface.parts(iframe per html part; new<DiffPart>per diff part); full snippet→surface rename; feedback-loop behavior preserved verbatim.Back-compat
Old snippet endpoints, MCP tools, and the
?snippet=comment param all still work; stored boards migrate automatically. Existing agent configs keep working.Validation
npm test— 68 pass (store contract runs against both stores; new coverage for combined html+diff surfaces, part rendering, and thepublish_surfaceMCP tool).npm run typecheck(node + workers + viewer) clean;npm run lint/format:checkclean.npm run test:e2e(chromium) — 11/11 pass.shiki-js, no CSP/wasm issues).Heads-up: viewer bundle size
Bundling
@pierre/diffsinlines shiki's full grammar/theme set into the single-file viewer:index.html~10.2 MB (1.81 MB gzip), up from small. The runtime highlighter only loads the langs we preload, butvite-plugin-singlefilestatically inlines all lazily-importable grammars. Lever (deferred): a constrained shiki core import or externalizing grammars — but that risks the no-static-assets single-document invariant, so flagging rather than changing the build strategy here.Follow-ups (not in this PR)
parentId) — Phase 2.sideshow demodiff example; a diff-rendering e2e assertion.🤖 Generated with Claude Code