Skip to content

Commit da10c45

Browse files
fix: 将 pipeIpc 添加到 AppState 类型声明,消除 4 个 as any
- AppStateStore: 添加 pipeIpc?: PipeIpcState 可选字段 - PromptInputFooter: 直接访问 s.pipeIpc - useBackgroundTaskNavigation: 直接访问 s.pipeIpc - usePipeRouter: 直接访问 store.getState().pipeIpc - REPL.tsx: 移除 getPipeIpc(s as any) 中的 as any precheck 通过
1 parent 21c17b4 commit da10c45

5 files changed

Lines changed: 7 additions & 4 deletions

File tree

src/components/PromptInput/PromptInputFooter.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ function PipeStatusInline(): React.ReactNode {
256256
if (!feature('UDS_INBOX')) return null;
257257
// All hooks must be called before any conditional return to maintain
258258
// consistent hook count across renders (React rules of hooks).
259-
const pipeIpc = useAppState(s => (s as any).pipeIpc);
259+
const pipeIpc = useAppState(s => s.pipeIpc);
260260
const setAppState = useSetAppState();
261261
const [cursorIndex, setCursorIndex] = useState(0);
262262

src/hooks/useBackgroundTaskNavigation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export function useBackgroundTaskNavigation(options?: {
7272
const viewSelectionMode = useAppState(s => s.viewSelectionMode)
7373
const viewingAgentTaskId = useAppState(s => s.viewingAgentTaskId)
7474
const selectedIPAgentIndex = useAppState(s => s.selectedIPAgentIndex)
75-
const pipeIpc = useAppState(s => (s as any).pipeIpc)
75+
const pipeIpc = useAppState(s => s.pipeIpc)
7676
const setAppState = useSetAppState()
7777

7878
// Filter to running teammates and sort alphabetically to match TeammateSpinnerTree display

src/hooks/usePipeRouter.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ export function usePipeRouter({ store, setAppState, addNotification }: Deps): {
3737
if (!input.trim() || input.trim().startsWith('/')) return false
3838

3939
/* eslint-disable @typescript-eslint/no-require-imports */
40-
const pipeState = (store.getState() as any).pipeIpc
40+
const pipeState = store.getState().pipeIpc
4141
const selectedPipes: string[] = pipeState?.selectedPipes ?? []
4242
const routeMode: 'selected' | 'local' = pipeState?.routeMode ?? 'selected'
4343

src/screens/REPL.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4966,7 +4966,7 @@ export function REPL({
49664966
useMailboxBridge({ isLoading, onSubmitMessage: handleIncomingPrompt });
49674967
useMasterMonitor();
49684968
useSlaveNotifications();
4969-
const _pipeIpcState = useAppState(s => getPipeIpc(s as any));
4969+
const _pipeIpcState = useAppState(s => getPipeIpc(s));
49704970

49714971
usePipePermissionForward({ store, tools, setMessages, setToolUseConfirmQueue, getToolUseContext, mainLoopModel });
49724972
usePipeMuteSync({ setToolUseConfirmQueue });

src/state/AppStateStore.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import type { PermissionMode } from '../utils/permissions/PermissionMode.js'
3636
import { getInitialSettings } from '../utils/settings/settings.js'
3737
import type { SettingsJson } from '../utils/settings/types.js'
3838
import { shouldEnableThinkingByDefault } from '../utils/thinking.js'
39+
import type { PipeIpcState } from '../utils/pipeTransport.js'
3940
import type { Store } from './store.js'
4041

4142
export type CompletionBoundary =
@@ -159,6 +160,8 @@ export type AppState = DeepImmutable<{
159160
replBridgeInitialName: string | undefined
160161
// Always-on bridge: first-time remote dialog pending (set by /remote-control command)
161162
showRemoteCallout: boolean
163+
// Pipe IPC state — added at runtime when feature('PIPE_IPC') is enabled.
164+
pipeIpc?: PipeIpcState
162165
}> & {
163166
// Unified task state - excluded from DeepImmutable because TaskState contains function types
164167
tasks: { [taskId: string]: TaskState }

0 commit comments

Comments
 (0)