perf: speed up model/agent readiness on the initial draft

Load startup config under the owning project's directory key (resolving from a
worktree directory when needed) so the auto-opened draft, which activates the
project, finds a ready providers/agents snapshot instead of triggering a second
load. Also dedupe app.agents: listAgents now takes the directory directly and
shares an in-flight request, so the config store and agents store no longer
issue duplicate agent fetches at startup.
This commit is contained in:
Bohdan Triapitsyn
2026-06-14 22:04:32 +03:00
parent 9111611bdc
commit 296177357b
4 changed files with 56 additions and 12 deletions
+4 -2
View File
@@ -245,8 +245,10 @@ export const useAgentsStore = create<AgentsStore>()(
try {
const queryParams = configDirectory ? `?directory=${encodeURIComponent(configDirectory)}` : '';
// Ensure we list agents using the correct project context
const agents = await opencodeClient.withDirectory(configDirectory, () => opencodeClient.listAgents());
// Ensure we list agents using the correct project context. Pass the
// directory directly so this shares the in-flight request with the config
// store instead of issuing a duplicate agents fetch at startup.
const agents = await opencodeClient.listAgents(configDirectory);
const agentsWithScope = await Promise.all(
agents.map(async (agent) => {