HTML Docs / Product Direction Independent audit · 25 July 2026
Editing first

The page should be the result, not the editor.

A direction for making HTML Docs feel as dependable as a normal document editor—then giving it the design range of the web and a human-controlled Codex assistant.

This is not a recommendation to make a browser-based design tool. It is a recommendation to build a document editor whose structured model can compile into unusually beautiful, interactive HTML.
01 / Executive verdict

Invert the product.

HTML Docs is currently excellent at preserving an HTML artifact and increasingly capable at editing around it. The next version should instead make editing the canonical activity and treat HTML as one compiled output.

Build new “structured documents” on a canonical DocumentGraph. Human actions and agent actions must go through the same transaction engine. Keep today’s arbitrary-HTML workflow as a legacy-compatible mode and import path.
Current advantage
HTML fidelity

Imported pages retain their own styles, layout, scripts, and web-native richness.

Current constraint
Editing truth

The shell, region strings, live DOM, database, history, and agent edits must be reconciled.

Target advantage
One model

A dependable editor, controllable agents, and rich output all operate on the same structure.

The wager is that users do not need to choose between “Google Docs familiarity” and “the expressive range of HTML.” They need a stable document model, a visible design system, and rich blocks that expose direct manipulation rather than raw implementation details.

02 / What to borrow from Paper

Paper’s lesson is shared language.

Paper is useful inspiration because its human canvas and its agents speak the same web-native language. The transferable idea is not an infinite canvas; it is eliminating the translation layer between what a person edits and what an agent changes.

Web-native substrate Paper positions its canvas as real HTML and CSS, reducing translation between design and implementation. PAPER-03
Direct manipulation Keyboard creation, hierarchy navigation, flex controls, alignment, and deep selection remain first-class. PAPER-09
Shared tokens Named CSS-variable tokens let agent and human work through reusable design decisions instead of isolated values. PAPER-05
Agent as participant MCP is core enough to appear in product limits, and Paper documents Codex connectivity directly. PAPER-02 PAPER-04
  • 01 Direct manipulation and AI are complements.The canvas lets a person explore and judge; the agent removes repetition and carries changes across variants. Paper explicitly describes these as two sides of the same workflow. PAPER-08
  • 02 The design system is an editable product surface.Tokens and reusable styles make “beautiful” reproducible. They also constrain the agent enough to preserve intent. PAPER-05
  • 03 Agent context should come from selection.Paper’s build log describes teammate and agent presence and selection-aware context. HTML Docs should apply the same principle to document sections and blocks. PAPER-06
  • 04 The human remains the editor.Paper’s own framing is that the agent saves clicks while the person retains style and intention. That is the correct control model for HTML Docs. PAPER-07
Do not copy: an infinite design canvas, a property panel for every CSS declaration, or a workflow that requires design-tool literacy. HTML Docs’ primary object is a linear, readable document. Power should appear progressively when the selected block needs it.
03 / Audit of the current system

The product already contains half the answer.

The repository has block insertion, movement, conversion, slash commands, a Google Docs-like toolbar, structural undo, collaborative region syncing, and agent proposal cards. The problem is not a lack of features. It is that those features operate across multiple competing representations.

Current editing path
Arbitrary HTML Imported source, styles, scripts, interactive patterns
Shell + region strings Cheerio replaces leaf blocks with region placeholders
Editable Shadow DOM Reconstruction, guards, focus recovery, patching, persistence

What is strong

  • The Shadow DOM renderer preserves imported-page fidelity and isolates styles. LOCAL-01
  • The mutation engine already expresses useful block commands: insert, move, split, merge, convert, indent, and delete. LOCAL-03
  • Docsmith proposals are explicitly accepted or rejected; user control is already a product value. LOCAL-05
  • The desktop app already includes a Codex adapter and streams externally authored file changes into the editor. LOCAL-07 LOCAL-09

