From 2de67fe09163c902801dcdca600bacd09e3d9bf8 Mon Sep 17 00:00:00 2001 From: indifferentketchup Date: Fri, 15 May 2026 15:37:02 +0000 Subject: [PATCH] batch3 T6 typing fix: inline narrowing for body.state guard Boolean indirection (const stateOnly = ...; if (stateOnly)) didn't carry the narrowing to body.state inside the branch. Inline the check so TypeScript narrows correctly and the explicit cast on pendingState becomes unnecessary. Co-Authored-By: Claude Opus 4.7 (1M context) --- apps/web/src/hooks/usePanes.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/apps/web/src/hooks/usePanes.ts b/apps/web/src/hooks/usePanes.ts index 0f4481b..c17217c 100644 --- a/apps/web/src/hooks/usePanes.ts +++ b/apps/web/src/hooks/usePanes.ts @@ -78,9 +78,8 @@ export function usePanes(sessionId: string | undefined): { const update = useCallback( async (id: string, body: PaneUpdateRequest): Promise => { - const stateOnly = body.state !== undefined && body.position === undefined; - - if (stateOnly) { + if (body.state !== undefined && body.position === undefined) { + const nextState = body.state; // Optimistic local update setPanes((prev) => { if (!prev) return prev; @@ -90,10 +89,10 @@ export function usePanes(sessionId: string | undefined): { changed = true; // Narrow via discriminated union to satisfy TypeScript if (pane.kind === 'chat') { - return { ...pane, state: body.state as typeof pane.state }; + return { ...pane, state: nextState as typeof pane.state }; } if (pane.kind === 'file_browser') { - return { ...pane, state: body.state as typeof pane.state }; + return { ...pane, state: nextState as typeof pane.state }; } return pane; }); @@ -101,7 +100,6 @@ export function usePanes(sessionId: string | undefined): { }); // Coalesce: last state wins within debounce window - const nextState = body.state; pendingState.current.set(id, nextState); if (debounceTimer.current !== null) {