chore: Fix all 246 TypeScript errors in UI

- Extended SetupAPI interface with 20+ missing methods for Cursor, Codex,
  OpenCode, Gemini, and Copilot CLI integrations
- Fixed WorktreeInfo type to include isCurrent and hasWorktree fields
- Added null checks for optional API properties across all hooks
- Fixed Feature type conflicts between @automaker/types and local definitions
- Added missing CLI status hooks for all providers
- Fixed type mismatches in mutation callbacks and event handlers
- Removed dead code referencing non-existent GlobalSettings properties
- Updated mock implementations in electron.ts for all new API methods

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Shirone
2026-01-25 18:36:47 +01:00
parent 0fb471ca15
commit 5c335641fa
48 changed files with 1071 additions and 336 deletions

View File

@@ -36,6 +36,7 @@ export function useStartFeature(projectPath: string) {
worktreePath?: string;
}) => {
const api = getElectronAPI();
if (!api.autoMode) throw new Error('AutoMode API not available');
const result = await api.autoMode.runFeature(
projectPath,
featureId,
@@ -77,6 +78,7 @@ export function useResumeFeature(projectPath: string) {
useWorktrees?: boolean;
}) => {
const api = getElectronAPI();
if (!api.autoMode) throw new Error('AutoMode API not available');
const result = await api.autoMode.resumeFeature(projectPath, featureId, useWorktrees);
if (!result.success) {
throw new Error(result.error || 'Failed to resume feature');
@@ -116,6 +118,7 @@ export function useStopFeature() {
mutationFn: async (input: string | { featureId: string; projectPath?: string }) => {
const featureId = typeof input === 'string' ? input : input.featureId;
const api = getElectronAPI();
if (!api.autoMode) throw new Error('AutoMode API not available');
const result = await api.autoMode.stopFeature(featureId);
if (!result.success) {
throw new Error(result.error || 'Failed to stop feature');
@@ -151,6 +154,7 @@ export function useVerifyFeature(projectPath: string) {
return useMutation({
mutationFn: async (featureId: string) => {
const api = getElectronAPI();
if (!api.autoMode) throw new Error('AutoMode API not available');
const result = await api.autoMode.verifyFeature(projectPath, featureId);
if (!result.success) {
throw new Error(result.error || 'Failed to verify feature');
@@ -196,6 +200,7 @@ export function useApprovePlan(projectPath: string) {
feedback?: string;
}) => {
const api = getElectronAPI();
if (!api.autoMode) throw new Error('AutoMode API not available');
const result = await api.autoMode.approvePlan(
projectPath,
featureId,
@@ -246,6 +251,7 @@ export function useFollowUpFeature(projectPath: string) {
useWorktrees?: boolean;
}) => {
const api = getElectronAPI();
if (!api.autoMode) throw new Error('AutoMode API not available');
const result = await api.autoMode.followUpFeature(
projectPath,
featureId,
@@ -282,6 +288,7 @@ export function useCommitFeature(projectPath: string) {
return useMutation({
mutationFn: async (featureId: string) => {
const api = getElectronAPI();
if (!api.autoMode) throw new Error('AutoMode API not available');
const result = await api.autoMode.commitFeature(projectPath, featureId);
if (!result.success) {
throw new Error(result.error || 'Failed to commit changes');
@@ -310,6 +317,7 @@ export function useAnalyzeProject() {
return useMutation({
mutationFn: async (projectPath: string) => {
const api = getElectronAPI();
if (!api.autoMode) throw new Error('AutoMode API not available');
const result = await api.autoMode.analyzeProject(projectPath);
if (!result.success) {
throw new Error(result.error || 'Failed to analyze project');
@@ -339,7 +347,8 @@ export function useStartAutoMode(projectPath: string) {
return useMutation({
mutationFn: async (maxConcurrency?: number) => {
const api = getElectronAPI();
const result = await api.autoMode.start(projectPath, maxConcurrency);
if (!api.autoMode) throw new Error('AutoMode API not available');
const result = await api.autoMode.start(projectPath, String(maxConcurrency ?? ''));
if (!result.success) {
throw new Error(result.error || 'Failed to start auto mode');
}
@@ -369,6 +378,7 @@ export function useStopAutoMode(projectPath: string) {
return useMutation({
mutationFn: async () => {
const api = getElectronAPI();
if (!api.autoMode) throw new Error('AutoMode API not available');
const result = await api.autoMode.stop(projectPath);
if (!result.success) {
throw new Error(result.error || 'Failed to stop auto mode');

View File

@@ -8,7 +8,7 @@ import { useMutation, useQueryClient } from '@tanstack/react-query';
import { getElectronAPI, GitHubIssue, GitHubComment } from '@/lib/electron';
import { queryKeys } from '@/lib/query-keys';
import { toast } from 'sonner';
import type { LinkedPRInfo, ModelId } from '@automaker/types';
import type { LinkedPRInfo, ModelId, ThinkingLevel, ReasoningEffort } from '@automaker/types';
import { resolveModelString } from '@automaker/model-resolver';
/**
@@ -17,8 +17,8 @@ import { resolveModelString } from '@automaker/model-resolver';
interface ValidateIssueInput {
issue: GitHubIssue;
model?: ModelId;
thinkingLevel?: number;
reasoningEffort?: string;
thinkingLevel?: ThinkingLevel;
reasoningEffort?: ReasoningEffort;
comments?: GitHubComment[];
linkedPRs?: LinkedPRInfo[];
}

View File

@@ -22,6 +22,7 @@ export function useCreateWorktree(projectPath: string) {
return useMutation({
mutationFn: async ({ branchName, baseBranch }: { branchName: string; baseBranch?: string }) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.create(projectPath, branchName, baseBranch);
if (!result.success) {
throw new Error(result.error || 'Failed to create worktree');
@@ -58,6 +59,7 @@ export function useDeleteWorktree(projectPath: string) {
deleteBranch?: boolean;
}) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.delete(projectPath, worktreePath, deleteBranch);
if (!result.success) {
throw new Error(result.error || 'Failed to delete worktree');
@@ -87,6 +89,7 @@ export function useCommitWorktree() {
return useMutation({
mutationFn: async ({ worktreePath, message }: { worktreePath: string; message: string }) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.commit(worktreePath, message);
if (!result.success) {
throw new Error(result.error || 'Failed to commit changes');
@@ -117,6 +120,7 @@ export function usePushWorktree() {
return useMutation({
mutationFn: async ({ worktreePath, force }: { worktreePath: string; force?: boolean }) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.push(worktreePath, force);
if (!result.success) {
throw new Error(result.error || 'Failed to push changes');
@@ -146,6 +150,7 @@ export function usePullWorktree() {
return useMutation({
mutationFn: async (worktreePath: string) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.pull(worktreePath);
if (!result.success) {
throw new Error(result.error || 'Failed to pull changes');
@@ -188,6 +193,7 @@ export function useCreatePullRequest() {
};
}) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.createPR(worktreePath, options);
if (!result.success) {
throw new Error(result.error || 'Failed to create pull request');
@@ -243,10 +249,12 @@ export function useMergeWorktree(projectPath: string) {
};
}) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.mergeFeature(
projectPath,
branchName,
worktreePath,
undefined, // targetBranch - use default (main)
options
);
if (!result.success) {
@@ -284,6 +292,7 @@ export function useSwitchBranch() {
branchName: string;
}) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.switchBranch(worktreePath, branchName);
if (!result.success) {
throw new Error(result.error || 'Failed to switch branch');
@@ -319,6 +328,7 @@ export function useCheckoutBranch() {
branchName: string;
}) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.checkoutBranch(worktreePath, branchName);
if (!result.success) {
throw new Error(result.error || 'Failed to checkout branch');
@@ -346,6 +356,7 @@ export function useGenerateCommitMessage() {
return useMutation({
mutationFn: async (worktreePath: string) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.generateCommitMessage(worktreePath);
if (!result.success) {
throw new Error(result.error || 'Failed to generate commit message');
@@ -375,6 +386,7 @@ export function useOpenInEditor() {
editorCommand?: string;
}) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.openInEditor(worktreePath, editorCommand);
if (!result.success) {
throw new Error(result.error || 'Failed to open in editor');
@@ -400,6 +412,7 @@ export function useInitGit() {
return useMutation({
mutationFn: async (projectPath: string) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.initGit(projectPath);
if (!result.success) {
throw new Error(result.error || 'Failed to initialize git');
@@ -431,6 +444,7 @@ export function useSetInitScript(projectPath: string) {
return useMutation({
mutationFn: async (content: string) => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.setInitScript(projectPath, content);
if (!result.success) {
throw new Error(result.error || 'Failed to save init script');
@@ -461,6 +475,7 @@ export function useDeleteInitScript(projectPath: string) {
return useMutation({
mutationFn: async () => {
const api = getElectronAPI();
if (!api.worktree) throw new Error('Worktree API not available');
const result = await api.worktree.deleteInitScript(projectPath);
if (!result.success) {
throw new Error(result.error || 'Failed to delete init script');

View File

@@ -60,14 +60,13 @@ export {
// CLI Status
export {
useClaudeCliStatus,
useCursorCliStatus,
useCodexCliStatus,
useOpencodeCliStatus,
useGeminiCliStatus,
useCopilotCliStatus,
useGitHubCliStatus,
useApiKeysStatus,
usePlatformInfo,
useCursorCliStatus,
useCopilotCliStatus,
useGeminiCliStatus,
useOpencodeCliStatus,
} from './use-cli-status';
// Ideation

View File

@@ -1,7 +1,7 @@
/**
* CLI Status Query Hooks
*
* React Query hooks for fetching CLI tool status (Claude, Cursor, Codex, etc.)
* React Query hooks for fetching CLI tool status (Claude, GitHub CLI, etc.)
*/
import { useQuery } from '@tanstack/react-query';
@@ -19,6 +19,9 @@ export function useClaudeCliStatus() {
queryKey: queryKeys.cli.claude(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.setup) {
throw new Error('Setup API not available');
}
const result = await api.setup.getClaudeStatus();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch Claude status');
@@ -29,106 +32,6 @@ export function useClaudeCliStatus() {
});
}
/**
* Fetch Cursor CLI status
*
* @returns Query result with Cursor CLI status
*/
export function useCursorCliStatus() {
return useQuery({
queryKey: queryKeys.cli.cursor(),
queryFn: async () => {
const api = getElectronAPI();
const result = await api.setup.getCursorStatus();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch Cursor status');
}
return result;
},
staleTime: STALE_TIMES.CLI_STATUS,
});
}
/**
* Fetch Codex CLI status
*
* @returns Query result with Codex CLI status
*/
export function useCodexCliStatus() {
return useQuery({
queryKey: queryKeys.cli.codex(),
queryFn: async () => {
const api = getElectronAPI();
const result = await api.setup.getCodexStatus();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch Codex status');
}
return result;
},
staleTime: STALE_TIMES.CLI_STATUS,
});
}
/**
* Fetch OpenCode CLI status
*
* @returns Query result with OpenCode CLI status
*/
export function useOpencodeCliStatus() {
return useQuery({
queryKey: queryKeys.cli.opencode(),
queryFn: async () => {
const api = getElectronAPI();
const result = await api.setup.getOpencodeStatus();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch OpenCode status');
}
return result;
},
staleTime: STALE_TIMES.CLI_STATUS,
});
}
/**
* Fetch Gemini CLI status
*
* @returns Query result with Gemini CLI status
*/
export function useGeminiCliStatus() {
return useQuery({
queryKey: queryKeys.cli.gemini(),
queryFn: async () => {
const api = getElectronAPI();
const result = await api.setup.getGeminiStatus();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch Gemini status');
}
return result;
},
staleTime: STALE_TIMES.CLI_STATUS,
});
}
/**
* Fetch Copilot SDK status
*
* @returns Query result with Copilot SDK status
*/
export function useCopilotCliStatus() {
return useQuery({
queryKey: queryKeys.cli.copilot(),
queryFn: async () => {
const api = getElectronAPI();
const result = await api.setup.getCopilotStatus();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch Copilot status');
}
return result;
},
staleTime: STALE_TIMES.CLI_STATUS,
});
}
/**
* Fetch GitHub CLI status
*
@@ -139,6 +42,9 @@ export function useGitHubCliStatus() {
queryKey: queryKeys.cli.github(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.setup?.getGhStatus) {
throw new Error('GitHub CLI status API not available');
}
const result = await api.setup.getGhStatus();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch GitHub CLI status');
@@ -159,6 +65,9 @@ export function useApiKeysStatus() {
queryKey: queryKeys.cli.apiKeys(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.setup) {
throw new Error('Setup API not available');
}
const result = await api.setup.getApiKeys();
return result;
},
@@ -176,6 +85,9 @@ export function usePlatformInfo() {
queryKey: queryKeys.cli.platform(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.setup) {
throw new Error('Setup API not available');
}
const result = await api.setup.getPlatform();
if (!result.success) {
throw new Error('Failed to fetch platform info');
@@ -185,3 +97,95 @@ export function usePlatformInfo() {
staleTime: Infinity, // Platform info never changes
});
}
/**
* Fetch Cursor CLI status
*
* @returns Query result with Cursor CLI status
*/
export function useCursorCliStatus() {
return useQuery({
queryKey: queryKeys.cli.cursor(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.setup?.getCursorStatus) {
throw new Error('Cursor CLI status API not available');
}
const result = await api.setup.getCursorStatus();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch Cursor CLI status');
}
return result;
},
staleTime: STALE_TIMES.CLI_STATUS,
});
}
/**
* Fetch Copilot CLI status
*
* @returns Query result with Copilot CLI status
*/
export function useCopilotCliStatus() {
return useQuery({
queryKey: queryKeys.cli.copilot(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.setup?.getCopilotStatus) {
throw new Error('Copilot CLI status API not available');
}
const result = await api.setup.getCopilotStatus();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch Copilot CLI status');
}
return result;
},
staleTime: STALE_TIMES.CLI_STATUS,
});
}
/**
* Fetch Gemini CLI status
*
* @returns Query result with Gemini CLI status
*/
export function useGeminiCliStatus() {
return useQuery({
queryKey: queryKeys.cli.gemini(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.setup?.getGeminiStatus) {
throw new Error('Gemini CLI status API not available');
}
const result = await api.setup.getGeminiStatus();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch Gemini CLI status');
}
return result;
},
staleTime: STALE_TIMES.CLI_STATUS,
});
}
/**
* Fetch OpenCode CLI status
*
* @returns Query result with OpenCode CLI status
*/
export function useOpencodeCliStatus() {
return useQuery({
queryKey: queryKeys.cli.opencode(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.setup?.getOpencodeStatus) {
throw new Error('OpenCode CLI status API not available');
}
const result = await api.setup.getOpencodeStatus();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch OpenCode CLI status');
}
return result;
},
staleTime: STALE_TIMES.CLI_STATUS,
});
}

View File

@@ -22,6 +22,9 @@ export function useGitDiffs(projectPath: string | undefined, enabled = true) {
queryFn: async () => {
if (!projectPath) throw new Error('No project path');
const api = getElectronAPI();
if (!api.git) {
throw new Error('Git API not available');
}
const result = await api.git.getDiffs(projectPath);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch diffs');

View File

@@ -8,7 +8,7 @@ import { useQuery, useInfiniteQuery } from '@tanstack/react-query';
import { getElectronAPI } from '@/lib/electron';
import { queryKeys } from '@/lib/query-keys';
import { STALE_TIMES } from '@/lib/query-client';
import type { GitHubIssue, GitHubPR, GitHubComment, IssueValidation } from '@/lib/electron';
import type { GitHubIssue, GitHubPR, GitHubComment, StoredValidation } from '@/lib/electron';
interface GitHubIssuesResult {
openIssues: GitHubIssue[];
@@ -38,6 +38,9 @@ export function useGitHubIssues(projectPath: string | undefined) {
queryFn: async (): Promise<GitHubIssuesResult> => {
if (!projectPath) throw new Error('No project path');
const api = getElectronAPI();
if (!api.github) {
throw new Error('GitHub API not available');
}
const result = await api.github.listIssues(projectPath);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch issues');
@@ -64,6 +67,9 @@ export function useGitHubPRs(projectPath: string | undefined) {
queryFn: async (): Promise<GitHubPRsResult> => {
if (!projectPath) throw new Error('No project path');
const api = getElectronAPI();
if (!api.github) {
throw new Error('GitHub API not available');
}
const result = await api.github.listPRs(projectPath);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch PRs');
@@ -90,9 +96,12 @@ export function useGitHubValidations(projectPath: string | undefined, issueNumbe
queryKey: issueNumber
? queryKeys.github.validation(projectPath ?? '', issueNumber)
: queryKeys.github.validations(projectPath ?? ''),
queryFn: async (): Promise<IssueValidation[]> => {
queryFn: async (): Promise<StoredValidation[]> => {
if (!projectPath) throw new Error('No project path');
const api = getElectronAPI();
if (!api.github) {
throw new Error('GitHub API not available');
}
const result = await api.github.getValidations(projectPath, issueNumber);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch validations');
@@ -116,15 +125,18 @@ export function useGitHubRemote(projectPath: string | undefined) {
queryFn: async () => {
if (!projectPath) throw new Error('No project path');
const api = getElectronAPI();
if (!api.github) {
throw new Error('GitHub API not available');
}
const result = await api.github.checkRemote(projectPath);
if (!result.success) {
throw new Error(result.error || 'Failed to check remote');
}
return {
hasRemote: result.hasRemote ?? false,
hasRemote: result.hasGitHubRemote ?? false,
owner: result.owner,
repo: result.repo,
url: result.url,
url: result.remoteUrl,
};
},
enabled: !!projectPath,
@@ -165,6 +177,9 @@ export function useGitHubIssueComments(
queryFn: async ({ pageParam }: { pageParam: string | undefined }) => {
if (!projectPath || !issueNumber) throw new Error('Missing project path or issue number');
const api = getElectronAPI();
if (!api.github) {
throw new Error('GitHub API not available');
}
const result = await api.github.getIssueComments(projectPath, issueNumber, pageParam);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch comments');

View File

@@ -8,6 +8,7 @@ import { useQuery } from '@tanstack/react-query';
import { getElectronAPI } from '@/lib/electron';
import { queryKeys } from '@/lib/query-keys';
import { STALE_TIMES } from '@/lib/query-client';
import type { ModelDefinition } from '@automaker/types';
interface CodexModel {
id: string;
@@ -19,18 +20,6 @@ interface CodexModel {
isDefault: boolean;
}
interface OpencodeModel {
id: string;
name: string;
modelString: string;
provider: string;
description: string;
supportsTools: boolean;
supportsVision: boolean;
tier: string;
default?: boolean;
}
/**
* Fetch available models
*
@@ -41,6 +30,9 @@ export function useAvailableModels() {
queryKey: queryKeys.models.available(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.model) {
throw new Error('Model API not available');
}
const result = await api.model.getAvailable();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch available models');
@@ -62,6 +54,9 @@ export function useCodexModels(refresh = false) {
queryKey: queryKeys.models.codex(),
queryFn: async (): Promise<CodexModel[]> => {
const api = getElectronAPI();
if (!api.codex) {
throw new Error('Codex API not available');
}
const result = await api.codex.getModels(refresh);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch Codex models');
@@ -81,13 +76,16 @@ export function useCodexModels(refresh = false) {
export function useOpencodeModels(refresh = false) {
return useQuery({
queryKey: queryKeys.models.opencode(),
queryFn: async (): Promise<OpencodeModel[]> => {
queryFn: async (): Promise<ModelDefinition[]> => {
const api = getElectronAPI();
if (!api.setup?.getOpencodeModels) {
throw new Error('OpenCode models API not available');
}
const result = await api.setup.getOpencodeModels(refresh);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch OpenCode models');
}
return (result.models ?? []) as OpencodeModel[];
return (result.models ?? []) as ModelDefinition[];
},
staleTime: STALE_TIMES.MODELS,
});
@@ -103,6 +101,9 @@ export function useOpencodeProviders() {
queryKey: queryKeys.models.opencodeProviders(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.setup?.getOpencodeProviders) {
throw new Error('OpenCode providers API not available');
}
const result = await api.setup.getOpencodeProviders();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch OpenCode providers');
@@ -123,6 +124,9 @@ export function useModelProviders() {
queryKey: queryKeys.models.providers(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.model) {
throw new Error('Model API not available');
}
const result = await api.model.checkProviders();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch providers');

View File

@@ -8,7 +8,7 @@ import { useQuery } from '@tanstack/react-query';
import { getHttpApiClient } from '@/lib/http-api-client';
import { queryKeys } from '@/lib/query-keys';
import { STALE_TIMES } from '@/lib/query-client';
import type { PipelineConfig } from '@/store/app-store';
import type { PipelineConfig } from '@automaker/types';
/**
* Fetch pipeline config for a project

View File

@@ -34,6 +34,9 @@ export function useRunningAgents() {
queryKey: queryKeys.runningAgents.all(),
queryFn: async (): Promise<RunningAgentsResult> => {
const api = getElectronAPI();
if (!api.runningAgents) {
throw new Error('Running agents API not available');
}
const result = await api.runningAgents.getAll();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch running agents');

View File

@@ -26,6 +26,9 @@ export function useSessions(includeArchived = false) {
queryKey: queryKeys.sessions.all(includeArchived),
queryFn: async (): Promise<SessionListItem[]> => {
const api = getElectronAPI();
if (!api.sessions) {
throw new Error('Sessions API not available');
}
const result = await api.sessions.list(includeArchived);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch sessions');
@@ -48,6 +51,9 @@ export function useSessionHistory(sessionId: string | undefined) {
queryFn: async () => {
if (!sessionId) throw new Error('No session ID');
const api = getElectronAPI();
if (!api.agent) {
throw new Error('Agent API not available');
}
const result = await api.agent.getHistory(sessionId);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch session history');
@@ -74,6 +80,9 @@ export function useSessionQueue(sessionId: string | undefined) {
queryFn: async () => {
if (!sessionId) throw new Error('No session ID');
const api = getElectronAPI();
if (!api.agent) {
throw new Error('Agent API not available');
}
const result = await api.agent.queueList(sessionId);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch queue');

View File

@@ -25,11 +25,14 @@ export function useGlobalSettings() {
queryKey: queryKeys.settings.global(),
queryFn: async (): Promise<GlobalSettings> => {
const api = getElectronAPI();
if (!api.settings) {
throw new Error('Settings API not available');
}
const result = await api.settings.getGlobal();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch global settings');
}
return result.settings as GlobalSettings;
return result.settings as unknown as GlobalSettings;
},
staleTime: STALE_TIMES.SETTINGS,
});
@@ -47,11 +50,14 @@ export function useProjectSettings(projectPath: string | undefined) {
queryFn: async (): Promise<ProjectSettings> => {
if (!projectPath) throw new Error('No project path');
const api = getElectronAPI();
if (!api.settings) {
throw new Error('Settings API not available');
}
const result = await api.settings.getProject(projectPath);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch project settings');
}
return result.settings as ProjectSettings;
return result.settings as unknown as ProjectSettings;
},
enabled: !!projectPath,
staleTime: STALE_TIMES.SETTINGS,
@@ -68,6 +74,9 @@ export function useSettingsStatus() {
queryKey: queryKeys.settings.status(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.settings) {
throw new Error('Settings API not available');
}
const result = await api.settings.getStatus();
return result;
},
@@ -85,6 +94,9 @@ export function useCredentials() {
queryKey: queryKeys.settings.credentials(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.settings) {
throw new Error('Settings API not available');
}
const result = await api.settings.getCredentials();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch credentials');
@@ -111,6 +123,9 @@ export function useDiscoveredAgents(
queryKey: queryKeys.settings.agents(projectPath ?? '', sources),
queryFn: async () => {
const api = getElectronAPI();
if (!api.settings) {
throw new Error('Settings API not available');
}
const result = await api.settings.discoverAgents(projectPath, sources);
if (!result.success) {
throw new Error(result.error || 'Failed to discover agents');

View File

@@ -32,6 +32,9 @@ export function useClaudeUsage(enabled = true) {
queryKey: queryKeys.usage.claude(),
queryFn: async (): Promise<ClaudeUsage> => {
const api = getElectronAPI();
if (!api.claude) {
throw new Error('Claude API not available');
}
const result = await api.claude.getUsage();
// Check if result is an error response
if ('error' in result) {
@@ -65,6 +68,9 @@ export function useCodexUsage(enabled = true) {
queryKey: queryKeys.usage.codex(),
queryFn: async (): Promise<CodexUsage> => {
const api = getElectronAPI();
if (!api.codex) {
throw new Error('Codex API not available');
}
const result = await api.codex.getUsage();
// Check if result is an error response
if ('error' in result) {

View File

@@ -51,6 +51,9 @@ export function useWorktrees(projectPath: string | undefined, includeDetails = t
queryFn: async (): Promise<WorktreesResult> => {
if (!projectPath) throw new Error('No project path');
const api = getElectronAPI();
if (!api.worktree) {
throw new Error('Worktree API not available');
}
const result = await api.worktree.listAll(projectPath, includeDetails);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch worktrees');
@@ -80,6 +83,9 @@ export function useWorktreeInfo(projectPath: string | undefined, featureId: stri
queryFn: async () => {
if (!projectPath || !featureId) throw new Error('Missing project path or feature ID');
const api = getElectronAPI();
if (!api.worktree) {
throw new Error('Worktree API not available');
}
const result = await api.worktree.getInfo(projectPath, featureId);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch worktree info');
@@ -106,6 +112,9 @@ export function useWorktreeStatus(projectPath: string | undefined, featureId: st
queryFn: async () => {
if (!projectPath || !featureId) throw new Error('Missing project path or feature ID');
const api = getElectronAPI();
if (!api.worktree) {
throw new Error('Worktree API not available');
}
const result = await api.worktree.getStatus(projectPath, featureId);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch worktree status');
@@ -132,6 +141,9 @@ export function useWorktreeDiffs(projectPath: string | undefined, featureId: str
queryFn: async () => {
if (!projectPath || !featureId) throw new Error('Missing project path or feature ID');
const api = getElectronAPI();
if (!api.worktree) {
throw new Error('Worktree API not available');
}
const result = await api.worktree.getDiffs(projectPath, featureId);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch diffs');
@@ -180,6 +192,9 @@ export function useWorktreeBranches(worktreePath: string | undefined, includeRem
queryFn: async (): Promise<BranchesResult> => {
if (!worktreePath) throw new Error('No worktree path');
const api = getElectronAPI();
if (!api.worktree) {
throw new Error('Worktree API not available');
}
const result = await api.worktree.listBranches(worktreePath, includeRemote);
// Handle special git status codes
@@ -239,6 +254,9 @@ export function useWorktreeInitScript(projectPath: string | undefined) {
queryFn: async () => {
if (!projectPath) throw new Error('No project path');
const api = getElectronAPI();
if (!api.worktree) {
throw new Error('Worktree API not available');
}
const result = await api.worktree.getInitScript(projectPath);
if (!result.success) {
throw new Error(result.error || 'Failed to fetch init script');
@@ -265,11 +283,14 @@ export function useAvailableEditors() {
queryKey: queryKeys.worktrees.editors(),
queryFn: async () => {
const api = getElectronAPI();
if (!api.worktree) {
throw new Error('Worktree API not available');
}
const result = await api.worktree.getAvailableEditors();
if (!result.success) {
throw new Error(result.error || 'Failed to fetch editors');
}
return result.editors ?? [];
return result.result?.editors ?? [];
},
staleTime: STALE_TIMES.CLI_STATUS,
refetchOnWindowFocus: WORKTREE_REFETCH_ON_FOCUS,

View File

@@ -99,7 +99,7 @@ export function useProjectSettingsLoader() {
// These are stored directly on the project, so we need to update both
// currentProject AND the projects array to keep them in sync
// Type assertion needed because API returns Record<string, unknown>
const settingsWithExtras = settings as Record<string, unknown>;
const settingsWithExtras = settings as unknown as Record<string, unknown>;
const activeClaudeApiProfileId = settingsWithExtras.activeClaudeApiProfileId as
| string
| null

View File

@@ -9,7 +9,7 @@ import { useEffect, useRef } from 'react';
import { useQueryClient, QueryClient } from '@tanstack/react-query';
import { getElectronAPI } from '@/lib/electron';
import { queryKeys } from '@/lib/query-keys';
import type { AutoModeEvent, SpecRegenerationEvent } from '@/types/electron';
import type { AutoModeEvent, SpecRegenerationEvent, StreamEvent } from '@/types/electron';
import type { IssueValidationEvent } from '@automaker/types';
import { debounce, type DebouncedFunction } from '@automaker/utils/debounce';
import { useEventRecencyStore } from './use-event-recency';
@@ -165,6 +165,7 @@ export function useAutoModeQueryInvalidation(projectPath: string | undefined) {
}
const api = getElectronAPI();
if (!api.autoMode) return;
const unsubscribe = api.autoMode.onEvent((event: AutoModeEvent) => {
// Record that we received a WebSocket event (for event recency tracking)
// This allows polling to be disabled when WebSocket events are flowing
@@ -241,6 +242,7 @@ export function useSpecRegenerationQueryInvalidation(projectPath: string | undef
if (!projectPath) return;
const api = getElectronAPI();
if (!api.specRegeneration) return;
const unsubscribe = api.specRegeneration.onEvent((event: SpecRegenerationEvent) => {
// Only handle events for the current project
if (event.projectPath !== projectPath) return;
@@ -288,14 +290,14 @@ export function useGitHubValidationQueryInvalidation(projectPath: string | undef
// Record that we received a WebSocket event
recordGlobalEvent();
if (event.type === 'validation_complete' || event.type === 'validation_error') {
if (event.type === 'issue_validation_complete' || event.type === 'issue_validation_error') {
// Invalidate all validations for this project
queryClient.invalidateQueries({
queryKey: queryKeys.github.validations(projectPath),
});
// Also invalidate specific issue validation if we have the issue number
if ('issueNumber' in event && event.issueNumber) {
if (event.issueNumber) {
queryClient.invalidateQueries({
queryKey: queryKeys.github.validation(projectPath, event.issueNumber),
});
@@ -320,7 +322,9 @@ export function useSessionQueryInvalidation(sessionId: string | undefined) {
if (!sessionId) return;
const api = getElectronAPI();
const unsubscribe = api.agent.onStream((event) => {
if (!api.agent) return;
const unsubscribe = api.agent.onStream((data: unknown) => {
const event = data as StreamEvent;
// Only handle events for the current session
if ('sessionId' in event && event.sessionId !== sessionId) return;

View File

@@ -668,8 +668,9 @@ export function hydrateStoreFromSettings(settings: GlobalSettings): void {
maxConcurrency: number;
}
> = {};
if ((settings as Record<string, unknown>).autoModeByWorktree) {
const persistedSettings = (settings as Record<string, unknown>).autoModeByWorktree as Record<
if ((settings as unknown as Record<string, unknown>).autoModeByWorktree) {
const persistedSettings = (settings as unknown as Record<string, unknown>)
.autoModeByWorktree as Record<
string,
{ maxConcurrency?: number; branchName?: string | null }
>;

View File

@@ -26,7 +26,6 @@ import {
DEFAULT_MAX_CONCURRENCY,
getAllOpencodeModelIds,
getAllCursorModelIds,
getAllCodexModelIds,
getAllGeminiModelIds,
getAllCopilotModelIds,
migrateCursorModelIds,
@@ -34,7 +33,6 @@ import {
migratePhaseModelEntry,
type GlobalSettings,
type CursorModelId,
type CodexModelId,
type GeminiModelId,
type CopilotModelId,
} from '@automaker/types';
@@ -76,8 +74,6 @@ const SETTINGS_FIELDS_TO_SYNC = [
'cursorDefaultModel',
'enabledOpencodeModels',
'opencodeDefaultModel',
'enabledCodexModels',
'codexDefaultModel',
'enabledGeminiModels',
'geminiDefaultModel',
'enabledCopilotModels',
@@ -585,22 +581,6 @@ export async function refreshSettingsFromServer(): Promise<boolean> {
sanitizedEnabledOpencodeModels.push(sanitizedOpencodeDefaultModel);
}
// Sanitize Codex models
const validCodexModelIds = new Set(getAllCodexModelIds());
const DEFAULT_CODEX_MODEL: CodexModelId = 'codex-gpt-5.2-codex';
const sanitizedEnabledCodexModels = (serverSettings.enabledCodexModels ?? []).filter(
(id): id is CodexModelId => validCodexModelIds.has(id as CodexModelId)
);
const sanitizedCodexDefaultModel = validCodexModelIds.has(
serverSettings.codexDefaultModel as CodexModelId
)
? (serverSettings.codexDefaultModel as CodexModelId)
: DEFAULT_CODEX_MODEL;
if (!sanitizedEnabledCodexModels.includes(sanitizedCodexDefaultModel)) {
sanitizedEnabledCodexModels.push(sanitizedCodexDefaultModel);
}
// Sanitize Gemini models
const validGeminiModelIds = new Set(getAllGeminiModelIds());
const sanitizedEnabledGeminiModels = (serverSettings.enabledGeminiModels ?? []).filter(
@@ -726,8 +706,6 @@ export async function refreshSettingsFromServer(): Promise<boolean> {
cursorDefaultModel: sanitizedCursorDefault,
enabledOpencodeModels: sanitizedEnabledOpencodeModels,
opencodeDefaultModel: sanitizedOpencodeDefaultModel,
enabledCodexModels: sanitizedEnabledCodexModels,
codexDefaultModel: sanitizedCodexDefaultModel,
enabledGeminiModels: sanitizedEnabledGeminiModels,
geminiDefaultModel: sanitizedGeminiDefaultModel,
enabledCopilotModels: sanitizedEnabledCopilotModels,