From 37f1bb202c5999a792dfee69b0b953fcb17ca3c5 Mon Sep 17 00:00:00 2001 From: Fini Date: Sun, 24 May 2026 15:16:07 +0800 Subject: [PATCH] fix(host): drop in-flight design session when falling to chat path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Codex stop-time review caught a real cross-session leak in the intent gate introduced by the previous commit. `launch_if_pending` clears `current_chat` when the design branch is taken, but the chat branch only cleared `current_chat` (for the unwired-agent error path) — it never cleared `current_design`. Symptom: if a design turn is in flight (worker pumping `apply` requests + `Progress` deltas into the trailing assistant bubble) and the user sends a chat message, the new chat bubble begins streaming chat deltas while the still-running design worker keeps acking apply requests on the canonical doc and appending `Progress` strings to the same bubble. The fix mirrors the design branch — when the chat path is taken (chat intent, design intent without a Provider, or any unwired agent), `*current_design = None` drops the worker's command receiver so its next `apply` returns false and the turn ends. `cargo test -p op-host-desktop` 105 passed. workspace fmt + clippy clean. --- crates/op-host-desktop/src/chat_session.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/op-host-desktop/src/chat_session.rs b/crates/op-host-desktop/src/chat_session.rs index 3a7ceb8f0..fd40ee335 100644 --- a/crates/op-host-desktop/src/chat_session.rs +++ b/crates/op-host-desktop/src/chat_session.rs @@ -195,6 +195,13 @@ pub fn launch_if_pending( // the chat path. The assistant CLI will still answer the user // (most CLIs handle design verbs as chat). } + // Taking the chat path — drop any in-flight design turn so its + // worker's next `apply` returns false (channel dropped) and its + // `Progress` deltas stop streaming into this turn's fresh bubble + // (codex stop-gate: stale design session survived chat fallback, + // kept overwriting the new bubble content + applying ack'd + // EditorCommands long after the user moved on). + *current_design = None; let agent_idx = host.editor_state().editor_ui.chat_selected_agent; let Some(provider) = provider_for_agent(agent_idx) else { // Selected agent has no `ChatProvider` bridge yet (Codex /