From c4dc8b45cf02feb9635968c1b0e9eda84dfc9dd9 Mon Sep 17 00:00:00 2001 From: Iuliia Ivashko Date: Tue, 17 Mar 2026 02:47:30 +0200 Subject: [PATCH] fix: preserve manual agent selection during active runs (#678) (#679) --- packages/ui/src/hooks/useEventStream.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/packages/ui/src/hooks/useEventStream.ts b/packages/ui/src/hooks/useEventStream.ts index 156a48e0..7af4d791 100644 --- a/packages/ui/src/hooks/useEventStream.ts +++ b/packages/ui/src/hooks/useEventStream.ts @@ -1462,6 +1462,17 @@ export const useEventStream = (options?: { enabled?: boolean }) => { return true; } + if (currentSessionIdRef.current === sessionId) { + const explicitSelection = useContextStore.getState().getSessionAgentSelection(sessionId); + if (explicitSelection && explicitSelection !== agentCandidate) { + const status = useSessionStore.getState().sessionStatus?.get(sessionId); + const isBusy = status?.type === 'busy' || status?.type === 'retry'; + if (isBusy) { + return false; + } + } + } + const last = lastUserAgentSelectionRef.current.get(sessionId); if (!last) return true;