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) <noreply@anthropic.com>
This commit is contained in:
@@ -78,9 +78,8 @@ export function usePanes(sessionId: string | undefined): {
|
||||
|
||||
const update = useCallback(
|
||||
async (id: string, body: PaneUpdateRequest): Promise<void> => {
|
||||
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) {
|
||||
|
||||
Reference in New Issue
Block a user