Database governance built for humans and agents — controlling changes and access across every major database.
Go cicddata-governancedata-maskingdata-securitydatabase-accessdatabase-governancedevopsdevsecopsflywaygitopsliquibasemongodbmysqloraclepostgresqlschema-migrationssecuritysql-clientsqlservertidb
fix(plan): block inline comments before review submission (#21514)
boojacka6d838cba58f
diff --git a/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsx b/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsxindex 4cdec2a5b3..50a3e45a04 100644--- a/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsx+++ b/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsx@@ -565,7 +565,7 @@ function ThreadActivityRow({/>)}- issueName={issue.name}+ issue={issue}project={project}thread={thread}/>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.tsxindex 875f6496c7..913bb0b965 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@@ -7,6 +7,7 @@ import { afterEach, beforeEach, describe, expect, test, vi } from "vitest";import {IssueComment_ThreadState,IssueCommentSchema,+ IssueSchema,} from "@/types/proto-es/v1/issue_service_pb";import type { Project } from "@/types/proto-es/v1/project_service_pb";@@ -109,6 +110,7 @@ import { groupThreads } from "./threadModel";).IS_REACT_ACT_ENVIRONMENT = true;const ISSUE = "projects/p/issues/1";+const issue = create(IssueSchema, { name: ISSUE });const project = { name: "projects/p" } as Project;const comment = (@@ -182,11 +184,30 @@ const denySettle = () =>);describe("CommentThreadCard", () => {+ test("draft issues keep existing discussion visible and allow replies only after submission", async () => {+ const [thread] = groupThreads([+ comment("root", "Root question"),+ comment("reply", "Existing reply", { root: rootName }),+ ]);+ const props = { project, thread };+ render(<CommentThreadCard {...props} issue={create(IssueSchema, { ...issue, draft: true })} />);+ expect(container.textContent).toContain("Root question");+ expect(container.textContent).toContain("Existing reply");+ expect(buttonByText("plan.review.thread.reply-placeholder")).toBeUndefined();++ render(<CommentThreadCard {...props} issue={issue} replyDraft="New reply" />);+ click(buttonByText("plan.review.thread.reply-placeholder"));+ mocks.createIssueComment.mockResolvedValueOnce(comment("new-reply", "New reply", { root: rootName }));+ submitReply();+ await act(async () => {});+ expect(mocks.createIssueComment).toHaveBeenCalledExactlyOnceWith({ issueName: ISSUE, comment: "New reply", root: rootName });+ });+test("places statement context above the root author as a separate full-width region", () => {const [thread] = groupThreads([comment("root", "Root question")]);render(<CommentThreadCard- issueName={ISSUE}+ issue={issue}project={project}thread={thread}context={<div data-testid="anchor-context">SELECT 1;</div>}@@ -209,7 +230,7 @@ describe("CommentThreadCard", () => {comment("r1", "First reply", { root: rootName }),]);render(- <CommentThreadCard issueName={ISSUE} project={project} thread={thread} />+ <CommentThreadCard issue={issue} project={project} thread={thread} />);const bodies = Array.from(container.querySelectorAll("[data-testid='preview']")@@ -226,7 +247,7 @@ describe("CommentThreadCard", () => {comment("r1", "Reply", { root: rootName, creator: "users/[email protected]" }),]);render(- <CommentThreadCard issueName={ISSUE} project={project} thread={thread} />+ <CommentThreadCard issue={issue} project={project} thread={thread} />);expect(container.textContent).toContain("plan.review.thread.n-replies:1");expect(container.querySelector("[data-testid='preview']")).toBeNull();@@ -241,7 +262,7 @@ describe("CommentThreadCard", () => {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 issueName={ISSUE} project={project} thread={thread} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} />);const comments = container.querySelectorAll("[data-testid='thread-comment']");for (const comment of comments) {const content = comment.querySelector("[data-testid='comment-content']");@@ -254,17 +275,17 @@ describe("CommentThreadCard", () => {expect(container.querySelector("[data-testid='reply-composer-avatar']")).not.toBeNull();click(buttonByText("common.cancel"));expect(container.querySelector("[data-testid='reply-composer-avatar']")).toBeNull();- render(<CommentThreadCard issueName={ISSUE} project={project} thread={thread} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} />);expect(container.querySelector("[data-testid='thread-comment'] [data-testid='comment-avatar']")).not.toBeNull();});test("new replies do not hide replies already visible in a short thread", () => {const replies = Array.from({ length: 6 }, (_, index) => comment(`r${index}`, `Reply ${index}`, { root: rootName }));const [short] = groupThreads([comment("root", "Root"), ...replies.slice(0, 4)]);- render(<CommentThreadCard issueName={ISSUE} project={project} thread={short} />);+ render(<CommentThreadCard issue={issue} project={project} thread={short} />);expect(container.querySelectorAll("[data-testid='preview']")).toHaveLength(5);const [long] = groupThreads([comment("root", "Root"), ...replies]);- render(<CommentThreadCard issueName={ISSUE} project={project} thread={long} />);+ render(<CommentThreadCard issue={issue} project={project} thread={long} />);expect(container.querySelectorAll("[data-testid='preview']")).toHaveLength(7);});@@ -274,7 +295,7 @@ describe("CommentThreadCard", () => {);const [thread] = groupThreads([comment("root", "Root"), ...replies]);render(- <CommentThreadCard issueName={ISSUE} project={project} thread={thread} />+ <CommentThreadCard issue={issue} project={project} thread={thread} />);const visible = () =>Array.from(container.querySelectorAll("[data-testid='preview']")).map(@@ -297,7 +318,7 @@ describe("CommentThreadCard", () => {comment("root", "Root", { resolved: true }));render(- <CommentThreadCard issueName={ISSUE} project={project} thread={thread} />+ <CommentThreadCard issue={issue} project={project} thread={thread} />);click(buttonByText("plan.review.thread.reply-placeholder"));@@ -333,7 +354,7 @@ describe("CommentThreadCard", () => {const [thread] = groupThreads([comment("root", "Root", { resolved })]);const onThreadStateChanged = vi.fn();mocks.updateIssueComment.mockResolvedValue(comment("root", "Root", { resolved: !resolved }));- render(<CommentThreadCard issueName={ISSUE} project={project} thread={thread} collapsible={false} onThreadStateChanged={onThreadStateChanged} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} collapsible={false} onThreadStateChanged={onThreadStateChanged} />);click(buttonByText(resolved ? "common.reopen" : "plan.review.thread.resolve"));await act(async () => {});expect(onThreadStateChanged).toHaveBeenCalledExactlyOnceWith(!resolved);@@ -343,12 +364,12 @@ describe("CommentThreadCard", () => {const [thread] = groupThreads([comment("root", "Root")]);const onThreadStateChanged = vi.fn();mocks.updateIssueComment.mockRejectedValueOnce(new Error("offline"));- render(<CommentThreadCard issueName={ISSUE} project={project} thread={thread} collapsible={false} onThreadStateChanged={onThreadStateChanged} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} collapsible={false} onThreadStateChanged={onThreadStateChanged} />);click(buttonByText("plan.review.thread.resolve"));await act(async () => {});expect(onThreadStateChanged).not.toHaveBeenCalled();const [updated] = groupThreads([comment("root", "Root", {resolved: true})]);- render(<CommentThreadCard issueName={ISSUE} project={project} thread={updated} collapsible={false} onThreadStateChanged={onThreadStateChanged} />);+ render(<CommentThreadCard issue={issue} project={project} thread={updated} collapsible={false} onThreadStateChanged={onThreadStateChanged} />);expect(onThreadStateChanged).not.toHaveBeenCalled();expect(container.querySelector("[data-testid='preview']")).not.toBeNull();});@@ -358,7 +379,7 @@ describe("CommentThreadCard", () => {const onThreadStateChanged = vi.fn();let complete!: (value: ReturnType<typeof comment>) => void;mocks.updateIssueComment.mockReturnValueOnce(new Promise((resolve) => {complete = resolve;}));- render(<CommentThreadCard issueName={ISSUE} project={project} thread={thread} collapsible={false} onThreadStateChanged={onThreadStateChanged} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} collapsible={false} onThreadStateChanged={onThreadStateChanged} />);click(buttonByText("plan.review.thread.resolve"));render(<div />);await act(async () => {complete(comment("root", "Root", {resolved: true}));});@@ -373,7 +394,7 @@ describe("CommentThreadCard", () => {mocks.updateIssueComment.mockImplementationOnce(() => new Promise((resolve) => {finishState = resolve;}));const onReplyDraftChange = vi.fn();const onThreadStateChanged = vi.fn();- render(<CommentThreadCard issueName={ISSUE} project={project} thread={thread} collapsible={false} replyDraft="Decision details" onReplyDraftChange={onReplyDraftChange} onThreadStateChanged={onThreadStateChanged} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} collapsible={false} replyDraft="Decision details" onReplyDraftChange={onReplyDraftChange} onThreadStateChanged={onThreadStateChanged} />);// Open threads resolve when the box is ticked; resolved ones reopen by// default, so the box is left alone there.submitReply({ toggleState: !resolved });@@ -390,7 +411,7 @@ describe("CommentThreadCard", () => {test.each([false, true])("the composer checkbox mirrors the thread state: resolved=%s", (resolved) => {const [thread] = groupThreads([comment("root", "Root", { resolved })]);- render(<CommentThreadCard issueName={ISSUE} project={project} thread={thread} collapsible={false} replyDraft="Draft" onReplyDraftChange={vi.fn()} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} collapsible={false} replyDraft="Draft" onReplyDraftChange={vi.fn()} />);expect(stateCheckbox()?.getAttribute("aria-checked")).toBe(String(resolved));expect(container.querySelector("label")?.textContent).toBe(resolved ? "plan.review.thread.reopen-thread" : "plan.review.thread.resolve-thread"@@ -403,7 +424,7 @@ describe("CommentThreadCard", () => {const [thread] = groupThreads([comment("root", "Root")]);const onThreadStateChanged = vi.fn();mocks.createIssueComment.mockResolvedValueOnce(comment("reply", "Just a note", { root: rootName }));- render(<CommentThreadCard issueName={ISSUE} project={project} thread={thread} collapsible={false} replyDraft="Just a note" onReplyDraftChange={vi.fn()} onThreadStateChanged={onThreadStateChanged} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} collapsible={false} replyDraft="Just a note" onReplyDraftChange={vi.fn()} onThreadStateChanged={onThreadStateChanged} />);submitReply();await act(async () => {});expect(mocks.createIssueComment).toHaveBeenCalledTimes(1);@@ -416,7 +437,7 @@ describe("CommentThreadCard", () => {const onThreadStateChanged = vi.fn();mocks.createIssueComment.mockResolvedValue(comment("reply", "Not done yet", { root: rootName }));mocks.updateIssueComment.mockResolvedValueOnce(comment("root", "Root", { resolved: false }));- const props = { issueName: ISSUE, project, thread, collapsible: false, onReplyDraftChange: vi.fn(), onThreadStateChanged };+ const props = { issue, project, thread, collapsible: false, onReplyDraftChange: vi.fn(), onThreadStateChanged };render(<CommentThreadCard {...props} replyDraft="Not done yet" />);expect(stateCheckbox()?.getAttribute("aria-checked")).toBe("true");submitReply();@@ -439,7 +460,7 @@ describe("CommentThreadCard", () => {test("hides the state checkbox without the update permission", () => {denySettle();const [thread] = groupThreads([comment("root", "Root")]);- render(<CommentThreadCard issueName={ISSUE} project={project} thread={thread} collapsible={false} replyDraft="Draft" onReplyDraftChange={vi.fn()} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} collapsible={false} replyDraft="Draft" onReplyDraftChange={vi.fn()} />);expect(stateCheckbox()).toBeNull();expect(buttonByText("plan.review.thread.reply")).toBeDefined();});@@ -448,7 +469,7 @@ describe("CommentThreadCard", () => {const [thread] = groupThreads([comment("root", "Root")]);const onReplyDraftChange = vi.fn();mocks.createIssueComment.mockRejectedValueOnce(new Error("offline"));- render(<CommentThreadCard issueName={ISSUE} project={project} thread={thread} replyDraft="Keep this draft" onReplyDraftChange={onReplyDraftChange} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} replyDraft="Keep this draft" onReplyDraftChange={onReplyDraftChange} />);submitReply({ toggleState: true });await act(async () => {});expect(mocks.updateIssueComment).not.toHaveBeenCalled();@@ -462,7 +483,7 @@ describe("CommentThreadCard", () => {const onReplyDraftChange = vi.fn();mocks.createIssueComment.mockResolvedValueOnce(comment("reply", "Posted", {root: rootName}));mocks.updateIssueComment.mockRejectedValueOnce(new Error("status update failed"));- render(<CommentThreadCard issueName={ISSUE} project={project} thread={thread} replyDraft="Posted" onReplyDraftChange={onReplyDraftChange} onThreadStateChanged={onThreadStateChanged} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} replyDraft="Posted" onReplyDraftChange={onReplyDraftChange} onThreadStateChanged={onThreadStateChanged} />);submitReply({ toggleState: true });await act(async () => {});expect(onReplyDraftChange).toHaveBeenCalledWith(expect.any(Function));@@ -483,7 +504,7 @@ describe("CommentThreadCard", () => {comment("root", "Root", { creator: "users/[email protected]" }),]);render(- <CommentThreadCard issueName={ISSUE} project={project} thread={thread} />+ <CommentThreadCard issue={issue} project={project} thread={thread} />);expect(buttonByText("plan.review.thread.resolve")).toBeUndefined();});@@ -492,7 +513,7 @@ describe("CommentThreadCard", () => {denySettle();const [thread] = groupThreads([comment("root", "Root")]);render(- <CommentThreadCard issueName={ISSUE} project={project} thread={thread} />+ <CommentThreadCard issue={issue} project={project} thread={thread} />);expect(buttonByText("plan.review.thread.reply-placeholder")).toBeDefined();expect(buttonByText("plan.review.thread.resolve")).toBeUndefined();@@ -505,7 +526,7 @@ test.each(["ctrlKey", "metaKey"])("ignores %s+Enter while a reply is pending", alet complete!: (value: ReturnType<typeof comment>) => void;mocks.createIssueComment.mockImplementationOnce(() => new Promise(resolve => {complete = resolve;}));const onReplyDraftChange = vi.fn();- render(<CommentThreadCard issueName={ISSUE} project={project} thread={thread} replyDraft="My reply" onReplyDraftChange={onReplyDraftChange} />);+ render(<CommentThreadCard issue={issue} project={project} thread={thread} replyDraft="My reply" onReplyDraftChange={onReplyDraftChange} />);submitReply();expect(mocks.createIssueComment).toHaveBeenCalledTimes(1);expect(buttonByText("plan.review.thread.reply")?.disabled).toBe(true);@@ -518,7 +539,7 @@ test.each(["ctrlKey", "metaKey"])("ignores %s+Enter while a reply is pending", atest("disables Reply on an empty draft, checkbox or not", () => {const [thread] = groupThreads([comment("root", "Root")]);- const props = {issueName: ISSUE, project, thread, collapsible: false, onReplyDraftChange: vi.fn()};+ const props = {issue, project, thread, collapsible: false, onReplyDraftChange: vi.fn()};render(<CommentThreadCard {...props} replyDraft=" " />);click(stateCheckbox());expect(buttonByText("plan.review.thread.reply")?.disabled).toBe(true);@@ -542,7 +563,7 @@ test.each([function DraftOwner({ visible }: { visible: boolean }) {const [draft, setDraft] = useState("First reply");changeDraft = setDraft;- return visible ? <CommentThreadCard issueName={ISSUE} project={project} thread={thread} collapsible={false} replyDraft={draft} onReplyDraftChange={setDraft} /> : null;+ return visible ? <CommentThreadCard issue={issue} project={project} thread={thread} collapsible={false} replyDraft={draft} onReplyDraftChange={setDraft} /> : null;}render(<DraftOwner visible />);click(buttonByText("plan.review.thread.reply"));@@ -560,7 +581,7 @@ test.each([test("focuses and reveals the reply footer once when opened in Monaco", () => {const [thread] = groupThreads([comment("root", "Root")]);const reveal = vi.fn();- const view = (draft: string) => <MonacoViewZoneRevealContext value={reveal}><CommentThreadCard issueName={ISSUE} project={project} thread={thread} replyDraft={draft} onReplyDraftChange={vi.fn()} /></MonacoViewZoneRevealContext>;+ const view = (draft: string) => <MonacoViewZoneRevealContext value={reveal}><CommentThreadCard issue={issue} project={project} thread={thread} replyDraft={draft} onReplyDraftChange={vi.fn()} /></MonacoViewZoneRevealContext>;render(view(""));expect(reveal).not.toHaveBeenCalled();click(buttonByText("plan.review.thread.reply-placeholder"));diff --git a/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsx b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsxindex 99103b6d94..32234558e1 100644--- a/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsx+++ b/frontend/src/routes/project/plan-detail/components/threads/CommentThreadCard.tsx@@ -28,6 +28,7 @@ import { Checkbox } from "@/components/ui/checkbox";import { useCurrentUser, useUserByIdentifier } from "@/hooks/useAppState";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 { ThreadComment } from "./ThreadComment";import type { CommentThread } from "./threadModel";@@ -50,7 +51,7 @@ export function CommentThreadCard({className,collapsible = true,context,- issueName,+ issue,label,onClose,onThreadStateChanged,@@ -64,7 +65,7 @@ export function CommentThreadCard({collapsible?: boolean;// Full-width statement context above the root author and discussion.context?: ReactNode;- issueName: string;+ issue: Issue;// Extra header text after the timestamp (the anchored line range).label?: ReactNode;// Editor placement: closes the expanded thread back to its marker.@@ -78,7 +79,7 @@ export function CommentThreadCard({}) {const { t } = useTranslation();const currentUser = useCurrentUser();- const actions = useThreadActions(issueName);+ const actions = useThreadActions(issue.name);const [collapsed, setCollapsed] = useState(collapsible && thread.resolved);const [showAllReplies, setShowAllReplies] = useState(() => thread.replies.length <= FOLD_REPLIES_ABOVE@@ -128,7 +129,7 @@ export function CommentThreadCard({setCollapsed(thread.resolved);}, [collapsible, thread.resolved]);- const allowReply = canReplyToThread(project);+ const allowReply = canReplyToThread(project, issue);const allowSettle = canSettleThread(project);// The reply composer's checkbox names the action for the thread's current// state and, when checked, performs it after the reply is posted:diff --git a/frontend/src/routes/project/plan-detail/components/threads/StatementThreadsLayer.test.tsx b/frontend/src/routes/project/plan-detail/components/threads/StatementThreadsLayer.test.tsxindex 70a1ffccfe..c91d85287f 100644--- a/frontend/src/routes/project/plan-detail/components/threads/StatementThreadsLayer.test.tsx+++ b/frontend/src/routes/project/plan-detail/components/threads/StatementThreadsLayer.test.tsx@@ -422,12 +422,12 @@ const giveElementsHeight = () =>.spyOn(HTMLElement.prototype, "getBoundingClientRect").mockReturnValue(new DOMRect(0, 0, 700, 100));-const mount = (editor: IStandaloneCodeEditor) =>+const mount = (editor: IStandaloneCodeEditor, currentIssue = issue) =>act(() =>root.render(<StatementThreadsLayereditor={editor}- issue={issue}+ issue={currentIssue}monaco={fakeMonaco}sheetSha256={SHA}spec={spec}@@ -814,6 +814,31 @@ describe("StatementThreadsLayer", () => {).not.toHaveBeenCalled();});+ test("draft issues show existing threads but enable creation only after submission", () => {+ mocks.comments = [threadRoot("existing", 3, 4)];+ const fake = createFakeEditor();+ mount(fake.editor, create(IssueSchema, { name: ISSUE, draft: true }));++ expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/existing`);+ fake.fire("move", 2, MouseTargetType.CONTENT_TEXT);+ expect(classesOf(fake.decorations.current, 2)).not.toContain("bb-thread-add-glyph");+ fake.fire("down", 2, MouseTargetType.GUTTER_LINE_NUMBERS);+ fake.release();+ fake.fire("down", 2, MouseTargetType.GUTTER_LINE_DECORATIONS);+ expect(hosted(fake.widgets, "[data-testid='composer']")).toBeNull();+ expect(fake.editor.addAction).not.toHaveBeenCalled();+ expect(fake.editor.getDomNode()?.classList.contains("bb-thread-creatable")).toBe(false);++ mount(fake.editor);++ expect(fake.editor.addAction).toHaveBeenCalled();+ fake.fire("move", 2, MouseTargetType.CONTENT_TEXT);+ expect(classesOf(fake.decorations.current, 2)).toContain("bb-thread-add-glyph");+ fake.fire("down", 2, MouseTargetType.GUTTER_LINE_DECORATIONS);+ expect(hosted(fake.widgets, "[data-testid='composer']")).not.toBeNull();+ expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/existing`);+ });+test("status refreshes do not switch or close the automatically expanded thread", () => {mocks.comments = [threadRoot("first", 3, 4), threadRoot("other", 6, 9)];const fake = createFakeEditor();@@ -954,4 +979,3 @@ describe("StatementThreadsLayer", () => {expect(hosted(fake.widgets, "[data-testid='thread-walker']")).not.toBeNull();});});-diff --git a/frontend/src/routes/project/plan-detail/components/threads/StatementThreadsLayer.tsx b/frontend/src/routes/project/plan-detail/components/threads/StatementThreadsLayer.tsxindex b7708f7ee1..31829befd4 100644--- a/frontend/src/routes/project/plan-detail/components/threads/StatementThreadsLayer.tsx+++ b/frontend/src/routes/project/plan-detail/components/threads/StatementThreadsLayer.tsx@@ -57,6 +57,8 @@ type Composer = {revealNonce: number;};+const EMPTY_COMPOSERS: ReadonlyMap<number, Composer> = new Map();+// Binds comment threads to the read-only statement editor with Monaco's own// primitives, the way VS Code's comment controller does: glyph-margin// decorations for markers and the comment affordance, whole-line decorations@@ -92,7 +94,7 @@ export function StatementThreadsLayer({placementsForSheet(s, spec.id, sheetSha256));const actions = useThreadActions(issue.name);- const canCreate = canReplyToThread(project);+ const canCreate = canReplyToThread(project, issue);const threads = useMemo(() => groupThreads(comments), [comments]);const editorThreads = useMemo(@@ -202,6 +204,7 @@ export function StatementThreadsLayer({const [composers, setComposers] = useState<ReadonlyMap<number, Composer>>(() => new Map());+ const activeComposers = canCreate ? composers : EMPTY_COMPOSERS;const [composerDrafts, setComposerDrafts] = useState<Readonly<Record<number, string>>>({});@@ -311,7 +314,7 @@ export function StatementThreadsLayer({if (expandedEntry && !pendingSelection) {paint(expandedEntry.range, "bb-thread-line");}- for (const composer of composers.values()) {+ for (const composer of activeComposers.values()) {paint(composer.range, "bb-thread-line--selecting");}if (pendingSelection) paint(pendingSelection, "bb-thread-line--selecting");@@ -353,7 +356,7 @@ export function StatementThreadsLayer({},});}- if (actionLine !== undefined && !composers.has(actionLine)) {+ if (actionLine !== undefined && !activeComposers.has(actionLine)) {const actionRange = selection ?? {startLine: actionLine,endLine: actionLine,@@ -373,9 +376,9 @@ export function StatementThreadsLayer({};}, [actionLine,+ activeComposers,canCreate,commentedLines,- composers,editor,expandedEntry,markersByLine,@@ -506,7 +509,11 @@ export function StatementThreadsLayer({const isCreationAction =e.target.type ===monacoModule.editor.MouseTargetType.GUTTER_LINE_DECORATIONS;- if (isCreationAction && actionLine === line && !composers.has(line)) {+ if (+ isCreationAction &&+ actionLine === line &&+ !activeComposers.has(line)+ ) {e.event.preventDefault();openComposer(selection ?? { startLine: line, endLine: line });return;@@ -541,8 +548,8 @@ export function StatementThreadsLayer({};}, [actionLine,+ activeComposers,canCreate,- composers,editor,markersByLine,monacoModule,@@ -592,7 +599,7 @@ export function StatementThreadsLayer({);const publish = async (line: number, comment: string) => {- const range = composers.get(line)?.range;+ const range = activeComposers.get(line)?.range;if (!range) return;const created = await actions.publish(comment,@@ -636,7 +643,7 @@ export function StatementThreadsLayer({expandedThreadRef={expandedThreadRef}flashRoot={flashRoot}onFlashEnd={() => setFlashRoot(undefined)}- issueName={issue.name}+ issue={issue}onCollapse={(rootName) =>openThreads(openLine,@@ -652,7 +659,7 @@ export function StatementThreadsLayer({</div></MonacoViewZone>)}- {Array.from(composers, ([line, composer]) => (+ {Array.from(activeComposers, ([line, composer]) => (<MonacoViewZoneafterLineNumber={line}editor={editor}diff --git a/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.test.tsx b/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.test.tsxindex f425a229f3..3a270b268c 100644--- a/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.test.tsx+++ b/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.test.tsx@@ -3,7 +3,7 @@ import { TimestampSchema } from "@bufbuild/protobuf/wkt";import { cleanup, fireEvent, render } from "@testing-library/react";import { createRef, useState } from "react";import { afterEach, describe, expect, test, vi } from "vitest";-import { IssueCommentSchema } from "@/types/proto-es/v1/issue_service_pb";+import { IssueCommentSchema, IssueSchema } from "@/types/proto-es/v1/issue_service_pb";import type { EditorThread } from "./threadModel";import { ThreadStack } from "./ThreadStack";@@ -46,7 +46,7 @@ const entry = (name: string, resolved: boolean, seconds: number): EditorThread =},});const props = {- issueName: "projects/p/issues/1",+ issue: create(IssueSchema, { name: "projects/p/issues/1" }),project: undefined,onCollapse: vi.fn(),onExpand: vi.fn(),diff --git a/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsx b/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsxindex e850fded22..c16ece8264 100644--- a/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsx+++ b/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsx@@ -8,7 +8,7 @@ import { Button } from "@/components/ui/button";import { useUserByIdentifier } from "@/hooks/useAppState";import { cn } from "@/lib/utils";import { getTimeForPbTimestampProtoEs, unknownUser } from "@/types";-import type { IssueComment } from "@/types/proto-es/v1/issue_service_pb";+import type { Issue, IssueComment } from "@/types/proto-es/v1/issue_service_pb";import type { Project } from "@/types/proto-es/v1/project_service_pb";import { CommentThreadCard } from "./CommentThreadCard";import {@@ -54,7 +54,7 @@ export function ThreadStack({expandedThreadRef,flashRoot,onFlashEnd,- issueName,+ issue,onCollapse,onExpand,replyDrafts,@@ -67,7 +67,7 @@ export function ThreadStack({// The thread the walker just landed on; its card flashes once.flashRoot?: string;onFlashEnd?: () => void;- issueName: string;+ issue: Issue;onCollapse: (rootName: string) => void;onExpand: (rootName: string) => void;replyDrafts: Readonly<Record<string, string>>;@@ -139,7 +139,7 @@ export function ThreadStack({<CommentThreadCardclassName="shadow-sm"collapsible={false}- issueName={issueName}+ issue={issue}label={rangeLabel(entry)}onClose={() => onCollapse(entry.thread.root.name)}onThreadStateChanged={(resolved) =>diff --git a/frontend/src/routes/project/plan-detail/components/threads/useThreadActions.ts b/frontend/src/routes/project/plan-detail/components/threads/useThreadActions.tsindex 492d62bb10..f304c6d20f 100644--- a/frontend/src/routes/project/plan-detail/components/threads/useThreadActions.ts+++ b/frontend/src/routes/project/plan-detail/components/threads/useThreadActions.ts@@ -3,6 +3,7 @@ import { useTranslation } from "react-i18next";import { pushNotification } from "@/stores";import { useAppStore } from "@/stores/app";import {+ type Issue,IssueComment_ThreadState,type StatementAnchor,} from "@/types/proto-es/v1/issue_service_pb";@@ -18,9 +19,14 @@ export function canSettleThread(project: Project | undefined): boolean {);}-export function canReplyToThread(project: Project | undefined): boolean {+export function canReplyToThread(+ project: Project | undefined,+ issue: Issue+): boolean {return Boolean(- project && hasProjectPermissionV2(project, "bb.issueComments.create")+ !issue.draft &&+ project &&+ hasProjectPermissionV2(project, "bb.issueComments.create"));}