Skip to content
TypeScript

fix(web): long pull request lists no longer hide thread details controls (#20031)

Tanner Polley3dd9706af0b3
diff --git a/apps/web/src/components/chat/ThreadDetailsCard.tsx b/apps/web/src/components/chat/ThreadDetailsCard.tsx
index 95697af6abb..20b989caf7e 100644
--- a/apps/web/src/components/chat/ThreadDetailsCard.tsx
+++ b/apps/web/src/components/chat/ThreadDetailsCard.tsx
@@ -91,8 +91,13 @@ export function ThreadDetailsCard({
const measure = () => {
const frame = element.closest<HTMLElement>("[data-thread-details-card]");
const next = element.offsetHeight + (frame ? frame.offsetHeight - frame.clientHeight : 0);
- const lineage = element.querySelector<HTMLElement>("[data-thread-relationships-panel]");
- const fittingHeight = next - (lineage?.offsetHeight ?? 0);
+ // PR lists and lineage scroll as they expand. Counting them toward density would hide
+ // the section and workspace controls when the user asks to see more rows.
+ const lists = element.querySelectorAll<HTMLElement>(
+ "[data-thread-relationships-panel], [data-thread-details-pr-list]",
+ );
+ const fittingHeight =
+ next - Array.from(lists).reduce((sum, list) => sum + list.offsetHeight, 0);
setMeasurements((current) => {
const heights = current.key === measurementKey ? current.heights : { full: 0, compact: 0 };
const fullContentHeight =
diff --git a/apps/web/src/components/chat/ThreadDetailsPrRows.browser.test.tsx b/apps/web/src/components/chat/ThreadDetailsPrRows.browser.test.tsx
index 8da4e948d23..60bc23b71e4 100644
--- a/apps/web/src/components/chat/ThreadDetailsPrRows.browser.test.tsx
+++ b/apps/web/src/components/chat/ThreadDetailsPrRows.browser.test.tsx
@@ -1,36 +1,96 @@
import { EnvironmentId, ThreadId, type ThreadPullRequestLink } from "@t3tools/contracts";
-import { act } from "react";
+import { act, type ComponentProps } from "react";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, expect, it, vi } from "vite-plus/test";
+import { page, userEvent } from "vite-plus/test/browser";
+import "~/index.css";
const watchCommand = vi.hoisted(() => vi.fn());
+const fixture = vi.hoisted(() => ({ realRows: false }));
-// The row queries its own pull request; this test covers only which rows the list shows.
-vi.mock(import("./ThreadDetailsPrRow"), async (importOriginal) => ({
- ...(await importOriginal()),
- ThreadDetailsPrRow: ({
- number,
- onStopWatching,
- }: {
- number: number;
- onStopWatching?: (() => void) | undefined;
- }) => (
- <div data-row={String(number)}>
- {onStopWatching ? <button onClick={onStopWatching}>Stop watching #{number}</button> : null}
- </div>
- ),
-}));
+// List-only cases isolate query-backed rows; the density case uses their real layout.
+vi.mock(import("./ThreadDetailsPrRow"), async (importOriginal) => {
+ const actual = await importOriginal();
+ return {
+ ...actual,
+ ThreadDetailsPrRow: (props: ComponentProps<typeof actual.ThreadDetailsPrRow>) =>
+ fixture.realRows ? (
+ <actual.ThreadDetailsPrRow {...props} />
+ ) : (
+ <div data-row={String(props.number)}>
+ {props.onStopWatching ? (
+ <button onClick={props.onStopWatching}>Stop watching #{props.number}</button>
+ ) : null}
+ </div>
+ ),
+ };
+});
vi.mock(import("~/state/entities"), async (importOriginal) => ({
...(await importOriginal()),
useProjects: () => [],
+ useQuietThreadShell: (() => ({
+ environmentId: "environment",
+ projectId: "project",
+ worktreePath: null,
+ })) as never,
+ useProject: (() => ({ workspaceRoot: "/tmp/project" })) as never,
+ useThreadShellsForProjectRefs: () => [],
}));
vi.mock(import("~/state/use-atom-command"), async (importOriginal) => ({
...(await importOriginal()),
useAtomCommand: (() => watchCommand) as never,
}));
+vi.mock(import("./ChatCanvasContext"), async (original) => ({
+ ...(await original()),
+ useChatCanvas: (() => ({
+ container: { width: 1800, height: 500 },
+ lane: { padding: 48, minChatWidth: 640 },
+ layout: { frame: null },
+ })) as never,
+}));
+vi.mock(import("../../hooks/useT3ProjectFileScripts"), async (original) => ({
+ ...(await original()),
+ useT3ProjectFileScripts: () => [],
+}));
+vi.mock(import("./ThreadAutomationsPanel"), () => ({ ThreadAutomationsPanel: () => null }));
+vi.mock(import("./ThreadRelationshipsControl"), () => ({ ThreadRelationshipsPanel: () => null }));
+vi.mock(import("../pullRequest/usePullRequestActions"), async (original) => ({
+ ...(await original()),
+ usePullRequestHandoffs: () => ({ handoff: null, startAsk: vi.fn(), startHandoff: vi.fn() }),
+}));
+vi.mock(import("../BranchToolbarBranchSelector"), () => ({
+ BranchToolbarBranchSelector: () => (
+ <ThreadDetailsPrRows
+ threadRef={threadRef}
+ links={manyLinks}
+ currentLink={manyLinks[0]!}
+ onOpenLink={vi.fn()}
+ environmentId={threadRef.environmentId}
+ pr={null}
+ number={1}
+ reference={manyLinks[0]!}
+ status={null}
+ project={null}
+ label="#1"
+ openAriaLabel="Open pull request #1"
+ onOpen={vi.fn()}
+ />
+ ),
+}));
+
+import { PopoverCreateHandle } from "../ui/popover";
+import { ThreadDetailsPanel } from "./ThreadDetailsPanel";
import { ThreadDetailsPrRows } from "./ThreadDetailsPrRows";
+const threadRef = {
+ environmentId: EnvironmentId.make("environment"),
+ threadId: ThreadId.make("thread"),
+};
+const manyLinks = Array.from({ length: 70 }, (_, i) =>
+ link(i + 1, `branch-${i + 1}`, "main", "2026-01-01T00:00:00.000Z"),
+);
+
function link(
number: number,
headBranch: string,
@@ -73,6 +133,7 @@ afterEach(() => {
act(() => root.unmount());
container.remove();
vi.unstubAllGlobals();
+ fixture.realRows = false;
});
function render(links: ReadonlyArray<ThreadPullRequestLink>, current: ThreadPullRequestLink) {
@@ -166,3 +227,58 @@ it("lets only watched pull requests stop their watch", () => {
},
});
});
+
+it("keeps workspace controls after expanding and collapsing 70 linked pull requests", async () => {
+ fixture.realRows = true;
+ container.style.cssText = "position:relative;width:1800px;height:500px";
+ await act(async () => {
+ root.render(
+ <ThreadDetailsPanel
+ {...threadRef}
+ anchor={{ current: null }}
+ handle={PopoverCreateHandle()}
+ onPresentationChange={vi.fn()}
+ activeProjectName={undefined}
+ activeProjectScripts={undefined}
+ preferredScriptId={null}
+ keybindings={[]}
+ availableEditors={[]}
+ showOpenInPicker
+ gitCwd="/tmp/project"
+ isGitRepo
+ envLocked={false}
+ availableEnvironments={[]}
+ onEnvironmentChange={vi.fn()}
+ onEnvModeChange={vi.fn()}
+ envMode="local"
+ startFromOrigin={false}
+ onStartFromOriginChange={vi.fn()}
+ onComposerFocusRequest={vi.fn()}
+ onRunProjectScript={vi.fn()}
+ onAddProjectScript={vi.fn()}
+ onUpdateProjectScript={vi.fn()}
+ onDeleteProjectScript={vi.fn()}
+ />,
+ );
+ });
+ const runContext = page.getByRole("button", { name: "Run context" });
+ const editor = page.getByRole("group", { name: "Open in editor" });
+ await expect.element(runContext).toBeVisible();
+ await expect.element(editor).toBeVisible();
+
+ await userEvent.click(page.getByRole("button", { name: "Show 69 more" }));
+ await expect.element(page.getByRole("button", { name: "Show less" })).toBeInTheDocument();
+ const extraRows = () =>
+ container.querySelectorAll('[aria-label^="https://github.com/pingdotgg/t3code/pull/"]');
+ expect(extraRows()).toHaveLength(69);
+ // Let native ResizeObserver deliver the expanded content size before collapsing it.
+ await act(async () => {
+ await new Promise((resolve) => requestAnimationFrame(() => requestAnimationFrame(resolve)));
+ });
+ await userEvent.click(page.getByRole("button", { name: "Show less" }));
+ await expect.element(page.getByRole("button", { name: "Show 69 more" })).toBeVisible();
+ expect(extraRows()).toHaveLength(0);
+ await expect.element(page.getByRole("button", { name: "Open pull request #1" })).toBeVisible();
+ await expect.element(runContext).toBeVisible();
+ await expect.element(editor).toBeVisible();
+});
diff --git a/apps/web/src/components/chat/ThreadDetailsPrRows.tsx b/apps/web/src/components/chat/ThreadDetailsPrRows.tsx
index c653411ce65..8dfb4623801 100644
--- a/apps/web/src/components/chat/ThreadDetailsPrRows.tsx
+++ b/apps/web/src/components/chat/ThreadDetailsPrRows.tsx
@@ -101,8 +101,9 @@ export function ThreadDetailsPrRows({
return (
<>
{currentRow}
- {expanded
- ? rest.map((link) => (
+ {expanded ? (
+ <div data-thread-details-pr-list className="flex flex-col">
+ {rest.map((link) => (
<ThreadDetailsPrLinkRow
key={threadPullRequestKeyOf(link)}
environmentId={row.environmentId}
@@ -111,8 +112,9 @@ export function ThreadDetailsPrRows({
onActed={row.onActed}
onStopWatching={stopWatching(link)}
/>
- ))
- : null}
+ ))}
+ </div>
+ ) : null}
<ThreadDetailsControl
variant="ghost"
size="sm"