()
| 96 | |
| 97 | /** Process singleton. Tool and panel share the same ports/registry/store. */ |
| 98 | export function getWorkflowService(): WorkflowService { |
| 99 | if (cached) return cached |
| 100 | const bus = createProgressBus() |
| 101 | const store = createProgressStoreFromBus(bus) |
| 102 | const ports = createWorkflowPorts({ bus, store }) |
| 103 | const service = makeService(ports, store) |
| 104 | // Subscribe to run_done to write the terminal snapshot to disk (shared entry for completed/failed/killed; shutdown-kill also routes here). |
| 105 | // The store registers to the bus before this subscription, so when the listener runs store.get(runId) is already terminal. |
| 106 | attachRunStatePersistence(bus, store) |
| 107 | // Install the state-change notification bridge (commit 0768d4dc promised "auto-notify on completion" but the old implementation left it unfulfilled) |
| 108 | installWorkflowNotifications(service) |
| 109 | cached = service |
| 110 | return cached |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Construct the service (inject ports + store). |
no test coverage detected