Repository navigation
Conversation
People edit an HTML page's text without touching the page's own code: every element whose children are only text and <br> gets a `data-pid`, inserted into the original upload so the rest of the page stays byte for byte. Pids survive agent republishes by matching old and new elements (kept pid, then same path, then same tag, by text similarity), and a match on repeated labels or with a close runner-up is flagged uncertain so people's text on it is never carried silently. Splice-back writes changed text at each pid's source span and leaves untouched pids' bytes alone. One text rule serves seeding, splicing, comparison and the bridge: <br> is a newline and, outside <pre>, source indentation collapses, so editing one word in an indented paragraph never splices line breaks in. Checked on real agent pages up to 120 KB / 1,000 pids: stripping the pids gives the original, and restamping is a no-op. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Each pid's text lives in its own fragment `page/<blockId>/<pid>`, written through the one apply pipeline. A text edit replaces only the changed middle, so comment marks on the rest of the text stay. On an agent republish each pid is decided three ways against its last stamped text: untouched text takes the agent's, text only people changed is carried, and when both changed, or the match was uncertain, the agent's text wins and people's text is returned as a suggestion. People's text is read inside the edit on the document queue, so typing that races the republish is never lost. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Agents can place <primer-table>, <primer-code>, <primer-mermaid> and <primer-math> in an HTML page. The sanitizer keeps them with their literal `data-embed-id` and `lang`; each becomes the native BlockNote block (table, code, diagram, math) in its own fragment, and an untouched one exports as its original source. A missing, invalid or repeated id is refused at publish with the element's path, since an id set by a script can't anchor state. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The bridge reports each stamped element's DOM text after the page's scripts ran; a pid whose text no longer equals its source text was drawn by a script (a chart label, a counter) and gets no overlay editor, as do pids a script cloned or the sanitizer dropped. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A page's fragments are seeded from its stamped source at publish (each pid with its text, each embed with its native blocks), and its current HTML is rendered on demand by splicing in only the pids and embeds that changed. An embed counts as untouched when its blocks equal the blocks its source gives, recomputed from the stored stamped source, so no editor-writable state can make the export lie about it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…stack Both stacks kept. The working status that M4 removed stays removed (its MCP tool, client method, route row and banner). M10a's two migrations are replaced by one regenerated on top of M5's (0022, same tables and indexes). The comments, suggestions and delete-guard strings from M3-M5 get i18n keys in every locale, so the localisation lint holds. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Page text is untrusted input, so matching shares the banded similarity the Markdown republish merge uses and stops comparing past a total budget (remaining elements get fresh pids, which never carries text silently). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A page is untrusted input. Matching charged only similarity's character work, so pairs rejected by tag, path or length were free and a page with thousands of elements still did quadratic work. Now every examined pair costs at least 1, candidates come from tag and path indexes, both loops stop once the budget is spent, the pairs kept per stage are capped and only the first 3,000 elements per side are matched; the rest get fresh pids. Stamping and splicing applied each insertion by copying the whole page, also quadratic; both now build the output in one pass. A 20,000-element page of identical labels stamps and matches in well under a second. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
An HTML publish now makes a live document holding one page block over the stamped upload, like Markdown and text: the stamped source is stored once with the checkpoint that published it (pages/<documentId>/<versionId>.html, purged with the document), each pid's fragment is seeded with its text and each embed's with its blocks, and a legacy document's open threads are anchored where their quote occurs once in the page text. An HTML version of a page document carries people's text over three ways through the pipeline: the publisher's text wins where both changed, and the person who last wrote the lost text gets it back as their suggestion. The page block (packages/blocks) names its fragments: the page's pids and embed ids are props, so reachability, and with it thread orphaning, follows republishes. Its source key is editor-writable, so every read checks it lies in the document's own prefix. Bundles, export and print render a page document as its page with people's text spliced in; its frame is served from GET /api/documents/:docId/pages/:blockId/content with the artifact CSP, and GET /api/documents/:docId/pages/:blockId binds the host to it (policy, each pid's source text, embeds). Page text paragraphs carry the page block's id, so a pid target locates its block like any other: agents edit page text with `update` and a plain-text block under the usual version precondition, and suggestions on page text keep their fragment. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…uggest-mode republish) A page republish follows the same rule as Markdown: when nothing applied, no original is stored and no checkpoint written. An agent that may only suggest on a legacy document can't make it live (there is nothing to suggest against). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Its HTML republish proposes new text for the page's existing elements as suggestions; the page's source, elements and embeds change only by someone who may edit, so the stored source is discarded and no version is made. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…y document HTML publishes are live pages now, so the thread carry across HTML versions (lib/threadCarry.ts) has no caller and goes, with its tests. Tests of legacy behaviour create a legacy document directly (testing/legacy.ts); content assertions expect the stamped pids. Republishes of one document run one at a time, so two publishes on the same base can't both win. New tests pin a page document end to end: the upload becomes one page block; its frame is served with the artifact CSP; export splices people's text into the original; an agent's republish keeps text only people changed and returns both-changed text to its writer as a suggestion; a removed element's thread is orphaned, not lost; an agent edits a pid with ops and the comment on it stays; a suggest-mode agent only suggests and can't make a legacy document live. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
primer_get_doc lists a page document's pages: each page block's source as
published (with its data-pid attributes, to republish with them intact) and
each pid's current text, fenced as untrusted with the shared random-tag
fence, with the version an update expects. An `update` op on
{ tabId, blockId, pid } takes plain text. The authoring skill's HTML pages
section explains stamping, keeping pids on republish, carry-over and
suggestions, script-drawn text and the <primer-*> blocks.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…oint Page block props are editor-writable, so any editor could point a page at a missing source and make loadStamped throw for every reader. Loading a source now returns null (logged) on any storage error; an agent's read lists such a page as unavailable (`source: null`) and still returns the rest, loads each source once, and lists at most 20 pages and 5,000 pids. Export and checkpoints render the first page block whose source loads. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Feature `page-text`: after the page's load handlers ran, the bridge reports each stamped element's DOM text and rect (page_elements), then rects again on scroll and resize (page_rects), and clicks (pid_clicked). set_page_texts sets only text on elements carrying that data-pid, outside Primer blocks, with `\n` as <br>: nothing the host sends is parsed as markup. Feature `embeds`: <primer-*> blocks report rects and clicks (embed_clicked) and show the static HTML the host renders (set_embeds), Mermaid rendered in place. The host parses every message strictly (ids as the server stamps them, finite rects, bounded sizes). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A page block renders its page in the sandboxed frame (ArtifactIframe, which now grants a live page the page-text and embeds features and hands it their messages) and pushes people's current text and each Primer block's text-only HTML into it, again on every change of those fragments. Clicking an element opens the one host overlay (live/Overlay.tsx, C9): a BlockNote editor in Primer's window drawn over the element, bound to its sub-fragment, so keystrokes never reach the page. Page text gets BlockNote's comments, anchored in its fragment (the thread store can be scoped to one pid); a Primer block gets the full block editor. Text a script drew is read-only and opens no editor. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xt alone Found in the browser check: the host pushed people's text into every pid, so a pid a script redraws (a computed total) showed its source text again; now only editable pids get text pushed. The overlay follows the frame when the host scrolls, opens with the cursor at the end of the text, and drops BlockNote's side padding so it lines up with the element. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
feat: live HTML pages with in-place text editing and Primer blocks (collaboration M6) Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This was referenced Nov 19, 2026
This branch has not been deployed
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.
Replaces #156 (review history there).
One link of a linear stack, one milestone per PR. The base is
stack/14-m10a4-blocks(#176), so this diff is this milestone's own work plus the merge resolutions it needs against the links below it.Summary
HTML uploads become live page documents: the page renders as uploaded in its sandboxed frame, people edit its text in place, and agent republishes carry their text over.
Auto-stamping held; no fallback to agent-authored ids. At publish, every element whose children are only text and
<br>gets adata-pid. It is inserted into the original upload (parse5 with source offsets), so the rest of the page stays byte for byte.<br>is\n, and outside<pre>source whitespace collapses. Editing one word of an indented paragraph never splices line breaks in.Matching across republishes (
page/match.ts), in order:Repeated labels and close runner-ups are
uncertainand never carried silently. Matching uses the shared boundedlib/similarity.tswith a total budget. Every examined pair costs work, candidates come from tag and path indexes, pairs are capped, and only the first 3,000 elements per side are matched. Stamping and splicing are linear: a 20,000-element page of identical labels stamps and matches in about 0.2 s.State. Each pid's text lives in
page/<blockId>/<pid>, one paragraph whose block id is the page block's. A pid target{ tabId, blockId, pid }therefore locates its block like any other, so preconditions, suggestions and comment marks work unchanged.<primer-*>embeds live inembed/<blockId>/<embedId>as native blocks: table, code, diagram and math.pageblock (packages/blocks) carriessourceKey,title,pidsandembeds.reachableFragmentsfollows them, so a removed element's thread orphans instead of disappearing.Publish (
page/publish.ts,lib/publish.ts).pages/<docId>/<versionId>.html) and purged with the document.lib/threadCarry.tsare removed (one way).Republish: three-way carry-over through
applyPlan(page/carry.ts).doc_updates.touched) gets it back as an ordinary stored suggestion.mineis read inside the build on the document queue, so typing that races a republish is never lost.forbidden, with a fix).Splice-back on demand. Export, checkpoints (
static.html,export.html) and print splice changed pids and edited embeds into the stamped source. An embed counts as untouched when its blocks equal those re-derived from the stored source, so no editor-writable state can make an export lie.Agents.
primer_get_doclistspages: each page's source with its pids, and each pid's text (fenced withfenceUntrusted) and version.updateop on{ tabId, blockId, pid }takes plain text.Bridge (
v1.js, featurespage-textandembeds).set_page_textssets text only (\n→<br>), only on elements carrying that pid, never inside embeds.set_embedsfills<primer-*>elements with text-only HTML the host builds from the block state, and Mermaid renders in place.protocol.tsparses every message strictly.Host.
PageViewrenders the frame (GET /api/documents/:docId/pages/:blockId/content, artifact CSP, sandbox unchanged) and binds it viaGET …/pages/:blockId. It pushes current text to editable pids only, and pushes again on every fragment change.live/Overlay.tsx(C9) draws a BlockNote editor in Primer's window over the element, bound to its sub-fragment. Page text gets BlockNote comments through a pid-scopedPrimerThreadStore; embeds get the full block editor.Security
connect-src 'none'are unchanged. The overlay and every editing control live in the host. The page receives only text, set withtextContentand<br>.sourceKeyis honoured only insidepages/<documentId>/.Test evidence
codegen-drift-check,db:migrate:test,typecheck,pnpm -r build,pnpm test(api 1003 passed, web 364, mcp 125, blocks 3) andpnpm audit --audit-level=high. All pass.pnpm --filter @primer/api test:browser: 11 passed.data-pidattributes; script, style and nested-markup elements are not stamped;brbecomes a newline; an existingdata-pidis kept; offsets on a BOM, CRLF and astral characters;sourceKeydoesn't break the read;<primer-*>tags survive sanitize with literal ids; a missing embed id is refused; untouched embeds export verbatim;page_elementsand rejects malformed rects;set_page_textsonly touches stamped nodes (the realv1.jsin jsdom); a script-drawn pid is read-only;set_embedscontent is text only.pnpm dev, two people in separate browser contexts): an agent published a page with a script-drawn chart and total and a<primer-table>.<primer-table>was edited in the overlay, and both people's frames showed it.Deviations
script_text_read_only: only the browser can tell that text was drawn by a script. The server treats every pid as text, and the host makes script-drawn pids read-only.pages/<blockId>.html: the stamped source is stored once, immutably, with the checkpoint that published it, and each bundle'sstate.ydocnames it.🤖 Generated with Claude Code