mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 20:23:36 +00:00
fix(ui): improve React Query hooks and fix edge cases
- Update query keys to include all relevant parameters (branches, agents) - Fix use-branches to pass includeRemote parameter to query key - Fix use-settings to include sources in agents query key - Update running-agents-view to use correct query key structure - Update use-spec-loading to properly use spec query hooks - Add missing queryClient invalidation in auto-mode mutations - Add missing cache invalidation in spec mutations after creation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -99,21 +99,36 @@ export function useResumeFeature(projectPath: string) {
|
||||
* Stop a running feature
|
||||
*
|
||||
* @returns Mutation for stopping a feature
|
||||
*
|
||||
* @example
|
||||
* ```tsx
|
||||
* const stopFeature = useStopFeature();
|
||||
* // Simple stop
|
||||
* stopFeature.mutate('feature-id');
|
||||
* // Stop with project path for cache invalidation
|
||||
* stopFeature.mutate({ featureId: 'feature-id', projectPath: '/path/to/project' });
|
||||
* ```
|
||||
*/
|
||||
export function useStopFeature() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (featureId: string) => {
|
||||
mutationFn: async (input: string | { featureId: string; projectPath?: string }) => {
|
||||
const featureId = typeof input === 'string' ? input : input.featureId;
|
||||
const api = getElectronAPI();
|
||||
const result = await api.autoMode.stopFeature(featureId);
|
||||
if (!result.success) {
|
||||
throw new Error(result.error || 'Failed to stop feature');
|
||||
}
|
||||
return result;
|
||||
// Return projectPath for use in onSuccess
|
||||
return { ...result, projectPath: typeof input === 'string' ? undefined : input.projectPath };
|
||||
},
|
||||
onSuccess: () => {
|
||||
onSuccess: (data) => {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.runningAgents.all() });
|
||||
// Also invalidate features cache if projectPath is provided
|
||||
if (data.projectPath) {
|
||||
queryClient.invalidateQueries({ queryKey: queryKeys.features.all(data.projectPath) });
|
||||
}
|
||||
toast.success('Feature stopped');
|
||||
},
|
||||
onError: (error: Error) => {
|
||||
|
||||
Reference in New Issue
Block a user