Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI, Telegram or More.
fix(chat): clear isThinking at turn end — spinner no longer outlives the response
Salman Qureshi23efabbd16c8
diff --git a/src/channels/cli-live-activity.test.ts b/src/channels/cli-live-activity.test.tsindex da40a989..47523bcf 100644--- a/src/channels/cli-live-activity.test.ts+++ b/src/channels/cli-live-activity.test.ts@@ -67,4 +67,23 @@ describe('CLIChannel live activity feedback', () => {expect(channel.getTuiState().liveActivity).toBeNull();expect(channel.getTuiState().isThinking).toBe(false);});++ it('turn-end cleanup clears isThinking with the phase — plain-chat spinner must not outlive the turn', () => {+ // Regression: in plain chat the final pushLiveActivity ('Finalizing+ // response') sets isThinking, then no channel.send/sendCompletion+ // follows (response already streamed, no banner for simple turns), and+ // the agent's turn-end finally only called clearLiveActivity() — which+ // cleared the phase but left isThinking true, so the TUI rendered+ // "Processing · 1m 30s / Composing response" forever after the turn+ // was over (agent lifecycle already idle).+ vi.spyOn(process.stdout, 'write').mockImplementation((() => true) as typeof process.stdout.write);+ const channel = new CLIChannel();+ // What the agent does on the 'Finalizing response' step:+ channel.setLiveActivity('Finalizing response');+ expect(channel.getTuiState().isThinking).toBe(true);+ // What the agent's turn-end finally does:+ channel.clearLiveActivity();+ expect(channel.getTuiState().liveActivity).toBeNull();+ expect(channel.getTuiState().isThinking).toBe(false);+ });});\ No newline at end of filediff --git a/src/channels/cli.ts b/src/channels/cli.tsindex 828de575..47d54c3a 100644--- a/src/channels/cli.ts+++ b/src/channels/cli.ts@@ -1372,7 +1372,15 @@ export class CLIChannel extends BaseChannel {/** Clear the live activity block (task finished or idle). */clearLiveActivity(): void {- if (this.state.liveActivity) this.update({ liveActivity: null });+ // Turn-end cleanup: clear the phase AND the thinking state together.+ // In plain chat the final pushLiveActivity ('Finalizing response') sets+ // isThinking, and no channel.send/sendCompletion follows (the response+ // was already streamed; no banner for simple turns) — so the spinner+ // survived the turn and rendered "Processing" forever while the agent+ // was idle.+ if (this.state.liveActivity || this.state.isThinking) {+ this.update({ liveActivity: null, isThinking: false });+ }}updateBackgroundTasks(tasks: BackgroundTaskInfo[]): void {