Skip to content

Commit 31c97b0

Browse files
T3 Code Testclaude
andcommitted
fix(mobile): widget hides the previous account's agents on account switch
Switching T3 Connect accounts now shows "Loading agents…" until the new account's first read finishes, instead of leaving the old rows visible. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent f7773cf commit 31c97b0

3 files changed

Lines changed: 22 additions & 1 deletion

File tree

‎apps/mobile/src/features/agent-awareness/remoteRegistration.test.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1410,6 +1410,15 @@ describe("makeRelayDeviceRegistrationRequest", () => {
14101410
}),
14111411
);
14121412

1413+
it("hides the previous account's rows as soon as another account signs in", () => {
1414+
setAgentAwarenessRelayTokenProvider(() => Promise.resolve("clerk-token-a"), "user-a");
1415+
expect(publishWidgetMock).not.toHaveBeenCalled();
1416+
1417+
setAgentAwarenessRelayTokenProvider(() => Promise.resolve("clerk-token-b"), "user-b");
1418+
1419+
expect(publishWidgetMock).toHaveBeenLastCalledWith({ kind: "loading" });
1420+
});
1421+
14131422
it("shows the signed-out state after cloud sign-out", () => {
14141423
setAgentAwarenessRelayTokenProvider(() => Promise.resolve("clerk-token"), "user-a");
14151424

‎apps/mobile/src/features/agent-awareness/remoteRegistration.ts‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,15 @@ export function setAgentAwarenessRelayTokenProvider(
191191
if (relayTokenProviderIdentity && identity !== relayTokenProviderIdentity) {
192192
clearAndroidAgentNotifications();
193193
}
194+
// Hide the previous account's rows while the new account's first read runs.
195+
if (
196+
provider &&
197+
identity &&
198+
relayTokenProviderIdentity &&
199+
identity !== relayTokenProviderIdentity
200+
) {
201+
publishWidget({ kind: "loading" });
202+
}
194203
androidDeviceReplayedAt = null;
195204
deviceRegistrationGeneration++;
196205
activeDeviceRegistration = null;

‎apps/mobile/src/widgets/agentActivityWidgetTimeline.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export const AGENT_ACTIVITY_WIDGET_STALE_AFTER_MS = 10 * 60_000;
99
export type AgentActivityWidgetSource =
1010
| { readonly kind: "signed-out" }
1111
| { readonly kind: "unavailable" }
12+
| { readonly kind: "loading" }
1213
| { readonly kind: "snapshot"; readonly aggregate: RelayAgentActivityAggregateState | null };
1314

1415
export function agentActivityWidgetTimeline(source: AgentActivityWidgetSource, now: number) {
@@ -21,7 +22,9 @@ export function agentActivityWidgetTimeline(source: AgentActivityWidgetSource, n
2122
? "Sign in to T3 Connect to see agents"
2223
: source.kind === "unavailable"
2324
? "Couldn't reach T3 Connect"
24-
: "No active agents",
25+
: source.kind === "loading"
26+
? "Loading agents…"
27+
: "No active agents",
2528
activeCount: 0,
2629
updatedAt,
2730
activities: [],

0 commit comments

Comments
 (0)