Skip to content

fix(annotate): a bare Done starts no agent turn on any plugin host; submits count every document's and message's comments - #1701

Merged
backnotprop merged 4 commits into
mainfrom
fix/annotate-done-noop-and-folder-count
Oct 5, 2026
Merged

backnotprop merged 4 commits into
mainfrom
fix/annotate-done-noop-and-folder-count

Conversation

@backnotprop

@backnotprop backnotprop commented Oct 5, 2026 •

Copy link
Copy Markdown
Owner

Two bugs from the 0.28.1 smoke tests. Both were already in 0.28.0. Target: 0.28.2.

1. Done with nothing to send started a Claude turn (Claude Code mod)

Clicking Done in an annotate session with no annotations made Claude start a turn that contradicted itself: "Plannotator: notes.md — Feedback." followed by "User reviewed the document and has no feedback. Please address the annotation feedback above."

Cause: for a bare Done, the editor posts the zero-state sentence as feedback, and annotateHostResult only treated empty feedback as noop.

Fix: the server now recognizes this case from the request structure instead of matching the English sentence:

  • The editor adds nothingToSend: true to the /api/feedback body when its payload is the zero-state sentence. Content-bearing bodies are byte-identical to before.
  • Both annotate servers (Bun and Pi) put the flag on the decision only when annotations and codeAnnotations are empty (isNothingToSendFeedbackBody in packages/shared/annotate-decision.ts). A body that carries annotations is never treated as "nothing".
  • annotateHostResult turns the flag into noop: true with an empty message. The mod then logs "notes.md closed with no annotations. Nothing was sent to Claude." and starts no turn.
  • The mod's legacyResult (used when the CLI is older than the host result file) now treats the two zero-state sentences as no-ops. delivery.test.ts checks them against the editor's own constants.

Outputs for Done with nothing to send, before and after

Consumer Before After
Plain CLI stdout User reviewed the document and has no feedback. unchanged
--json (non-strict) {"decision":"annotated","feedback":"User reviewed…"} same fields and values, plus an additive "nothingToSend":true only in this case
Strict gates (--require-approval / --result-file) not reachable: under --gate the empty primary is Approve on /api/approve record and exit codes unchanged (the strict serializer never gets the flag)
--hook {"decision":"block","reason":"User reviewed…"} unchanged
Claude Code mod result record noop:false, a turn with "…Please address the annotation feedback above." noop:true, message:"", log line only
Mod with a CLI older than the result file turn log line only
OpenCode CLI bridge (OC1 CLI runtime, OC2 native commands) delivers a feedback turn containing the sentence no prompt (the bridge honors nothingToSend from the --json / opencode-annotate-last record)
OpenCode 1 embedded runtime (commands.ts) feedback rides the command's message as a feedback turn no prompt. The command's own message still runs its one empty turn, the known OC1 limit; no second turn is added, and the #1698 agent bookkeeping is untouched
Pi (/plannotator-annotate, /plannotator-last) sends a followUp feedback prompt containing the sentence "Annotation closed (no feedback)." and no message
Amp (formatAnnotationFeedback, reads --json) appends a "please address" user message "Annotation session closed without feedback." and no message
Droid (emitAnnotateDecision, reads --json) prints the feedback heading + "Please address…" "Annotation session closed."
Skill-run hosts (classic Claude Code skill, Codex, Gemini, Copilot, Vibe, Kiro) the model reads the plain-stdout sentence unchanged: this is the stdout contract kept byte-identical
Feedback archive decision: "feedback" plus a sidecar holding the sentence unchanged

Also checked:

  • annotate-last: it uses the same path (the document sentence, or "…messages…" in multi-select). Both are covered.
  • Code review: there is no equivalent. Its empty primary is Approve, an LGTM is already noop, and an annotated decision with zero annotations is already noop.
  • Discard-and-finish (non-gated, no direct edits): also marked nothingToSend, which is correct because the reviewer chose to discard everything.

Not changed:

  • The feedback archive records a bare Done as feedback with a sidecar, not as a decision-only line. Fixing that is not a one-place change in the normalizer: both servers would have to pass the flag, and it needs a decision value for "done". So it is left as is.
  • Version skew: a 0.28.0/0.28.1 CLI emits neither the result-record flag nor the --json field, so the mod, the OpenCode CLI bridge, Amp and Droid still start the turn until the binary updates. The OpenCode embedded runtime and Pi ship their own server, so they are fixed as soon as the plugin is.

2. Folder session: "Feedback · 1 comment" for 2 comments

The posted annotations array held only the open document's comments. As a result, annotationCount, the mod's "N comments" and the archive's counts.annotations all undercounted.

Fix: a new collectSubmittedAnnotations (packages/editor/feedbackDocuments.ts) builds the array from the same resolveFeedbackSections split the feedback text is exported from:

  • the session's own document
  • every other document
  • in multi-message annotate-last, every message (same bug there)

Multi-message annotate-last and external comments: each message's entry was built from LOCAL annotations only (snapshotSession). SSE external comments (agent / WebMCP) were therefore missing from the exported feedback, the submit body and the archive. A session holding only such a comment posted the "no feedback" sentence marked nothingToSend. A new mergeExternalsIntoMessageEntries merges them into the CURRENT message's entry, falling back to the latest message, and dedupes them against draft-restored copies. The export and the collector both read it. The header's has-annotations check now counts externals in this mode too, so the primary reads Send Feedback.

