Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import AgentActivity, { type AgentActivityProps } from "../../widgets/AgentActivity";

export function getAgentLiveActivities() {
return AgentActivity.getInstances();
}

export function startAgentLiveActivity(props: AgentActivityProps) {
return AgentActivity.start(props);
}
12 changes: 12 additions & 0 deletions apps/mobile/src/features/agent-awareness/agentLiveActivity.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import type { LiveActivity } from "expo-widgets";
import type { AgentActivityProps } from "../../widgets/AgentActivity";

export function getAgentLiveActivities(): Array<LiveActivity<AgentActivityProps>> {
return [];
}

export function startAgentLiveActivity(
_props: AgentActivityProps,
): LiveActivity<AgentActivityProps> | null {
return null;
}
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,9 @@ vi.mock("expo-widgets", () => ({
addPushToStartTokenListener: vi.fn(() => ({ remove: vi.fn() })),
}));

vi.mock("../../widgets/AgentActivity", () => ({
default: {
getInstances: widgetMocks.getInstances,
start: widgetMocks.start,
},
vi.mock("./agentLiveActivity", () => ({
getAgentLiveActivities: widgetMocks.getInstances,
startAgentLiveActivity: widgetMocks.start,
}));

// The state modules pull the whole connection stack (and native expo modules)
Expand Down
18 changes: 11 additions & 7 deletions apps/mobile/src/features/agent-awareness/remoteRegistration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ import {
loadPreferences,
saveAgentAwarenessRegistrationRecord,
} from "../../persistence/imperative";
import AgentActivity, { type AgentActivityProps } from "../../widgets/AgentActivity";
import type { AgentActivityProps } from "../../widgets/AgentActivity";
import { getAgentLiveActivities, startAgentLiveActivity } from "./agentLiveActivity";
import { resolveCloudPublicConfig } from "../cloud/publicConfig";
import { supportsAgentAwarenessPush } from "./capabilities";
import { makeRelayDeviceRegistrationRequest, resolveApsEnvironment } from "./registrationPayload";
Expand Down Expand Up @@ -522,11 +523,11 @@ function armAgentAwarenessLiveActivityForLocalWorkNow(input: {
readonly projectTitle: string;
}): void {
try {
if (AgentActivity.getInstances().length > 0) {
if (getAgentLiveActivities().length > 0) {
return;
}
const nowIso = new Date(Date.now()).toISOString();
const activity = AgentActivity.start({
const activity = startAgentLiveActivity({
title: "T3 Code",
subtitle: "Agent work in progress",
activeCount: 1,
Expand All @@ -545,6 +546,9 @@ function armAgentAwarenessLiveActivityForLocalWorkNow(input: {
},
],
});
if (!activity) {
return;
}
logRegistrationDebug("live activity card armed for local work", {
threadTitle: input.threadTitle,
});
Expand Down Expand Up @@ -842,7 +846,7 @@ function endLocalLiveActivities(context: string): void {
return;
}
try {
for (const activity of AgentActivity.getInstances()) {
for (const activity of getAgentLiveActivities()) {
activity.end("immediate").catch((error: unknown) => {
logRegistrationError(context, error);
});
Expand Down Expand Up @@ -1069,7 +1073,7 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect<
}

let activities = yield* Effect.try({
try: () => AgentActivity.getInstances(),
try: () => getAgentLiveActivities(),
catch: (cause) =>
new AgentAwarenessOperationError({
operation: "list-active-live-activities",
Expand Down Expand Up @@ -1118,7 +1122,7 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect<
// The snapshot request 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: () => AgentActivity.getInstances(),
try: () => getAgentLiveActivities(),
catch: () => [] as ReadonlyArray<LiveActivity<AgentActivityProps>>,
}).pipe(Effect.orElseSucceed(() => [] as ReadonlyArray<LiveActivity<AgentActivityProps>>));
if (armedMeanwhile.length > 0) {
Expand All @@ -1127,7 +1131,7 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect<
const aggregate = snapshot.aggregate;
const primed = yield* Effect.try({
try: () =>
AgentActivity.start({
startAgentLiveActivity({
title: aggregate.title,
subtitle: aggregate.subtitle,
activeCount: aggregate.activeCount,
Expand Down
Loading