GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(mobile): iOS Agent Activity widget shows your agents instead of a blank tile by shivamhwp · Pull Request #21163 · pingdotgg/t3code

fix(mobile): iOS Agent Activity widget shows your agents instead of a blank tile #21163

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Sign up for GitHub

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
juliusmarminge merged 17 commits into main from fix/ios-agent-activity-widget
Nov 9, 2026

Uh oh!

There was an error while loading. Please reload this page.

Merged

fix(mobile): iOS Agent Activity widget shows your agents instead of a blank tile #21163

Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
5a1c6d9
fix(mobile): iOS Agent Activity widget renders instead of a blank tile
Oct 18, 2026
25247c6
fix(mobile): reconcile Live Activities before the widget's relay read
Oct 19, 2026
f7773cf
fix(mobile): a slow older widget read no longer overwrites newer rows
Oct 19, 2026
31c97b0
fix(mobile): widget hides the previous account's agents on account sw…
Oct 19, 2026
f3ddbac
Merge main into fix/ios-agent-activity-widget
shivamhwp Oct 21, 2026
1ba2c18
fix(mobile): widget keeps its rows across a cold start and never re-p…
shivamhwp Oct 21, 2026
9a71d10
fix(mobile): a failed read after a cold start never leaves a stale wi…
shivamhwp Oct 21, 2026
49a8baa
fix(mobile): widget rows keep their owner across a provider release
shivamhwp Oct 21, 2026
a736547
fix(mobile): only the newest widget read may prime a Live Activity
shivamhwp Oct 21, 2026
217c694
Merge remote-tracking branch 'github/main' into fix/ios-agent-activit…
maria-rcks Oct 26, 2026
9644c16
fix(mobile): preserve account widget rows across cold starts
maria-rcks Oct 26, 2026
ca9b8d5
fix(mobile): omit absent widget owners from native storage
maria-rcks Oct 26, 2026
13aef01
chore: merge main into ios agent activity widget
maria-rcks Oct 30, 2026
c27c70e
fix(mobile): keep widget checks compatible with main
maria-rcks Oct 30, 2026
e34eaaf
Merge remote-tracking branch 'origin/main' into prbatch/21163
shivamhwp Nov 7, 2026
f070681
fix(mobile): drop the widget's account cache and guard reads by regis…
shivamhwp Nov 7, 2026
9e1694d
test(mobile): cover a sign-out and re-sign-in during a widget read
shivamhwp Nov 7, 2026
File filter
Filter by extension

Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

7 changes: 6 additions & 1 deletion 7 apps/mobile/app.config.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,12 @@ const widgetsPlugin: NonNullable<ExpoConfig["plugins"]>[number] = [
displayName: "Agent Activity",
description: "Shows the current state of active T3 Code agents.",
android: null,
ios: { supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"] },
ios: {
supportedFamilies: ["systemSmall", "systemMedium", "accessoryRectangular"],
// Embeds the layout so the gallery preview and a new widget render
// before the app has run once; the app replaces it on publish.
initialLayout: "./src/widgets/AgentActivityWidget.tsx",
},
},
],
},
Expand Down
151 changes: 143 additions & 8 deletions 151 apps/mobile/src/features/agent-awareness/remoteRegistration.test.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@ import { describe, expect, it } from "@effect/vitest";
import Constants from "expo-constants";
import * as Cause from "effect/Cause";
import * as Effect from "effect/Effect";
import * as Deferred from "effect/Deferred";
import * as Exit from "effect/Exit";
import * as Fiber from "effect/Fiber";
import * as Layer from "effect/Layer";
import { Cookies, FetchHttpClient, HttpClientRequest, HttpClientResponse } from "effect/http";
import { ManagedRelay } from "@t3tools/client-runtime/relay";

