summaryrefslogtreecommitdiffhomepage
path: root/packages/session-orchestrator/src
diff options
context:
space:
mode:
authorAdam Malczewski <[email protected]>2026-06-27 18:49:50 +0900
committerAdam Malczewski <[email protected]>2026-06-27 18:49:50 +0900
commitd19f75caca6f6ad49e95b83021cb4cf00a39297f (patch)
treebc106b082cc492095d502be9702a65365acbbd2a /packages/session-orchestrator/src
parent87e85e026e54b1dc25b0648af298ab0a8a715701 (diff)
downloaddispatch-d19f75caca6f6ad49e95b83021cb4cf00a39297f.tar.gz
dispatch-d19f75caca6f6ad49e95b83021cb4cf00a39297f.zip
feat(concurrency): add "queued" ConversationStatus — emit when request blocks on acquire, re-emit "active" when slot granted
Diffstat (limited to 'packages/session-orchestrator/src')
-rw-r--r--packages/session-orchestrator/src/orchestrator.ts20
1 files changed, 20 insertions, 0 deletions
diff --git a/packages/session-orchestrator/src/orchestrator.ts b/packages/session-orchestrator/src/orchestrator.ts
index b73647d..617c079 100644
--- a/packages/session-orchestrator/src/orchestrator.ts
+++ b/packages/session-orchestrator/src/orchestrator.ts
@@ -611,13 +611,33 @@ export function createSessionOrchestrator(
// when the stream completes (after all tokens are generated). The
// promptStartedAt (turn start time) is used for oldest-agent-first
// scheduling when multiple agents are queued.
+ //
+ // Status lifecycle with concurrency: "active" is emitted early (in
+ // payloadPromise.then, before this code runs). If acquire() blocks,
+ // onQueued emits "queued" (broadcast-only — persisted status stays
+ // "active"). When the slot is granted, onAcquired emits "active"
+ // again, transitioning "queued" → "active" so the FE switches from
+ // the loading ring back to dots. A request that gets a slot
+ // immediately never emits "queued" — onAcquired fires right after
+ // the early "active", which is a harmless no-op re-broadcast.
const limiter = deps.resolveConcurrencyLimiter?.();
if (limiter !== undefined) {
+ const emitStatus = (status: "queued" | "active"): void => {
+ void deps.conversationStore.getWorkspaceId(conversationId).then((workspaceId) => {
+ deps.emit?.(conversationStatusChanged, {
+ conversationId,
+ status,
+ workspaceId,
+ });
+ });
+ };
provider = wrapProviderWithConcurrency(
provider,
limiter,
conversationId,
promptStartedAt,
+ () => emitStatus("queued"),
+ () => emitStatus("active"),
);
}