Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(core): dispatch loadAgentProfiles on web identity flip\n\nOn web, restartApp() is a no-op so CoreStateProvider stays mounted after\nan A→B identity flip. After handleIdentityFlip() commits identity B to the\nsnapshot store, subsequent polls see previousIdentity === nextIdentity === B,\nmaking shouldClearScopedCaches false — loadAgentProfiles() was never reached.\n\nSplit the loadAgentProfiles() dispatch out of the !isFlip guard. Thread\nreset stays gated on !isFlip (handleIdentityFlip already dispatches\nresetUserScopedState for flip paths). Profile reload now fires for both\nboot and web flip: on Tauri the restartApp() restart unmounts the provider\nand the dispatch is harmlessly abandoned; on web it completes.\n\nAll 37 CoreStateProvider tests pass.\n

shanu1974a28de541
diff --git a/app/src/providers/CoreStateProvider.tsx b/app/src/providers/CoreStateProvider.tsx
index 928b86cdb2..537e36d38d 100644
--- a/app/src/providers/CoreStateProvider.tsx
+++ b/app/src/providers/CoreStateProvider.tsx
@@ -418,15 +418,27 @@ export default function CoreStateProvider({ children }: { children: ReactNode })
}
log('post-identity thread reload failed: %O', sanitizeError(err));
});
- // Seed the active agent profile from the backend at the earliest safe
- // moment — before any chat request can fire with a stale 'default' id.
- // Without this, activeProfileId resets to 'default' on every reboot
- // because the agentProfile slice is not persisted (#5872).
+ }
+
+ // Seed the active agent profile at the earliest safe moment so no chat
+ // request can fire with a stale 'default' id (#5872). Intentionally not
+ // gated on !isFlip: on Tauri a flip triggers restartApp() so the provider
+ // remounts with undefined previousIdentity and profiles load on the boot
+ // poll; on web restartApp() is a no-op and by the next poll
+ // previousIdentity === nextIdentity, making shouldClearScopedCaches false
+ // — so we must dispatch here while it is still true.
+ if (
+ requestId === snapshotRequestIdRef.current &&
+ shouldClearScopedCaches &&
+ nextIdentity &&
+ !isLogout
+ ) {
+ const profileReloadRequestId = requestId;
void store
.dispatch(loadAgentProfiles())
.unwrap()
.catch(err => {
- if (threadReloadRequestId !== snapshotRequestIdRef.current) {
+ if (profileReloadRequestId !== snapshotRequestIdRef.current) {
return;
}
log('post-identity agent profiles load failed: %O', sanitizeError(err));