Skip to content

Commit fe7b6ef

Browse files
only21milcodex
andcommitted
fix(web): show linked pull request state in command palette rows
Co-Authored-By: GPT-6.1 Sol <[email protected]>
1 parent 05696c6 commit fe7b6ef

2 files changed

Lines changed: 73 additions & 2 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import { EnvironmentId, type ThreadPullRequestLink } from "@t3tools/contracts";
2+
import { expect, it, vi } from "vite-plus/test";
3+
4+
import { render } from "../../test/render";
5+
import { AppAtomRegistryProvider } from "../rpc/atomRegistry";
6+
import { makeThreadFixture } from "../test-fixtures";
7+
import { ThreadRowLeadingStatus } from "./ThreadStatusIndicators";
8+
9+
const environmentId = EnvironmentId.make("environment-test");
10+
11+
vi.mock(import("../state/entities"), async (original) => ({
12+
...(await original()),
13+
useProject: () => null,
14+
useServerConfigs: (() =>
15+
new Map([
16+
[environmentId, { environment: { capabilities: { threadPullRequests: true } } }],
17+
])) as never,
18+
}));
19+
20+
it("updates palette PR status from linked snapshots without a legacy link or branch PR", async () => {
21+
const link: ThreadPullRequestLink = {
22+
host: "github.com",
23+
repository: "example/repo",
24+
number: 7,
25+
url: "https://github.com/example/repo/pull/7",
26+
source: "manual",
27+
linkedAt: "2026-01-01T00:00:00Z",
28+
stack: null,
29+
snapshot: {
30+
state: "merged",
31+
title: "Linked change",
32+
headBranch: "deleted-branch",
33+
baseBranch: "main",
34+
isDraft: false,
35+
updatedAt: null,
36+
syncedAt: "2026-01-03T00:00:00Z",
37+
},
38+
};
39+
const row = (pullRequest: ThreadPullRequestLink) => (
40+
<AppAtomRegistryProvider>
41+
<ThreadRowLeadingStatus
42+
thread={makeThreadFixture({
43+
environmentId,
44+
linkedPullRequest: null,
45+
branchPullRequest: null,
46+
pullRequests: [pullRequest],
47+
})}
48+
/>
49+
</AppAtomRegistryProvider>
50+
);
51+
await using screen = await render(row(link));
52+
await expect.element(screen.getByLabelText("PR #7 - Merged: Linked change")).toBeVisible();
53+
await expect.element(screen.getByLabelText("PR #7, status pending")).not.toBeInTheDocument();
54+
55+
await screen.rerender(row({ ...link, snapshot: null }));
56+
await expect.element(screen.getByLabelText("PR #7, status pending")).toBeVisible();
57+
await expect
58+
.element(screen.getByLabelText("PR #7 - Merged: Linked change"))
59+
.not.toBeInTheDocument();
60+
61+
await screen.rerender(
62+
row({ ...link, snapshot: { ...link.snapshot!, state: "open", isDraft: true } }),
63+
);
64+
await expect.element(screen.getByLabelText("PR #7 - Draft: Linked change")).toBeVisible();
65+
await expect.element(screen.getByLabelText("PR #7, status pending")).not.toBeInTheDocument();
66+
});

‎apps/web/src/components/ThreadStatusIndicators.tsx‎

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,8 @@ export function ThreadRowLeadingStatus({
885885
thread.environmentId,
886886
thread.linkedPullRequest,
887887
leaseLiveStatus,
888+
thread.pullRequests,
889+
thread.branchPullRequest,
888890
);
889891
const gitStatus = useEnvironmentQuery(
890892
leaseLiveStatus &&
@@ -909,8 +911,11 @@ export function ThreadRowLeadingStatus({
909911
linkedPullRequest: thread.linkedPullRequest,
910912
linkedPullRequestStatus: linkedPullRequest,
911913
};
912-
const pr = resolveDisplayedThreadPr(displayedPrInput);
913-
const prStatus = prStatusIndicator(pr, resolveDisplayedThreadPrProvider(displayedPrInput));
914+
const pr = linkedPullRequest?.pr ?? resolveDisplayedThreadPr(displayedPrInput);
915+
const prStatus = prStatusIndicator(
916+
pr,
917+
linkedPullRequest?.sourceControlProvider ?? resolveDisplayedThreadPrProvider(displayedPrInput),
918+
);
914919
const threadStatus = resolveThreadStatusPill({
915920
thread: {
916921
...thread,

0 commit comments

Comments
 (0)