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(
|
const update = useCallback(
|
||||||
async (id: string, body: PaneUpdateRequest): Promise<void> => {
|
async (id: string, body: PaneUpdateRequest): Promise<void> => {
|
||||||
const stateOnly = body.state !== undefined && body.position === undefined;
|
if (body.state !== undefined && body.position === undefined) {
|
||||||
|
const nextState = body.state;
|
||||||
if (stateOnly) {
|
|
||||||
// Optimistic local update
|
// Optimistic local update
|
||||||
setPanes((prev) => {
|
setPanes((prev) => {
|
||||||
if (!prev) return prev;
|
if (!prev) return prev;
|
||||||
@@ -90,10 +89,10 @@ export function usePanes(sessionId: string | undefined): {
|
|||||||
changed = true;
|
changed = true;
|
||||||
// Narrow via discriminated union to satisfy TypeScript
|
// Narrow via discriminated union to satisfy TypeScript
|
||||||
if (pane.kind === 'chat') {
|
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') {
|
if (pane.kind === 'file_browser') {
|
||||||
return { ...pane, state: body.state as typeof pane.state };
|
return { ...pane, state: nextState as typeof pane.state };
|
||||||
}
|
}
|
||||||
return pane;
|
return pane;
|
||||||
});
|
});
|
||||||
@@ -101,7 +100,6 @@ export function usePanes(sessionId: string | undefined): {
|
|||||||
});
|
});
|
||||||
|
|
||||||
// Coalesce: last state wins within debounce window
|
// Coalesce: last state wins within debounce window
|
||||||
const nextState = body.state;
|
|
||||||
pendingState.current.set(id, nextState);
|
pendingState.current.set(id, nextState);
|
||||||
|
|
||||||
if (debounceTimer.current !== null) {
|
if (debounceTimer.current !== null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user