From c58708e3fdd9c16bd9969a3ffa950348759ab289 Mon Sep 17 00:00:00 2001 From: ciregenz Date: Sun, 24 May 2026 01:50:27 -0700 Subject: [PATCH] [eric] agents: unlock chat input when a send/edit fails (clear stuck 'running') --- frontend/src/shared/state/agentsSlice.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/frontend/src/shared/state/agentsSlice.ts b/frontend/src/shared/state/agentsSlice.ts index 9c5aa6c8..b956102e 100644 --- a/frontend/src/shared/state/agentsSlice.ts +++ b/frontend/src/shared/state/agentsSlice.ts @@ -1086,6 +1086,22 @@ const agentsSlice = createSlice({ session.status = 'running'; } }) + // The optimistic .pending above set status='running'; on a failed send/edit nothing + // ever cleared it, so the input stayed locked forever. Release it. Guard on 'running' + // so a status the WS already advanced isn't clobbered, and use 'completed' (not a + // blocked terminal) so a later WS 'running' can still take if the agent did start. + .addCase(sendMessage.rejected, (state, action) => { + const session = state.sessions[action.meta.arg.sessionId]; + if (session && session.status === 'running') { + session.status = 'completed'; + } + }) + .addCase(editMessage.rejected, (state, action) => { + const session = state.sessions[action.meta.arg.sessionId]; + if (session && session.status === 'running') { + session.status = 'completed'; + } + }) .addCase(stopAgent.fulfilled, (state, action) => { const session = state.sessions[action.payload]; if (session) {