Skip to content

Commit 3331b93

Browse files
only21milcodex
andauthored
fix(web): show linked pull request state in command palette rows (#23156)
Co-authored-by: GPT-6.1 Sol <[email protected]>
1 parent 549b651 commit 3331b93

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
@@ -674,6 +674,8 @@ export function ThreadRowLeadingStatus({ thread }: { thread: SidebarThreadSummar
674674
thread.environmentId,
675675
thread.linkedPullRequest,
676676
leaseLiveStatus,
677+
thread.pullRequests,
678+
thread.branchPullRequest,
677679
);
678680
const gitStatus = useEnvironmentQuery(
679681
leaseLiveStatus &&
@@ -696,8 +698,11 @@ export function ThreadRowLeadingStatus({ thread }: { thread: SidebarThreadSummar
696698
linkedPullRequest: thread.linkedPullRequest,
697699
linkedPullRequestStatus: linkedPullRequest,
698700
};
699-
const pr = resolveDisplayedThreadPr(displayedPrInput);
700-
const prStatus = prStatusIndicator(pr, resolveDisplayedThreadPrProvider(displayedPrInput));
701+
const pr = linkedPullRequest?.pr ?? resolveDisplayedThreadPr(displayedPrInput);
702+
const prStatus = prStatusIndicator(
703+
pr,
704+
linkedPullRequest?.sourceControlProvider ?? resolveDisplayedThreadPrProvider(displayedPrInput),
705+
);
701706
const threadStatus = resolveThreadStatusPill({
702707
thread: {
703708
...thread,

0 commit comments

Comments
 (0)