Add agent and model selection with automatic defaults and subagent support

- Implement automatic agent/model selection for new sessions (first agent, prioritize Anthropic default)
- Extract and restore agent/model from last assistant message when resuming sessions
- Add subagent support: child sessions can select subagents, parent sessions cannot
- Display subagent badge in agent dropdown for identification
- Truncate agent descriptions to 50 characters in dropdown
- Improve model search to include full provider/model ID path
- Auto-select input text on focus for easy model search
- Add getDefaultModel() with priority: agent model → Anthropic → first provider
This commit is contained in:
Shantur Rathore
2025-10-23 09:25:26 +01:00
parent 0add900f1b
commit 7cf0f9a179
8 changed files with 920 additions and 14 deletions

View File

@@ -37,6 +37,8 @@ import {
getParentSessions,
loadMessages,
sendMessage,
updateSessionAgent,
updateSessionModel,
} from "./stores/sessions"
import { setupTabKeyboardShortcuts } from "./lib/keyboard"
@@ -58,6 +60,14 @@ const SessionView: Component<{
await sendMessage(props.instanceId, props.sessionId, prompt)
}
async function handleAgentChange(agent: string) {
await updateSessionAgent(props.instanceId, props.sessionId, agent)
}
async function handleModelChange(model: { providerId: string; modelId: string }) {
await updateSessionModel(props.instanceId, props.sessionId, model)
}
return (
<Show
when={session()}
@@ -75,7 +85,15 @@ const SessionView: Component<{
messages={s().messages || []}
messagesInfo={s().messagesInfo}
/>
<PromptInput instanceId={props.instanceId} sessionId={s().id} onSend={handleSendMessage} />
<PromptInput
instanceId={props.instanceId}
sessionId={s().id}
onSend={handleSendMessage}
agent={s().agent}
model={s().model}
onAgentChange={handleAgentChange}
onModelChange={handleModelChange}
/>
</div>
)}
</Show>