fix: mission creation for Claude Code backend
- Skip agent validation for Claude Code backend in create_mission Claude Code has its own built-in agents that don't exist in OpenCode's agent list, so validation was incorrectly failing. - Filter model dropdown by selected backend Claude Code only supports Anthropic models, so the dropdown now only shows those when Claude Code backend is selected. Also resets model override when switching to Claude Code if non-Anthropic model was selected.
This commit is contained in:
@@ -169,9 +169,36 @@ export function NewMissionDialog({
|
||||
return backend && agent ? { backend, agent } : null;
|
||||
};
|
||||
|
||||
// Get the currently selected backend
|
||||
const selectedBackend = useMemo(() => {
|
||||
const parsed = parseSelectedValue(selectedAgentValue);
|
||||
return parsed?.backend || null;
|
||||
}, [selectedAgentValue]);
|
||||
|
||||
// Filter providers based on selected backend
|
||||
// Claude Code only supports Anthropic models
|
||||
const filteredProviders = useMemo(() => {
|
||||
if (selectedBackend === 'claudecode') {
|
||||
// Only show Anthropic (Claude) models for Claude Code
|
||||
return providers.filter(p => p.id === 'anthropic');
|
||||
}
|
||||
// Show all providers for OpenCode or when no backend is selected
|
||||
return providers;
|
||||
}, [providers, selectedBackend]);
|
||||
|
||||
const formatWorkspaceType = (type: Workspace['workspace_type']) =>
|
||||
type === 'host' ? 'host' : 'isolated';
|
||||
|
||||
// Reset model override when switching to Claude Code if current model isn't Anthropic
|
||||
useEffect(() => {
|
||||
if (selectedBackend === 'claudecode' && newMissionModelOverride) {
|
||||
// Check if current model is from Anthropic
|
||||
if (!newMissionModelOverride.startsWith('anthropic/')) {
|
||||
setNewMissionModelOverride('');
|
||||
}
|
||||
}
|
||||
}, [selectedBackend, newMissionModelOverride]);
|
||||
|
||||
// Click outside handler
|
||||
useEffect(() => {
|
||||
if (!open) return;
|
||||
@@ -362,7 +389,7 @@ export function NewMissionDialog({
|
||||
<option value="" className="bg-[#1a1a1a]">
|
||||
Default (agent or global)
|
||||
</option>
|
||||
{providers.map((provider) => (
|
||||
{filteredProviders.map((provider) => (
|
||||
<optgroup key={provider.id} label={provider.name} className="bg-[#1a1a1a]">
|
||||
{provider.models.map((model) => (
|
||||
<option
|
||||
|
||||
@@ -1083,10 +1083,14 @@ pub async fn create_mission(
|
||||
}
|
||||
|
||||
// Validate agent exists before creating mission (fail fast with clear error)
|
||||
// Skip validation for Claude Code - it has its own built-in agents
|
||||
if let Some(ref agent_name) = agent {
|
||||
super::library::validate_agent_exists(&state, agent_name)
|
||||
.await
|
||||
.map_err(|e| (StatusCode::BAD_REQUEST, e))?;
|
||||
let is_claudecode = backend.as_deref() == Some("claudecode");
|
||||
if !is_claudecode {
|
||||
super::library::validate_agent_exists(&state, agent_name)
|
||||
.await
|
||||
.map_err(|e| (StatusCode::BAD_REQUEST, e))?;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref backend_id) = backend {
|
||||
|
||||
Reference in New Issue
Block a user