Skip to content

Give the root's Chat and Planner reach into child documents - #482

Merged
MaggieAppleton merged 22 commits into
mainfrom
planner-children
Oct 11, 2026
Merged

MaggieAppleton merged 22 commits into
mainfrom
planner-children

Conversation

@MaggieAppleton

@MaggieAppleton MaggieAppleton commented Oct 11, 2026 •

Copy link
Copy Markdown
Collaborator

What changes

There is now one Chat per root document. Child documents no longer have their own Chat: the root's Chat applies to every child, and the Planner can read and edit children from it.

  • Focus: when a child is open, a message to the Planner from the root's Chat carries that child as focus. The server checks the child belongs to the root, and the Planner's prompt names it.
  • New Planner tools: list_children, read_child, edit_child and anchor_child.
    • They share their edit and anchor code with edit_plan and anchor_plan, including dialect validation and persistence before publication.
    • Every call rechecks the Planner owner's access (push or admin), the parentage, the repository and the archive state, under the child's own transition.
    • Background jobs never get them.
  • Child comments: "Send to Chopin" in a child runs on the root's Chat with the child as focus, and the reply lands in the child's thread. A refusal or failure shows in the child, never as silence.
  • MCP: invoke_planner on a child runs on the root's Chat in the same way, under the root's existing owner.
  • Web: the root's composer sends the open child as focus. Clicking a child-comment notice in the root's transcript opens the child and its thread.

⚠️ Child Chat data is deleted at startup

As agreed (child chats were disposable), startup clears stored conversation data for child channels.

  • It runs under the writer lease, in one transaction, and is idempotent.
  • It never touches roots, documents, comment threads or question records.
  • A child whose decision records cite its own chat messages is kept and logged, so it still loads. Its old conversation is never served.
flowchart LR
  subgraph Root document
    Chat[Root Chat] -->|chat:send focus = child| Planner
    Planner -->|list_children / read_child| Children
    Planner -->|edit_child / anchor_child| ChildDoc[Child document]
  end
  ChildComment[Comment in child: Send to Chopin] -->|routed with focus| Chat
  MCP[invoke_planner on child] -->|routed with focus| Chat
  Planner -->|reply_comment| ChildThread[Child comment thread]
Loading

Testing

  • Unit tests:
    • storage children() and the child-conversation cleanup, as memory and Postgres contract tests (including a stale lease, diverged sidecars, archived children and children with no snapshot row)
    • checked child access
    • focus validation, including a busy queue draining
    • the child tools, authorization and error shielding
    • the tool boundary, including the Copilot adapter live check
    • comment and MCP routing, including room holds released only when the routed turn ends and a root closed mid-turn
    • web open-comment scoping
  • New e2e/harness-children.e2e.ts, run with the fake Planner harness:
    • focus goes to edit_child, which lands in the child only
    • the child socket serves no Chat
    • Send to Chopin in a child, then opening it from the root's notice, with no false "no longer here"
    • switching from child A to child B
  • bun run types, unit tests (4195 in the touched packages) and the design-contract check pass on the rebased head.

Initial bundle

To stay under the initial JS budget, DocumentRouteSwap moves out of hosted.tsx into a lazy document-route-view.tsx. It shows the same "Opening document…" fallback and preloads the workspace host. The parent-focus helper moves into the lazy host. Initial gzip drops by about 1 KB locally.

Design-contract review

Renewed after a data-flow review, with the maintainer's approval:

  • document-workspace-host.tsx: the presentation gains a channel id and callbacks, not styles.
  • document-workspace-host.tsx again: renewed after the focus helper moved in. No class or style changes.
  • comment-layer.tsx and resolved-layer.tsx: the flagged expressions are unchanged, so only the hashes are new.

Slice 6 of the nested-documents work.

🤖 Generated with Claude Code

