feat: Update ProfileForm to conditionally display enabled Cursor models

- Integrated useAppStore to fetch enabledCursorModels for dynamic rendering of Cursor model selection.
- Added a message to inform users when no Cursor models are enabled, guiding them to settings for configuration.
- Refactored the model selection logic to filter available models based on the enabled list, enhancing user experience and clarity.
This commit is contained in:
Kacper
2025-12-29 22:21:01 +01:00
parent 8e10f522c0
commit 4115110c06

View File

@@ -17,6 +17,7 @@ import type {
CursorModelId, CursorModelId,
} from '@automaker/types'; } from '@automaker/types';
import { CURSOR_MODEL_MAP, cursorModelHasThinking } from '@automaker/types'; import { CURSOR_MODEL_MAP, cursorModelHasThinking } from '@automaker/types';
import { useAppStore } from '@/store/app-store';
import { CLAUDE_MODELS, THINKING_LEVELS, ICON_OPTIONS } from '../constants'; import { CLAUDE_MODELS, THINKING_LEVELS, ICON_OPTIONS } from '../constants';
interface ProfileFormProps { interface ProfileFormProps {
@@ -34,6 +35,8 @@ export function ProfileForm({
isEditing, isEditing,
hotkeyActive, hotkeyActive,
}: ProfileFormProps) { }: ProfileFormProps) {
const { enabledCursorModels } = useAppStore();
const [formData, setFormData] = useState({ const [formData, setFormData] = useState({
name: profile.name || '', name: profile.name || '',
description: profile.description || '', description: profile.description || '',
@@ -223,7 +226,14 @@ export function ProfileForm({
Cursor Model Cursor Model
</Label> </Label>
<div className="flex flex-col gap-2"> <div className="flex flex-col gap-2">
{Object.entries(CURSOR_MODEL_MAP).map(([id, config]) => ( {enabledCursorModels.length === 0 ? (
<div className="text-sm text-muted-foreground p-3 border border-dashed rounded-md text-center">
No Cursor models enabled. Enable models in Settings AI Providers.
</div>
) : (
Object.entries(CURSOR_MODEL_MAP)
.filter(([id]) => enabledCursorModels.includes(id as CursorModelId))
.map(([id, config]) => (
<button <button
key={id} key={id}
type="button" type="button"
@@ -262,7 +272,8 @@ export function ProfileForm({
</Badge> </Badge>
</div> </div>
</button> </button>
))} ))
)}
</div> </div>
{formData.cursorModel && cursorModelHasThinking(formData.cursorModel) && ( {formData.cursorModel && cursorModelHasThinking(formData.cursorModel) && (
<p className="text-xs text-muted-foreground"> <p className="text-xs text-muted-foreground">