fix(vscode): backfill agent selections when agentsLoaded arrives after messagesLoaded

This commit is contained in:
kirillk
2026-04-06 12:20:18 -04:00
parent 84e8db9e4b
commit 11a96f542d
@@ -483,6 +483,17 @@ export const SessionProvider: ParentComponent = (props) => {
}
}),
)
// Rescan already-loaded message history so sessions whose messagesLoaded
// arrived before agentsLoaded (and therefore got no agent selection) are
// backfilled now that we know the valid agent names.
batch(() => {
for (const [sid, msgs] of Object.entries(store.messages)) {
if (store.agentSelections[sid]) continue
const agent = resolveSessionAgent(msgs, names)
if (agent) setStore("agentSelections", sid, agent)
}
})
})
// Request agents in case the initial push was missed.