@devries-cameron20 / t3code Mirror · read-only / commits / c342f3dec2
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 21, 14:45 UTC

fix(web): settled threads no longer offer a PR watch the server refuses (#29867)

Co-authored-by: Julius Marminge <julius0216@outlook.com>

Alex Southwell committed Nov 15, 2026 at 02:20 UTC c342f3dec2c99f8060f5f52bc12190c7ee8661cd
4 files changed +49 -9
apps/mobile/src/features/threads/useLinkedPullRequestActions.ts
+5 -8
@@ -11,7 +11,10 @@ import {
11 squashAtomCommandFailure,
12 type AtomCommandResult,
13 } from "@t3tools/client-runtime/state/runtime";
14 -import { planThreadPullRequestMutation } from "@t3tools/client-runtime/thread-pull-request-compatibility";
14 +import {
15 + canStartThreadPullRequestWatch,
16 + planThreadPullRequestMutation,
17 +} from "@t3tools/client-runtime/thread-pull-request-compatibility";
18 import {
19 capitalizeTerm,
20 sourceControlClients,
@@ -43,13 +46,7 @@ export function useLinkedPullRequestActions(input: {
46 );
47 const canEdit = canOperate && capabilities !== undefined;
48 const canWatch = canOperate && capabilities?.threadPullRequestWatch === true;
46 - const canStartWatch =
47 - canWatch &&
48 - thread !== null &&
49 - thread.archivedAt === null &&
50 - thread.settledAt === null &&
51 - thread.settledOverride !== "settled" &&
52 - thread.lineage.relationshipToParent !== "subagent";
49 + const canStartWatch = canWatch && thread !== null && canStartThreadPullRequestWatch(thread);
50 const link = useAtomCommand(threadEnvironment.linkPullRequest, { reportFailure: false });
51 const unlink = useAtomCommand(threadEnvironment.unlinkPullRequest, { reportFailure: false });
52 const watch = useAtomCommand(threadEnvironment.watchPullRequest, { reportFailure: false });
apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx
+6 -1
@@ -9,6 +9,7 @@ import {
9 resolveThreadPullRequestChains,
10 visibleThreadPullRequests,
11 } from "@t3tools/client-runtime/thread-pull-requests";
12 +import { canStartThreadPullRequestWatch } from "@t3tools/client-runtime/thread-pull-request-compatibility";
13 import {
14 ArrowUpRightIcon,
15 EyeIcon,
@@ -92,6 +93,7 @@ function LinkRowImpl({
93 speedMode,
94 onUnlink,
95 onSetWatching,
96 + canStartWatch,
97 }: {
98 line: PullRequestListLine;
99 threadRef: ScopedThreadRef;
@@ -99,6 +101,7 @@ function LinkRowImpl({
101 speedMode: boolean;
102 onUnlink: (link: ThreadPullRequestLink) => void;
103 onSetWatching: ((link: ThreadPullRequestLink, watching: boolean) => void) | null;
104 + canStartWatch: boolean;
105 }) {
106 const openPrLink = useOpenPrLink(threadRef);
107 const [menuOpen, setMenuOpen] = useState(false);
@@ -330,7 +333,7 @@ function LinkRowImpl({
333 <ArrowUpRightIcon className="size-3.5" />
334 Open
335 </MenuItem>
333 - {onSetWatching !== null && open ? (
336 + {onSetWatching !== null && open && (watching || canStartWatch) ? (
337 <MenuItem onClick={() => onSetWatching(link, !watching)}>
338 {watching ? <EyeOffIcon className="size-3.5" /> : <EyeIcon className="size-3.5" />}
339 {watching ? "Stop watching" : "Watch for changes"}
@@ -398,6 +401,7 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
401 const watch = useAtomCommand(threadEnvironment.watchPullRequest, { reportFailure: true });
402 const capabilities = useServerConfigs().get(threadRef.environmentId)?.environment.capabilities;
403 const supportsWatch = capabilities?.threadPullRequestWatch === true;
404 + const canStartWatch = thread !== null && canStartThreadPullRequestWatch(thread);
405 const handleUnlink = (link: ThreadPullRequestLink) => {
406 void unlink({
407 environmentId: threadRef.environmentId,
@@ -465,6 +469,7 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
469 speedMode={speedMode}
470 onUnlink={handleUnlink}
471 onSetWatching={supportsWatch ? handleSetWatching : null}
472 + canStartWatch={canStartWatch}
473 />
474 )}
475 estimatedItemSize={44}
packages/client-runtime/src/threadPullRequestCompatibility.test.ts
+25
@@ -2,6 +2,7 @@ import type { ExecutionEnvironmentCapabilities } from "@t3tools/contracts";
2 import { ThreadId } from "@t3tools/contracts";
3 import { describe, expect, it } from "@effect/vitest";
4 import {
5 + canStartThreadPullRequestWatch,
6 planThreadPullRequestMutation,
7 threadPullRequestLinkMode,
8 } from "./threadPullRequestCompatibility.ts";
@@ -57,4 +58,28 @@ describe("thread pull request capability negotiation", () => {
58 },
59 });
60 });
61 +
62 + it("offers a new watch only where the server accepts one", () => {
63 + const active = {
64 + archivedAt: null,
65 + settledAt: null,
66 + settledOverride: null,
67 + lineage: { parentThreadId: null, relationshipToParent: null, rootThreadId: input.threadId },
68 + } as const;
69 + expect(canStartThreadPullRequestWatch(active)).toBe(true);
70 + expect(canStartThreadPullRequestWatch({ ...active, settledOverride: "active" })).toBe(true);
71 + expect(canStartThreadPullRequestWatch({ ...active, settledOverride: "settled" })).toBe(false);
72 + expect(canStartThreadPullRequestWatch({ ...active, settledAt: "2026-01-01T00:00:00Z" })).toBe(
73 + false,
74 + );
75 + expect(canStartThreadPullRequestWatch({ ...active, archivedAt: "2026-01-01T00:00:00Z" })).toBe(
76 + false,
77 + );
78 + expect(
79 + canStartThreadPullRequestWatch({
80 + ...active,
81 + lineage: { ...active.lineage, relationshipToParent: "subagent" },
82 + }),
83 + ).toBe(false);
84 + });
85 });
packages/client-runtime/src/threadPullRequestCompatibility.ts
+13
@@ -3,6 +3,7 @@ import type {
3 ThreadId,
4 ThreadPullRequestKey,
5 } from "@t3tools/contracts";
6 +import type { EnvironmentThreadShell } from "./state/models.ts";
7 import { normalizeThreadPullRequestKey } from "./threadPullRequests.ts";
8
9 /** "unsupported" until the environment's server config has loaded. */
@@ -12,6 +13,18 @@ export function threadPullRequestLinkMode(
13 return capabilities ? ("multiple" as const) : ("unsupported" as const);
14 }
15
16 +/** The server refuses new watches on settled, archived, and subagent threads. */
17 +export function canStartThreadPullRequestWatch(
18 + thread: Pick<EnvironmentThreadShell, "archivedAt" | "settledAt" | "settledOverride" | "lineage">,
19 +): boolean {
20 + return (
21 + thread.archivedAt === null &&
22 + thread.settledAt === null &&
23 + thread.settledOverride !== "settled" &&
24 + thread.lineage.relationshipToParent !== "subagent"
25 + );
26 +}
27 +
28 export function planThreadPullRequestMutation({
29 capabilities,
30 threadId,