fix(mobile): iOS home screen widgets render instead of a containerBackground error #6464
Closedjakeleventhal(GitHub profile, opens in a new tab)wants to merge 1 commit into
main fromrefs/pull/6464/headopened View on GitHubgithub-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:unvouched
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:L
- apps/mobile/src/widgets/AgentActivity.tsx lines 80 to 83OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -50,9 +64,20 @@64+5065 // This function is serialized into the widget extension's JS bundle, so it5166 // must stay self-contained: no references to module-scope helpers, only the5267 // imported view/modifier factories.5368 export function AgentActivity(5469 props: AgentActivityProps,55- environment: LiveActivityEnvironment,70+ environment: AgentActivityEnvironment,5671 ): LiveActivityLayout {5772 "widget";587374+ // Placeholder / first-paint entries arrive with empty props. Treat missing75+ // fields as idle rather than throwing inside the widget JS runtime.76+ const activities = Array.isArray(props.activities) ? props.activities : [];77+ const activeCount = typeof props.activeCount === "number" ? props.activeCount : 0;78+ const widgetFamily = environment.widgetFamily;79+ const isHomeScreenWidget = typeof widgetFamily === "string";80+ const useCompactWidget =81+ widgetFamily === "systemSmall" ||82+ widgetFamily === "accessoryCircular" ||83+ widgetFamily === "accessoryInline";apps/mobile/src/features/agent-awareness/remoteRegistration.ts line 1095OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1057,3 +1091,5 @@10571091 // prime, so only an explicit false blocks it.10581092 if (preferences?.liveActivitiesEnabled !== false) {10591093 const snapshot = yield* readAgentActivitySnapshot();1094+ if (snapshot) {1095+ publishHomeScreenWidget(
- apps/mobile/src/widgets/AgentActivity.tsx lines 281 to 288Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -241,11 +256,10 @@241- alignment="leading"242- spacing={6}243- modifiers={deepLink ? [padding({ all: 14 }), widgetURL(deepLink)] : [padding({ all: 14 })]}244- >245- {/* Logo pinned to the leading edge; the status texts centered across the246- full width (ZStack so the logo doesn't skew the centering). No footer —247- overflow beyond the visible rows is inferable from the count. */}248- <ZStack>249- <HStack spacing={0} alignment="center">250- {renderLogo(13, primaryForeground)}251- <Spacer minLength={0} />256+ // Compact card for the watchOS Smart Stack + CarPlay (the `.small` family)257+ // and lock-screen accessory widgets.258+ const renderCompactLayout = () => (259+ <VStack260+ alignment="leading"261+ spacing={5}262+ modifiers={[263+ padding({ all: 10 }),264+ ...(widgetFamily ? [containerBackground("clear", "widget")] : []),265+ ]}
- apps/mobile/src/features/agent-awareness/remoteRegistration.ts line 527OutdatedResolvedby jakeleventhal(GitHub profile, opens in a new tab)@@ -497,4 +522,6 @@497522 deepLink: "/",498523 },499524 ],500- });525+ };526+ publishAgentActivityWidget(props);527+ const activity = AgentActivity.start(props);apps/mobile/src/features/agent-awareness/remoteRegistration.ts line 35OutdatedResolvedby jakeleventhal(GitHub profile, opens in a new tab)@@ -29,4 +29,7 @@2929 loadPreferences,3030 saveAgentAwarenessRegistrationRecord,3131 } from "../../persistence/imperative";32-import AgentActivity, { type AgentActivityProps } from "../../widgets/AgentActivity";32+import AgentActivity, {33+ publishAgentActivityWidget,34+ type AgentActivityProps,35+} from "../../widgets/AgentActivity";
t3dotgg(GitHub profile, opens in a new tab) added labelsvouch:trusted
t3dotgg(GitHub profile, opens in a new tab) removed labelsvouch:unvouched
- apps/mobile/src/features/agent-awareness/remoteRegistration.ts line 597OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -555,3 +586,12 @@555586 );556587 }557588589+function refreshAgentActivityWidget(): Effect.Effect<590+ RelayAgentActivitySnapshotResponse | null,591+ never,592+ ManagedRelay.ManagedRelayClient593+> {594+ return Effect.gen(function* () {595+ const snapshot = yield* readAgentActivitySnapshot();596+ if (snapshot) {597+ publishAgentActivityWidget(apps/mobile/src/features/agent-awareness/remoteRegistration.ts lines 745 to 778Resolvedby jakeleventhal(GitHub profile, opens in a new tab)@@ -555,3 +586,15 @@555586 );556587 }557588589+function refreshAgentActivityWidget(): Effect.Effect<590+ RelayAgentActivitySnapshotResponse | null,591+ never,592+ ManagedRelay.ManagedRelayClient593+> {594+ return Effect.gen(function* () {595+ const snapshot = yield* readAgentActivitySnapshot();596+ if (snapshot) {597+ publishAgentActivityWidget(598+ snapshot.aggregate ? widgetPropsFromAggregate(snapshot.aggregate) : idleWidgetProps(),599+ );600+ }
- apps/mobile/src/features/agent-awareness/remoteRegistration.ts line 548Resolvedby jakeleventhal(GitHub profile, opens in a new tab)@@ -519,4 +546,3 @@519546 deepLink: "/",520547 },521548 ],522- });
- apps/mobile/src/features/agent-awareness/remoteRegistration.ts line 548Resolvedby jakeleventhal(GitHub profile, opens in a new tab)@@ -502,21 +568 @@502568 }503- const nowIso = new Date(Date.now()).toISOString();504- const activity = AgentActivity.start({505- title: "T3 Code",506- subtitle: "Agent work in progress",507- activeCount: 1,508- updatedAt: nowIso,509- activities: [510- {511- environmentId: "",512- threadId: "",513- projectTitle: input.projectTitle,514- threadTitle: input.threadTitle,515- modelTitle: "",516- phase: "starting",517- status: "Connecting",518- updatedAt: nowIso,519- deepLink: "/",520- },521- ],522- });
- apps/mobile/src/widgets/AgentActivity.tsx line 365OutdatedResolvedby jakeleventhal(GitHub profile, opens in a new tab)@@ -258,12 +354,12 @@258- // The all-done header carries the outcome tint (emerald /259- // red) the way the Done/Failed status labels do.260- foregroundStyle(allDone ? headerTint : primaryForeground),261- lineLimit(1),354+ font({ weight: "semibold", size: 12 }),355+ foregroundStyle(primaryForeground),356+ lineLimit(2),262357 ]}263358 >264- {agentsLabel}359+ {heroRow.threadTitle}360+ </Text>361+ ) : (362+ <Text modifiers={[font({ size: 11 }), foregroundStyle(secondaryForeground)]}>363+ {outcomeLabel}265364 </Text>266- {attentionSuffix ? (267- <Text modifiers={[font({ size: 13 }), foregroundStyle(secondaryForeground)]}>·</Text>268- ) : null}269- {attentionSuffix ? (365+ )}
- apps/mobile/src/features/agent-awareness/remoteRegistration.ts line 701Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -512,16 +564,9 @@512- threadId: "",513- projectTitle: input.projectTitle,514- threadTitle: input.threadTitle,515- modelTitle: "",516- phase: "starting",517- status: "Connecting",518- updatedAt: nowIso,519- deepLink: "/",520- },521- ],522- });564+ const props = localWorkStartingWidgetProps(input);565+ publishAgentActivityWidget(props);566+ const activity = AgentActivity.start(props);523567 logRegistrationDebug("live activity card armed for local work", {524568 threadTitle: input.threadTitle,525569 });526570 runRegistrationInBackground(527- registerLiveActivityPushToken({ activity }).pipe(Effect.asVoid),571+ registerLiveActivityPushToken({ activity }).pipe(572+ Effect.ensuring(refreshAgentActivityWidget()),
- apps/mobile/src/features/agent-awareness/remoteRegistration.ts line 747Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -555,3 +606,11 @@555606 );556607 }557608609+function refreshAgentActivityWidget(): Effect.Effect<610+ RelayAgentActivitySnapshotResponse | null,611+ never,612+ ManagedRelay.ManagedRelayClient613+> {614+ return Effect.gen(function* () {615+ const expectedDeviceGeneration = deviceRegistrationGeneration;616+ const expectedRefreshGeneration = ++widgetRefreshGeneration;
- apps/mobile/src/features/agent-awareness/remoteRegistration.ts line 1166OutdatedResolvedby jakeleventhal(GitHub profile, opens in a new tab)@@ -1078,11 +1163,4 @@10781163 } else if (snapshot?.aggregate && snapshot.aggregate.activeCount > 0) {10791164 const aggregate = snapshot.aggregate;10801165 const primed = yield* Effect.try({1081- try: () =>1082- AgentActivity.start({1083- title: aggregate.title,1084- subtitle: aggregate.subtitle,1085- activeCount: aggregate.activeCount,1086- updatedAt: aggregate.updatedAt,1087- activities: aggregate.activities,1088- }),1166+ try: () => AgentActivity.start(widgetPropsFromAggregate(aggregate)),
- apps/mobile/src/features/agent-awareness/remoteRegistration.ts lines 1167 to 1168OutdatedResolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -1078,2 +1167,2 @@10781167 } else if (snapshot?.aggregate && snapshot.aggregate.activeCount > 0) {10791168 const aggregate = snapshot.aggregate;
github-actions[bot](GitHub profile, opens in a new tab) removed labelssize:L
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:XL
- apps/mobile/src/features/agent-awareness/remoteRegistration.ts line 244Resolvedby macroscopeapp[bot](GitHub profile, opens in a new tab)@@ -197,3 +223,4 @@197223 }198224 ensurePushTokenListener();199225 ensureAppStateListener();226+ startLiveWidgetObserver();
- apps/mobile/src/widgets/AgentActivity.tsx lines 581 to 587OutdatedResolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -378,3 +576,12 @@378576 };379577 }380578579+export const AgentActivityWidget = createWidget<AgentActivityProps>("AgentActivity", AgentActivity);580+581+export function publishAgentActivityWidget(props: AgentActivityProps): void {582+ try {583+ AgentActivityWidget.updateSnapshot(props);584+ } catch {585+ // Personal-team and Android builds have no widget extension.586+ }587+}
- apps/mobile/src/features/agent-awareness/remoteRegistration.ts line 138Resolvedby jakeleventhal(GitHub profile, opens in a new tab)@@ -115,3 +127,5 @@115127 let relayTokenProvider: (() => Promise<string | null>) | null = null;116128 let relayTokenProviderIdentity: string | null = null;117129 let deviceRegistrationGeneration = 0;130+let widgetRefreshGeneration = 0;131+const liveWidgetActivitiesAtom = createLiveWidgetActivitiesAtom({
- apps/mobile/src/features/agent-awareness/liveWidgetActivity.test.ts line 157Resolvedby coderabbitai[bot](GitHub profile, opens in a new tab)@@ -0,0 +135,21 @@135+ activeCount = activities.filter(136+ (value) => value.phase !== "completed" && value.phase !== "failed",137+ ).length,138+): RelayAgentActivitySnapshotResponse {139+ return {140+ aggregate: {141+ title: "T3 Code",142+ subtitle: "Agent work in progress",143+ activeCount,144+ updatedAt: NOW,145+ activities,146+ },147+ };148+}149+150+describe("live widget activity", () => {151+ it("expires terminal rows without a catalog or shell update", async () => {152+ vi.useFakeTimers();153+ vi.setSystemTime(NOW_MS);154+ const h = harness(shell([thread({ session: session("ready") })]), Date.now);155+ const stop = h.registry.mount(h.atom);
juliusmarminge closed this
Sign in to join this conversation.




Navigate logical layers of code changes, visualize relationships, and explore their blast radius.
No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
⚙️ Run configuration
Configuration used: Repository: pingdotgg/t3code/.coderabbit.yaml
Review profile: CHILL
Plan: Advanced
Run ID:
01b3b840-c4c7-45ee-9c5b-3d608ec14fbb📥 Commits
Reviewing files that changed from the base of the PR and between 7a497f5cfdd521ad68d3c172e0a91f34c6393e64 and f1775889861f0965df5bdde656de0de0bc3e3632.
📒 Files selected for processing (15)
apps/mobile/src/features/agent-awareness/agentLiveActivity.ios.tsapps/mobile/src/features/agent-awareness/agentLiveActivity.tsapps/mobile/src/features/agent-awareness/liveWidgetActivity.test.tsapps/mobile/src/features/agent-awareness/liveWidgetActivity.tsapps/mobile/src/features/agent-awareness/remoteRegistration.test.tsapps/mobile/src/features/agent-awareness/remoteRegistration.tsapps/mobile/src/features/showcase/showcaseAgentActivity.tsapps/mobile/src/widgets/AgentActivity.test.tsapps/mobile/src/widgets/AgentActivity.tsxinfra/relay/src/agentActivity/MobileRegistrations.test.tsinfra/relay/src/http/Api.tspackages/client-runtime/src/relay/managedRelay.test.tspackages/client-runtime/src/relay/managedRelay.tspackages/contracts/src/relay.test.tspackages/contracts/src/relay.tsIncluded review availability: Your plan provides up to 10 included reviews per hour; 3 remain after this review.
📝 Walkthrough
Walkthrough#
Adds mobile home-screen agent activity widgets. The change aggregates local shell activity, reconciles it with relay snapshots, supports excluded environments, renders multiple widget families, and publishes updates across registration and app-state lifecycle events.
Changes#
Agent activity widget
packages/contracts/src/relay.ts,packages/client-runtime/src/relay/managedRelay.ts,infra/relay/src/agentActivity/MobileRegistrations.ts,infra/relay/src/http/Api.ts, related testsapps/mobile/src/features/agent-awareness/liveWidgetActivity.ts,apps/mobile/src/features/agent-awareness/liveWidgetActivity.test.tsapps/mobile/src/widgets/AgentActivity.tsx,apps/mobile/src/widgets/AgentActivity.test.ts,apps/mobile/src/features/agent-awareness/agentLiveActivity*,apps/mobile/src/features/showcase/showcaseAgentActivity.tsAgentActivitysupports Live Activity and widget environments, with home-screen and accessory layouts. It renders idle, stale, and unavailable-count states. Snapshot publishing reports success or failure. Platform exports and showcase data handle widget publishing and missing counts.apps/mobile/src/features/agent-awareness/remoteRegistration.ts,apps/mobile/src/features/agent-awareness/remoteRegistration.test.tsPriority: ➖ Normal
Estimated code review effort: 4 (Complex) | ~60 minutes
Change: Bug fix
Sequence Diagram(s)#
Suggested reviewers:
juliusmarmingeMerge Risk: 🔵 Low · up to
f1775Switching accounts now clears the previous account's saved widget activity and ignores stale relay reads. In a narrow case, the widget may briefly show locally observed rows with an unknown total until the new account's snapshot arrives. Separately, one test can hide its real failure behind a cleanup error. Neither issue affects most users, so the change is mergeable with owner awareness. Native rendering on devices remains unverified, as the PR notes.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 warning)#
✅ Passed checks (4 passed)
✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment `@coderabbitai help` to get the list of available commands.