| ... | @@ -35,7 +35,8 @@ import { | ... | @@ -35,7 +35,8 @@ import { |
| 35 | loadPreferences, | 35 | loadPreferences, |
| 36 | saveAgentAwarenessRegistrationRecord, | 36 | saveAgentAwarenessRegistrationRecord, |
| 37 | } from "../../persistence/imperative"; | 37 | } from "../../persistence/imperative"; |
| 38 | import AgentActivity, { type AgentActivityProps } from "../../widgets/AgentActivity"; | 38 | import type { AgentActivityProps } from "../../widgets/AgentActivity"; |
| | 39 | import { getAgentLiveActivities, startAgentLiveActivity } from "./agentLiveActivity"; |
| 39 | import { resolveCloudPublicConfig } from "../cloud/publicConfig"; | 40 | import { resolveCloudPublicConfig } from "../cloud/publicConfig"; |
| 40 | import { supportsAgentAwarenessPush } from "./capabilities"; | 41 | import { supportsAgentAwarenessPush } from "./capabilities"; |
| 41 | import { makeRelayDeviceRegistrationRequest, resolveApsEnvironment } from "./registrationPayload"; | 42 | import { makeRelayDeviceRegistrationRequest, resolveApsEnvironment } from "./registrationPayload"; |
| ... | @@ -522,11 +523,11 @@ function armAgentAwarenessLiveActivityForLocalWorkNow(input: { | ... | @@ -522,11 +523,11 @@ function armAgentAwarenessLiveActivityForLocalWorkNow(input: { |
| 522 | readonly projectTitle: string; | 523 | readonly projectTitle: string; |
| 523 | }): void { | 524 | }): void { |
| 524 | try { | 525 | try { |
| 525 | if (AgentActivity.getInstances().length > 0) { | 526 | if (getAgentLiveActivities().length > 0) { |
| 526 | return; | 527 | return; |
| 527 | } | 528 | } |
| 528 | const nowIso = new Date(Date.now()).toISOString(); | 529 | const nowIso = new Date(Date.now()).toISOString(); |
| 529 | const activity = AgentActivity.start({ | 530 | const activity = startAgentLiveActivity({ |
| 530 | title: "T3 Code", | 531 | title: "T3 Code", |
| 531 | subtitle: "Agent work in progress", | 532 | subtitle: "Agent work in progress", |
| 532 | activeCount: 1, | 533 | activeCount: 1, |
| ... | @@ -545,6 +546,9 @@ function armAgentAwarenessLiveActivityForLocalWorkNow(input: { | ... | @@ -545,6 +546,9 @@ function armAgentAwarenessLiveActivityForLocalWorkNow(input: { |
| 545 | }, | 546 | }, |
| 546 | ], | 547 | ], |
| 547 | }); | 548 | }); |
| | 549 | if (!activity) { |
| | 550 | return; |
| | 551 | } |
| 548 | logRegistrationDebug("live activity card armed for local work", { | 552 | logRegistrationDebug("live activity card armed for local work", { |
| 549 | threadTitle: input.threadTitle, | 553 | threadTitle: input.threadTitle, |
| 550 | }); | 554 | }); |
| ... | @@ -842,7 +846,7 @@ function endLocalLiveActivities(context: string): void { | ... | @@ -842,7 +846,7 @@ function endLocalLiveActivities(context: string): void { |
| 842 | return; | 846 | return; |
| 843 | } | 847 | } |
| 844 | try { | 848 | try { |
| 845 | for (const activity of AgentActivity.getInstances()) { | 849 | for (const activity of getAgentLiveActivities()) { |
| 846 | activity.end("immediate").catch((error: unknown) => { | 850 | activity.end("immediate").catch((error: unknown) => { |
| 847 | logRegistrationError(context, error); | 851 | logRegistrationError(context, error); |
| 848 | }); | 852 | }); |
| ... | @@ -1069,7 +1073,7 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect< | ... | @@ -1069,7 +1073,7 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect< |
| 1069 | } | 1073 | } |
| 1070 | | 1074 | |
| 1071 | let activities = yield* Effect.try({ | 1075 | let activities = yield* Effect.try({ |
| 1072 | try: () => AgentActivity.getInstances(), | 1076 | try: () => getAgentLiveActivities(), |
| 1073 | catch: (cause) => | 1077 | catch: (cause) => |
| 1074 | new AgentAwarenessOperationError({ | 1078 | new AgentAwarenessOperationError({ |
| 1075 | operation: "list-active-live-activities", | 1079 | operation: "list-active-live-activities", |
| ... | @@ -1118,7 +1122,7 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect< | ... | @@ -1118,7 +1122,7 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect< |
| 1118 | // The snapshot request yields; an arm-on-send may have created the | 1122 | // The snapshot request yields; an arm-on-send may have created the |
| 1119 | // card in the meantime. Re-check so two cards are never started. | 1123 | // card in the meantime. Re-check so two cards are never started. |
| 1120 | const armedMeanwhile = yield* Effect.try({ | 1124 | const armedMeanwhile = yield* Effect.try({ |
| 1121 | try: () => AgentActivity.getInstances(), | 1125 | try: () => getAgentLiveActivities(), |
| 1122 | catch: () => [] as ReadonlyArray<LiveActivity<AgentActivityProps>>, | 1126 | catch: () => [] as ReadonlyArray<LiveActivity<AgentActivityProps>>, |
| 1123 | }).pipe(Effect.orElseSucceed(() => [] as ReadonlyArray<LiveActivity<AgentActivityProps>>)); | 1127 | }).pipe(Effect.orElseSucceed(() => [] as ReadonlyArray<LiveActivity<AgentActivityProps>>)); |
| 1124 | if (armedMeanwhile.length > 0) { | 1128 | if (armedMeanwhile.length > 0) { |
| ... | @@ -1127,7 +1131,7 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect< | ... | @@ -1127,7 +1131,7 @@ export function refreshActiveLiveActivityRemoteRegistration(): Effect.Effect< |
| 1127 | const aggregate = snapshot.aggregate; | 1131 | const aggregate = snapshot.aggregate; |
| 1128 | const primed = yield* Effect.try({ | 1132 | const primed = yield* Effect.try({ |
| 1129 | try: () => | 1133 | try: () => |
| 1130 | AgentActivity.start({ | 1134 | startAgentLiveActivity({ |
| 1131 | title: aggregate.title, | 1135 | title: aggregate.title, |
| 1132 | subtitle: aggregate.subtitle, | 1136 | subtitle: aggregate.subtitle, |
| 1133 | activeCount: aggregate.activeCount, | 1137 | activeCount: aggregate.activeCount, |