import type { EnvironmentId } from "@t3tools/contracts";
import type { EnvironmentId, ThreadId } from "@t3tools/contracts";
import type { RelayAgentActivityAggregateState } from "@t3tools/contracts/relay";
import { verifyDpopProof } from "@t3tools/shared/dpop";
import type { SavedRemoteConnection } from "../../lib/connection";
import * as Dpop from "../cloud/dpop";
Expand Down Expand Up @@ -61,6 +63,7 @@ const widgetMocks = vi.hoisted(() => ({
getInstances: vi.fn(() => []),
start: vi.fn(() => ({})),
}));
const publishWidgetMock = vi.hoisted(() => vi.fn((_source: unknown) => Promise.resolve()));
const environmentConfigsMock = vi.hoisted(() => ({
configs: new Map<
string,
Expand Down Expand Up @@ -97,6 +100,10 @@ vi.mock("expo-widgets", () => ({
addPushToStartTokenListener: vi.fn(() => ({ remove: vi.fn() })),
}));

vi.mock("../../widgets/publishAgentActivityWidget", () => ({
publishAgentActivityWidget: publishWidgetMock,
}));

vi.mock("./agentLiveActivity", () => ({
getAgentLiveActivities: widgetMocks.getInstances,
startAgentLiveActivity: widgetMocks.start,
Expand Down Expand Up @@ -271,6 +278,7 @@ describe("makeRelayDeviceRegistrationRequest", () => {
widgetMocks.getInstances.mockReset();
widgetMocks.getInstances.mockReturnValue([]);
widgetMocks.start.mockClear();
publishWidgetMock.mockClear();
environmentConfigsMock.configs.clear();
});

Expand Down Expand Up @@ -680,12 +688,14 @@ describe("makeRelayDeviceRegistrationRequest", () => {
return Effect.gen(function* () {
yield* runBackgroundOperations();

expect(fetchMock).toHaveBeenCalledTimes(2);
const [request, init] = fetchMock.mock.calls[1] as unknown as [
unknown,
RequestInit | undefined,
];
const url = request instanceof Request ? request.url : String(request);
const requestUrl = (request: unknown) =>
request instanceof Request ? request.url : String(request);
const deviceCalls = fetchMock.mock.calls.filter(([request]) =>
requestUrl(request).endsWith("/v1/mobile/devices"),
);
expect(deviceCalls).toHaveLength(1);
const [request, init] = deviceCalls[0] as unknown as [unknown, RequestInit | undefined];
const url = requestUrl(request);
const method = request instanceof Request ? request.method : init?.method;
const headers = request instanceof Request ? request.headers : new Headers(init?.headers);
const dpop = headers.get("dpop");
Expand Down Expand Up @@ -905,9 +915,12 @@ describe("makeRelayDeviceRegistrationRequest", () => {
},
};

// Sign-in first reads the widget snapshot, then registers the device; fail
// both lookups so the queued registration is the one that must recover.
const tokenProvider = vi
.fn<() => Promise<string | null>>()
.mockRejectedValueOnce(new Error("auth unavailable"))
.mockRejectedValueOnce(new Error("auth unavailable"))
.mockResolvedValue("clerk-token-user-a");
setAgentAwarenessRelayTokenProvider(tokenProvider);
const tokenListener = vi.mocked(Notifications.addPushTokenListener).mock.calls.at(-1)?.[0];
Expand All @@ -918,7 +931,7 @@ describe("makeRelayDeviceRegistrationRequest", () => {
yield* runBackgroundOperations();

expect(backgroundRuntime.pending).toHaveLength(0);
expect(tokenProvider).toHaveBeenCalledTimes(2);
expect(tokenProvider).toHaveBeenCalledTimes(3);
}).pipe(Effect.provide(layerRelayTest));
});

Expand Down Expand Up @@ -1249,4 +1262,126 @@ describe("makeRelayDeviceRegistrationRequest", () => {
}).pipe(Effect.provide(layerRelayTest));
},
);

describe("home-screen widget", () => {
// These cover the widget path only, so keep the Live Activity from priming.
beforeEach(() => {
vi.mocked(loadPreferences).mockResolvedValue({ liveActivitiesEnabled: false } as Preferences);
});

const aggregate: RelayAgentActivityAggregateState = {
title: "T3 Code",
subtitle: "Agent work in progress",
activeCount: 1,
updatedAt: "2026-10-18T10:00:00.000Z",
activities: [
{
environmentId: "env-1" as EnvironmentId,
threadId: "thread-1" as ThreadId,
projectTitle: "t3code",
threadTitle: "Fix the widget",
modelTitle: "GPT-5.5",
phase: "running",
status: "Working",
updatedAt: "2026-10-18T10:00:00.000Z",
deepLink: "/threads/env-1/thread-1",
},
],
};

// The shared fetch-backed relay layer keeps the first test's fetch stub,
// so these tests answer the snapshot read through a fake client instead.
function fakeRelay(
getAgentActivitySnapshot: () => Effect.Effect<
{ readonly aggregate: typeof aggregate },
ManagedRelay.ManagedRelayRequestFailedError
>,
) {
Constants.expoConfig!.extra = { relay: { url: "https://relay.example.test/" } };
const unexpected = () => Effect.die("Unexpected relay request");
return Layer.succeed(
ManagedRelay.ManagedRelayClient,
ManagedRelay.ManagedRelayClient.of({
relayUrl: "https://relay.example.test",
listEnvironments: unexpected,
listDevices: unexpected,
createEnvironmentLinkChallenge: unexpected,
linkEnvironment: unexpected,
unlinkEnvironment: unexpected,
getEnvironmentStatus: unexpected,
connectEnvironment: unexpected,
registerDevice: unexpected,
unregisterDevice: unexpected,
registerLiveActivity: unexpected,
getAgentActivitySnapshot,
resetTokenCache: Effect.void,
}),
);
}

it.effect("repaints from the relay snapshot when activity is reconciled", () => {
const relay = fakeRelay(() => Effect.succeed({ aggregate }));
setAgentAwarenessRelayTokenProvider(() => Promise.resolve("clerk-token"), "user-a");

return Effect.gen(function* () {
yield* refreshActiveLiveActivityRemoteRegistration();

expect(publishWidgetMock).toHaveBeenLastCalledWith({ kind: "snapshot", aggregate });
}).pipe(Effect.provide(relay));
});

it.effect("keeps the last rows when a later read fails, but never the signed-out state", () => {
const relayDown = new ManagedRelay.ManagedRelayRequestFailedError({
action: "read relay agent activity snapshot",
transportFailed: true,
cause: new Error("relay down"),
});
let relayUp = false;
const relay = fakeRelay(() =>
relayUp ? Effect.succeed({ aggregate }) : Effect.fail(relayDown),
);
setAgentAwarenessRelayTokenProvider(() => Promise.resolve("clerk-token"), "user-a");

return Effect.gen(function* () {
yield* refreshActiveLiveActivityRemoteRegistration();
expect(publishWidgetMock).toHaveBeenLastCalledWith({ kind: "unavailable" });

relayUp = true;
yield* refreshActiveLiveActivityRemoteRegistration();
relayUp = false;
publishWidgetMock.mockClear();
yield* refreshActiveLiveActivityRemoteRegistration();
expect(publishWidgetMock).not.toHaveBeenCalled();
}).pipe(Effect.provide(relay));
});

it("shows the signed-out state after cloud sign-out", () => {
setAgentAwarenessRelayTokenProvider(() => Promise.resolve("clerk-token"), "user-a");

setAgentAwarenessRelayTokenProvider(null);

expect(publishWidgetMock).toHaveBeenLastCalledWith({ kind: "signed-out" });
});

it.effect("drops a snapshot that arrives after the account changed", () =>
Effect.gen(function* () {
const requested = yield* Deferred.make<void>();
const response = yield* Deferred.make<{ readonly aggregate: typeof aggregate }>();
const relay = fakeRelay(() =>
Deferred.succeed(requested, undefined).pipe(Effect.andThen(Deferred.await(response))),
);
setAgentAwarenessRelayTokenProvider(() => Promise.resolve("clerk-token-a"), "user-a");

const refresh = yield* Effect.forkChild(
refreshActiveLiveActivityRemoteRegistration().pipe(Effect.provide(relay)),
);
yield* Deferred.await(requested);
setAgentAwarenessRelayTokenProvider(() => Promise.resolve("clerk-token-b"), "user-b");
yield* Deferred.succeed(response, { aggregate });
yield* Fiber.join(refresh);

expect(publishWidgetMock).not.toHaveBeenCalledWith({ kind: "snapshot", aggregate });
}),
);
});
});
36 changes: 33 additions & 3 deletions 36 apps/mobile/src/features/agent-awareness/remoteRegistration.ts
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ import {
saveAgentAwarenessRegistrationRecord,
} from "../../persistence/imperative";
import type { AgentActivityProps } from "../../widgets/AgentActivity";
import type { AgentActivityWidgetSource } from "../../widgets/agentActivityWidgetTimeline";
import { publishAgentActivityWidget } from "../../widgets/publishAgentActivityWidget";
import { getAgentLiveActivities, startAgentLiveActivity } from "./agentLiveActivity";
import { resolveCloudPublicConfig } from "../cloud/publicConfig";
import { supportsAgentAwarenessPush } from "./capabilities";
Expand Down Expand Up @@ -89,6 +91,9 @@ const ACTIVITY_TOKEN_REREGISTER_INTERVAL_MS = 60_000;
const LIVE_ACTIVITY_STALE_AFTER_MS = 10 * 60_000;
const liveActivityStaleDate = () => new Date(Date.now() + LIVE_ACTIVITY_STALE_AFTER_MS);
const registeredActivityPushTokens = new Map<string, number>();
// A failed read keeps the current account's last rows, but must not leave the
// widget claiming the user is signed out or showing a previous account.
let widgetShowsCurrentAccount = false;
let androidDeviceReplayedAt: number | null = null;
let pushTokenSubscription: { remove: () => void } | null = null;
let appStateSubscription: { remove: () => void } | null = null;
Expand Down Expand Up @@ -188,6 +193,7 @@ export function setAgentAwarenessRelayTokenProvider(
activeDeviceRegistration = null;
pendingDeviceRegistration = null;
registeredActivityPushTokens.clear();
widgetShowsCurrentAccount = false;
}
relayTokenProvider = provider;
relayTokenProviderIdentity = provider ? (identity ?? null) : null;
Expand All @@ -204,6 +210,7 @@ export function setAgentAwarenessRelayTokenProvider(
// Without a signed-in user the relay can no longer update or end these
// activities, so they would sit orphaned on the lock screen.
endLocalLiveActivities("live activity cleanup after cloud sign-out failed");
publishWidget({ kind: "signed-out" });
setRegistrationStatus("unknown");
void clearAgentAwarenessRegistrationRecord().catch((error: unknown) => {
logRegistrationError("clear registration record on sign-out failed", error);
Expand Down Expand Up @@ -810,6 +817,15 @@ function ensureAppStateListener(): void {
});
}

function publishWidget(source: AgentActivityWidgetSource): void {
if (!canRegisterRemoteLiveActivities()) {
return;
}
publishAgentActivityWidget(source).catch((error: unknown) => {
logRegistrationError("agent activity widget publish failed", error);
});
}

function endLocalLiveActivities(context: string): void {
if (!canRegisterRemoteLiveActivities()) {
return;
Expand Down Expand Up @@ -900,6 +916,7 @@ export function __resetAgentAwarenessRemoteRegistrationForTest(): void {
registrationStatusListeners.clear();
registeredActivityPushTokens.clear();
activityPushTokenLocks.clear();
widgetShowsCurrentAccount = false;
}

export function unregisterAgentAwarenessDeviceForCurrentUser(
Expand Down Expand Up @@ -1041,6 +1058,20 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect<
return;
}

// The home-screen widget has no push path of its own, so every foreground
// refresh repaints it from the same snapshot that primes the Live Activity.
const identity = relayTokenProviderIdentity;
const snapshot = yield* readAgentActivitySnapshot();
Comment thread
macroscopeapp[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

if (!relayTokenProvider || relayTokenProviderIdentity !== identity) {
return;
}
if (snapshot) {
widgetShowsCurrentAccount = true;
publishWidget({ kind: "snapshot", aggregate: snapshot.aggregate });
} else if (!widgetShowsCurrentAccount) {
publishWidget({ kind: "unavailable" });
}

Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved

Uh oh!

There was an error while loading. Please reload this page.

let activities = yield* Effect.try({
try: () => getAgentLiveActivities(),
catch: (cause) =>
Expand Down Expand Up @@ -1082,9 +1113,8 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect<
}),
}).pipe(Effect.orElseSucceed(() => null));
if (preferences?.liveActivitiesEnabled !== false) {
const snapshot = yield* readAgentActivitySnapshot();
// The snapshot request yields; an arm-on-send may have created the
// card in the meantime. Re-check so two cards are never started.
// Loading preferences yields; an arm-on-send may have created the card
// in the meantime. Re-check so two cards are never started.
const armedMeanwhile = yield* Effect.try({
try: () => getAgentLiveActivities(),
catch: () => [] as ReadonlyArray<LiveActivity<AgentActivityProps>>,
Expand Down
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402792 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.