Skip to content

Commit 9d0acf4

Browse files
committed
fix(composer): keep Waiting banner while queueing behind background work
Do not fold awaited background work into isWorking, which hid the banner and Stop action. Populate pending tasks on mobile detail-derived shells so Queue still works when the shell stream is missing.
1 parent 0cb021b commit 9d0acf4

2 files changed

Lines changed: 17 additions & 5 deletions

File tree

‎apps/mobile/src/state/use-thread-selection.ts‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
deriveLatestThreadRun,
1818
deriveThreadRuntime,
1919
} from "@t3tools/client-runtime/state/thread-execution";
20+
import { derivePendingBackgroundWork } from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
2021
import * as Option from "effect/Option";
2122

2223
import { scopedThreadKey } from "../lib/scopedEntities";
@@ -66,6 +67,8 @@ function threadDetailToShell(
6667
const runtime = deriveThreadRuntime(projection);
6768
const pendingRequest =
6869
projection.runtimeRequests.find((request) => request.status === "pending") ?? null;
70+
const latestBackgroundRun =
71+
latestRun === null ? null : (projection.runs.find((run) => run.id === latestRun.runId) ?? null);
6972
return presentThreadShell(environmentId, {
7073
id: thread.id,
7174
projectId: thread.projectId,
@@ -94,6 +97,17 @@ function threadDetailToShell(
9497
latestVisibleMessage: null,
9598
latestUserMessageAt: latestUserMessageAt(projection),
9699
hasActionableProposedPlan: false,
100+
// Detail fallbacks used to omit the roster; without it, Queue follow-ups start immediately.
101+
pendingBackgroundTasks: [
102+
...derivePendingBackgroundWork({
103+
latestRun: latestBackgroundRun,
104+
providerThreads: projection.providerThreads,
105+
turnItems: projection.turnItems,
106+
activeProviderThreadId: thread.activeProviderThreadId,
107+
runs: projection.runs,
108+
pullRequests: thread.pullRequests,
109+
}),
110+
],
97111
itemCount: projection.turnItems.length,
98112
visibleItemCount: projection.visibleTurnItems.length,
99113
createdAt: thread.createdAt,

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1465,13 +1465,11 @@ export default function ChatView(props: ChatViewProps) {
14651465
const pendingBackgroundTasks = deriveThreadPendingBackgroundTasks(serverProjection);
14661466
// Awaited background work parks runtime at idle; treat it like an active turn for
14671467
// follow-up queueing so the composer does not look ready or hold a stuck send spinner.
1468+
// Keep this out of `isWorking`: useThreadLifecycle only presents the Waiting banner
1469+
// and its Stop action when the turn is not already working.
14681470
const isWaitingOnBackgroundWork = backgroundWorkHoldsCompletion(pendingBackgroundTasks);
14691471
const isWorking =
1470-
phase === "running" ||
1471-
isSendBusy ||
1472-
isCompacting ||
1473-
isWaitingOnBackgroundWork ||
1474-
runlessWorkStartedAt !== null;
1472+
phase === "running" || isSendBusy || isCompacting || runlessWorkStartedAt !== null;
14751473
const activeContextWindow = deriveLatestContextWindowSnapshot(
14761474
serverVisibleTurnItems ?? [],
14771475
activeThreadLiveTokenUsage,

0 commit comments

Comments
 (0)