It is used by both /api/feedback and /api/approve bodies.

Archive: each comment on a document other than the session's own target carries the new additive documentPath, and the archive normalizer records it. This follows the cross-tool contract: the field is added, not repurposed. file keeps its existing meaning, a code annotation's file. AGENTS.md is updated.

Verification

Headless Chromium against the real CLI (temp PLANNOTATOR_DATA_DIR, --use-mock-keychain --password-store=basic, freshly built apps/hook/dist):

  • Folder session, one comment each on a.md and b.md:
    • posted annotations holds 2 entries, each with its documentPath
    • host record has annotationCount: 2
    • archive has counts.annotations: 2 and documentPath per record
  • Single file, bare Done:
    • plain stdout is the sentence, --json is {"decision":"annotated",…}
    • the body carries nothingToSend: true
    • host record has noop: true, message: ""

New tests:

  • apps/hook/server/annotate-host-result.test.ts: real CLI process in plain and --json modes, the flag ignored when annotations are present, and a folder session with the archive on. With the host-result change reverted, the two no-op tests fail.
  • host-result.test.ts, annotate-decision.test.ts, feedbackDocuments.test.ts (collectSubmittedAnnotations).
  • App.decisionControl.test.tsx: Done carries the flag; a note does not.
  • Mod: delivery.test.ts (legacy sentences), controller.test.ts (the CLI's record through the in-memory Host gives a log and no submit; the legacy stdout path likewise).
  • annotate-output.test.ts: --json gains the field only for a bare Done; plaintext, --hook and the strict serializer stay byte-identical.
  • Pi: annotate-outcome.test.ts (a bare Done delivers nothing).
  • Amp: plannotator.test.ts (registered annotate/last commands append nothing for a bare Done). Droid: run-plannotator.test.js (prints "Annotation session closed.").
  • feedbackDocuments.test.ts: mergeExternalsIntoMessageEntries. An external comment reaches the export, which is no longer the sentence, and the submit body. Draft-restored copies are not doubled.
  • OpenCode:
    • commands.test.ts: embedded annotate and last send no prompt.
    • cli-bridge.test.ts: no prompt from a nothingToSend record.
    • New annotate-done-cli.test.ts: the bridge runs the REAL CLI. A bare Done sends no prompt, and real feedback still does; with the bridge check removed, the Done test fails.

Suites:

  • bun run typecheck, including the mod typecheck: clean.
  • bun test: 6155 pass, 0 fail.
  • apps/opencode-plugin: 301 pass.
  • apps/pi-extension: 358 pass.
  • apps/hook: 446 pass (includes the mod's bun tests).
  • apps/amp-plugin: 30 pass.
  • apps/droid-plugin: 8 pass.
  • DOM_TESTS=1 bun test packages/editor: 264 pass.
  • scripts/test-claude-code-mod.sh: 14 pass on the earlier commits. On the last rerun Claude Code refused to load hooks modules ("the rollout switch was saved off … not refreshed yet"), which is an environment issue. That commit touches no mod files.

…s count every document's comments

- The editor marks a Done whose payload is the zero-state sentence with
  nothingToSend: true. Both annotate servers carry it onto the decision only
  next to empty annotation arrays (isNothingToSendFeedbackBody), and the
  Claude Code mod's host result record turns it into noop. Plain stdout,
  --json, strict gates, OpenCode and Pi output are unchanged.
- The mod's legacyResult treats the zero-state sentences an older CLI prints
  as a no-op.
- The submit body's annotations now carry every document's comments (folder
  sessions, linked documents, multi-message annotate-last) via
  collectSubmittedAnnotations, so annotationCount, the mod's 'N comments' and
  the feedback archive counts match the feedback text. Comments on another
  document carry the additive documentPath field, recorded by the archive.
- Pi: classifyAnnotateOutcome reads a nothingToSend decision as
  'Annotation closed (no feedback).' (no follow-up message).
- OpenCode embedded handlers (handleAnnotateCommand,
  handleAnnotateLastCommand) send no prompt for it.
- The CLI adds an additive nothingToSend: true to the non-strict annotate
  --json record and the opencode-annotate-last record in that case only;
  the OpenCode CLI bridge (OC1 CLI runtime, OC2 native commands) honors it.
  Plaintext, --hook, the strict-gate record and exit codes are unchanged.
@backnotprop backnotprop changed the title fix(annotate): Done with nothing to send starts no agent turn; folder submits count every document fix(annotate): a bare Done starts no agent turn on any host; folder submits count every document Oct 5, 2026
…ries external comments

- Amp (formatAnnotationFeedback) and Droid (emitAnnotateDecision) read
  annotate --json too: an annotated record marked nothingToSend now sends
  nothing. Records from an older CLI (no field) behave as before.
- Multi-message annotate-last built its entries from local annotations
  only, so SSE external (agent / WebMCP) comments were missing from the
  exported feedback, the submit body and the archive, and a session holding
  only such a comment posted the no-feedback sentence marked nothing to
  send. mergeExternalsIntoMessageEntries puts them on the current message;
  the header's has-annotations check counts them too.
@backnotprop backnotprop changed the title fix(annotate): a bare Done starts no agent turn on any host; folder submits count every document fix(annotate): a bare Done starts no agent turn on any plugin host; submits count every document's and message's comments Oct 5, 2026
@backnotprop
backnotprop merged commit 152cfd9 into main Oct 5, 2026
28 checks passed
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