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:
@@ -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[];
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 ===
|
||||
|
||||
Reference in New Issue
Block a user