feat(server): agents can watch a PR and get woken when checks, reviews, or conflicts need them (#15057)

Co-authored-by: Claude Opus 5.5 (1M context) <[email protected]>
This commit is contained in:
Theo BrowneandClaude Opus 5.5 authored and GitHub committed 2026-10-03 03:08:44 -07:00
1 parent e8545b293b
commit 18b21325c3
31 files changed
+1531 -39

No files matched your search

@@ -3,7 +3,14 @@ import {
resolveThreadPullRequestChains,
visibleThreadPullRequests,
} from "@t3tools/shared/threadPullRequests";
import { ArrowUpRightIcon, LinkIcon, MoreHorizontalIcon, PlusIcon } from "lucide-react";
import {
ArrowUpRightIcon,
EyeIcon,
EyeOffIcon,
LinkIcon,
MoreHorizontalIcon,
PlusIcon,
} from "lucide-react";
import { useCallback, useMemo } from "react";
import { writeTextToClipboard } from "~/hooks/useCopyToClipboard";
@@ -68,14 +75,19 @@ function LinkRow({
line,
threadRef,
onUnlink,
onSetWatching,
}: {
line: PullRequestListLine;
threadRef: ScopedThreadRef;
onUnlink: (link: ThreadPullRequestLink) => void;
/** Null when the environment cannot watch pull requests. */
onSetWatching: ((link: ThreadPullRequestLink, watching: boolean) => void) | null;
}) {
const openPrLink = useOpenPrLink(threadRef);
const { link, depth, stack } = line;
const snapshot = link.snapshot;
const open = snapshot === null || snapshot.state === "open";
const watching = link.watch !== undefined;
return (
<div
className={cn(PULL_REQUEST_ROW_CLASS, "relative hover:bg-accent/60")}
@@ -116,10 +128,21 @@ function LinkRow({
}
title={snapshot?.title ?? link.repository}
signals={
snapshot?.state === "open" ? (
open ? (
<>
{snapshot.checksState ? <ChecksGlyph state={snapshot.checksState} /> : null}
{snapshot.reviewDecision ? (
{watching ? (
<Tooltip>
<TooltipTrigger render={<span className="inline-flex shrink-0" />}>
<EyeIcon role="img" aria-label="Watching" className="size-3.5" />
</TooltipTrigger>
<TooltipPopup>
Watching: the agent wakes when checks finish, someone comments, or the branch
conflicts
</TooltipPopup>
</Tooltip>
) : null}
{snapshot?.checksState ? <ChecksGlyph state={snapshot.checksState} /> : null}
{snapshot?.reviewDecision ? (
<PullRequestReviewDecisionGlyph decision={snapshot.reviewDecision} />
) : null}
</>
@@ -220,6 +243,12 @@ function LinkRow({
<ArrowUpRightIcon className="size-3.5" />
Open
</MenuItem>
{onSetWatching !== null && open ? (
<MenuItem onClick={() => onSetWatching(link, !watching)}>
{watching ? <EyeOffIcon className="size-3.5" /> : <EyeIcon className="size-3.5" />}
{watching ? "Stop watching" : "Watch for changes"}
</MenuItem>
) : null}
<MenuItem onClick={() => onUnlink(link)}>
<PullRequestGlyph.unlink className="size-3.5" />
{link.source === "stack" ? "Dismiss from thread" : "Unlink from thread"}
@@ -248,6 +277,10 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
const thread = useThreadShell(threadRef);
const openLinkDialog = useCallback(() => openLinkPullRequestDialog(threadRef), [threadRef]);
const unlink = useAtomCommand(threadEnvironment.unlinkPullRequest, { reportFailure: true });
const watch = useAtomCommand(threadEnvironment.watchPullRequest, { reportFailure: true });
const supportsWatch =
useServerConfigs().get(threadRef.environmentId)?.environment.capabilities
.threadPullRequestWatch === true;
const links = useMemo(() => visibleThreadPullRequests(thread?.pullRequests ?? []), [thread]);
const lines = useMemo(() => pullRequestListLines(resolveThreadPullRequestChains(links)), [links]);
const handleUnlink = useCallback(
@@ -264,6 +297,21 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
},
[threadRef, unlink],
);
const handleSetWatching = useCallback(
(link: ThreadPullRequestLink, watching: boolean) => {
void watch({
environmentId: threadRef.environmentId,
input: {
threadId: threadRef.threadId,
host: link.host,
repository: link.repository,
number: link.number,
watching,
},
});
},
[threadRef, watch],
);
const openCount = useMemo(
() => links.filter((link) => link.snapshot === null || link.snapshot.state === "open").length,
[links],
@@ -304,6 +352,7 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
line={line}
threadRef={threadRef}
onUnlink={handleUnlink}
onSetWatching={supportsWatch ? handleSetWatching : null}
/>
))}
</div>