Registry Mirror
Skip to content

Conversation

@backnotprop

Copy link
Copy Markdown
Owner

Refs #1392 (the feedback-after-disconnect part; the issue's Settings/Obsidian report is separate).

Problem

In plannotator annotate, with the server process killed and the page still open, Send Feedback failed with ERR_CONNECTION_REFUSED and the page showed nothing, so the reviewer believed it was sent. Plan review was worse: a 500 on approve or deny went straight to the Approved / Feedback Sent screen. Code review set a "Failed to send" string that nothing displayed.

What changed

One shared toast, showSendFailureToast (packages/ui/components/SendFailureToast.tsx, reasons in packages/ui/utils/sendFailure.ts), on the existing sonner toasts. On a failed decision POST the page and its annotations stay exactly as they were, no sent or closing screen appears, and the toast shows:

  • "Feedback not sent" / "Approval not sent" and why: Plannotator isn't running or can't be reached, the HTTP status, or the review was already decided.
  • Retry: the same handler with the same options, sending the page as it is now. It does nothing while another send is in flight.
  • Copy feedback: read when clicked, so it copies what Retry would send, in the form the page's own Copy feedback uses. It is left out for a bare approval or a Done with nothing to send.

It stays until dismissed, at the bottom centre (clear of the header and the annotation panel), 420px on desktop. A new failure replaces it, a send starting takes it down, and it goes when the review is decided. No new keyboard shortcuts.

Per app:

  • Annotate and annotate-last (packages/editor/App.tsx): send feedback and gate approve. Before, both failed silently.
  • Plan review (packages/editor/App.tsx): approve and deny. Before, a network error was silent and a 500 showed the Approved / Feedback Sent screen. Only 409 code: "plan_revised" now reads as "The agent revised the plan", so Pi's closed-session 409 is no longer mistaken for a revision.
  • Code review (packages/review-editor/App.tsx): send feedback and approve. Before, failures were silent.
  • Pi: it serves the same built HTML, so it gets the client change.

Success behaviour is unchanged. 409 session_mismatch keeps its reload banner.

Server: code: "already_decided"

The annotate and review servers (Bun packages/server/annotate.ts and review.ts; Pi apps/pi-extension/server/serverAnnotate.ts and serverReview.ts) add code: "already_decided" to their existing 409 "This review session has already been decided." (another window sent first, or the agent closed it). Pi's plan server already used that code for a closed session. The client shows "This review was already decided, in another window or because its session ended." with Copy feedback and no Retry. The change is additive: the status and the error text are unchanged.

Drafts

Annotations autosaved before the server stopped come back when the same file is opened again (the e2e proves it). The open page keeps everything in memory, and Copy feedback covers anything added after the server was gone.

Not covered

/api/exit (Close, which sends nothing) and the platform status post after a PR review is posted (fire-and-forget by design). The Bun plan server's /api/approve and /api/deny still have no already-decided guard; the client no longer double-sends, but a server guard would be a separate change.

Tests

  • DOM tests: packages/editor/App.decisionControl.test.tsx, App.planDecisionControl.test.tsx and packages/review-editor/App.decisionControl.test.tsx. They simulate fetch rejecting and a 500 for annotate, annotate-last, gate approve, plan approve/deny and review send/approve, and they cover:
    • Copy feedback's text.
    • Retry sending once.
    • A successful send clearing the message.
    • Retry while a send is in flight sending nothing (fails with the guard removed).
    • Already decided showing its own message without Retry.
    • Pi's plan already_decided refusal not being read as a revision.
      The first nine fail on the code before this change.
  • E2E: tests/e2e/annotate-send-failure.spec.ts, against the compiled binary, headless, with a temp HOME and PLANNOTATOR_DATA_DIR, NO_BROWSER and PLANNOTATOR_INBOX_CONNECT=0. Two tests:
    • Kill the annotate server with the page open, then check the message, Copy feedback, Retry, and the draft coming back on reopen.
    • Two real windows: the second window's send gets the real 409 already-decided.
  • Typecheck, the touched DOM and server tests, and the builds (review → hook → opencode) pass after merging main.

Screenshots

1440×900, written by the e2e (local paths):

  • /tmp/feedback-send-fail/shots/annotate-send-failure-light.png
  • /tmp/feedback-send-fail/shots/annotate-send-failure-dark.png
  • /tmp/feedback-send-fail/shots/annotate-send-already-decided-light.png

The docs paragraph "A decision that does not land" is in docs/agent-guides/server-and-storage.md.

Approved by the owner in the Inbox, 2026-10-27

)

A decision POST that failed (the server stopped, or it answered non-2xx)
left the page unchanged with no message, so the reviewer believed it was
sent. Plan review's approve and deny were worse: a 500 fell through to the
Approved / Feedback Sent screen.

Every send path now keeps the page and its annotations as they are and
shows one persistent toast: Feedback not sent / Approval not sent, why
(not running or unreachable, or the status), Retry (the same handler and
options again) and Copy feedback (the text the send carried, as the page's
own Copy copies it). A successful send dismisses it.

Covered: plan approve/deny, annotate and annotate-last feedback and
approve, code review send feedback and approve. Client-only; Pi serves the
same built HTML.
…#1392)

Review findings on the send-failure toast:

- Retry could post a second decision beside one in flight (deny, deny,
  deny on plan review, whose Bun server has no already-decided check, so
  integrations and the archive ran twice). Each send now brackets itself
  with sendStarted()/sendSettled(): a send starting takes the toast down,
  Retry is a no-op while a send is in flight, and the toast goes when the
  review is decided. Each failure is a new toast id, since a reused id
  raced sonner's deferred dismissal and the new toast vanished.
- The annotate and review servers (Bun and Pi) put code: already_decided
  on their 409 for a decision after the review was decided. The toast says
  so and offers no Retry.
- Plan review treated any 409 as "The agent revised the plan"; only
  code: plan_revised is a revision now, so Pi's closed-session refusal
  gets the already-decided message.
- Copy feedback reads the page when clicked, so it copies what Retry would
  send now.
- The toast is 420px on desktop, so the reason fits on two lines.
@backnotprop
backnotprop merged commit a104c20 into main Oct 27, 2026
30 of 31 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