The best way to control Claude Code, Codex and more from any computer or phone
perf(pr): PR panel paints from saved data and reads ahead on intent (#32911)
Co-authored-by: maria-rcks <maria@kuuro.net> Co-authored-by: Shivam Sharma <91240327+shivamhwp@users.noreply.github.com> Co-authored-by: Julius Marminge <julius0216@outlook.com> Co-authored-by: Julius Marminge <51714798+juliusmarminge@users.noreply.github.com>
Bilal Bakr committed
Nov 17, 2026 at 01:52 UTC
4b22bb47d42bb442d76f378104f8928cb27ed42c
13 files changed
+235
-25
apps/mobile/src/features/pull-requests/usePullRequestStack.ts
+8
-1
@@ -1,6 +1,8 @@
1
import { threadPullRequestLinkMode } from "@t3tools/client-runtime/thread-pull-request-compatibility";
2
import type { PullRequestDetail } from "@t3tools/contracts";
3
import { sourceControlClients } from "@t3tools/client-runtime/source-control-clients";
4
+import { useAtomValue } from "@effect/atom-react";
5
+import { Atom } from "effect/reactivity";
6
import { useMemo } from "react";
7
import { useEnvironmentServerConfig, useNavigationThreadShells } from "../../state/entities";
8
import { pullRequestStackAtom } from "../../state/pull-requests";
@@ -8,6 +10,8 @@ import { useEnvironmentQuery } from "../../state/query";
10
import { savedPullRequestStack } from "./pullRequestStack";
11
import { pullRequestTarget, type PullRequestParams } from "./usePullRequestDiff";
12
13
+const NOT_ANSWERED = Atom.make(false);
14
+
15
export function usePullRequestStack(params: PullRequestParams, pr: PullRequestDetail | null) {
16
const target = pullRequestTarget(params);
17
const config = useEnvironmentServerConfig(target.environmentId);
@@ -37,11 +41,14 @@ export function usePullRequestStack(params: PullRequestParams, pr: PullRequestDe
41
const query = useEnvironmentQuery(
42
supported ? pullRequestStackAtom({ ...target, input: reference }) : null,
43
);
44
+ const answered = useAtomValue(
45
+ supported ? pullRequestStackAtom.answered({ ...target, input: reference }) : NOT_ANSWERED,
46
+ );
47
const stack = query.isSuccess ? query.data : (query.data ?? saved);
48
return {
49
...query,
50
stack,
44
- isFresh: supported && query.isSuccess && !query.isPending,
51
+ isFresh: supported && query.isSuccess && !query.isPending && answered,
52
supportsStackActions: supported && pr?.capabilities.stackActions === true,
53
};
54
}
apps/web/src/components/pullRequest/PullRequestDetailLayout.tsx
+14
-2
@@ -1,5 +1,5 @@
1
import { ArrowLeftIcon, FileDiffIcon } from "lucide-react";
2
-import type { ComponentProps, ReactNode } from "react";
2
+import { useEffect, useRef, type ComponentProps, type ReactNode } from "react";
3
4
import { cn } from "~/lib/utils";
5
@@ -77,6 +77,10 @@ export function PullRequestDetailTabBar<Tab extends string>({
77
inert?: boolean;
78
children?: ReactNode;
79
}) {
80
+ // A pointer passing over a tab is not intent; it must rest like a list row does.
81
+ const pointerIntent = useRef<ReturnType<typeof setTimeout> | undefined>(undefined);
82
+ // oxlint-disable-next-line t3code/no-unreasoned-state-sync -- A rest timer still pending when the bar unmounts must not read for a closed panel.
83
+ useEffect(() => () => clearTimeout(pointerIntent.current), []);
84
return (
85
<nav
86
className="col-span-2 flex min-w-0 flex-wrap items-center gap-2 border-t border-border/60 px-4 py-2"
@@ -97,7 +101,15 @@ export function PullRequestDetailTabBar<Tab extends string>({
101
<Toggle
102
key={tab.value}
103
value={tab.value}
100
- onPointerEnter={onTabIntent ? () => onTabIntent(tab.value) : undefined}
104
+ onPointerEnter={
105
+ onTabIntent
106
+ ? () => {
107
+ clearTimeout(pointerIntent.current);
108
+ pointerIntent.current = setTimeout(() => onTabIntent(tab.value), 150);
109
+ }
110
+ : undefined
111
+ }
112
+ onPointerLeave={onTabIntent ? () => clearTimeout(pointerIntent.current) : undefined}
113
onFocus={onTabIntent ? () => onTabIntent(tab.value) : undefined}
114
>
115
{tab.label}
apps/web/src/components/pullRequest/PullRequestDetailPanel.permissions.browser.test.tsx
+36
-2
@@ -7,11 +7,13 @@ import {
7
type PullRequestDetailView,
8
} from "@t3tools/contracts";
9
import { expect, it, vi } from "vite-plus/test";
10
+import { userEvent } from "vite-plus/test/browser";
11
import { DraftId, useComposerDraftStore } from "~/composerDraftStore";
11
-import { act, render } from "../../../test/render";
12
+import { act, fakeTimers, render } from "../../../test/render";
13
13
-const { permissions } = vi.hoisted(() => ({
14
+const { permissions, reads } = vi.hoisted(() => ({
15
permissions: { checkout: true, operate: true },
16
+ reads: { diff: [] as unknown[] },
17
}));
18
19
vi.mock(import("~/state/session"), async (original) => ({
@@ -51,6 +53,19 @@ vi.mock(import("~/state/usePullRequestStack"), async (original) => ({
53
refresh: vi.fn(),
54
})) as never,
55
}));
56
+vi.mock(import("~/state/pullRequests"), async (original) => {
57
+ const actual = await original();
58
+ return {
59
+ ...actual,
60
+ pullRequestEnvironment: {
61
+ ...actual.pullRequestEnvironment,
62
+ diff: ((target: unknown) => {
63
+ reads.diff.push(target);
64
+ return actual.pullRequestEnvironment.diff(target as never);
65
+ }) as never,
66
+ },
67
+ };
68
+});
69
vi.mock(import("~/state/use-atom-command"), async (original) => ({
70
...(await original()),
71
useAtomCommand: (() => vi.fn()) as never,
@@ -133,6 +148,7 @@ const panel = (attach = false) => (
148
function setup() {
149
permissions.checkout = true;
150
permissions.operate = true;
151
+ reads.diff = [];
152
useComposerDraftStore.setState({ draftsByThreadKey: {} });
153
}
154
@@ -162,3 +178,21 @@ it("can still add conflict resolution to an existing composer without checkout s
178
expect(draft?.prompt).toContain("conflicts");
179
expect(draft?.prompt).toContain(detail.url);
180
});
181
+
182
+it("reads the first diff page once the pointer rests on the Code tab", async () => {
183
+ setup();
184
+ await using screen = await render(panel());
185
+ using _timers = fakeTimers({ now: 0 });
186
+ const code = screen.getByRole("button", { name: "Code", exact: true });
187
+ await expect.element(code).toBeVisible();
188
+
189
+ await userEvent.hover(code);
190
+ await act(() => vi.advanceTimersByTime(149));
191
+ expect(reads.diff).toEqual([]);
192
+ await act(() => vi.advanceTimersByTime(1));
193
+ // The page the Code tab reads first, keyed as the tab keys it, so a click paints from it.
194
+ expect(reads.diff).toContainEqual({
195
+ environmentId,
196
+ input: { projectId: detail.projectId, repository: detail.repository, number: detail.number },
197
+ });
198
+});
apps/web/src/components/pullRequest/PullRequestDetailPanel.tsx
+10
-1
@@ -472,6 +472,13 @@ export function PullRequestDetailPanel({
472
} else if (!tabMountState.tabs.has(tab)) {
473
setTabMountState({ key: tabScopeKey, tabs: new Set(tabMountState.tabs).add(tab) });
474
}
475
+ // A pointer on the Code tab reads the page it opens on; only intent costs the host a read.
476
+ const [codeIntentKey, setCodeIntentKey] = useState<string | null>(null);
477
+ useEnvironmentQuery(
478
+ codeIntentKey === pullRequestKey && !mountedTabs.has("code")
479
+ ? pullRequestEnvironment.diff({ environmentId, input: { ...reference } })
480
+ : null,
481
+ );
482
// Each tab restores the condensed state its own scrolling left behind.
483
const [condensedByTab, setCondensedByTab] = useState<
484
Partial<Record<PullRequestDetailTab, boolean>>
@@ -1714,7 +1721,9 @@ export function PullRequestDetailPanel({
1721
value={tab}
1722
onValueChange={selectTab}
1723
onTabIntent={(item) => {
1717
- if (item === "code") void loadCodeTab();
1724
+ if (item !== "code") return;
1725
+ void loadCodeTab();
1726
+ setCodeIntentKey(pullRequestKey);
1727
}}
1728
>
1729
{tab === "summary" ? (
apps/web/src/components/pullRequest/PullRequestRow.tsx
+3
-3
@@ -14,6 +14,7 @@ import { getSourceControlPresentationForKind } from "~/sourceControlPresentation
14
15
import { Tooltip, TooltipPopup, TooltipTrigger } from "../ui/tooltip";
16
import { PullRequestChecksPopover } from "./PullRequestChecksPopover";
17
+import { pullRequestPanelReference } from "./usePullRequestDetail";
18
import type { EnvironmentPullRequestEntry } from "./pullRequestList.logic";
19
import { openOnHostLabel, showPullRequestLinkContextMenu } from "./pullRequestLinkContextMenu";
20
import {
@@ -164,9 +165,8 @@ function PullRequestRowImpl({
165
checksState={entry.checksState}
166
environmentId={entry.environmentId}
167
reference={{
167
- projectId: entry.projectId,
168
- repository: entry.repository,
169
- number: entry.number,
168
+ ...pullRequestPanelReference({ ...entry, host: entry.host.toLowerCase() }),
169
+ allowStale: false,
170
}}
171
/>
172
)}
apps/web/src/components/pullRequest/PullRequestStackMenu.tsx
+3
-2
@@ -81,6 +81,7 @@ export function PullRequestStackMenu({
81
mergeHasClosed ||
82
mergeLayers.length === 0 ||
83
mergeLayers.some((layer) => layer.isDraft);
84
+ const staleReason = notice ?? "Checking the stack with the host…";
85
const rebaseDisabled = pending || stale || hasUnknownHead || hasClosed || unmerged.length === 0;
86
const run = async () => {
87
if (
@@ -218,7 +219,7 @@ export function PullRequestStackMenu({
219
size="xs"
220
disabled={mergeDisabled && !stale}
221
aria-disabled={mergeDisabled || undefined}
221
- aria-description={stale ? (notice ?? undefined) : undefined}
222
+ aria-description={stale ? staleReason : undefined}
223
onClick={mergeDisabled ? undefined : () => setConfirmation("merge")}
224
>
225
<PullRequestGlyph.merged aria-hidden className="size-3.5" />
@@ -229,7 +230,7 @@ export function PullRequestStackMenu({
230
/>
231
<TooltipPopup>
232
{stale
232
- ? notice
233
+ ? staleReason
234
: `Merge stack through #${reference.number} into ${stack.base} (${mergeLayers.length} ${mergeLayers.length === 1 ? terminology.singular : terminology.plural})`}
235
</TooltipPopup>
236
</Tooltip>
apps/web/src/components/pullRequest/ThreadPullRequestsPanel.tsx
+55
-2
@@ -27,7 +27,10 @@ import {
27
} from "~/components/chat/composerMentionDrag";
28
import { writeTextToClipboard } from "~/hooks/useCopyToClipboard";
29
import { findProjectForChangeRequest } from "@t3tools/client-runtime/change-request-links";
30
-import { useOpenPrLink } from "~/lib/openPullRequestLink";
30
+import { pullRequestLinkPanelTarget, useOpenPrLink } from "~/lib/openPullRequestLink";
31
+import { useClientSettings } from "~/hooks/useSettings";
32
+import { usePrimaryEnvironmentId } from "~/state/environments";
33
+import { usePullRequestIntentPrefetch } from "./usePullRequestIntentPrefetch";
34
import { cn } from "~/lib/utils";
35
import { useShortcutModifierState } from "~/shortcutModifierState";
36
import { useProjects, useServerConfigs, useThreadShell } from "~/state/entities";
@@ -93,6 +96,7 @@ function LinkRowImpl({
96
speedMode,
97
onUnlink,
98
onSetWatching,
99
+ onIntent,
100
canStartWatch,
101
}: {
102
line: PullRequestListLine;
@@ -101,6 +105,7 @@ function LinkRowImpl({
105
speedMode: boolean;
106
onUnlink: (link: ThreadPullRequestLink) => void;
107
onSetWatching: ((link: ThreadPullRequestLink, watching: boolean) => void) | null;
108
+ onIntent: (link: ThreadPullRequestLink | null) => void;
109
canStartWatch: boolean;
110
}) {
111
const openPrLink = useOpenPrLink(threadRef);
@@ -134,6 +139,14 @@ function LinkRowImpl({
139
return (
140
<div
141
className={cn(PULL_REQUEST_ROW_CLASS, "relative hover:bg-accent/60")}
142
+ onPointerEnter={() => onIntent(link)}
143
+ onPointerLeave={(event) => {
144
+ if (!event.currentTarget.contains(document.activeElement)) onIntent(null);
145
+ }}
146
+ onFocus={() => onIntent(link)}
147
+ onBlur={(event) => {
148
+ if (!event.currentTarget.matches(":hover")) onIntent(null);
149
+ }}
150
onContextMenu={(event) => {
151
event.preventDefault();
152
event.stopPropagation();
@@ -400,6 +413,37 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
413
const unlink = useAtomCommand(threadEnvironment.unlinkPullRequest, { reportFailure: true });
414
const watch = useAtomCommand(threadEnvironment.watchPullRequest, { reportFailure: true });
415
const capabilities = useServerConfigs().get(threadRef.environmentId)?.environment.capabilities;
416
+ const primaryEnvironmentId = usePrimaryEnvironmentId();
417
+ const opensInApp = useClientSettings((settings) => settings.pullRequestLinksOpenInApp);
418
+ const prefetch = usePullRequestIntentPrefetch((target) =>
419
+ links.some(
420
+ (link) =>
421
+ link.number === target.number &&
422
+ link.repository.toLowerCase() === target.repository.toLowerCase(),
423
+ ),
424
+ );
425
+ const intendLink = (link: ThreadPullRequestLink | null) => {
426
+ const target =
427
+ link === null || !opensInApp
428
+ ? null
429
+ : pullRequestLinkPanelTarget({
430
+ url: link.url,
431
+ environmentId: threadRef.environmentId,
432
+ primaryEnvironmentId,
433
+ lendHostProject: true,
434
+ });
435
+ prefetch(
436
+ target?.host === undefined
437
+ ? null
438
+ : {
439
+ environmentId: target.project.environmentId,
440
+ projectId: target.project.id,
441
+ host: target.host,
442
+ repository: target.repository,
443
+ number: target.number,
444
+ },
445
+ );
446
+ };
447
const supportsWatch = capabilities?.threadPullRequestWatch === true;
448
const canStartWatch = thread !== null && canStartThreadPullRequestWatch(thread);
449
const handleUnlink = (link: ThreadPullRequestLink) => {
@@ -427,7 +471,15 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
471
};
472
473
// Legend rows update only for data/extraData changes; include all external inputs.
430
- const rowInputs = { speedMode, environmentProjects, capabilities, supportsWatch, thread };
474
+ const rowInputs = {
475
+ speedMode,
476
+ environmentProjects,
477
+ capabilities,
478
+ supportsWatch,
479
+ thread,
480
+ opensInApp,
481
+ primaryEnvironmentId,
482
+ };
483
484
if (linkCount === 0) {
485
return (
@@ -469,6 +521,7 @@ function EnabledThreadPullRequestsPanel({ threadRef }: { threadRef: ScopedThread
521
speedMode={speedMode}
522
onUnlink={handleUnlink}
523
onSetWatching={supportsWatch ? handleSetWatching : null}
524
+ onIntent={intendLink}
525
canStartWatch={canStartWatch}
526
/>
527
)}
apps/web/src/components/pullRequest/pullRequestStackSnapshot.test.ts
+3
-2
@@ -88,10 +88,11 @@ describe("saved stack navigation", () => {
88
isFresh: true,
89
notice: null,
90
});
91
- expect(pullRequestStackView({ ...query, isPending: true }, saved).isFresh).toBe(true);
91
+ // A shown answer being read again may be one restored from the device, so it cannot clear a merge.
92
+ expect(pullRequestStackView({ ...query, isPending: true }, saved).isFresh).toBe(false);
93
expect(pullRequestStackView({ ...query, data: null, isPending: true }, saved)).toMatchObject({
94
data: null,
94
- isFresh: true,
95
+ isFresh: false,
96
});
97
});
98
});
apps/web/src/components/pullRequest/pullRequestStackSnapshot.ts
+2
-1
@@ -59,7 +59,8 @@ export function pullRequestStackView(
59
const data = query.isSuccess ? query.data : (query.data ?? saved);
60
return {
61
data,
62
- isFresh: query.isSuccess,
62
+ // A settled read: one still out may be showing an answer restored from the device.
63
+ isFresh: query.isSuccess && !query.isPending,
64
notice:
65
data === null
66
? null
apps/web/src/lib/openPullRequestLink.ts
+22
-7
@@ -40,6 +40,27 @@ export function usePullRequestPreviewTarget(environmentId: EnvironmentId | null,
40
});
41
}
42
43
+/** Where a click on this link opens the in-app panel, read at call time as the click reads it. */
44
+export function pullRequestLinkPanelTarget(input: {
45
+ readonly url: string;
46
+ readonly environmentId: EnvironmentId | undefined;
47
+ readonly primaryEnvironmentId: EnvironmentId | null;
48
+ readonly lendHostProject: boolean;
49
+}) {
50
+ // Read at click time: every provider status push replaces the config map, and
51
+ // subscribing would hand every rendered link a new handler. Projects likewise, so a
52
+ // link can resolve against a snapshot that arrived after this handler was built.
53
+ const serverConfigs = appAtomRegistry.get(environmentServerConfigsAtom);
54
+ return resolveChangeRequestLinkTarget({
55
+ url: input.url,
56
+ projects: readProjects(),
57
+ configLoaded: (environmentId) => serverConfigs.has(environmentId),
58
+ environmentId: input.environmentId,
59
+ primaryEnvironmentId: input.primaryEnvironmentId,
60
+ lendHostProject: input.lendHostProject,
61
+ });
62
+}
63
+
64
function shouldOpenPullRequestExternally(
65
event: Pick<MouseEvent<HTMLElement>, "metaKey" | "ctrlKey"> &
66
Partial<Pick<MouseEvent<HTMLElement>, "button">>,
@@ -76,14 +97,8 @@ export function useOpenChangeRequestLink(
97
const resolvedThreadRef = targetThreadRef ?? threadRef;
98
const resolvedPanelRef = panelRef ?? resolvedThreadRef;
99
const openPullRequest = () => {
79
- // Read at click time: every provider status push replaces the config map, and
80
- // subscribing would hand every rendered link a new handler. Projects likewise, so a
81
- // link can resolve against a snapshot that arrived after this handler was built.
82
- const serverConfigs = appAtomRegistry.get(environmentServerConfigsAtom);
83
- const target = resolveChangeRequestLinkTarget({
100
+ const target = pullRequestLinkPanelTarget({
101
url: targetUrl,
85
- projects: readProjects(),
86
- configLoaded: (environmentId) => serverConfigs.has(environmentId),
102
environmentId: resolvedThreadRef?.environmentId ?? targetEnvironmentId,
103
primaryEnvironmentId,
104
lendHostProject: resolvedPanelRef !== undefined,
apps/web/src/state/usePullRequestStack.ts
+10
-1
@@ -10,6 +10,8 @@ import { pullRequestStackAtom } from "./pullRequests";
10
import { useEnvironmentQuery } from "./query";
11
import { environmentThreadShells } from "./threads";
12
13
+const NOT_ANSWERED = Atom.make(false);
14
+
15
const sameLinks = Schema.toEquivalence(Schema.Array(ThreadPullRequestLink));
16
17
// Shell pushes recreate link arrays; reuse equal lists so streaming does not re-render the stack.
@@ -34,5 +36,12 @@ export function usePullRequestStack(
36
const query = useEnvironmentQuery(
37
reference === null ? null : pullRequestStackAtom({ environmentId, input: reference }),
38
);
37
- return { ...query, ...pullRequestStackView(query, saved) };
39
+ const answered = useAtomValue(
40
+ reference === null
41
+ ? NOT_ANSWERED
42
+ : pullRequestStackAtom.answered({ environmentId, input: reference }),
43
+ );
44
+ const view = pullRequestStackView(query, saved);
45
+ // A saved answer paints; merging waits for this session's own host answer.
46
+ return { ...query, ...view, isFresh: view.isFresh && answered };
47
}
packages/client-runtime/src/state/pullRequests.test.ts
+50
@@ -45,6 +45,7 @@ import {
45
applyPullRequestSummaryEdits,
46
createLinkedPullRequestSummaryAtomFamily,
47
createPullRequestEnvironmentAtoms,
48
+ createPullRequestStackAtomFamily,
49
editHeldPullRequestListEntries,
50
heldPullRequestListEntriesAtom,
51
pullRequestHostAnswer,
@@ -2930,3 +2931,52 @@ it.effect.each(["accepted", "refused"] as const)(
2931
}),
2932
),
2933
);
2934
+
2935
+it.effect("paints a saved stack answer at once while the host read is out", () =>
2936
+ Effect.scoped(
2937
+ Effect.gen(function* () {
2938
+ const saved = new Map<string, string>();
2939
+ const store = {
2940
+ load: (_environmentId: EnvironmentId, key: string) =>
2941
+ Effect.sync(() => Option.fromUndefinedOr(saved.get(key))),
2942
+ save: (_environmentId: EnvironmentId, key: string, payload: string) =>
2943
+ Effect.sync(() => void saved.set(key, payload)),
2944
+ };
2945
+ const earlier = yield* makeTestRuntime(
2946
+ {
2947
+ [WS_METHODS.pullRequestsStack]: () => Effect.succeed(null),
2948
+ } as unknown as WsRpcProtocolClient,
2949
+ undefined,
2950
+ false,
2951
+ {},
2952
+ store,
2953
+ );
2954
+ const target = { environmentId: TARGET.environmentId, input: actionReference };
2955
+ const stacks = createPullRequestStackAtomFamily(earlier.runtime);
2956
+ const first = stacks(target);
2957
+ earlier.registry.mount(first);
2958
+ yield* Effect.promise(() => executeAtomQuery(earlier.registry, first));
2959
+ expect(earlier.registry.get(stacks.answered(target))).toBe(true);
2960
+
2961
+ // A later session finds the answer saved while its own read waits on the host.
2962
+ const sent = yield* Deferred.make<void>();
2963
+ const waiting = yield* makeTestRuntime(
2964
+ {
2965
+ [WS_METHODS.pullRequestsStack]: () =>
2966
+ Deferred.succeed(sent, undefined).pipe(Effect.andThen(Effect.never)),
2967
+ } as unknown as WsRpcProtocolClient,
2968
+ undefined,
2969
+ false,
2970
+ {},
2971
+ store,
2972
+ );
2973
+ const waitingStacks = createPullRequestStackAtomFamily(waiting.runtime);
2974
+ const stack = waitingStacks(target);
2975
+ waiting.registry.mount(stack);
2976
+ yield* Deferred.await(sent);
2977
+ expect(waiting.registry.get(stack)).toMatchObject({ _tag: "Success", value: null });
2978
+ // Offline, a saved answer settles without the host; only a host answer may clear a merge.
2979
+ expect(waiting.registry.get(waitingStacks.answered(target))).toBe(false);
2980
+ }),
2981
+ ),
2982
+);
packages/client-runtime/src/state/pullRequests.ts
+19
-1
@@ -4,6 +4,7 @@ import {
4
PullRequestDetail as PullRequestDetailSchema,
5
PullRequestPreview,
6
PullRequestReviewGuideResult,
7
+ PullRequestStack,
8
PullRequestListResult,
9
PullRequestChecks,
10
PullRequestDiffResult,
@@ -776,14 +777,31 @@ export function createPullRequestStackAtomFamily<R, E>(
777
refreshes = createPullRequestRefreshAtomFamily(runtime),
778
) {
779
const routedRequest = createPullRequestRouter();
779
- return createEnvironmentRpcQueryAtomFamily(runtime, {
780
+ const hostAnswers = Atom.family((_key: string) =>
781
+ Atom.make(false).pipe(Atom.setIdleTTL(5 * 60_000)),
782
+ );
783
+ const answeredKey = (target: {
784
+ readonly environmentId: EnvironmentId;
785
+ readonly input: PullRequestRef;
786
+ }) => JSON.stringify([target.environmentId, target.input]);
787
+ const stack = createEnvironmentRpcQueryAtomFamily(runtime, {
788
label: "environment-data:pull-requests:stack",
789
+ // A saved answer paints at once; `answered` stays false until the host answers.
790
+ persistence: persistQuery(Schema.NullOr(PullRequestStack)),
791
tag: WS_METHODS.pullRequestsStack,
792
execute: (input) => routedRequest(WS_METHODS.pullRequestsStack, input),
793
staleTimeMs: 60_000,
794
idleTtlMs: LINKED_PULL_REQUEST_IDLE_TTL_MS,
795
refreshTrigger: ({ environmentId }) => refreshes({ environmentId, input: {} }),
796
+ onAnswer: (target, _value, registry) =>
797
+ Effect.sync(() => registry.set(hostAnswers(answeredKey(target)), true)),
798
});
799
+ /** Whether this session has the host's own answer, which is what merging one layer alone needs. */
800
+ const answered = (target: {
801
+ readonly environmentId: EnvironmentId;
802
+ readonly input: PullRequestRef;
803
+ }) => hostAnswers(answeredKey(target));
804
+ return Object.assign(stack, { answered });
805
}
806
807
export function pullRequestDetailToVcsStatus(