Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(chat): preserve streamed messages when a response is cancelled

Steven Enamakelc7369739f197
diff --git a/app/src/services/chatService.ts b/app/src/services/chatService.ts
index 7a58331138..601261470b 100644
--- a/app/src/services/chatService.ts
+++ b/app/src/services/chatService.ts
@@ -340,6 +340,13 @@ export interface ChatApprovalRequestEvent {
* expiry countdown on the approval card. Absent on an older core.
*/
expires_at?: string;
+ /**
+ * `true` when the park can outlive the chat turn it is shown on — an
+ * async-delegated sub-agent (wire contract: `DomainEvent::ApprovalRequested.
+ * detached`, additive). The card is kept across that turn's `chat_done` and
+ * cleared by `approval_decided` instead. Absent for an in-turn park.
+ */
+ detached?: boolean;
}
/**
diff --git a/app/src/store/chatRuntimeSlice.ts b/app/src/store/chatRuntimeSlice.ts
index 7d37f72897..c6e1919fee 100644
--- a/app/src/store/chatRuntimeSlice.ts
+++ b/app/src/store/chatRuntimeSlice.ts
@@ -671,6 +671,25 @@ export interface PendingApproval {
* `ToolCallMessagePart.approval.resolution` union.
*/
resolution?: 'expired' | 'cancelled';
+ /**
+ * The park can outlive the turn it is shown on
+ * (`ChatApprovalRequestEvent.detached`): an async-delegated sub-agent asking
+ * for approval after — or while — its parent turn finishes. Turn-end
+ * handlers keep a detached entry (its gate is still parked; clearing it was
+ * what left every async `image_agent` approval invisible until it expired)
+ * and `approval_decided` clears it instead.
+ */
+ detached?: boolean;
+}
+
+/**
+ * Drop the thread's parked approval at a turn boundary, unless it is detached
+ * from that turn (see `PendingApproval.detached`) — a detached park is still
+ * waiting on the user after the turn that surfaced it ends.
+ */
+function dropTurnBoundApproval(state: ChatRuntimeState, threadId: string): void {
+ if (state.pendingApprovalByThread[threadId]?.detached) return;
+ delete state.pendingApprovalByThread[threadId];
}
/**