mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-02-02 20:43: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:
@@ -22,9 +22,11 @@ export function useBranches() {
|
||||
const branches = branchData?.branches ?? [];
|
||||
const aheadCount = branchData?.aheadCount ?? 0;
|
||||
const behindCount = branchData?.behindCount ?? 0;
|
||||
// Use conservative defaults (false) until data is confirmed
|
||||
// This prevents the UI from assuming git capabilities before the query completes
|
||||
const gitRepoStatus: GitRepoStatus = {
|
||||
isGitRepo: branchData?.isGitRepo ?? true,
|
||||
hasCommits: branchData?.hasCommits ?? true,
|
||||
isGitRepo: branchData?.isGitRepo ?? false,
|
||||
hasCommits: branchData?.hasCommits ?? false,
|
||||
};
|
||||
|
||||
const fetchBranches = useCallback(
|
||||
|
||||
@@ -34,8 +34,8 @@ export function RunningAgentsView() {
|
||||
}, [refetch]);
|
||||
|
||||
const handleStopAgent = useCallback(
|
||||
(featureId: string) => {
|
||||
stopFeature.mutate(featureId);
|
||||
(featureId: string, projectPath: string) => {
|
||||
stopFeature.mutate({ featureId, projectPath });
|
||||
},
|
||||
[stopFeature]
|
||||
);
|
||||
@@ -168,7 +168,7 @@ export function RunningAgentsView() {
|
||||
<Button
|
||||
variant="destructive"
|
||||
size="sm"
|
||||
onClick={() => handleStopAgent(agent.featureId)}
|
||||
onClick={() => handleStopAgent(agent.featureId, agent.projectPath)}
|
||||
disabled={stopFeature.isPending}
|
||||
>
|
||||
<Square className="h-3.5 w-3.5 mr-1.5" />
|
||||
|
||||
@@ -27,15 +27,13 @@ export function useSpecLoading() {
|
||||
const loadSpec = useCallback(async () => {
|
||||
if (!currentProject?.path) return;
|
||||
|
||||
// First check if generation is running
|
||||
await queryClient.invalidateQueries({
|
||||
// Fetch fresh status data to avoid stale cache issues
|
||||
// Using fetchQuery ensures we get the latest data before checking
|
||||
const statusData = await queryClient.fetchQuery<{ isRunning: boolean }>({
|
||||
queryKey: queryKeys.specRegeneration.status(currentProject.path),
|
||||
staleTime: 0, // Force fresh fetch
|
||||
});
|
||||
|
||||
const statusData = queryClient.getQueryData<{ isRunning: boolean }>(
|
||||
queryKeys.specRegeneration.status(currentProject.path)
|
||||
);
|
||||
|
||||
if (statusData?.isRunning) {
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user