MCPcopy Create free account
hub / github.com/anus-dev/ANUS / atCompletionReducer

Function atCompletionReducer

packages/cli/src/ui/hooks/useAtCompletion.ts:51–96  ·  view source on GitHub ↗
(
  state: AtCompletionState,
  action: AtCompletionAction,
)

Source from the content-addressed store, hash-verified

49};
50
51function atCompletionReducer(
52 state: AtCompletionState,
53 action: AtCompletionAction,
54): AtCompletionState {
55 switch (action.type) {
56 case 'INITIALIZE':
57 return {
58 ...state,
59 status: AtCompletionStatus.INITIALIZING,
60 isLoading: true,
61 };
62 case 'INITIALIZE_SUCCESS':
63 return { ...state, status: AtCompletionStatus.READY, isLoading: false };
64 case 'SEARCH':
65 // Keep old suggestions, don't set loading immediately
66 return {
67 ...state,
68 status: AtCompletionStatus.SEARCHING,
69 pattern: action.payload,
70 };
71 case 'SEARCH_SUCCESS':
72 return {
73 ...state,
74 status: AtCompletionStatus.READY,
75 suggestions: action.payload,
76 isLoading: false,
77 };
78 case 'SET_LOADING':
79 // Only show loading if we are still in a searching state
80 if (state.status === AtCompletionStatus.SEARCHING) {
81 return { ...state, isLoading: action.payload, suggestions: [] };
82 }
83 return state;
84 case 'ERROR':
85 return {
86 ...state,
87 status: AtCompletionStatus.ERROR,
88 isLoading: false,
89 suggestions: [],
90 };
91 case 'RESET':
92 return initialState;
93 default:
94 return state;
95 }
96}
97
98export interface UseAtCompletionProps {
99 enabled: boolean;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected