diff --git a/desktop/src/stores/chatStore.test.ts b/desktop/src/stores/chatStore.test.ts index cbddbe71..b9c401bf 100644 --- a/desktop/src/stores/chatStore.test.ts +++ b/desktop/src/stores/chatStore.test.ts @@ -2230,6 +2230,41 @@ describe('chatStore history mapping', () => { vi.useRealTimers() }) + it('clears transient worktree startup text when normal thinking resumes', () => { + useChatStore.setState({ + sessions: { + [TEST_SESSION_ID]: makeSession({ + chatState: 'idle', + }), + }, + }) + + useChatStore.getState().handleServerMessage(TEST_SESSION_ID, { + type: 'status', + state: 'thinking', + verb: 'Creating worktree', + }) + expect(useChatStore.getState().sessions[TEST_SESSION_ID]?.statusVerb).toBe('Creating worktree') + + useChatStore.getState().handleServerMessage(TEST_SESSION_ID, { + type: 'status', + state: 'thinking', + verb: 'Thinking', + }) + expect(useChatStore.getState().sessions[TEST_SESSION_ID]?.statusVerb).toBe('') + + useChatStore.getState().handleServerMessage(TEST_SESSION_ID, { + type: 'status', + state: 'thinking', + verb: 'Creating worktree', + }) + useChatStore.getState().handleServerMessage(TEST_SESSION_ID, { + type: 'status', + state: 'thinking', + }) + expect(useChatStore.getState().sessions[TEST_SESSION_ID]?.statusVerb).toBe('') + }) + it('sends a desktop notification when the agent finishes a markdown reply', () => { vi.useFakeTimers() diff --git a/desktop/src/stores/chatStore.ts b/desktop/src/stores/chatStore.ts index a5a30765..600f8fed 100644 --- a/desktop/src/stores/chatStore.ts +++ b/desktop/src/stores/chatStore.ts @@ -799,9 +799,13 @@ export const useChatStore = create((set, get) => ({ const shouldFlush = hasPendingStreamText && msg.state === 'idle' return { chatState: preserveStreamingTurn ? 'streaming' : msg.state, - ...(msg.verb && msg.verb !== 'Thinking' ? { statusVerb: msg.verb } : {}), + statusVerb: msg.state === 'idle' + ? '' + : msg.verb && msg.verb !== 'Thinking' + ? msg.verb + : '', ...(msg.tokens ? { tokenUsage: { ...session.tokenUsage, output_tokens: msg.tokens } } : {}), - ...(msg.state === 'idle' ? { activeThinkingId: null, statusVerb: '' } : {}), + ...(msg.state === 'idle' ? { activeThinkingId: null } : {}), ...(shouldFlush ? { messages: appendAssistantTextMessage(session.messages, pendingText, Date.now()), streamingText: '',