chore: Enhance type safety and improve code consistency across components

- Added a new `typecheck` script in `package.json` for better type checking in the UI workspace.
- Refactored several components to remove unnecessary type assertions and improve type safety, particularly in `new-project-modal.tsx`, `edit-project-dialog.tsx`, and `task-progress-panel.tsx`.
- Updated event handling in `git-diff-panel.tsx` to use async functions for better error handling.
- Improved type definitions in various files, including `setup-view` and `electron.ts`, to ensure consistent usage of types across the codebase.
- Cleaned up global type definitions for better clarity and maintainability.

These changes aim to streamline the development process and reduce potential runtime errors.
This commit is contained in:
Shirone
2026-01-25 18:11:48 +01:00
parent b65037d995
commit 0fb471ca15
28 changed files with 320 additions and 125 deletions

View File

@@ -1,15 +1,31 @@
import { useState, useCallback } from 'react';
import { toast } from 'sonner';
import { createLogger } from '@automaker/utils/logger';
import type { ModelProvider } from '@automaker/types';
import type { CliStatus } from '@/store/setup-store';
const logger = createLogger('CliInstallation');
interface InstallApiResult {
success: boolean;
message?: string;
error?: string;
}
interface InstallProgressEvent {
cli?: string;
data?: string;
type?: string;
}
interface UseCliInstallationOptions {
cliType: 'claude';
installApi: () => Promise<any>;
onProgressEvent?: (callback: (progress: any) => void) => (() => void) | undefined;
cliType: ModelProvider;
installApi: () => Promise<InstallApiResult>;
onProgressEvent?: (
callback: (progress: InstallProgressEvent) => void
) => (() => void) | undefined;
onSuccess?: () => void;
getStoreState?: () => any;
getStoreState?: () => CliStatus | null;
}
export function useCliInstallation({
@@ -32,15 +48,13 @@ export function useCliInstallation({
let unsubscribe: (() => void) | undefined;
if (onProgressEvent) {
unsubscribe = onProgressEvent(
(progress: { cli?: string; data?: string; type?: string }) => {
if (progress.cli === cliType) {
setInstallProgress((prev) => ({
output: [...prev.output, progress.data || progress.type || ''],
}));
}
unsubscribe = onProgressEvent((progress: InstallProgressEvent) => {
if (progress.cli === cliType) {
setInstallProgress((prev) => ({
output: [...prev.output, progress.data || progress.type || ''],
}));
}
);
});
}
const result = await installApi();

View File

@@ -1,11 +1,34 @@
import { useState, useCallback } from 'react';
import { createLogger } from '@automaker/utils/logger';
import type { ModelProvider } from '@automaker/types';
import type { CliStatus, ClaudeAuthStatus, CodexAuthStatus } from '@/store/setup-store';
interface CliStatusApiResponse {
success: boolean;
status?: 'installed' | 'not_installed';
installed?: boolean;
method?: string;
version?: string;
path?: string;
auth?: {
authenticated: boolean;
method: string;
hasCredentialsFile?: boolean;
hasStoredOAuthToken?: boolean;
hasStoredApiKey?: boolean;
hasEnvApiKey?: boolean;
hasEnvOAuthToken?: boolean;
hasAuthFile?: boolean;
hasApiKey?: boolean;
};
error?: string;
}
interface UseCliStatusOptions {
cliType: 'claude' | 'codex';
statusApi: () => Promise<any>;
setCliStatus: (status: any) => void;
setAuthStatus: (status: any) => void;
cliType: ModelProvider;
statusApi: () => Promise<CliStatusApiResponse>;
setCliStatus: (status: CliStatus | null) => void;
setAuthStatus: (status: ClaudeAuthStatus | CodexAuthStatus | null) => void;
}
const VALID_AUTH_METHODS = {

View File

@@ -1,4 +1,3 @@
// @ts-nocheck - CLI setup wizard with step validation and setup store state
import { useState, useEffect, useCallback } from 'react';
import { Button } from '@/components/ui/button';
import { Input } from '@/components/ui/input';
@@ -45,6 +44,33 @@ type VerificationStatus = 'idle' | 'verifying' | 'verified' | 'error';
type CliSetupAuthStatus = ClaudeAuthStatus | CodexAuthStatus;
interface CliStatusApiResponse {
success: boolean;
status?: 'installed' | 'not_installed';
installed?: boolean;
method?: string;
version?: string;
path?: string;
auth?: {
authenticated: boolean;
method: string;
hasCredentialsFile?: boolean;
hasStoredOAuthToken?: boolean;
hasStoredApiKey?: boolean;
hasEnvApiKey?: boolean;
hasEnvOAuthToken?: boolean;
hasAuthFile?: boolean;
hasApiKey?: boolean;
};
error?: string;
}
interface InstallApiResponse {
success: boolean;
message?: string;
error?: string;
}
interface CliSetupConfig {
cliType: ModelProvider;
displayName: string;
@@ -73,8 +99,8 @@ interface CliSetupConfig {
buildCliAuthStatus: (previous: CliSetupAuthStatus | null) => CliSetupAuthStatus;
buildApiKeyAuthStatus: (previous: CliSetupAuthStatus | null) => CliSetupAuthStatus;
buildClearedAuthStatus: (previous: CliSetupAuthStatus | null) => CliSetupAuthStatus;
statusApi: () => Promise<any>;
installApi: () => Promise<any>;
statusApi: () => Promise<CliStatusApiResponse>;
installApi: () => Promise<InstallApiResponse>;
verifyAuthApi: (
method: 'cli' | 'api_key',
apiKey?: string