From 5513d5d8e4b01279c31587a19fc7d6c4bb8ad5c9 Mon Sep 17 00:00:00 2001 From: iven Date: Sat, 21 Mar 2026 19:52:14 +0800 Subject: [PATCH] fix(domains): resolve TypeScript type errors in domain hooks - Add type assertions for Valtio snapshot readonly arrays - Remove unused fromPromise import from hands machine - Ensures type compatibility with Valtio's useSnapshot Co-Authored-By: Claude Opus 4.6 --- desktop/src/domains/chat/hooks.ts | 12 ++++++------ desktop/src/domains/hands/hooks.ts | 20 ++++++++++---------- desktop/src/domains/hands/machine.ts | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/desktop/src/domains/chat/hooks.ts b/desktop/src/domains/chat/hooks.ts index 9de9d89..4c46231 100644 --- a/desktop/src/domains/chat/hooks.ts +++ b/desktop/src/domains/chat/hooks.ts @@ -20,9 +20,9 @@ export function useChatState() { * Hook to access messages only. * Only re-renders when messages change. */ -export function useMessages(): readonly Message[] { +export function useMessages() { const { messages } = useSnapshot(chatStore); - return messages; + return messages as readonly Message[]; } /** @@ -45,17 +45,17 @@ export function useCurrentAgent(): Agent | null { /** * Hook to access all agents. */ -export function useAgents(): readonly Agent[] { +export function useAgents() { const { agents } = useSnapshot(chatStore); - return agents; + return agents as readonly Agent[]; } /** * Hook to access conversations. */ -export function useConversations(): readonly Conversation[] { +export function useConversations() { const { conversations } = useSnapshot(chatStore); - return conversations; + return conversations as readonly Conversation[]; } /** diff --git a/desktop/src/domains/hands/hooks.ts b/desktop/src/domains/hands/hooks.ts index 333df12..f5c614e 100644 --- a/desktop/src/domains/hands/hooks.ts +++ b/desktop/src/domains/hands/hooks.ts @@ -17,41 +17,41 @@ export function useHandsState() { /** * Hook to access hands list. */ -export function useHands(): readonly Hand[] { +export function useHands() { const { hands } = useSnapshot(handsStore); - return hands; + return hands as readonly Hand[]; } /** * Hook to access a specific hand by ID. */ -export function useHand(id: string): Hand | undefined { +export function useHand(id: string) { const { hands } = useSnapshot(handsStore); - return hands.find(h => h.id === id); + return hands.find(h => h.id === id) as Hand | undefined; } /** * Hook to access approval queue. */ -export function useApprovalQueue(): readonly ApprovalRequest[] { +export function useApprovalQueue() { const { approvalQueue } = useSnapshot(handsStore); - return approvalQueue; + return approvalQueue as readonly ApprovalRequest[]; } /** * Hook to access triggers. */ -export function useTriggers(): readonly Trigger[] { +export function useTriggers() { const { triggers } = useSnapshot(handsStore); - return triggers; + return triggers as readonly Trigger[]; } /** * Hook to access a specific run. */ -export function useRun(runId: string): HandRun | undefined { +export function useRun(runId: string) { const { runs } = useSnapshot(handsStore); - return runs[runId]; + return runs[runId] as HandRun | undefined; } /** diff --git a/desktop/src/domains/hands/machine.ts b/desktop/src/domains/hands/machine.ts index f9b0547..672d6dd 100644 --- a/desktop/src/domains/hands/machine.ts +++ b/desktop/src/domains/hands/machine.ts @@ -4,7 +4,7 @@ * XState machine for managing hand execution lifecycle. * Provides predictable state transitions for automation tasks. */ -import { setup, assign, fromPromise } from 'xstate'; +import { setup, assign } from 'xstate'; import type { HandContext, HandsEvent } from './types'; // === Machine Setup ===