What creates drag

  • A character edit lives in native contenteditable history, while a structural edit lives in a separate snapshot history.
  • Shell edits can rebuild the Shadow DOM, so caret and selection must be captured and restored.
  • Remote patches need active-region, recent-edit, selection, and IME guards to avoid overwriting local intent.
  • Formatting and focus depend on DOM selection timing and legacy browser commands; the existing editor-options investigation documents recurring failure modes. LOCAL-11

Root cause: imported HTML is both the thing being preserved and the substrate being edited. This makes every direct-editing affordance a negotiation with arbitrary DOM, CSS, and script behavior. The current implementation handles that complexity thoughtfully; the volume of defensive logic is itself evidence that the abstraction boundary is wrong for an editing-first product.

04 / Target experience

Familiar in ten seconds. Powerful on demand.

A blank document should require no explanation: click, type, select, format, paste, undo, comment, and share. The superpower appears only when the user asks for structure, design, data, or an agent.

A brief for the next release
The writing surface stays quiet. Structure, style, and responsive behavior are encoded in the document—not exposed as a wall of controls.
Design token: Insight / Lime · Radius / Compact · Spacing / 4
42% faster onboarding
A typed metric block: editable as content, styled as a component, exportable as semantic HTML.
LEVEL 01
Write

Paragraphs, headings, lists, links, comments, tables, images, keyboard shortcuts, paste, and unified undo.

LEVEL 02
Structure

Slash menu, block handles, outline, drag/reorder, columns, callouts, cards, sections, and reusable patterns.

LEVEL 03
Design

Document themes, tokens, style presets, responsive preview, and a contextual inspector for selected rich blocks.

LEVEL 04
Delegate

Selection-aware Codex actions, inspectable diffs, scoped acceptance, agent history, and reusable document skills.

Rich HTML without raw-HTML anxiety

D3 and other web libraries belong behind typed blocks, not inside the text flow. A chart block should store a dataset, visualization specification, theme references, and accessibility text. D3 may render it, while the editor exposes a data table and contextual controls. The same principle applies to diagrams, tab groups, metric grids, embeds, and interactive explainers.

05 / Canonical model

Separate content, design, rendering, and action.

The structured document should be small enough to reason about and rich enough to compile. It should never require an agent—or a toolbar button—to patch arbitrary DOM as its primary operation.

Shared transaction architecture Human editor and Codex send commands to a transaction engine operating on a document graph and design system, which render to editor, collaboration, and published outputs. HUMAN Direct editor AGENT Codex tools ONE WRITE PATH Transaction engine • validate intent + scope • apply schema commands • record author + inverse CANONICAL STATE DocumentGraph nodes · marks · stable IDs tokens · component recipes PROJECTIONS Editor renderer selection · caret · node views Collaboration presence · CRDT · versions Published HTML semantic · responsive · rich PDF · slides · video
The editor and agent share commands, not DOM ownership. HTML becomes a renderer target, while the transaction log supplies undo, attribution, collaboration, and review.
LayerOwnsDoes not own
DocumentGraphStable node IDs, block hierarchy, text, marks, semantic attributes, referencesBrowser DOM, transient selection UI, generated CSS
DesignSystemColor, typography, spacing, radius, breakpoints, component recipes, theme variantsOne-off inline styling hidden from the user
Transaction engineValidated commands, preconditions, inverse operations, attribution, version boundariesSpecial “AI edit” code paths
RenderersEditing DOM, published HTML/CSS/JS, responsive previews, export formatsCanonical document state
Rich-block pluginsTyped props, editor node view, output renderer, migrations, accessibility contractUnbounded access to the editor runtime

A rawHtml block remains essential as an isolated escape hatch for advanced imports and bespoke elements. It should have source/preview modes, explicit security boundaries, and limited interaction with surrounding rich text. It is a feature—not the foundation.

06 / Human–agent contract

Codex should propose transactions, not rewrite pages.

The user controls scope and judgment. The agent receives structured context, uses the document’s design system by default, and returns small, attributable operations that can be previewed and reversed.

