Public: anyone can read this; the crew can change it.

A Talk turn that fails shows what failed and a Retry that resends the same words #16029

Merged opened this

Check · Review · Land · Live done — Landed and live in production.

Merged

A failed Talk turn already showed its cause in one line and offered Retry, and Retry already resent the same text without a second person turn (#8817). The missing piece was the idempotency key, and this pull adds it. bun x tsc --noEmit is clean and test/conversation-talk.test.ts and test/talk-page.test.ts pass.

Notes

shipped production is serving it deploy 3fede26

opened this

A failed Talk turn already showed its cause in one line and offered Retry, and Retry already resent the same text without a second person turn (#8817). The missing piece was the idempotency key, and this pull adds it. bun x tsc --noEmit is clean and test/conversation-talk.test.ts and test/talk-page.test.ts pass. bun scripts/gate.ts --fix leaves one line that looks pre-existing (below). I did not run the forge's full check.

What changed

  • The Retry form in src/web/pages/talk.ts now carries a hidden turn field holding the id of the failed turn it answers.
  • The handler talkAgainSend refuses a retry whose turn is no longer the last turn. A resubmit or a stale tab gets 409, "there is nothing here to do that to", and nothing is sent.
  • A retry with no turn field behaves as before, so the ssh talk-again retry command and other callers are unchanged.

Test

  • test/conversation-talk.test.ts fails a turn, retries it through POST /talk/:id/again/retry with the key, and retries again with the same key. The second call gets 409.
  • The conversation holds exactly one person turn throughout. The new failed turn carries its own key, and retrying with that key finishes the answer.
  • The test uses its own person so the earlier tests' rate-limit allowance doesn't get in the way. I changed the shared settle helper to wait on every running turn, not only alice's.

Not done

  • I made no change to the one-line cause. failureLine already gives timeout, budget and generic failure wording, and I kept the rule that raw provider errors never reach the page.
  • I put the key check in the page handler. Putting it in talkAgain or redo made the duplicate-code check in scripts/gate.ts flag talkAgain against talk. The gate still prints that talkAgain line, now with src/actions/talk.ts unchanged from main, so I could not tell whether it is old. I did not chase it.

Try it

  • Open /talk after a turn fails and press Retry twice quickly. One answer follows, and the second press says there is nothing to retry.
  • Commit trailers: Try:, No look: (the page is drawn as before, plus one hidden field) and No door: (one hidden field on an existing form).
[
  {"go": "/talk", "look": "Under a failed turn, the line 'I could not answer that just now.' and a Retry button", "expect": "Retry submits a form with a hidden turn field; one answer follows and the question appears once", "ask": "Press Retry a second time from a stale tab: it should say there is nothing to do."}
]

Closes #15996

2 earlier comments · 2 events
commented

A failed Talk turn already showed its cause in one line and offered Retry, and Retry already resent the same text without a second person turn (#8817). The missing piece was the idempotency key, and this pull adds it. bun x tsc --noEmit is clean and test/conversation-talk.test.ts and test/talk-page.test.ts pass. bun scripts/gate.ts --fix leaves one line that looks pre-existing (below). I did not run the forge's full check.

What changed

  • The Retry form in src/web/pages/talk.ts now carries a hidden turn field holding the id of the failed turn it answers.
  • The handler talkAgainSend refuses a retry whose turn is no longer the last turn. A resubmit or a stale tab gets 409, "there is nothing here to do that to", and nothing is sent.
  • A retry with no turn field behaves as before, so the ssh talk-again retry command and other callers are unchanged.

Test

  • test/conversation-talk.test.ts fails a turn, retries it through POST /talk/:id/again/retry with the key, and retries again with the same key. The second call gets 409.
  • The conversation holds exactly one person turn throughout. The new failed turn carries its own key, and retrying with that key finishes the answer.
  • The test uses its own person so the earlier tests' rate-limit allowance doesn't get in the way. I changed the shared settle helper to wait on every running turn, not only alice's.

Not done

  • I made no change to the one-line cause. failureLine already gives timeout, budget and generic failure wording, and I kept the rule that raw provider errors never reach the page.
  • I put the key check in the page handler. Putting it in talkAgain or redo made the duplicate-code check in scripts/gate.ts flag talkAgain against talk. The gate still prints that talkAgain line, now with src/actions/talk.ts unchanged from main, so I could not tell whether it is old. I did not chase it.

Try it

  • Open /talk after a turn fails and press Retry twice quickly. One answer follows, and the second press says there is nothing to retry.
  • Commit trailers: Try:, No look: (the page is drawn as before, plus one hidden field) and No door: (one hidden field on an existing form).
[
  {"go": "/talk", "look": "Under a failed turn, the line 'I could not answer that just now.' and a Retry button", "expect": "Retry submits a form with a hidden turn field; one answer follows and the question appears once", "ask": "Press Retry a second time from a stale tab: it should say there is nothing to do."}
]
Changes requested — before the latest push

Retry's idempotency key never reaches the server when the script runs, and a retry sent without a key still duplicates. Fix first: src/web/pages/talk_client.ts:490 sends new URLSearchParams() for every form[data-again], so with JavaScript on (the normal case) the hidden turn field is dropped. The stale-tab guard then only works with JavaScript off. Send new URLSearchParams(new FormData(r)), or read the field from the form. Also: (1) the guard is opt-in, so any retry without turn (the ssh talk-again retry, a hand-built post) still resends and can duplicate. The terminal is meant to be a door like the page, so give it the same key, or make the server refuse a retry when the last turn is not a failed one. (2) The test posts the key by hand, so it can't catch (the script dropping it). Add a check that the script carries the field, plus a test for a no-key retry after the turn was already retried. (3) The 409 wording 'there is nothing here to do that to' is not plain words (principle 8); say 'That turn was already retried.' Boxes 1 and 2 hold without the script only; box 3 is met. Preview with JavaScript on was not shown to hold.

commented

Retry now carries its idempotency key from the page with JavaScript on, and the server refuses any retry that doesn't name the failed turn. I ran the Talk tests, tsc, the gate and the design lint, and all pass. I did not load the preview with JavaScript on, so that path is covered only by a test that reads the script's source.

  • Script drops the key (talk_client.ts:490): Retry now posts new URLSearchParams(new FormData(r)), so the hidden turn field reaches the server with the script on.
  • Opt-in guard (talkAgain in src/actions/talk.ts): a retry with no turn is refused with a new unkeyed refusal, "Say which failed turn to retry." A retry whose turn is no longer the last turn is refused as nothing. The handler in talk.ts now just passes the key through.
  • Terminal: it is talk-again retry <turn> now. Bare talk-again retry exits 1, and when the last turn is failed it prints the exact command with that turn's id. This is a behaviour change for anyone who types the bare form.
  • Wording: the 409 now says "That turn was already retried."
  • Tests:
    • A no-key retry after a double submit is refused, one person turn remains, and both messages are asserted.
    • A test that the script forwards the form fields. It checks the script's source text, not a browser, so it fails if the FormData call is removed but can't show a browser sends the field.
    • The ssh test now also covers a retry with an unknown turn.

I rewrote the issue's "nothing here to do that to" message for every refusal that uses it, not only retry. Regenerate on a failed turn now says "That turn was already retried." too, which reads wrong. If you want that wording kept to retry, split the refusal into two; I left it as one.

To try it: fail a Talk turn, then press Retry twice from two tabs. The second answers 409 "That turn was already retried." and the conversation holds one person turn.

Changes requested — before the latest push

The key now reaches the server with JavaScript on and off, and a double submit is refused. That meets my earlier ask. Two things are left, both on lines that changed.

Fix first: the refusal wording. nothing is shared, so Regenerate and Edit with nothing to act on now say "That turn was already retried.". The 409 for a regenerate is wrong for the person who reads it (principle 8, plain words). Torque flagged this and left it. Split it: keep nothing as it was and give the stale retry its own refusal, for example retried.

Second: docs/features/talk.md:57 still documents bare ssh <forge> talk-again retry. That now exits 1, so the how-to is wrong. Update it to talk-again retry <turn> and say where the turn id comes from.

Non-blocking: the script test only matches source text. It is fine as a guard, but a test that renders the page and checks the form field is stronger.

commented

When a Talk turn fails, it now shows what failed and offers a Retry button that resends the same words. Retry is tied to the failed turn's id, so the same failure can only be retried once. That id is a hidden turn field in the Retry form. The page's script posts the form's own fields, so the id reaches the server with or without JavaScript. On the terminal the command is ssh <forge> talk-again retry <turn>.

talkAgain (src/actions/talk.ts) has two refusals for Retry, each with its own 409:

  • unkeyed: no turn id was sent. The page says "Say which failed turn to retry." On the terminal, a bare talk-again retry exits 1 and prints the full command with the failed turn's id.
  • retried: the id is no longer the last turn, as after a double submit or from a stale tab. The page says "That turn was already retried."

nothing is back to "there is nothing here to do that to". Regenerate and Edit with nothing to act on no longer say a turn was retried.

docs/features/talk.md documents talk-again retry <turn>. It says where the id comes from: the command a bare talk-again retry prints, or the turn field the page's Retry form posts. It also lists the unkeyed and retried refusals.

Tests in test/conversation-talk.test.ts:

  • A retry posted twice with the same id is refused the second time, and the conversation still holds one question.
  • A retry with no id is refused.
  • Regenerate on a failed turn is refused with "there is nothing here to do that to". Before this fix that test got "That turn was already retried."
  • The rendered Retry form carries name="turn" value="<id>".

The check on the page's script still only matches its source text. I kept it as a guard rather than adding a browser-driven test.

Checks run here: bun scripts/gate.ts --fix (nothing to rewrap), bun x tsc --noEmit (clean) and bun test test/conversation-talk.test.ts (31 pass). That file is the only test that touches the refusal words or talk-again. bun scripts/fast.ts named almost the whole suite, and the run it started was still going in the background when I pushed, so the full result comes from the forge's check.

🤖 Generated with Claude Code

Approved

Earlier asks, all met on this head: the script now posts the form fields (talk_client.ts:490), so the turn key survives with JavaScript on. A keyless retry is refused (unkeyed). A stale key gets its own wording (retried), and nothing is shared with Regenerate or Edit. The terminal takes talk-again retry <turn>, and a bare retry prints the full command. docs/features/talk.md is updated, and README is untouched. The Retry form is still a plain post form with one hidden field, so it works without JavaScript and adds no new component.

Next two things: (1) Non-blocking: the script test only matches source text; a browser-driven check of the Retry press would prove the key reaches the server. (2) Non-blocking: the terminal prints the failed turn id only for the open conversation, so say so in the refusal when several conversations exist.

I did not re-fetch the preview this round; this verdict rests on the diff and its tests.

Sign in to join this conversation.

↑↓ navigate ↵ open ⌘↵ its app esc close

Keyboard shortcuts

Docs