Resend the saved prompt on `clai2` web Retry, and guard Edit against double submits

Merged
MP
1mo ago
+66-30

Follow-up to #12220 (part of #12199). Stacked on #12231 (agent/clai2-12199-rollback-test).

This handles the remaining valid findings of a late local review of #12220. The other findings were already fixed on #12220 (bare clear, rollback, and the busy guard), or don't apply (publish is typed for SessionMessage, not Snapshot).

  • Retry sends the prompt as saved. POST …/rewind/{run_id} now accepts {"text": null}, and Retry sends that, so the server resends the saved prompt text the way the terminal's rewind restores it. Before, Retry sent the transcript's display text, which leaves out /monty notes and shows other attachments as placeholders.
  • No double submits. Send, Retry, Edit, and Enter are blocked while a rewind request is in flight. Enter in the editor no longer adds a newline while a turn runs.
  • An open editor belongs to its prompt. The draft is keyed by run_id, so a snapshot that puts another prompt in the same row closes it instead of rewinding to the wrong prompt.
  • Docs. The route is added to the web README's route table and to the list of unprefixed routes.
  • Tests. The Python test checks that Retry with null resends the saved prompt and its image. The browser test numbers each answer, so Retry is shown to start a new turn.

Verified: tests/clai2/test_web_rewind.py passes, the full tests/clai2/browser suite passes (35), and tsc, ruff, and pyright are clean.

Merge after #12220 and #12231. Then retarget this PR to main.


Summary by cubic

Fixes Retry on the web UI so it resends the prompt as saved, and guards Edit against double submits and stale rows.

  • Retry sends {"text": null} to the rewind route so the server resends the saved prompt text with its images; previously Retry sent the transcript's display text, which left out /monty notes and showed attachments as placeholders. The rewind body now requires the text key, so null is the explicit way to ask for the saved prompt and omitting the key fails with 422.
  • Send, Retry, Edit, and Enter stay blocked while a rewind request is in flight, and Enter no longer adds a newline while a turn runs.
  • The edit draft is keyed by run_id, so a snapshot that puts another prompt in the same row closes the editor instead of rewinding to the wrong prompt.
  • The rewind route now appears in the web README's route table and unprefixed route list.
  • Tests check that Retry resends the saved prompt with its image, that omitting text is rejected, and that each answer numbers a new turn.