mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-01 08:13:37 +00:00
feat(ui): add React Query hooks for data fetching
- Add useFeatures, useFeature, useAgentOutput for feature data - Add useGitHubIssues, useGitHubPRs, useGitHubValidations, useGitHubIssueComments - Add useClaudeUsage, useCodexUsage with polling intervals - Add useRunningAgents, useRunningAgentsCount - Add useWorktrees, useWorktreeInfo, useWorktreeStatus, useWorktreeDiffs - Add useGlobalSettings, useProjectSettings, useCredentials - Add useAvailableModels, useCodexModels, useOpencodeModels - Add useSessions, useSessionHistory, useSessionQueue - Add useIdeationPrompts, useIdeas - Add CLI status queries (claude, cursor, codex, opencode, github) - Add useCursorPermissionsQuery, useWorkspaceDirectories - Add usePipelineConfig, useSpecFile, useSpecRegenerationStatus Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
37
apps/ui/src/hooks/queries/use-git.ts
Normal file
37
apps/ui/src/hooks/queries/use-git.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Git Query Hooks
|
||||
*
|
||||
* React Query hooks for git operations.
|
||||
*/
|
||||
|
||||
import { useQuery } from '@tanstack/react-query';
|
||||
import { getElectronAPI } from '@/lib/electron';
|
||||
import { queryKeys } from '@/lib/query-keys';
|
||||
import { STALE_TIMES } from '@/lib/query-client';
|
||||
|
||||
/**
|
||||
* Fetch git diffs for a project (main project, not worktree)
|
||||
*
|
||||
* @param projectPath - Path to the project
|
||||
* @param enabled - Whether to enable the query
|
||||
* @returns Query result with files and diff content
|
||||
*/
|
||||
export function useGitDiffs(projectPath: string | undefined, enabled = true) {
|
||||
return useQuery({
|
||||
queryKey: queryKeys.git.diffs(projectPath ?? ''),
|
||||
queryFn: async () => {
|
||||
if (!projectPath) throw new Error('No project path');
|
||||
const api = getElectronAPI();
|
||||
const result = await api.git.getDiffs(projectPath);
|
||||
if (!result.success) {
|
||||
throw new Error(result.error || 'Failed to fetch diffs');
|
||||
}
|
||||
return {
|
||||
files: result.files ?? [],
|
||||
diff: result.diff ?? '',
|
||||
};
|
||||
},
|
||||
enabled: !!projectPath && enabled,
|
||||
staleTime: STALE_TIMES.WORKTREES,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user