The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
test(app): cover the identity-FLIP half of the agent-profile seed (#5872)\n\nThe guard deliberately omits `!isFlip`, unlike the neighbouring loadThreads\nblock, but only the non-flip path had a test. A refactor "tidying" `!isFlip`\nback in to match its neighbour would have passed every test in the file while\nsilently breaking the web path, where restartApp() is a no-op and the next\npoll has shouldClearScopedCaches false, so the dispatch would never fire.\n\nAlso softens the comment above the dispatch: it narrows the stale-'default'\nwindow, it does not close it. The dispatch is not awaited, so a send issued\nbefore it resolves still reads 'default'. Closing it for good means omitting\n`profileId` while the slice is loading and letting the core resolve an absent\nid against its own authoritative active_profile_id -- that belongs in the send\npath, not here.\n
M3gA-Mind77f4e41309d4
diff --git a/app/src/providers/CoreStateProvider.tsx b/app/src/providers/CoreStateProvider.tsxindex 537e36d38d..921f4abebe 100644--- a/app/src/providers/CoreStateProvider.tsx+++ b/app/src/providers/CoreStateProvider.tsx@@ -420,8 +420,14 @@ export default function CoreStateProvider({ children }: { children: ReactNode })});}- // Seed the active agent profile at the earliest safe moment so no chat- // request can fire with a stale 'default' id (#5872). Intentionally not+ // Seed the active agent profile at the earliest safe moment, so the window+ // in which a chat request could carry the stale 'default' id is as short as+ // the snapshot allows (#5872). It is a narrowing, NOT a guarantee: this+ // dispatch is deliberately not awaited, so a send issued before it resolves+ // still reads 'default' from the slice. Closing that window for good means+ // omitting `profileId` while the slice is still loading — the core keeps+ // its own authoritative `active_profile_id` and resolves an absent id+ // against it — which belongs in the send path, not here. 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 polldiff --git a/app/src/providers/__tests__/CoreStateProvider.test.tsx b/app/src/providers/__tests__/CoreStateProvider.test.tsxindex ac4f43abf6..2189eee58d 100644--- a/app/src/providers/__tests__/CoreStateProvider.test.tsx+++ b/app/src/providers/__tests__/CoreStateProvider.test.tsx@@ -974,6 +974,47 @@ describe('CoreStateProvider — identity-change cache clearing', () => {expect(listProfiles).toHaveBeenCalled();});++ // The isFlip = TRUE half, which is the whole reason the guard above omits+ // `!isFlip` (the neighbouring loadThreads block does gate on it). Without+ // this, a future refactor "tidying" `!isFlip` back in to match its neighbour+ // would pass every test in this file and silently break the web path, where+ // restartApp() is a no-op and the next poll has shouldClearScopedCaches+ // false — so this dispatch would never fire again.+ it('still dispatches loadAgentProfiles when the identity FLIPS (#5872)', async () => {+ // u1 established first; `tok*` is not a local session token+ // (isLocalSessionToken requires a 3-part `….local` shape), so the+ // subsequent change to u2 gives seedUserId !== nextIdentity && !isLocalSession+ // => isFlip === true.+ setActiveUserId('u1');+ fetchSnapshot.mockResolvedValue(makeSnapshot({ userId: 'u1', sessionToken: 'tok1' }));+ listTeams.mockResolvedValue([]);++ let ctx: CoreStateContextValue | undefined;+ render(+ <CoreStateProvider>+ <Consumer+ captureCtx={next => {+ ctx = next;+ }}+ />+ </CoreStateProvider>+ );+ await waitFor(() => expect(screen.getByTestId('ready').textContent).toBe('ready'));+ await act(async () => {});++ // Ignore the establish-time load; we are asserting on the flip itself.+ listProfiles.mockClear();++ fetchSnapshot.mockResolvedValue(makeSnapshot({ userId: 'u2', sessionToken: 'tok2' }));+ await act(async () => {+ await ctx!.refresh();+ });+ await waitFor(() => expect(screen.getByTestId('user').textContent).toBe('u2'));+ await act(async () => {});++ expect(listProfiles).toHaveBeenCalled();+ });});describe('coreStatePollFailureWarningMessage', () => {