feat(ui): Enhance AI model handling with Cursor support

- Refactor model handling to support both Claude and Cursor models across various components.
- Introduce `stripProviderPrefix` utility for consistent model ID processing.
- Update `CursorProvider` to utilize `isCursorModel` for model validation.
- Implement model override functionality in GitHub issue validation and enhancement routes.
- Add `useCursorStatusInit` hook to initialize Cursor CLI status on app startup.
- Update UI components to reflect changes in model selection and validation processes.

This update improves the flexibility of AI model usage and enhances user experience by allowing quick model overrides.
This commit is contained in:
Kacper
2025-12-30 04:01:56 +01:00
parent 3d655c3298
commit 39f2c8c9ff
38 changed files with 713 additions and 258 deletions

View File

@@ -16,6 +16,7 @@ import { Markdown } from '@/components/ui/markdown';
import { cn } from '@/lib/utils';
import type { IssueDetailPanelProps } from '../types';
import { isValidationStale } from '../utils';
import { ModelOverrideTrigger } from '@/components/shared';
export function IssueDetailPanel({
issue,
@@ -27,6 +28,7 @@ export function IssueDetailPanel({
onClose,
onShowRevalidateConfirm,
formatDate,
modelOverride,
}: IssueDetailPanelProps) {
const isValidating = validatingIssues.has(issue.number);
const cached = cachedValidations.get(issue.number);
@@ -83,10 +85,23 @@ export function IssueDetailPanel({
<Clock className="h-4 w-4 mr-1 text-yellow-500" />
View (stale)
</Button>
<ModelOverrideTrigger
currentModel={modelOverride.effectiveModel}
onModelChange={modelOverride.setOverride}
phase="validationModel"
isOverridden={modelOverride.isOverridden}
size="sm"
variant="icon"
/>
<Button
variant="default"
size="sm"
onClick={() => onValidateIssue(issue, { forceRevalidate: true })}
onClick={() =>
onValidateIssue(issue, {
forceRevalidate: true,
model: modelOverride.effectiveModel,
})
}
>
<Wand2 className="h-4 w-4 mr-1" />
Re-validate
@@ -96,10 +111,24 @@ export function IssueDetailPanel({
}
return (
<Button variant="default" size="sm" onClick={() => onValidateIssue(issue)}>
<Wand2 className="h-4 w-4 mr-1" />
Validate with AI
</Button>
<>
<ModelOverrideTrigger
currentModel={modelOverride.effectiveModel}
onModelChange={modelOverride.setOverride}
phase="validationModel"
isOverridden={modelOverride.isOverridden}
size="sm"
variant="icon"
/>
<Button
variant="default"
size="sm"
onClick={() => onValidateIssue(issue, { model: modelOverride.effectiveModel })}
>
<Wand2 className="h-4 w-4 mr-1" />
Validate with AI
</Button>
</>
);
})()}
<Button variant="outline" size="sm" onClick={() => onOpenInGitHub(issue.url)}>

View File

@@ -205,8 +205,8 @@ export function useIssueValidation({
}, []);
const handleValidateIssue = useCallback(
async (issue: GitHubIssue, options: { forceRevalidate?: boolean } = {}) => {
const { forceRevalidate = false } = options;
async (issue: GitHubIssue, options: { forceRevalidate?: boolean; model?: string } = {}) => {
const { forceRevalidate = false, model } = options;
if (!currentProject?.path) {
toast.error('No project selected');
@@ -233,6 +233,9 @@ export function useIssueValidation({
description: 'You will be notified when the analysis is complete',
});
// Use provided model override or fall back to global validationModel
const modelToUse = model || validationModel;
try {
const api = getElectronAPI();
if (api.github?.validateIssue) {
@@ -244,7 +247,7 @@ export function useIssueValidation({
issueBody: issue.body || '',
issueLabels: issue.labels.map((l) => l.name),
},
validationModel
modelToUse
);
if (!result.success) {

View File

@@ -1,4 +1,5 @@
import type { GitHubIssue, StoredValidation } from '@/lib/electron';
import type { ModelAlias, CursorModelId } from '@automaker/types';
export interface IssueRowProps {
issue: GitHubIssue;
@@ -18,11 +19,21 @@ export interface IssueDetailPanelProps {
cachedValidations: Map<number, StoredValidation>;
onValidateIssue: (
issue: GitHubIssue,
options?: { showDialog?: boolean; forceRevalidate?: boolean }
options?: {
showDialog?: boolean;
forceRevalidate?: boolean;
model?: ModelAlias | CursorModelId;
}
) => Promise<void>;
onViewCachedValidation: (issue: GitHubIssue) => Promise<void>;
onOpenInGitHub: (url: string) => void;
onClose: () => void;
onShowRevalidateConfirm: () => void;
formatDate: (date: string) => string;
/** Model override state */
modelOverride: {
effectiveModel: ModelAlias | CursorModelId;
isOverridden: boolean;
setOverride: (model: ModelAlias | CursorModelId | null) => void;
};
}