diff --git a/apps/web/src/components/chat/BackgroundWorkDetails.tsx b/apps/web/src/components/chat/BackgroundWorkDetails.tsx index 72ca70c2b16e1..263db6f6044a1 100644 --- a/apps/web/src/components/chat/BackgroundWorkDetails.tsx +++ b/apps/web/src/components/chat/BackgroundWorkDetails.tsx @@ -4,7 +4,10 @@ import type { ThreadId, } from "@t3tools/contracts"; import type { ThreadStructure } from "@t3tools/client-runtime/state/shell"; -import { backgroundWorkHoldsCompletion } from "@t3tools/shared/orchestrationV2PendingBackgroundWork"; +import { + backgroundWorkHoldsCompletion, + isPullRequestWatchTask, +} from "@t3tools/shared/orchestrationV2PendingBackgroundWork"; import { T, useGT } from "gt-react"; import { useState } from "react"; @@ -80,7 +83,7 @@ export function BackgroundWorkDetails(props: {

{title}

- {backgroundWorkHoldsCompletion([task]) + {backgroundWorkHoldsCompletion([task]) || isPullRequestWatchTask(task) ? gt("Waiting", { $context: "status of background work" }) : gt("Running", { $context: "status of background work" })} diff --git a/packages/client-runtime/src/state/threadExecution.test.ts b/packages/client-runtime/src/state/threadExecution.test.ts index d932e2c0395b3..39f8b0f7b18eb 100644 --- a/packages/client-runtime/src/state/threadExecution.test.ts +++ b/packages/client-runtime/src/state/threadExecution.test.ts @@ -898,4 +898,15 @@ describe("presentPendingBackgroundWork", () => { ]); expect(presentation?.items[0]?.label).toBe("mv a.ts b.ts\ncat > b.ts <<'EOF'\nexport {};\nEOF"); }); + + it("says a pull request watch is waiting after it stops holding the thread", () => { + const presentation = presentPendingBackgroundWork([ + { + taskId: "pull-request-watch:github.com/acme/app#1", + kind: "monitor", + description: "Watching pull request #1", + }, + ]); + expect(presentation?.title).toBe("Waiting ยท Watching pull request #1"); + }); }); diff --git a/packages/client-runtime/src/state/threadExecution.ts b/packages/client-runtime/src/state/threadExecution.ts index 7e5ad55dc53b2..efa14b79f6961 100644 --- a/packages/client-runtime/src/state/threadExecution.ts +++ b/packages/client-runtime/src/state/threadExecution.ts @@ -28,6 +28,7 @@ import { } from "@t3tools/contracts"; import { backgroundWorkHoldsCompletion, + isPullRequestWatchTask, derivePendingBackgroundWork, } from "@t3tools/shared/orchestrationV2PendingBackgroundWork"; import { @@ -714,7 +715,8 @@ export function presentPendingBackgroundWork( resolve: MFunctionType = mFallback, ): PendingBackgroundWorkPresentation | null { if (tasks.length === 0) return null; - const waiting = backgroundWorkHoldsCompletion(tasks); + // A watch waits on its host even once it stops holding the thread; nothing of it runs. + const waiting = backgroundWorkHoldsCompletion(tasks) || tasks.every(isPullRequestWatchTask); const items = tasks .map((task): PendingBackgroundWorkItem => { const description = task.description?.trim();