fix(claude): report thinking for local-mode sessions (#2209)

* fix(claude): report thinking for local-mode sessions

Local Claude sessions have no SDK stream, so nothing ever set the
session's thinking flag and the web UI showed them idle mid-turn.
Derive it from the local hooks instead: UserPromptSubmit/PreToolUse
turn it on, Stop/StopFailure/SessionEnd turn it off. Esc interrupts
fire no Stop hook, so the transcript's interrupt marker also clears
it, and leaving local mode always resets it.

Fixes #1864

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

* fix(claude): ignore interrupt markers from an earlier local turn

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
SSU-WEI HUANG
2026-10-28 10:31:44 +08:00
committed by GitHub
co-authored by Claude Opus 5.5
parent eb49ccd62b
commit 00bbbfa780
6 changed files with 77 additions and 0 deletions
@@ -25,6 +25,9 @@ describe('buildHookSettings local approvals', () => {
expect(settings.hooks.PostToolUse).toBeDefined()
expect(settings.hooks.PostToolUseFailure).toBeDefined()
expect(settings.hooks.SessionEnd).toBeDefined()
expect(settings.hooks.Stop).toBeDefined()
expect(settings.hooks.StopFailure).toBeDefined()
expect(buildHookSettings('forward-cmd', undefined, true, false).hooks.Stop).toBeUndefined()
expect(settings.hooks.PermissionRequest?.[0].hooks[0]).toEqual({
type: 'command',
command: 'forward-cmd',
@@ -28,6 +28,8 @@ type HookSettings = {
PostModelSwitch?: HookCommandConfig[];
PostToolUse?: HookCommandConfig[];
PostToolUseFailure?: HookCommandConfig[];
Stop?: HookCommandConfig[];
StopFailure?: HookCommandConfig[];
SessionEnd?: HookCommandConfig[];
};
};
@@ -79,6 +81,8 @@ export function buildHookSettings(
}];
hooks.PostToolUse = [{ matcher: '*', ...commandHook }];
hooks.PostToolUseFailure = [{ matcher: '*', ...commandHook }];
hooks.Stop = [commandHook];
hooks.StopFailure = [commandHook];
hooks.SessionEnd = [{ matcher: '*', ...commandHook }];
}