Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions apps/web/src/components/chat/ThreadDetailsCard.browser.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ function Card({
rows = 1,
automationRows = 0,
serverOverflowRows = 0,
issueListRows = 0,
}: {
threadRef: ScopedThreadRef;
inline: boolean;
Expand All @@ -55,6 +56,8 @@ function Card({
automationRows?: number;
/** Rows of 100px that expanded server lists add, which density ignores. */
serverOverflowRows?: number;
/** Rows of 100px that expanded linked issues add, which density ignores. */
issueListRows?: number;
}) {
return (
// The web root renders in StrictMode, which re-runs ref callbacks on every mount.
Expand Down Expand Up @@ -92,6 +95,9 @@ function Card({
style={{ height: serverOverflowRows * 100 }}
/>
) : null}
{issueListRows > 0 ? (
<div data-thread-details-issue-list style={{ height: issueListRows * 100 }} />
) : null}
</>
)}
</ThreadDetailsCard>
Expand Down Expand Up @@ -196,3 +202,13 @@ it("stays full while expanded server rows overflow", async () => {
.element(page.getByRole("region", { name: "Thread details" }))
.toHaveAttribute("data-density", "full");
});

it("stays full while expanded issue rows overflow", async () => {
using fixture = setup();
await using _screen = await render(
<Card threadRef={threadB} inline fixture={fixture} rows={2} issueListRows={6} />,
);
await expect
.element(page.getByRole("region", { name: "Thread details" }))
.toHaveAttribute("data-density", "full");
});
6 changes: 3 additions & 3 deletions apps/web/src/components/chat/ThreadDetailsCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,10 +80,10 @@ export function ThreadDetailsCard({
const measure = () => {
const frame = element.closest<HTMLElement>("[data-thread-details-card]");
const next = element.offsetHeight + (frame ? frame.offsetHeight - frame.clientHeight : 0);
// PR lists, servers, lineage, side chats and automations scroll as they grow. Counting them
// toward density would hide the section and workspace controls when the user asks to see more.
// PR and issue lists, servers, lineage, side chats and automations scroll as they grow.
// Counting them toward density would hide the section and workspace controls when the user asks to see more.
const lists = element.querySelectorAll<HTMLElement>(
"[data-thread-relationships-panel], [data-thread-side-chats-panel], [data-thread-details-pr-list], [data-thread-automations-panel], [data-thread-details-server-overflow]",
"[data-thread-relationships-panel], [data-thread-side-chats-panel], [data-thread-details-pr-list], [data-thread-details-issue-list], [data-thread-automations-panel], [data-thread-details-server-overflow]",
);
const fittingHeight =
next - Array.from(lists).reduce((sum, list) => sum + list.offsetHeight, 0);
Expand Down
40 changes: 22 additions & 18 deletions apps/web/src/components/chat/ThreadDetailsIssueRows.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -160,27 +160,31 @@ export function ThreadDetailsIssueRows({
const [expandedThread, setExpandedThread] = useState<string | null>(null);
const threadKey = scopedThreadKey(threadRef);
const expanded = expandedThread === threadKey;
const hasMore = compact && links.length > 1;
const visibleLinks = hasMore && !expanded ? links.slice(0, 1) : links;
const row = (link: ThreadIssueLink) => (
<LinkedIssueRow
key={threadIssueKeyOf(link)}
link={link}
threadRef={threadRef}
compact={compact}
mountScope={mountScope}
onOpen={onOpen}
/>
);
const [first, ...rest] = links;
if (first === undefined || !compact || rest.length === 0) return <>{links.map(row)}</>;
return (
<>
{visibleLinks.map((link) => (
<LinkedIssueRow
key={threadIssueKeyOf(link)}
link={link}
threadRef={threadRef}
compact={compact}
mountScope={mountScope}
onOpen={onOpen}
/>
))}
{hasMore ? (
<ThreadDetailsMoreButton
expanded={expanded}
remaining={links.length - 1}
onToggle={() => setExpandedThread(expanded ? null : threadKey)}
/>
{row(first)}
{expanded ? (
<div data-thread-details-issue-list className="flex flex-col">
{rest.map(row)}
</div>
) : null}
<ThreadDetailsMoreButton
expanded={expanded}
remaining={rest.length}
onToggle={() => setExpandedThread(expanded ? null : threadKey)}
/>
</>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -455,6 +455,8 @@ it("names the first linked issue and reveals more issues on demand", async () =>
await expect.element(extra).not.toBeInTheDocument();
await screen.getByRole("button", { name: "Show 1 more" }).click();
await expect.element(extra).toBeVisible();
// The details card leaves this list out of its density measurement.
expect(extra.element().closest("[data-thread-details-issue-list]")).not.toBeNull();
await screen.getByRole("button", { name: "Show less" }).click();
await expect.element(extra).not.toBeInTheDocument();
});
Expand Down
Loading