Skip to content

Commit eeb2b26

Browse files
committed
fix: allow explicit reset delivery retry
1 parent 59e5b5e commit eeb2b26

2 files changed

Lines changed: 42 additions & 0 deletions

File tree

‎ui/src/pages/chat/chat-send-actions.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ const resetRetryState = (
8686
...entry,
8787
sendAttempts: 0,
8888
sendError: undefined,
89+
sendRequestStartedAtMs: undefined,
8990
sendRunId: entry.sendState === "failed" ? generateUUID() : entry.sendRunId,
9091
sendState,
9192
});

‎ui/src/pages/chat/chat-send.test.ts‎

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4541,6 +4541,47 @@ describe("handleSendChat", () => {
45414541
expect(replacementRequest).not.toHaveBeenCalled();
45424542
});
45434543

4544+
it("retries an explicitly approved unconfirmed reset with the same run id", async () => {
4545+
const runId = "unconfirmed-reset-run";
4546+
const item = {
4547+
...createQueuedLocalCommand("unconfirmed-reset-retry", "/reset"),
4548+
sendAttempts: 1,
4549+
sendError: "Delivery could not be confirmed after reconnect.",
4550+
sendRequestStartedAtMs: 10,
4551+
sendRunId: runId,
4552+
sendState: "unconfirmed" as const,
4553+
};
4554+
const host = makeHost({
4555+
requestHandlers: {
4556+
"chat.send": (params: unknown) => {
4557+
const payload = requireRecord(params, "retried reset payload");
4558+
return { runId: payload.idempotencyKey, status: "ok" };
4559+
},
4560+
},
4561+
chatQueue: [item],
4562+
confirmConversationReset: vi.fn(async () => true),
4563+
hello: {
4564+
type: "hello-ok",
4565+
protocol: 4,
4566+
auth: { role: "operator", scopes: ["operator.admin"] },
4567+
features: { methods: ["chat.send"] },
4568+
},
4569+
});
4570+
admitHostQueueItems(host);
4571+
4572+
await retryQueuedChatMessage(host, item.id);
4573+
4574+
expect(host.confirmConversationReset).toHaveBeenCalledOnce();
4575+
expect(host.request).toHaveBeenCalledWith(
4576+
"chat.send",
4577+
expect.objectContaining({
4578+
idempotencyKey: runId,
4579+
message: "/reset",
4580+
}),
4581+
);
4582+
expect(listStoredChatOutboxes(host)).toStrictEqual([]);
4583+
});
4584+
45444585
it("retires a queued local command without applying its late result after a route switch", async () => {
45454586
const command = createDeferred<Awaited<ReturnType<ExecuteSlashCommand>>>();
45464587
executeSlashCommandMock.mockImplementationOnce(() => command.promise);

0 commit comments

Comments
 (0)