{
  "baseVersion": "doc_v184",
  "scope": { "sectionId": "sec_launch" },
  "operations": [
    { "type": "replaceText", "nodeId": "p_42", "from": 18, "to": 41, "text": "time to first publish" },
    { "type": "insertNode", "after": "p_42", "node": { "type": "sourceNote" } }
  ],
  "explanation": "Narrows the metric and attaches its cohort source."
} // illustrative API, not a committed schema
  • 01 Scope is explicit.Default to the selection, current block, or current section. Expanding to the whole document requires a visible user choice.
  • 02 Diffs render on the document.Text changes appear inline; block and design changes show before/after previews. Raw HTML is not the primary review surface.
  • 03 Acceptance is granular.Accept one operation, one block, one section, or all. Reject and “revise this” stay beside the proposal.
  • 04 Everything is reversible and attributable.Agent operations participate in the same undo and version history as human edits, with author, prompt, and rationale metadata.
  • 05 Skills target the model.A “launch brief” skill produces structured nodes and design tokens. It does not emit an opaque page that the editor must reverse-engineer.

Docsmith’s existing accept/reject cards are the right control primitive, while the desktop Codex adapter is the right transport primitive. The missing layer is a common transaction protocol between them. Today, web proposals replace region HTML or insert blocks, while desktop agents can edit the backing HTML file. Both should converge on model commands. LOCAL-06 LOCAL-08

07 / Architecture recommendation

Time-box the editor engine; commit to the transaction boundary.

The strategic decision is the structured, transactional model—not a library logo. Run a two-week spike comparing ProseMirror and Lexical against HTML Docs’ hardest requirements, with a provisional lean toward ProseMirror.

Why ProseMirror leads

Its official model centers on schemas, immutable editor state, transactions, selection state, transforms, history, collaboration, and custom node views. Those primitives map directly to HTML Docs’ need for one write path and typed rich blocks. ARCH-01

Why Lexical stays in the spike

Lexical also offers immutable state, command-driven updates, React integration, history, and Yjs collaboration support. Its ergonomics and performance may be attractive, so it should be tested rather than dismissed. ARCH-03

Spike acceptance tests

  • IME composition, multi-block selection, paste from Google Docs/Word/web, tables, mobile selection, and screen-reader semantics.
  • Unified undo across text, structure, token, and agent transactions.
  • Custom node views for chart, columns, callout, image, raw HTML, and interactive embeds.
  • Concurrent edits and offline recovery with a Yjs-backed prototype; Yjs provides shared CRDT types, provider separation, awareness, and editor bindings. ARCH-02
  • Deterministic standalone HTML export and round-trip stability for the structured schema.
Backend note: Supabase can remain the system of record for identity, document metadata, snapshots, permissions, comments, and exports. Do not make per-region database rows the real-time editing protocol for structured documents. Evaluate a CRDT update stream plus periodic snapshots, with transport chosen after load and offline tests.

Compatibility strategy

Add an explicit document mode: legacy_html or structured. Existing public documents remain on the current renderer. New documents default to structured. Import conversion produces a preview and confidence report; unsupported structures become typed raw blocks rather than silently degrading. No dual-write bridge should become permanent.

08 / First product wedge

Prove the inversion with new documents.

Do not begin by migrating every page HTML Docs has ever imported. Begin with a coherent authoring loop that demonstrates writing quality, design richness, and agent control in one surface.

Wedge: create a new structured document, write and format it normally, insert one beautiful data-rich block, ask Codex to improve a selected section, review the diff, and publish a standalone responsive HTML page.
IncludeConcrete boundaryDefer
Core writingParagraph, H1–H3, lists, todo, quote, code, divider, link, comment, table, imageArbitrary nested DOM conversion
Rich blocksCallout, columns, metric grid, chart, diagram, embedGeneral-purpose page builder
DesignDocument theme, semantic tokens, presets, responsive previewEvery CSS property
AgentSelection/section scope, transaction diff, accept/reject/revise, undoSilent autonomous full-doc rewrite
OutputDeterministic, semantic, responsive standalone HTMLLossless import/export of every third-party script

