Skip to content

Commit 40ed54e

Browse files
t3dotggclaude
andcommitted
fix: sweep only when background work can have ended
subagent.updated and provider-thread.updated now start a settle sweep only when the subagent stopped or the roster no longer holds completion, so progress updates during long background work cost nothing. Web also reads placement from the observation it just made, like mobile. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent dffc397 commit 40ed54e

2 files changed

Lines changed: 13 additions & 5 deletions

File tree

‎apps/server/src/orchestration-v2/ThreadSettlementService.ts‎

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { resolveProjectSettings } from "@t3tools/shared/projectSettings";
66
import { visibleThreadPullRequests } from "@t3tools/shared/threadPullRequests";
77
import {
88
CommandId,
9+
isOrchestrationV2WorkActive,
910
type ThreadId,
1011
type OrchestrationV2DomainEvent,
1112
type OrchestrationV2ThreadShell,
@@ -591,10 +592,17 @@ export const make = Effect.gen(function* () {
591592
case "thread.pull-request-link-updated":
592593
case "thread.pull-request-synced":
593594
case "provider-session.detached":
594-
case "provider-thread.updated":
595-
case "subagent.updated":
596595
case "run.background-work-cancelled":
597596
return enqueueThread(event.threadId);
597+
// Sweep only when the work can have ended: progress updates cannot settle anything.
598+
case "subagent.updated":
599+
return isOrchestrationV2WorkActive(event.payload.status)
600+
? Effect.void
601+
: enqueueThread(event.threadId);
602+
case "provider-thread.updated":
603+
return backgroundWorkHoldsCompletion(event.payload.pendingBackgroundTasks ?? [])
604+
? Effect.void
605+
: enqueueThread(event.threadId);
598606
case "turn-item.updated":
599607
return turnItemUpdateCanEndBackgroundWork(event.payload)
600608
? enqueueThread(event.threadId)

‎apps/web/src/components/Sidebar.tsx‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -516,13 +516,13 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {
516516
const { threads, scopedProjectKeys, serverConfigs, optimisticDrop, workingShelfEnabled } = input;
517517
const preciseNow = new Date().toISOString();
518518
const visible = filterSidebarV2VisibleThreads(threads, scopedProjectKeys);
519-
inboxReturns.observe(workingShelfEnabled ? threads : null);
519+
const inboxObservation = inboxReturns.observe(workingShelfEnabled ? threads : null);
520520
const pinned: EnvironmentThreadShell[] = [];
521521
const active: EnvironmentThreadShell[] = [];
522522
const working: EnvironmentThreadShell[] = [];
523523
const inbox = (thread: EnvironmentThreadShell, manuallyMoved = false) =>
524524
workingShelfEnabled &&
525-
(manuallyMoved ? isThreadWorking(thread) : inboxReturns.isWorking(thread))
525+
(manuallyMoved ? isThreadWorking(thread) : inboxObservation.isWorking(thread))
526526
? working
527527
: active;
528528
const snoozed: EnvironmentThreadShell[] = [];
@@ -574,7 +574,7 @@ function partitionSidebarThreads(input: SidebarThreadPartitionInput) {
574574
// Capability gates dragging only; mixed server versions must preserve the same pinned order across clients.
575575
const sortedPinned = sortPinnedThreadsForSidebar(pinned);
576576
const sortedActive = workingShelfEnabled
577-
? sortInboxThreadsByReturn(active, inboxReturns.returnedAt)
577+
? sortInboxThreadsByReturn(active, inboxObservation.returnedAt)
578578
: sortThreadsForSidebar(active);
579579
return {
580580
pinnedThreads:

0 commit comments

Comments
 (0)