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) {