Files
mcpctl/.taskmaster/tasks/task_108.md

76 lines
2.0 KiB
Markdown
Raw Permalink Normal View History

# Task ID: 108
**Title:** Implement Model Switch for Model Studio
**Status:** done
**Dependencies:** 105 ✓, 82 ✓
**Priority:** medium
**Description:** Add ability to switch the active proxymodel for a project mid-session from model studio.
**Details:**
Extend `src/cli/src/commands/console/model-studio.tsx`:
```typescript
function ModelPicker({ models, current, onSelect }: {
models: string[];
current: string;
onSelect: (name: string) => void;
}) {
const [selectedIdx, setSelectedIdx] = useState(models.indexOf(current));
useInput((input, key) => {
if (key.upArrow) setSelectedIdx(i => Math.max(0, i - 1));
if (key.downArrow) setSelectedIdx(i => Math.min(models.length - 1, i + 1));
if (key.return) onSelect(models[selectedIdx]);
});
return (
<Box flexDirection="column" borderStyle="single">
<Text bold>Select ProxyModel:</Text>
{models.map((m, i) => (
<Text key={m} inverse={i === selectedIdx}>
{m === current ? '✓ ' : ' '}{m}
</Text>
))}
</Box>
);
}
// Add to main component:
const [showModelPicker, setShowModelPicker] = useState(false);
const [activeModel, setActiveModel] = useState('default');
useInput((input) => {
if (input === 'm') setShowModelPicker(true);
});
async function switchModel(name: string) {
// Call mcplocal API to switch model
await fetch(`http://localhost:${port}/projects/${projectName}/proxymodel`, {
method: 'PUT',
body: JSON.stringify({ proxyModel: name }),
});
setActiveModel(name);
setShowModelPicker(false);
// Emit model_switched event
trafficCapture.emit({
eventType: 'model_switched',
projectName,
previousModel: activeModel,
newModel: name,
timestamp: Date.now(),
});
}
```
Add PUT endpoint to mcplocal for switching proxymodel.
**Test Strategy:**
Integration test: 'm' opens model picker, selecting a model updates the active model, subsequent content flows through new model, model_switched event is emitted.