()
| 8199 | } |
| 8200 | |
| 8201 | async getActivityList(): Promise<Record<string, WorkspaceActivitySnapshot>> { |
| 8202 | try { |
| 8203 | const snapshots = await this.extensionMetadata.getAllSnapshots(); |
| 8204 | const workspaceIds = new Set(snapshots.keys()); |
| 8205 | for (const workspaceId of this.activeWorkflowRunIdsByWorkspace.keys()) { |
| 8206 | workspaceIds.add(workspaceId); |
| 8207 | } |
| 8208 | try { |
| 8209 | for (const metadata of await this.config.getAllWorkspaceMetadata()) { |
| 8210 | workspaceIds.add(metadata.id); |
| 8211 | } |
| 8212 | } catch (error) { |
| 8213 | log.debug("Failed to include all workspaces while listing activity", { error }); |
| 8214 | } |
| 8215 | |
| 8216 | const entries = await Promise.all( |
| 8217 | Array.from( |
| 8218 | workspaceIds, |
| 8219 | async (workspaceId): Promise<readonly [string, WorkspaceActivitySnapshot] | null> => { |
| 8220 | const snapshot = snapshots.get(workspaceId) ?? null; |
| 8221 | const hadWorkflowActivityCache = this.activeWorkflowRunIdsByWorkspace.has(workspaceId); |
| 8222 | const activeWorkflowRunCount = await this.getActiveWorkflowRunCount(workspaceId); |
| 8223 | // Keep a zero-count tombstone for workspaces whose workflow-only activity |
| 8224 | // was cleared while a frontend activity subscription was disconnected. |
| 8225 | if (snapshot == null && activeWorkflowRunCount === 0 && !hadWorkflowActivityCache) { |
| 8226 | return null; |
| 8227 | } |
| 8228 | return [ |
| 8229 | workspaceId, |
| 8230 | // Overlay the optimistic mid-stream goal here too: the renderer |
| 8231 | // bootstraps via this list (the subscription does not replay |
| 8232 | // historical snapshots), and `getAllSnapshots()` returns the |
| 8233 | // still-pre-stream persisted goal. Without this, a reconnect/reload |
| 8234 | // during a mid-stream goal set would seed the UI with the stale |
| 8235 | // goal until the next live emit or goal read. |
| 8236 | mergeActiveWorkflowRunCount( |
| 8237 | this.overlayPendingGoal(workspaceId, snapshot), |
| 8238 | activeWorkflowRunCount |
| 8239 | ), |
| 8240 | ] as const; |
| 8241 | } |
| 8242 | ) |
| 8243 | ); |
| 8244 | return Object.fromEntries( |
| 8245 | entries.filter( |
| 8246 | (entry): entry is readonly [string, WorkspaceActivitySnapshot] => entry != null |
| 8247 | ) |
| 8248 | ); |
| 8249 | } catch (error) { |
| 8250 | log.error("Failed to list activity:", error); |
| 8251 | return {}; |
| 8252 | } |
| 8253 | } |
| 8254 | async getChatHistory(workspaceId: string): Promise<MuxMessage[]> { |
| 8255 | try { |
| 8256 | // Only return messages from the latest compaction boundary onward. |
no test coverage detected