Repository navigation
Annotate drafts follow the file's path (0.29 PR 2) - #1710
Merged
Merged
Conversation
Single-file annotate drafts are also saved under a path key (the #1590 dual-key pattern via review-draft.ts), so comments come back after an agent edits the file and the review is reopened. Every other document a local-file or folder session comments on is saved under its own path and merged in when it is opened in any session. A decision clears the session's keys and every document it covered. Bun and Pi servers. Co-Authored-By: Claude <noreply@anthropic.com>
…nonical paths
- useAnnotationDraft: a save refused as stale (409 with draftGeneration)
adopts the server's generation and saves once more; DraftTransport.save
may resolve { staleGeneration } (optional, additive).
- Documents the server keeps no path copy for (outside the session roots,
a symlink alias of the root, a self-link copy of the root) ride the
session draft again (composeSessionDraft).
- Document paths must name an existing regular file and are canonicalized
with realpath, so an alias of the root is the root.
- Tests: stale retry against real draft sessions, unbacked documents,
linked-document edits, symlink/missing/directory paths; docs.
Co-Authored-By: Claude <noreply@anthropic.com>
A second tab's save after a decision got a stale 409, retried above the
tombstone, and was accepted, so the next session restored comments that
were already sent. Once settled, every save answers 409 { decided: true }
in both runtimes (saveRequest shapes the response), and useAnnotationDraft
never retries a decided refusal.
Co-Authored-By: Claude <noreply@anthropic.com>
…by-path # Conflicts: # apps/pi-extension/server/serverAnnotate.ts # apps/pi-extension/vendor.sh # packages/server/annotate.ts
An agent close deletes nothing, so session-draft saves and document-copy writes that arrive after it now land (a comment typed in the last debounce window was dropped); the tab also flushes its pending saves on the session-closed event. A reviewer decision still refuses later saves, and the closed tab's DELETE stays a no-op. The closed-tab copy now says what brings the draft back: a local file or folder even after edits, a URL or agent message only unchanged, a live app by its address. Co-Authored-By: Claude <noreply@anthropic.com>
This was referenced Oct 5, 2026
backnotprop
added a commit
that referenced
this pull request
Oct 5, 2026
* feat(annotate): several files in one review (0.29 PR 4, bundles) plannotator annotate spec.md mock.html notes.md (every argument an existing file named by its path) opens ONE review of the files, in the typed order, with one decision. No flag, no file-count limit. - Shared rule (annotate-target.ts, vendored to Pi): probeAnnotateBundlePath, the bundle selection, resolveAnnotateBundleFiles (type and 2MB checks that name the file). Prose, URLs, folders and searched names keep the #1483 tiers; the ambiguity error gains a hint on hosts that open bundles. Strict gates take only a single target or only file paths (else exit 2). - Server mode annotate-bundle in Bun and Pi: /api/plan carries bundle, /api/doc follows the single-file rule per file, history saved per text file at open, per-file draft copies (#1710), host status documents, archive surface annotate-bundle with target.documents. - CLI: host result record gains documents; the agent message names every file. - Editor: first file opens by itself, header switcher (2 of 3 · name), the Files tab and All files panel in bundle order, export one section per file in bundle order, Ask AI surface line names file N of M. - Tool contract: description line for lists, plannotatorBundleSubject, isOlderCliBundleRefusal; Bash take-over maps several file paths to a list. Mod launches bundles and maps an older CLI's refusal to an update message. - Pi and OpenCode (embedded and CLI bridge) slash commands open bundles too. Co-Authored-By: Claude <noreply@anthropic.com> * fix(annotate): bundle review follow-ups - Move annotate-bundle out of @plannotator/core into packages/shared (no new core export, so the published-UI smoke passes without a core publish). - A list of file paths with a missing file fails naming it (shared 'missing' selection) on the CLI, Pi and OpenCode; tool list entries are passed as paths (bare word -> ./word) so the tool and Bash take-over get the same rule. - Strict refusal decided by probe only (no fetch, live probe or Resolved: line). - A symlinked bundle file is served: its real directory is a root for it. - The CLI uses the shared selection end to end (a.md ./a.md opens a.md). - .env named as refused; bundle files have no Close pill and leaving a linked document returns to the last bundle file; docs; engine-harness bundle case. Co-Authored-By: Claude <noreply@anthropic.com> * fix(annotate): an existing path is never reported missing A stray . or .. (or any existing directory) beside file paths was read as a missing file ('File not found: .'), where main opened the file. The missing selection now needs the new pathExists option (annotatePathExists): only a token with nothing at its path, and nothing found by search, is missing. Wired on the CLI, Pi and OpenCode; test rows on the shared rule and the CLI. Symlink-root comment corrected; AGENTS.md notes the dotted-word edge. Co-Authored-By: Claude <noreply@anthropic.com> --------- Co-authored-by: Claude <noreply@anthropic.com>
This was referenced Oct 6, 2026
1 task
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.
PR 2 of the 0.29 agent-sessions design (
.product/drafts/agent-sessions-0.29/DESIGN.md, "Drafts survive an edit and a reopen").Problem
Annotate drafts were keyed only by a hash of the document text. When an agent edited the file and the review was reopened, the reviewer's saved comments did not come back.
What changes
Single local file (mode
annotate, not a URL). The draft is now saved under the content key and also under a path key,annotateFileDraftKey(<abs path>). This reuses the #1590 dual-key logic inreview-draft.ts, with the content key in the role of the patch key:draftGeneration.409with the current generation.Per-document copies. This covers every document a local-file or folder session comments on, other than the session's own root: a folder session's files and a single-file session's linked documents.
/api/draft/document./api/planadvertises it withdocumentDrafts: true.Clearing:
409. The decisions are/api/feedback,/api/approve, and the reviewer's Close (/api/exit).Out of scope: URL, live-app and annotate-last sessions.
PLANNOTATOR_ANNOTATE_HISTORYdoes not govern drafts. They are crash recovery, and the design ties that flag to history copies only.Both runtimes are covered. Shared logic is in
packages/shared/annotate-draft.ts, vendored to Pi. The Bun server and the Pi mirror route through it.Tests
packages/server/annotate-draft.scenarios.tsruns against both runtimes throughannotate-draft.test.ts(Bun) andapps/pi-extension/server/serverAnnotate-drafts.test.ts(Pi). It covers:409packages/editor/documentDrafts.test.ts: write planning and merge rules.packages/editor/App.documentDrafts.test.tsx(DOM, added toDOM_TESTS): opening a linked document merges its saved comment, and the session draft never carries it.bun test packages/server apps/pi-extension packages/shared packages/editor,DOM_TESTS=1 bun test --isolate packages/editorplus the draft/linked-doc DOM suites, andbun run typecheck.Notes for review