Skip to content
3 changes: 2 additions & 1 deletion apps/web/src/components/chat/BackgroundWorkDetails.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import type {
ThreadId,
} from "@t3tools/contracts";
import type { ThreadStructure } from "@t3tools/client-runtime/state/shell";
import { isPullRequestWatchTask } from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
import { useState } from "react";

import { InlineButton } from "../ui/button";
Expand Down Expand Up @@ -59,7 +60,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">
{task.awaited ? "Waiting" : "Running"}
{task.awaited || isPullRequestWatchTask(task) ? "Waiting" : "Running"}
</span>
</div>
{command ? (
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 @@ -756,4 +756,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 @@ -26,6 +26,7 @@ import {
} from "@t3tools/contracts";
import {
backgroundWorkHoldsCompletion,
isPullRequestWatchTask,
derivePendingBackgroundWork,
} from "@t3tools/shared/orchestrationV2PendingBackgroundWork";
import {
Expand Down Expand Up @@ -596,7 +597,8 @@ export function presentPendingBackgroundWork(
tasks: ReadonlyArray<OrchestrationV2PendingBackgroundTask>,
): 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