This wedge uses assets HTML Docs already has: the block command vocabulary, familiar toolbar work, Docsmith review model, export/presentation capability, shared editor package, and desktop agent transports. The investment goes into unifying them, not recreating them.

09 / Phased roadmap

Build the foundation in visible slices.

0 · 1–2 weeks

Measure and spike

Instrument current text-loss, caret-jump, undo, paste, and collaboration failures. Compare ProseMirror and Lexical using the acceptance matrix. Draft DocumentGraph, transaction, and plugin contracts.

1 · 4–6 weeks

Structured writing alpha

New-document mode, core blocks, reliable paste, one history, comments, basic collaboration, themes/tokens, and deterministic HTML export. Keep it behind a workspace flag.

2 · 4–6 weeks

Shared agent protocol

Define MCP/desktop tools around transactions. Connect Docsmith and Claude/Codex adapters. Ship selection scope, on-canvas diffs, partial acceptance, attribution, and undo.

3 · 6–8 weeks

Rich-document system

Columns, metric grids, chart, diagram, responsive inspector, component recipes, workspace design systems, and skills that emit model-native structures.

4 · after proof

Import and migration

Conversion audit, side-by-side preview, raw-block fallback, opt-in legacy migration, and lifecycle policy for the old editor. Preserve existing published URLs throughout.

10 / Success measures

Judge the editor before judging the magic.

The targets below are proposed product gates, not measured current performance. Baselines should be captured during Phase 0.

Editing integrity
Zero known text-loss paths

Automated matrix covers typing, IME, paste, format, undo, remote edits, and reconnect. Track lost-character and caret-jump telemetry separately.

Interaction latency
<16 ms p50 · <50 ms p95

Measure local keypress-to-paint for representative 100-, 1,000-, and 5,000-block documents.

Familiarity
≥90% core-task completion

First-time users create, format, comment, and publish without AI assistance or facilitator instruction.

Agent control
100% inspectable + reversible

Every agent mutation names its scope, exposes a review state, records attribution, and supplies an inverse operation.

Design reuse
≥70% token adherence

Rich-block styling uses named document/workspace tokens rather than unique values. Track overrides as visible exceptions.

Output confidence
Deterministic snapshot parity

Published HTML matches approved responsive snapshots and meets accessibility checks for all first-party blocks.

11 / Risks and guardrails

The danger is building three products at once.

Scope expands into a design tool.Keep the primary canvas linear and document-first. Add contextual controls only for selected rich blocks; no infinite canvas in the first product.
Imports lose visual fidelity.Keep legacy rendering, preview conversions side by side, report unsupported structures, and isolate them in raw blocks instead of pretending conversion is lossless.
Rich blocks become a security hole.Require typed props, sandbox untrusted embeds, control script execution, version plugin schemas, and define accessibility/export contracts.
Collaboration migration causes split truth.Use explicit document modes and a single authoritative store per mode. Avoid permanent dual writes between region rows and the new model.
Agents bypass the design system.Expose only model transactions and named tokens to ordinary tools. Make raw-code operations a separately permissioned, visibly exceptional mode.
Desktop and web diverge.Keep schema, commands, renderer contracts, and agent tool definitions in shared packages; surfaces may differ, document semantics may not.
12 / Decisions to make now

Approve the boundary, then prove it.

  • D1 Approve a second document mode.New structured documents can evolve without destabilizing legacy HTML documents.
  • D2 Approve one transaction path for humans and agents.This is the non-negotiable architectural seam.
  • D3 Fund the two-week editor-engine spike.Use the same hard acceptance matrix for ProseMirror and Lexical; choose on evidence.
  • D4 Choose the wedge narrative.“Write normally → add a rich block → delegate a selected change → publish beautiful HTML.”
  • D5 Protect existing documents.No forced migration until structured mode proves editing integrity, export fidelity, and collaborative reliability.
North star

HTML Docs should feel like the document editor people already know—until they ask it to become something ordinary document editors cannot make.