Skip to content
7 changes: 5 additions & 2 deletions apps/web/src/components/chat/BackgroundWorkDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -80,7 +83,7 @@ export function BackgroundWorkDetails(props: {
<div className="flex items-baseline justify-between gap-3">
<h3 className="font-medium">{title}</h3>
<span className="shrink-0 text-xs text-muted-foreground">
{backgroundWorkHoldsCompletion([task])
{backgroundWorkHoldsCompletion([task]) || isPullRequestWatchTask(task)
? gt("Waiting", { $context: "status of background work" })
: gt("Running", { $context: "status of background work" })}
</span>
Expand Down
11 changes: 11 additions & 0 deletions packages/client-runtime/src/state/threadExecution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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");
});
});
4 changes: 3 additions & 1 deletion packages/client-runtime/src/state/threadExecution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
} from "@t3tools/contracts";
import {
backgroundWorkHoldsCompletion,
isPullRequestWatchTask,
derivePendingBackgroundWork,
} from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
import {
Expand Down Expand Up @@ -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();
Expand Down
Loading