Skip to content

Database governance built for humans and agents — controlling changes and access across every major database.

fix(plan): clarify thread hierarchy and activity spacing (#21542)

boojacka3bd659b796c
diff --git a/frontend/src/components/issue-activity/IssueCommentActivity.tsx b/frontend/src/components/issue-activity/IssueCommentActivity.tsx
index 1512d4a30d..0c5215446e 100644
--- a/frontend/src/components/issue-activity/IssueCommentActivity.tsx
+++ b/frontend/src/components/issue-activity/IssueCommentActivity.tsx
@@ -120,18 +120,20 @@ export function canEditIssueComment(
// and the left icon gutter around an arbitrary body.
export function ActivityRowFrame({
children,
+ compact = false,
icon,
id,
isLast,
}: {
children: ReactNode;
+ compact?: boolean;
icon: ReactNode;
id?: string;
isLast: boolean;
}) {
return (
<li>
- <div className="relative pb-3" id={id}>
+ <div className="relative pb-4" id={id}>
{!isLast && (
<span
aria-hidden="true"
@@ -139,7 +141,7 @@ export function ActivityRowFrame({
/>
)}
<div className="relative flex items-start">
- <div className="pt-1.5">{icon}</div>
+ <div className={cn(!compact && "pt-1.5")}>{icon}</div>
<div className="min-w-0 flex-1">{children}</div>
</div>
</div>
@@ -167,7 +169,7 @@ export function ActivityRowShell({
subjectSuffix?: ReactNode;
}) {
return (
- <ActivityRowFrame icon={icon} id={id} isLast={isLast}>
+ <ActivityRowFrame compact={!body} icon={icon} id={id} isLast={isLast}>
<div
className={cn(
"overflow-hidden rounded-sm border",
@@ -176,7 +178,12 @@ export function ActivityRowShell({
: "ml-1 border-transparent"
)}
>
- <div className={cn("px-3 py-2", body && "flex flex-col gap-y-2")}>
+ <div
+ className={cn(
+ "px-3",
+ body ? "flex flex-col gap-y-2 py-2" : "flex min-h-7 items-center"
+ )}
+ >
<div
className={cn(
"flex items-center justify-between gap-x-2",
diff --git a/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.test.tsx b/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.test.tsx
index 260a709716..c4378ec5c6 100644
--- a/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.test.tsx
+++ b/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.test.tsx
@@ -115,10 +115,10 @@ vi.mock("../../shared/stores/usePlanDetailStore", () => ({
vi.mock("../threads/CommentThreadCard", () => ({
CommentThreadCard: ({
- context,
+ renderContext,
thread,
}: {
- context: ReactNode;
+ renderContext?: (onCollapse?: () => void) => ReactNode;
thread: { root: { name: string }; replies: { name: string }[] };
}) => (
<div
@@ -126,7 +126,7 @@ vi.mock("../threads/CommentThreadCard", () => ({
data-root={thread.root.name}
data-testid="thread-card"
>
- {context}
+ {renderContext?.()}
</div>
),
}));
diff --git a/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsx b/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsx
index ab8ac18034..9951deb1ba 100644
--- a/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsx
+++ b/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsx
@@ -547,17 +547,20 @@ function ThreadActivityRow({
>
<CommentThreadCard
className="ml-3"
- context={
- anchor && (
- <StatementAnchorContext
- anchor={anchor}
- onViewInStatement={viewInStatement}
- placement={placement}
- plan={plan}
- renderPlanChangeReference={renderPlanChangeReference}
- project={project}
- />
- )
+ renderContext={
+ anchor
+ ? (onCollapse) => (
+ <StatementAnchorContext
+ anchor={anchor}
+ onCollapse={onCollapse}
+ onViewInStatement={viewInStatement}
+ placement={placement}
+ plan={plan}
+ renderPlanChangeReference={renderPlanChangeReference}
+ project={project}
+ />
+ )
+ : undefined
}
issue={issue}
project={project}
diff --git a/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.css b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.css
new file mode 100644
index 0000000000..091e90d9cc
--- /dev/null
+++ b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.css
@@ -0,0 +1,3 @@
+.bb-thread-replies .markdown-body {
+ background-color: transparent;
+}
diff --git a/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.test.tsx b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.test.tsx
index 69bd62de45..46f41ad405 100644
--- a/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.test.tsx
+++ b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.test.tsx
@@ -219,7 +219,7 @@ describe("CommentThreadCard", () => {
issue={issue}
project={project}
thread={thread}
- context={<div data-testid="anchor-context">SELECT 1;</div>}
+ renderContext={() => <div data-testid="anchor-context">SELECT 1;</div>}
/>
);
const card = container.querySelector("[data-testid='comment-thread']");
@@ -264,6 +264,11 @@ describe("CommentThreadCard", () => {
container.querySelectorAll("[data-testid='preview']")
).map((node) => node.textContent);
expect(bodies).toEqual(["Root question", "First reply", "Second reply"]);
+ const comments = container.querySelectorAll("[data-testid='thread-comment']");
+ const replies = container.querySelector("[data-testid='thread-replies']");
+ expect(replies?.contains(comments[0])).toBe(false);
+ expect(replies?.contains(comments[1])).toBe(true);
+ expect(replies?.contains(comments[2])).toBe(true);
expect(container.querySelector("[data-thread-state]")?.getAttribute("data-thread-state")).toBe("open");
expect(buttonByText("plan.review.thread.resolve")).toBeDefined();
expect(buttonByText("plan.review.thread.reply-placeholder")).toBeDefined();
@@ -288,6 +293,28 @@ describe("CommentThreadCard", () => {
expect(buttonByText("plan.review.thread.resolve")).toBeUndefined();
});
+ test("a resolved anchored thread collapses from its context header", () => {
+ const [thread] = groupThreads([comment("root", "Root", { resolved: true })]);
+ render(
+ <CommentThreadCard
+ issue={issue}
+ project={project}
+ renderContext={(onCollapse) => (
+ <button data-testid="context-collapse" onClick={onCollapse} type="button">
+ Collapse context
+ </button>
+ )}
+ thread={thread}
+ />
+ );
+ click(buttonByText("plan.review.thread.resolved"));
+ expect(container.querySelector("[data-testid='context-collapse']")).not.toBeNull();
+ expect(container.querySelectorAll('button[aria-label="common.collapse"]')).toHaveLength(0);
+ click(container.querySelector("[data-testid='context-collapse']"));
+ expect(container.querySelector("[data-testid='context-collapse']")).toBeNull();
+ expect(container.querySelector("[data-testid='preview']")).toBeNull();
+ });
+
test("roots and replies share header avatars and a full-width body", () => {
const [thread] = groupThreads([comment("root", "Root"), comment("r1", "Reply", { root: rootName })]);
render(<CommentThreadCard issue={issue} project={project} thread={thread} />);
diff --git a/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsx b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsx
index f19a12c55d..f9d6054d80 100644
--- a/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsx
+++ b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsx
@@ -30,6 +30,7 @@ import { cn } from "@/lib/utils";
import { getTimeForPbTimestampProtoEs, unknownUser } from "@/types";
import type { Issue } from "@/types/proto-es/v1/issue_service_pb";
import type { Project } from "@/types/proto-es/v1/project_service_pb";
+import "./CommentThreadCard.css";
import { ThreadComment } from "./ThreadComment";
import type { CommentThread } from "./threadModel";
import {
@@ -50,7 +51,7 @@ const FOLD_REPLIES_ABOVE = 4;
export function CommentThreadCard({
className,
collapsible = true,
- context,
+ renderContext,
issue,
label,
onClose,
@@ -64,7 +65,7 @@ export function CommentThreadCard({
// Whether a resolved thread may collapse to its summary row.
collapsible?: boolean;
// Full-width statement context above the root author and discussion.
- context?: ReactNode;
+ renderContext?: (onCollapse?: () => void) => ReactNode;
issue: Issue;
// Extra header text after the timestamp (the anchored line range).
label?: ReactNode;
@@ -210,15 +211,19 @@ export function CommentThreadCard({
data-thread-state={thread.resolved ? "resolved" : "open"}
id={thread.root.name}
>
- {context && (
+ {renderContext && (
<div className="min-w-0 overflow-hidden rounded-t-sm border-b border-block-border">
- {context}
+ {renderContext(
+ thread.resolved && collapsible
+ ? () => setCollapsed(true)
+ : undefined
+ )}
</div>
)}
<ThreadComment
actions={
<>
- {thread.resolved && collapsible && (
+ {thread.resolved && collapsible && !renderContext && (
<Button
aria-label={t("common.collapse")}
onClick={() => setCollapsed(true)}
@@ -255,29 +260,37 @@ export function CommentThreadCard({
</>
}
/>
- {hiddenCount > 0 && (
- <div className="flex justify-center border-t border-block-border bg-control-bg/50 py-1">
- <Button
- onClick={() => setShowAllReplies(true)}
- size="xs"
- appearance="link"
- >
- <ChevronDown className="size-3.5" />
- {t("plan.review.thread.n-replies-hidden", { count: hiddenCount })}
- <span className="text-control-placeholder">·</span>
- {t("plan.review.activity.show-all")}
- </Button>
+ {(hiddenCount > 0 || visibleReplies.length > 0) && (
+ <div
+ className="bb-thread-replies bg-control-bg/50"
+ data-testid="thread-replies"
+ >
+ {hiddenCount > 0 && (
+ <div className="flex justify-center py-1">
+ <Button
+ onClick={() => setShowAllReplies(true)}
+ size="xs"
+ appearance="link"
+ >
+ <ChevronDown className="size-3.5" />
+ {t("plan.review.thread.n-replies-hidden", {
+ count: hiddenCount,
+ })}
+ <span className="text-control-placeholder">·</span>
+ {t("plan.review.activity.show-all")}
+ </Button>
+ </div>
+ )}
+ {visibleReplies.map((reply) => (
+ <ThreadComment
+ comment={reply}
+ key={reply.name}
+ onEdit={actions.edit}
+ project={project}
+ />
+ ))}
</div>
)}
- {visibleReplies.map((reply) => (
- <ThreadComment
- className="border-t border-block-border"
- comment={reply}
- key={reply.name}
- onEdit={actions.edit}
- project={project}
- />
- ))}
{(allowReply || allowSettle) && (
<div
className="flex flex-wrap items-center gap-2 border-t border-block-border bg-control-bg/50 px-2 py-2 sm:px-3"
diff --git a/frontend/src/routes/project/plan-detail/components/threads/StatementAnchorContext.test.tsx b/frontend/src/routes/project/plan-detail/components/threads/StatementAnchorContext.test.tsx
index 12136e46af..7521b7c52c 100644
--- a/frontend/src/routes/project/plan-detail/components/threads/StatementAnchorContext.test.tsx
+++ b/frontend/src/routes/project/plan-detail/components/threads/StatementAnchorContext.test.tsx
@@ -1,5 +1,5 @@
import { create } from "@bufbuild/protobuf";
-import { cleanup, render, waitFor } from "@testing-library/react";
+import { cleanup, fireEvent, render, waitFor } from "@testing-library/react";
import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";
import { Plan_ChangeDatabaseConfigSchema, Plan_SpecSchema, PlanSchema } from "@/types/proto-es/v1/plan_service_pb";
import { ProjectSchema } from "@/types/proto-es/v1/project_service_pb";
@@ -61,6 +61,22 @@ beforeEach(() => {
afterEach(cleanup);
describe("StatementAnchorContext", () => {
+ test("places the collapse action in the statement context header", () => {
+ const onCollapse = vi.fn();
+ const { container, getByRole } = render(
+ <StatementAnchorContext
+ {...props}
+ anchor={anchor(2, 2)}
+ onCollapse={onCollapse}
+ placement={OUTDATED}
+ />
+ );
+ const button = getByRole("button", { name: "common.collapse" });
+ expect(container.querySelector("[data-testid='statement-anchor']")?.firstElementChild?.contains(button)).toBe(true);
+ fireEvent.click(button);
+ expect(onCollapse).toHaveBeenCalledOnce();
+ });
+
test.each([
{ start: 1, end: 1, displayed: [1], selected: [1], label: "Line 1" },
{ start: 2, end: 2, displayed: [1, 2], selected: [2], label: "Line 2" },
diff --git a/frontend/src/routes/project/plan-detail/components/threads/StatementAnchorContext.tsx b/frontend/src/routes/project/plan-detail/components/threads/StatementAnchorContext.tsx
index 7383a41010..307d9dd323 100644
--- a/frontend/src/routes/project/plan-detail/components/threads/StatementAnchorContext.tsx
+++ b/frontend/src/routes/project/plan-detail/components/threads/StatementAnchorContext.tsx
@@ -1,4 +1,4 @@
-import { Ban, ExternalLink, History } from "lucide-react";
+import { Ban, ChevronUp, ExternalLink, History } from "lucide-react";
import { useEffect, useMemo, useState } from "react";
import { useTranslation } from "react-i18next";
import type { PlanChangeReferenceRenderer } from "@/components/issue-activity/IssueCommentActivity";
@@ -31,6 +31,7 @@ import {
// highlight at the comment's current placement.
export function StatementAnchorContext({
anchor,
+ onCollapse,
onViewInStatement,
placement,
plan,
@@ -38,6 +39,7 @@ export function StatementAnchorContext({
renderPlanChangeReference,
}: {
anchor: StatementAnchor;
+ onCollapse?: () => void;
onViewInStatement?: () => void;
placement: Placement | undefined;
plan: Plan;
@@ -101,6 +103,16 @@ export function StatementAnchorContext({
onViewInStatement={onViewInStatement}
state={state}
/>
+ {onCollapse && (
+ <Button
+ aria-label={t("common.collapse")}
+ onClick={onCollapse}
+ size="xs"
+ appearance="secondary"
+ >
+ <ChevronUp className="size-3.5" />
+ </Button>
+ )}
</div>
</div>
{!isLoading && statement && range && (