fix: start draft sessions from default model/agent and honor OpenCode default_agent
A new draft session inherited the previous session's model/agent instead of resetting to defaults, because opening a draft restored the directory snapshot without re-applying the startup default cascade. When the prior session ran in a worktree, defaults were resolved against the worktree directory's provider list, which omits project/global-scoped providers, so the default agent's model fell back to opencode/big-pickle. Resolve the default agent/model via a shared cascade (settings default -> OpenCode default_agent -> build -> first), resolve the model from the agent's pinned model/variant or OpenCode's config model, and activate the project's config (not the worktree's) when opening a draft.
This commit is contained in:
@@ -617,7 +617,16 @@ export const useSessionUIStore = create<SessionUIState>()((set, get) => ({
|
||||
useInputStore.getState().setPendingInputText(options.initialPrompt)
|
||||
}
|
||||
|
||||
void activateConfigForDirectory(directory)
|
||||
// Config (providers/agents/default model+agent) lives at the PROJECT level. When the user
|
||||
// came from a worktree session, `directory` is the worktree path, whose provider list does
|
||||
// not include project/global-scoped providers (e.g. the default agent's non-opencode model)
|
||||
// — resolving defaults against it would wrongly fall back to opencode/big-pickle. Activate
|
||||
// the project's config instead so the default cascade matches app startup, then re-apply it
|
||||
// (a fresh draft must start from defaults, not inherit the previous session's selection).
|
||||
const configDirectory = normalizePath(selectedProject?.path ?? null) ?? directory
|
||||
void activateConfigForDirectory(configDirectory).then(() => {
|
||||
useConfigStore.getState().applyDefaultModelAgentSelection()
|
||||
})
|
||||
},
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user