| @@ -26,6 +26,7 @@ import { · 25 unmodified lines |
| 26 | 26 | WebSocketRequest, |
| 27 | 27 | WsPush, |
| 28 | 28 | WsResponse, |
| 29 | + ServerProviderStatus, |
| 29 | 30 | } from "@t3tools/contracts"; |
| 30 | 31 | import * as NodeHttpServer from "@effect/platform-node/NodeHttpServer"; |
| 31 | 32 | import { |
| @@ -268,9 +269,6 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return< · 236 unmodified lines |
| 268 | 269 | ), |
| 269 | 270 | ); |
| 270 | 271 | |
| 271 | | − // Read provider statuses lazily so background health checks are reflected. |
| 272 | | − const getProviderStatuses = () => Effect.runSync(providerHealth.getStatuses); |
| 273 | | − |
| 274 | 272 | const clients = yield* Ref.make(new Set<WebSocket>()); |
| 275 | 273 | const logger = createLogger("ws"); |
| 276 | 274 | |
| @@ -618,6 +616,23 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return< · 341 unmodified lines |
| 618 | 616 | const subscriptionsScope = yield* Scope.make("sequential"); |
| 619 | 617 | yield* Effect.addFinalizer(() => Scope.close(subscriptionsScope, Exit.void)); |
| 620 | 618 | |
| 619 | + // Push updated provider statuses to connected clients once background health checks finish. |
| 620 | + let providers: ReadonlyArray<ServerProviderStatus> = []; |
| 621 | + yield* providerHealth.getStatuses.pipe( |
| 622 | + Effect.flatMap((statuses) => { |
| 623 | + providers = statuses; |
| 624 | + return broadcastPush({ |
| 625 | + type: "push", |
| 626 | + channel: WS_CHANNELS.serverConfigUpdated, |
| 627 | + data: { |
| 628 | + issues: [], |
| 629 | + providers: statuses, |
| 630 | + }, |
| 631 | + }); |
| 632 | + }), |
| 633 | + Effect.forkIn(subscriptionsScope), |
| 634 | + ); |
| 635 | + |
| 621 | 636 | yield* Stream.runForEach(orchestrationEngine.streamDomainEvents, (event) => |
| 622 | 637 | broadcastPush({ |
| 623 | 638 | type: "push", |
| @@ -632,23 +647,11 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return< · 8 unmodified lines |
| 632 | 647 | channel: WS_CHANNELS.serverConfigUpdated, |
| 633 | 648 | data: { |
| 634 | 649 | issues: event.issues, |
| 635 | | − providers: getProviderStatuses(), |
| 650 | + providers, |
| 636 | 651 | }, |
| 637 | 652 | }), |
| 638 | 653 | ).pipe(Effect.forkIn(subscriptionsScope)); |
| 639 | 654 | |
| 640 | | − // Push updated provider statuses to connected clients once background health checks finish. |
| 641 | | − providerHealth.onReady((statuses) => { |
| 642 | | − broadcastPush({ |
| 643 | | − type: "push", |
| 644 | | − channel: WS_CHANNELS.serverConfigUpdated, |
| 645 | | − data: { |
| 646 | | − issues: [], |
| 647 | | − providers: statuses, |
| 648 | | − }, |
| 649 | | − }).pipe(Effect.runPromise).catch(() => {}); |
| 650 | | − }); |
| 651 | | − |
| 652 | 655 | yield* Scope.provide(orchestrationReactor.start, subscriptionsScope); |
| 653 | 656 | |
| 654 | 657 | let welcomeBootstrapProjectId: ProjectId | undefined; |
| @@ -896,7 +899,7 @@ export const createServer = Effect.fn(function* (): Effect.fn.Return< · 241 unmodified lines |
| 896 | 899 | keybindingsConfigPath, |
| 897 | 900 | keybindings: keybindingsConfig.keybindings, |
| 898 | 901 | issues: keybindingsConfig.issues, |
| 899 | | − providers: getProviderStatuses(), |
| 902 | + providers, |
| 900 | 903 | availableEditors, |
| 901 | 904 | }; |
| 902 | 905 | |