MaggieAppleton and others added 22 commits October 11, 2026 14:04
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A child document's Chat is its root's. Startup now clears each child's
stored transcript, workflow runs, conversation analysis and Planner summary
under the writer lease, once and idempotently, keeping and logging any
child whose decision records still cite a Chat message. No server path
attaches a Conversation runtime to a child, greets it with Chat history,
or accepts a Chat message, control frame, MCP invocation or comment
instruction for it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ldren

Opening a child no longer backfills legacy Planner asks into conversation
threads, which would have recreated a child Conversation and pinned the
child against the startup cleanup. A child greet sends an empty
Conversation snapshot, so a kept child's stored analysis is never served.
The storage contract now covers diverged current and checkpoint sidecars,
archived children and children without a checkpoint.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A child has no Chat, so a comment sent to Chopin inside one, and an
invoke_planner call naming one, now run on the root's Chat with the child
as focus. The root turn answers in the child's thread with reply_comment
and its edit_child writes become the thread's result. Each route re-asks
storage that the child still belongs to a live root in the same
repository and refuses before saving anything when it does not.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A child comment or MCP instruction queued on the root's Chat released the
root and child rooms when whatever turn was running settled, which could
be before its own turn ran. The hold now ends with the instruction's own
end, and at once when it folds into a waiting turn or is refused. Closing a
Chat tells waiting instructions they were skipped. The root's open path is
one helper that also refuses a root being archived.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A Chat closed during a routed child comment turn never reports the turn's
end, so the child room stayed held and its thread kept showing work. The
turn's running promise now stands in for that report, and a closed Chat
counts as working on nothing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
A scripted CHILD-EDIT turn in the fake harness lists, reads and edits the
focused child through the real host tools, and a comment turn on a child
thread reads the child rather than the root. The new harness spec covers the
root's Chat sending the open child as focus, the edit landing durably in the
child only, the child socket serving and accepting no Chat, Send to Chopin on
a child comment replying in the child thread, and transcript notices opening
the right child and thread without the root editor claiming it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/design-contract/exceptions/dynamic-web.json:
- apps/web/src/document-workspace-host.tsx (parent <RoomWorkspace>
  workspaceProps(...)): reviewed against origin/main. The document
  presentation now carries `onChildOpen: openChild`, and the nested
  presentation adds `childId` and `onChildOpen`. RoomWorkspace passes
  childId to Chat as its focus channel id and onChildOpen to Chat's
  onOpenChild; openChild resolves stored parentage, navigates and awaits
  sync. workspaceProps still returns no className or style. The exact case
  value, reason and source hash are renewed.

scripts/design-contract/exceptions/dynamic-editor.json:
- packages/editor/src/comment-layer.tsx (preview/surface className and
  style, hit style): the dynamic expressions are textually unchanged. The
  branch scopes OPEN_COMMENT requests to the store's channel and holds a
  request until its thread arrives; no class, style or paint value flows
  from that state. Source hash renewed.
- packages/editor/src/resolved-layer.tsx (preview className and style):
  unchanged expressions; the only change passes threads.channel to
  openCommentThread. Source hash renewed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The initial JavaScript budget failed by 6 B gzip in the container build.
DocumentRouteSwap, its route keying and ContentSwapLayer now load in a
lazy document-route-view chunk; hosted.tsx fetches the workspace host in
parallel, so the host arrives no later than before. The parent focus
restore after a child closes now picks its DOM target inside the lazily
loaded host, which passes it to the shell's focus state machine.

Initial JavaScript drops by about 3 KB raw and 980 B gzip.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
scripts/design-contract/exceptions/dynamic-web.json:
- apps/web/src/document-workspace-host.tsx (parent and child
  <RoomWorkspace> workspaceProps(...)): reviewed. The only change in the
  owner passes parentFocusTarget, a DOM focus helper, to
  onParentRestored after a child closes. No className, style or paint
  value flows from it; the workspaceProps expressions are unchanged.
  Source hash renewed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MaggieAppleton
MaggieAppleton merged commit 2e1624c into main Oct 11, 2026
3 checks passed
@MaggieAppleton
MaggieAppleton deleted the planner-children branch October 11, 2026 13:27
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