mirror of
https://github.com/getpaseo/paseo.git
synced 2026-11-04 15:34:39 +00:00
fix(acp): apply queued session updates before ending a turn
The ACP SDK starts each notification's handler without awaiting it but resolves responses synchronously, so a prompt response can settle while earlier session updates are still queued. A tool update applied after the turn's terminal published a running row that nothing closed. Drain the notification lane before terminalizing open rows and ending the turn. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5.5
parent
0d0b89314e
commit
1559dbc559
@@ -596,10 +596,13 @@ class AcpRuntime {
|
||||
turnId,
|
||||
state: "started",
|
||||
});
|
||||
// The SDK dispatches notifications without awaiting them, so the prompt response can resolve
|
||||
// while earlier session updates are still queued. Apply them before the turn ends.
|
||||
const settled = this.call(
|
||||
this.connection.prompt({ sessionId: this.nativeSessionId, prompt }),
|
||||
).then(
|
||||
(response): void => {
|
||||
async (response): Promise<void> => {
|
||||
await this.drainNotifications();
|
||||
const state = response.stopReason === "cancelled" ? "canceled" : "completed";
|
||||
this.fallbackChunkIds.clear();
|
||||
this.terminalizeTransientItems(state);
|
||||
@@ -611,7 +614,8 @@ class AcpRuntime {
|
||||
});
|
||||
return undefined;
|
||||
},
|
||||
(error): void => {
|
||||
async (error): Promise<void> => {
|
||||
await this.drainNotifications();
|
||||
this.fallbackChunkIds.clear();
|
||||
this.terminalizeTransientItems("failed");
|
||||
this.emit({
|
||||
|
||||
Reference in New Issue
Block a user