Skip to content

Commit 02bd7b6

Browse files
adalundheclaude
andcommitted
fix(ui): keep revert and fork while automatic recovery is pending
With automatic recovery enabled, the crash alert showed progress and hid the revert and fork controls. A failed automatic revert stays pending until the next interval, and one that keeps failing left the user with no way out of the conversation. The alert keeps its "Recovering this conversation" state in automatic mode and now offers both choices. A manual revert joins the recovery already admitted instead of starting a second one, and a fork reads only a saved checkpoint, so neither races the automatic attempt. Verified with Node 24: vitest for SessionRecoveryAlert and ChatTranscript.recovery (12 tests), eslint and tsc --noEmit pass. Signed-off-by: Ada Lundhe <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent 94026a0 commit 02bd7b6

3 files changed

Lines changed: 37 additions & 30 deletions

File tree

‎docs/lifecycle-retries.md‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,9 @@ should likewise retain the `request_id` passed to `create_sandbox`.
4343

4444
Controller-wide automatic recovery is opt-in through `sessions.automaticRecovery`
4545
and is disabled by default. Chat offers a revert or a fork from an existing READY
46-
checkpoint after a confirmed runtime crash when automatic recovery is disabled.
47-
Automatic recovery shows progress without manual choices. Call `SessionService.RevertSession` with the Session ID to restore
46+
checkpoint after a confirmed runtime crash. With automatic recovery enabled, chat
47+
shows recovery in progress and keeps both choices, because a failed automatic
48+
revert stays pending until the next attempt. A manual revert joins it. Call `SessionService.RevertSession` with the Session ID to restore
4849
its recorded runtime to the last durable snapshot.
4950
The caller needs Session update access. The operation verifies Substrate's CRASHED state and the recorded Actor identity.
5051
Recovery fails interrupted turns and waiting tasks absent from the retained snapshot.

‎ui/src/components/chat/SessionRecoveryAlert.test.tsx‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,16 @@ describe("conversation recovery choices", () => {
5858
await act(async () => finish());
5959
});
6060

61-
it("shows automatic recovery progress without manual actions", () => {
62-
show({ needed: true, automatic: true, failedMessages: [] });
61+
it("keeps revert and fork available while automatic recovery is pending", async () => {
62+
const { onRevert, onFork } = show({ needed: true, automatic: true, failedMessages: [] });
6363
expect(screen.getByText("Recovering this conversation")).toBeInTheDocument();
64-
expect(screen.queryByRole("button")).not.toBeInTheDocument();
65-
expect(screen.queryByRole("combobox")).not.toBeInTheDocument();
64+
expect(screen.queryByText("The agent runtime crashed")).not.toBeInTheDocument();
65+
await userEvent.click(screen.getByRole("button", { name: "Revert to last snapshot" }));
66+
expect(onRevert).toHaveBeenCalledOnce();
67+
fireEvent.mouseDown(screen.getByRole("combobox", { name: "Saved snapshot to fork" }));
68+
await userEvent.click(await screen.findByText("Saved conversation"));
69+
await userEvent.click(screen.getByRole("button", { name: "Fork snapshot" }));
70+
expect(onFork).toHaveBeenCalledWith("ready");
6671
});
6772

6873
it("prevents another manual request while recovery is running", () => {

‎ui/src/components/chat/SessionRecoveryAlert.tsx‎

Lines changed: 25 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -44,31 +44,32 @@ export function SessionRecoveryAlert({
4444
description={(
4545
<>
4646
<div>{automatic
47-
? "Automatic recovery will restore the last saved runtime state. Messages the recovered agent did not retain are marked as failed."
47+
? "Automatic recovery will restore the last saved runtime state. If it does not finish, revert now or start a new conversation from a saved snapshot. Messages the recovered agent did not retain are marked as failed."
4848
: "Revert to the last runtime snapshot, or start a new conversation from a saved snapshot. Recovery does not replay messages it did not retain."}</div>
49-
{!automatic && (
50-
<Space wrap style={{ marginTop: 8, maxWidth: "100%" }}>
51-
<Button loading={isRecovering} disabled={busy} onClick={() => void onRevert()}>
52-
Revert to last snapshot
53-
</Button>
54-
{ready.length > 0 && (
55-
<>
56-
<Select
57-
aria-label="Saved snapshot to fork"
58-
placeholder="Choose a saved snapshot"
59-
disabled={busy}
60-
value={selected}
61-
onChange={setCheckpointId}
62-
options={ready.map((checkpoint) => ({ value: checkpoint.id, label: checkpoint.name }))}
63-
style={{ width: 240, maxWidth: "100%" }}
64-
/>
65-
<Button loading={isForking} disabled={!selected || busy} onClick={() => void fork()}>
66-
Fork snapshot
67-
</Button>
68-
</>
69-
)}
70-
</Space>
71-
)}
49+
{/* Automatic recovery can fail and stay pending, so the manual choices stay
50+
available. A revert joins the recovery already admitted rather than
51+
starting a second one. */}
52+
<Space wrap style={{ marginTop: 8, maxWidth: "100%" }}>
53+
<Button loading={isRecovering} disabled={busy} onClick={() => void onRevert()}>
54+
Revert to last snapshot
55+
</Button>
56+
{ready.length > 0 && (
57+
<>
58+
<Select
59+
aria-label="Saved snapshot to fork"
60+
placeholder="Choose a saved snapshot"
61+
disabled={busy}
62+
value={selected}
63+
onChange={setCheckpointId}
64+
options={ready.map((checkpoint) => ({ value: checkpoint.id, label: checkpoint.name }))}
65+
style={{ width: 240, maxWidth: "100%" }}
66+
/>
67+
<Button loading={isForking} disabled={!selected || busy} onClick={() => void fork()}>
68+
Fork snapshot
69+
</Button>
70+
</>
71+
)}
72+
</Space>
7273
</>
7374
)}
7475
/>

0 commit comments

Comments
 (0)