Skip to content

Commit f771009

Browse files
committed
fix(web): Queued messages can be edited during Compact and send
When a stale Claude thread compacts before a send, the message queues behind T3's idle /compact run. The thread shell hides that silent run, so its runtime reports the queued run, and derivePhase reads queued as connecting. hasServerAcknowledgedLocalDispatch held the send as unacknowledged for the whole compaction: the composer stayed busy, and saving an edit to the queued message with Enter did nothing. A queued runtime whose latest user message has changed now counts as acknowledged.
1 parent 6d12bb1 commit f771009

2 files changed

Lines changed: 33 additions & 3 deletions

File tree

‎apps/web/src/components/ChatView.logic.test.ts‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,35 @@ describe("hasServerAcknowledgedLocalDispatch", () => {
176176
).toBe(false);
177177
});
178178

179+
it("acknowledges a message queued behind an idle compaction", () => {
180+
const localDispatch = createLocalDispatchSnapshot(
181+
makeThread({ latestRun: completedTurn, runtime: readySession }),
182+
{ latestUserMessageId: MessageId.make("message-before-send") },
183+
);
184+
// The shell hides the silent compaction run, so its runtime reports the queued message's run.
185+
const queuedRun = {
186+
...completedTurn,
187+
runId: RunId.make("turn-queued"),
188+
status: "queued" as const,
189+
requestedAt: "2026-03-29T00:01:00.000Z",
190+
startedAt: null,
191+
completedAt: null,
192+
};
193+
194+
expect(
195+
hasServerAcknowledgedLocalDispatch({
196+
localDispatch,
197+
phase: "running",
198+
latestRun: queuedRun,
199+
latestUserMessageId: MessageId.make("message-queued"),
200+
runtime: { ...readySession, status: "queued" },
201+
hasPendingApproval: false,
202+
hasPendingUserInput: false,
203+
threadError: null,
204+
}),
205+
).toBe(true);
206+
});
207+
179208
it("waits for the matching running turn before acknowledging", () => {
180209
const localDispatch = createLocalDispatchSnapshot(
181210
makeThread({ latestRun: completedTurn, runtime: readySession }),

‎apps/web/src/components/ChatView.logic.ts‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1097,14 +1097,15 @@ export function hasServerAcknowledgedLocalDispatch(input: {
10971097
if (input.hasPendingApproval || input.hasPendingUserInput || Boolean(input.threadError)) {
10981098
return true;
10991099
}
1100+
const latestUserMessageChanged =
1101+
input.localDispatch.latestUserMessageId !== (input.latestUserMessageId ?? null);
11001102
if (input.phase === "connecting" || derivePhase(input.runtime ?? null) === "connecting") {
1101-
return false;
1103+
// A message queued behind other work, such as an idle compaction the shell hides, has landed.
1104+
return input.runtime?.status === "queued" && latestUserMessageChanged;
11021105
}
11031106

11041107
const latestRun = input.latestRun ?? null;
11051108
const runtime = input.runtime ?? null;
1106-
const latestUserMessageChanged =
1107-
input.localDispatch.latestUserMessageId !== (input.latestUserMessageId ?? null);
11081109
const latestRunChanged =
11091110
input.localDispatch.latestRunId !== (latestRun?.runId ?? null) ||
11101111
input.localDispatch.latestRunRequestedAt !== (latestRun?.requestedAt ?? null) ||

0 commit comments

Comments
 (0)