mirror of
https://github.com/AutoMaker-Org/automaker.git
synced 2026-01-31 20:03:37 +00:00
- Fix 75 ESLint errors by updating eslint.config.mjs: - Add missing browser globals (MouseEvent, AbortController, Response, etc.) - Add Vite define global (__APP_VERSION__) - Configure @ts-nocheck to require descriptions - Add no-unused-vars rule for .mjs scripts - Fix runtime bug in agent-output-modal.tsx (setOutput -> setStreamedContent) - Remove ~120 unused variable warnings across 97 files: - Remove unused imports (React hooks, lucide icons, types) - Remove unused constants and variables - Remove unused function definitions - Prefix intentionally unused parameters with underscore - Add descriptions to all @ts-nocheck comments (25 files) - Clean up misc issues: - Remove invalid deprecation plugin comments - Fix eslint-disable comment placement - Add missing RefreshCw import in code-view.tsx Reduces lint warnings from ~300 to 67 (all remaining are no-explicit-any) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
111 lines
3.1 KiB
TypeScript
111 lines
3.1 KiB
TypeScript
import { useState } from 'react';
|
|
import { toast } from 'sonner';
|
|
import { useAppStore } from '@/store/app-store';
|
|
import type { CursorModelId } from '@automaker/types';
|
|
import {
|
|
CursorCliStatus,
|
|
CursorCliStatusSkeleton,
|
|
CursorPermissionsSkeleton,
|
|
ModelConfigSkeleton,
|
|
} from '../cli-status/cursor-cli-status';
|
|
import { useCursorStatus } from '../hooks/use-cursor-status';
|
|
import { useCursorPermissions } from '../hooks/use-cursor-permissions';
|
|
import { CursorPermissionsSection } from './cursor-permissions-section';
|
|
import { CursorModelConfiguration } from './cursor-model-configuration';
|
|
import { ProviderToggle } from './provider-toggle';
|
|
|
|
export function CursorSettingsTab() {
|
|
// Global settings from store
|
|
const {
|
|
enabledCursorModels,
|
|
cursorDefaultModel,
|
|
setCursorDefaultModel,
|
|
toggleCursorModel,
|
|
currentProject,
|
|
} = useAppStore();
|
|
|
|
// Custom hooks for data fetching
|
|
const { status, isLoading, loadData } = useCursorStatus();
|
|
const {
|
|
permissions,
|
|
isLoadingPermissions,
|
|
isSavingPermissions,
|
|
copiedConfig,
|
|
loadPermissions,
|
|
applyProfile,
|
|
copyConfig,
|
|
} = useCursorPermissions(currentProject?.path);
|
|
|
|
// Local state for model configuration saving
|
|
const [isSaving, setIsSaving] = useState(false);
|
|
|
|
const handleDefaultModelChange = (model: CursorModelId) => {
|
|
setIsSaving(true);
|
|
try {
|
|
setCursorDefaultModel(model);
|
|
toast.success('Default model updated');
|
|
} catch {
|
|
toast.error('Failed to update default model');
|
|
} finally {
|
|
setIsSaving(false);
|
|
}
|
|
};
|
|
|
|
const handleModelToggle = (model: CursorModelId, enabled: boolean) => {
|
|
setIsSaving(true);
|
|
try {
|
|
toggleCursorModel(model, enabled);
|
|
} catch {
|
|
toast.error('Failed to update models');
|
|
} finally {
|
|
setIsSaving(false);
|
|
}
|
|
};
|
|
|
|
if (isLoading) {
|
|
return (
|
|
<div className="space-y-6">
|
|
<CursorCliStatusSkeleton />
|
|
<CursorPermissionsSkeleton />
|
|
<ModelConfigSkeleton />
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
{/* Provider Visibility Toggle */}
|
|
<ProviderToggle provider="cursor" providerLabel="Cursor" />
|
|
|
|
{/* CLI Status */}
|
|
<CursorCliStatus status={status} isChecking={isLoading} onRefresh={loadData} />
|
|
|
|
{/* CLI Permissions Section */}
|
|
<CursorPermissionsSection
|
|
status={status}
|
|
permissions={permissions}
|
|
isLoadingPermissions={isLoadingPermissions}
|
|
isSavingPermissions={isSavingPermissions}
|
|
copiedConfig={copiedConfig}
|
|
currentProject={currentProject}
|
|
onApplyProfile={applyProfile}
|
|
onCopyConfig={copyConfig}
|
|
onLoadPermissions={loadPermissions}
|
|
/>
|
|
|
|
{/* Model Configuration - Always show (global settings) */}
|
|
{status?.installed && (
|
|
<CursorModelConfiguration
|
|
enabledCursorModels={enabledCursorModels}
|
|
cursorDefaultModel={cursorDefaultModel}
|
|
isSaving={isSaving}
|
|
onDefaultModelChange={handleDefaultModelChange}
|
|
onModelToggle={handleModelToggle}
|
|
/>
|
|
)}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default CursorSettingsTab;
|