TypeScript
fix(web): show linked pull request state in command palette rows (#23156)
Victor Vogel3331b9393755
diff --git a/apps/web/src/components/ThreadStatusIndicators.linkedPr.browser.test.tsx b/apps/web/src/components/ThreadStatusIndicators.linkedPr.browser.test.tsxnew file mode 100644index 00000000000..2f690d88f5b--- /dev/null+++ b/apps/web/src/components/ThreadStatusIndicators.linkedPr.browser.test.tsx@@ -0,0 +1,66 @@+import { EnvironmentId, type ThreadPullRequestLink } from "@t3tools/contracts";+import { expect, it, vi } from "vite-plus/test";++import { render } from "../../test/render";+import { AppAtomRegistryProvider } from "../rpc/atomRegistry";+import { makeThreadFixture } from "../test-fixtures";+import { ThreadRowLeadingStatus } from "./ThreadStatusIndicators";++const environmentId = EnvironmentId.make("environment-test");++vi.mock(import("../state/entities"), async (original) => ({+ ...(await original()),+ useProject: () => null,+ useServerConfigs: (() =>+ new Map([+ [environmentId, { environment: { capabilities: { threadPullRequests: true } } }],+ ])) as never,+}));++it("updates palette PR status from linked snapshots without a legacy link or branch PR", async () => {+ const link: ThreadPullRequestLink = {+ host: "github.com",+ repository: "example/repo",+ number: 7,+ url: "https://github.com/example/repo/pull/7",+ source: "manual",+ linkedAt: "2026-01-01T00:00:00Z",+ stack: null,+ snapshot: {+ state: "merged",+ title: "Linked change",+ headBranch: "deleted-branch",+ baseBranch: "main",+ isDraft: false,+ updatedAt: null,+ syncedAt: "2026-01-03T00:00:00Z",+ },+ };+ const row = (pullRequest: ThreadPullRequestLink) => (+ <AppAtomRegistryProvider>+ <ThreadRowLeadingStatus+ thread={makeThreadFixture({+ environmentId,+ linkedPullRequest: null,+ branchPullRequest: null,+ pullRequests: [pullRequest],+ })}+ />+ </AppAtomRegistryProvider>+ );+ await using screen = await render(row(link));+ await expect.element(screen.getByLabelText("PR #7 - Merged: Linked change")).toBeVisible();+ await expect.element(screen.getByLabelText("PR #7, status pending")).not.toBeInTheDocument();++ await screen.rerender(row({ ...link, snapshot: null }));+ await expect.element(screen.getByLabelText("PR #7, status pending")).toBeVisible();+ await expect+ .element(screen.getByLabelText("PR #7 - Merged: Linked change"))+ .not.toBeInTheDocument();++ await screen.rerender(+ row({ ...link, snapshot: { ...link.snapshot!, state: "open", isDraft: true } }),+ );+ await expect.element(screen.getByLabelText("PR #7 - Draft: Linked change")).toBeVisible();+ await expect.element(screen.getByLabelText("PR #7, status pending")).not.toBeInTheDocument();+});diff --git a/apps/web/src/components/ThreadStatusIndicators.tsx b/apps/web/src/components/ThreadStatusIndicators.tsxindex 0af0e063bde..ea49b01665b 100644--- a/apps/web/src/components/ThreadStatusIndicators.tsx+++ b/apps/web/src/components/ThreadStatusIndicators.tsx@@ -674,6 +674,8 @@ export function ThreadRowLeadingStatus({ thread }: { thread: SidebarThreadSummarthread.environmentId,thread.linkedPullRequest,leaseLiveStatus,+ thread.pullRequests,+ thread.branchPullRequest,);const gitStatus = useEnvironmentQuery(leaseLiveStatus &&@@ -696,8 +698,11 @@ export function ThreadRowLeadingStatus({ thread }: { thread: SidebarThreadSummarlinkedPullRequest: thread.linkedPullRequest,linkedPullRequestStatus: linkedPullRequest,};- const pr = resolveDisplayedThreadPr(displayedPrInput);- const prStatus = prStatusIndicator(pr, resolveDisplayedThreadPrProvider(displayedPrInput));+ const pr = linkedPullRequest?.pr ?? resolveDisplayedThreadPr(displayedPrInput);+ const prStatus = prStatusIndicator(+ pr,+ linkedPullRequest?.sourceControlProvider ?? resolveDisplayedThreadPrProvider(displayedPrInput),+ );const threadStatus = resolveThreadStatusPill({thread: {...thread,