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 <noreply@anthropic.com>
This commit is contained in:
iven
2026-03-21 19:52:14 +08:00
parent 7ffd5e1531
commit 5513d5d8e4
3 changed files with 17 additions and 17 deletions

View File

@@ -20,9 +20,9 @@ export function useChatState() {
* Hook to access messages only. * Hook to access messages only.
* Only re-renders when messages change. * Only re-renders when messages change.
*/ */
export function useMessages(): readonly Message[] { export function useMessages() {
const { messages } = useSnapshot(chatStore); 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. * Hook to access all agents.
*/ */
export function useAgents(): readonly Agent[] { export function useAgents() {
const { agents } = useSnapshot(chatStore); const { agents } = useSnapshot(chatStore);
return agents; return agents as readonly Agent[];
} }
/** /**
* Hook to access conversations. * Hook to access conversations.
*/ */
export function useConversations(): readonly Conversation[] { export function useConversations() {
const { conversations } = useSnapshot(chatStore); const { conversations } = useSnapshot(chatStore);
return conversations; return conversations as readonly Conversation[];
} }
/** /**

View File

@@ -17,41 +17,41 @@ export function useHandsState() {
/** /**
* Hook to access hands list. * Hook to access hands list.
*/ */
export function useHands(): readonly Hand[] { export function useHands() {
const { hands } = useSnapshot(handsStore); const { hands } = useSnapshot(handsStore);
return hands; return hands as readonly Hand[];
} }
/** /**
* Hook to access a specific hand by ID. * Hook to access a specific hand by ID.
*/ */
export function useHand(id: string): Hand | undefined { export function useHand(id: string) {
const { hands } = useSnapshot(handsStore); 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. * Hook to access approval queue.
*/ */
export function useApprovalQueue(): readonly ApprovalRequest[] { export function useApprovalQueue() {
const { approvalQueue } = useSnapshot(handsStore); const { approvalQueue } = useSnapshot(handsStore);
return approvalQueue; return approvalQueue as readonly ApprovalRequest[];
} }
/** /**
* Hook to access triggers. * Hook to access triggers.
*/ */
export function useTriggers(): readonly Trigger[] { export function useTriggers() {
const { triggers } = useSnapshot(handsStore); const { triggers } = useSnapshot(handsStore);
return triggers; return triggers as readonly Trigger[];
} }
/** /**
* Hook to access a specific run. * Hook to access a specific run.
*/ */
export function useRun(runId: string): HandRun | undefined { export function useRun(runId: string) {
const { runs } = useSnapshot(handsStore); const { runs } = useSnapshot(handsStore);
return runs[runId]; return runs[runId] as HandRun | undefined;
} }
/** /**

View File

@@ -4,7 +4,7 @@
* XState machine for managing hand execution lifecycle. * XState machine for managing hand execution lifecycle.
* Provides predictable state transitions for automation tasks. * Provides predictable state transitions for automation tasks.
*/ */
import { setup, assign, fromPromise } from 'xstate'; import { setup, assign } from 'xstate';
import type { HandContext, HandsEvent } from './types'; import type { HandContext, HandsEvent } from './types';
// === Machine Setup === // === Machine Setup ===