mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-03 08:53:36 +00:00
- Add feature mutations (create, update, delete with optimistic updates) - Add auto-mode mutations (start, stop, approve plan) - Add worktree mutations (create, delete, checkout, switch branch) - Add settings mutations (update global/project, validate API keys) - Add GitHub mutations (create PR, validate PR) - Add cursor permissions mutations (apply profile, copy config) - Add spec mutations (generate, update, save) - Add pipeline mutations (toggle, update config) - Add session mutations with cache invalidation Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
83 lines
2.1 KiB
TypeScript
83 lines
2.1 KiB
TypeScript
/**
|
|
* Ideation Mutation Hooks
|
|
*
|
|
* React Query mutations for ideation operations like generating suggestions.
|
|
*/
|
|
|
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
import { getElectronAPI } from '@/lib/electron';
|
|
import { queryKeys } from '@/lib/query-keys';
|
|
import { toast } from 'sonner';
|
|
import type { IdeaCategory, IdeaSuggestion } from '@automaker/types';
|
|
|
|
/**
|
|
* Input for generating ideation suggestions
|
|
*/
|
|
interface GenerateSuggestionsInput {
|
|
promptId: string;
|
|
category: IdeaCategory;
|
|
}
|
|
|
|
/**
|
|
* Result from generating suggestions
|
|
*/
|
|
interface GenerateSuggestionsResult {
|
|
suggestions: IdeaSuggestion[];
|
|
promptId: string;
|
|
category: IdeaCategory;
|
|
}
|
|
|
|
/**
|
|
* Generate ideation suggestions based on a prompt
|
|
*
|
|
* @param projectPath - Path to the project
|
|
* @returns Mutation for generating suggestions
|
|
*
|
|
* @example
|
|
* ```tsx
|
|
* const generateMutation = useGenerateIdeationSuggestions(projectPath);
|
|
*
|
|
* generateMutation.mutate({
|
|
* promptId: 'prompt-1',
|
|
* category: 'ux',
|
|
* }, {
|
|
* onSuccess: (data) => {
|
|
* console.log('Generated', data.suggestions.length, 'suggestions');
|
|
* },
|
|
* });
|
|
* ```
|
|
*/
|
|
export function useGenerateIdeationSuggestions(projectPath: string) {
|
|
const queryClient = useQueryClient();
|
|
|
|
return useMutation({
|
|
mutationFn: async (input: GenerateSuggestionsInput): Promise<GenerateSuggestionsResult> => {
|
|
const { promptId, category } = input;
|
|
|
|
const api = getElectronAPI();
|
|
if (!api.ideation?.generateSuggestions) {
|
|
throw new Error('Ideation API not available');
|
|
}
|
|
|
|
const result = await api.ideation.generateSuggestions(projectPath, promptId, category);
|
|
|
|
if (!result.success) {
|
|
throw new Error(result.error || 'Failed to generate suggestions');
|
|
}
|
|
|
|
return {
|
|
suggestions: result.suggestions ?? [],
|
|
promptId,
|
|
category,
|
|
};
|
|
},
|
|
onSuccess: () => {
|
|
// Invalidate ideation ideas cache
|
|
queryClient.invalidateQueries({
|
|
queryKey: queryKeys.ideation.ideas(projectPath),
|
|
});
|
|
},
|
|
// Toast notifications are handled by the component since it has access to prompt title
|
|
});
|
|
}
|