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): improve inline thread navigation and anchor jumps (#21543)
boojack65cf75596396
diff --git a/frontend/src/routes/project/plan-detail/components/PlanDetailStatementSection.test.tsx b/frontend/src/routes/project/plan-detail/components/PlanDetailStatementSection.test.tsxindex c8684afe1c..63cd9120bc 100644--- a/frontend/src/routes/project/plan-detail/components/PlanDetailStatementSection.test.tsx+++ b/frontend/src/routes/project/plan-detail/components/PlanDetailStatementSection.test.tsx@@ -12,6 +12,14 @@ import { PlanDetailStatementSection } from "./PlanDetailStatementSection";const mocks = vi.hoisted(() => ({page: undefined as unknown,sheets: new Map<string, Sheet>(),+ threadFocus: undefined as+ | { commentName: string; specId: string; lineNumber: number; nonce: number }+ | undefined,+ clearThreadFocus: vi.fn(),+ setPosition: vi.fn(),+ revealLineInCenter: vi.fn(),+ focus: vi.fn(),+ scrollIntoView: vi.fn(),}));vi.mock("react-i18next", () => ({@@ -19,8 +27,27 @@ vi.mock("react-i18next", () => ({useTranslation: () => ({ t: (key: string) => key }),}));vi.mock("@/components/monaco", () => ({- MonacoEditor: ({ onChange }: { onChange: (value: string) => void }) => (+ MonacoEditor: ({+ onChange,+ onReady,+ }: {+ onChange: (value: string) => void;+ onReady: (monaco: unknown, editor: unknown) => void;+ }) => (<>+ <button+ onClick={() =>+ onReady({}, {+ getModel: () => ({ getLineCount: () => 3 }),+ setPosition: mocks.setPosition,+ revealLineInCenter: mocks.revealLineInCenter,+ focus: mocks.focus,+ getDomNode: () => ({ scrollIntoView: mocks.scrollIntoView }),+ })+ }+ >+ Editor ready+ </button><button onClick={() => onChange("SELECT 2;\n".repeat(220_000))}>Make large draft</button>@@ -44,6 +71,13 @@ vi.mock("@/stores/app", () => ({}),}));+vi.mock("../shared/stores/usePlanDetailStore", () => ({+ usePlanDetailStore: (selector: (state: unknown) => unknown) =>+ selector({+ threadFocus: mocks.threadFocus,+ clearThreadFocus: mocks.clearThreadFocus,+ }),+}));vi.mock("../shell/PlanDetailContext", () => ({usePlanDetailContext: () => mocks.page,}));@@ -55,6 +89,8 @@ vi.mock("./threads/StatementThreadsLayer", () => ({afterEach(() => {cleanup();mocks.sheets.clear();+ mocks.threadFocus = undefined;+ vi.clearAllMocks();});test("shows the large-sheet warning as soon as the saved sheet changes", async () => {@@ -139,3 +175,57 @@ test("shows a draft-specific warning before saving and removes it below the limifireEvent.click(getByText("Make small draft"));expect(queryByText("issue.statement-exceeds-preview-limit")).toBeNull();});++test("reveals an Activity anchor after the edit editor is ready", () => {+ const sheetName = `projects/p/sheets/${"c".repeat(64)}`;+ const spec = create(Plan_SpecSchema, {+ id: "spec",+ config: {+ case: "changeDatabaseConfig",+ value: create(Plan_ChangeDatabaseConfigSchema, { sheet: sheetName }),+ },+ });+ const content = new TextEncoder().encode("SELECT 1;\nSELECT 2;\nSELECT 3;");+ mocks.sheets.set(+ sheetName,+ create(SheetSchema, { name: sheetName, content, contentSize: BigInt(content.length) })+ );+ mocks.page = {+ currentUser: { name: "users/test" },+ isCreating: false,+ plan: create(PlanSchema, { creator: "users/test", specs: [spec] }),+ project: { name: "projects/p" },+ readonly: false,+ setEditing: vi.fn(),+ };++ const { getByText, rerender } = render(+ <PlanDetailStatementSection spec={spec} />+ );+ fireEvent.click(getByText("common.edit"));+ mocks.threadFocus = {+ commentName: "comments/1",+ specId: "spec",+ lineNumber: 3,+ nonce: 7,+ };+ rerender(<PlanDetailStatementSection spec={spec} />);+ expect(mocks.revealLineInCenter).not.toHaveBeenCalled();++ fireEvent.click(getByText("Editor ready"));+ expect(mocks.setPosition).toHaveBeenCalledWith({ lineNumber: 3, column: 1 });+ expect(mocks.revealLineInCenter).toHaveBeenCalledWith(3);+ expect(mocks.focus).toHaveBeenCalled();+ expect(mocks.scrollIntoView).toHaveBeenCalledWith({ block: "nearest" });+ expect(mocks.clearThreadFocus).toHaveBeenCalledWith(7);++ mocks.threadFocus = {+ commentName: "comments/2",+ specId: "spec",+ lineNumber: 99,+ nonce: 8,+ };+ rerender(<PlanDetailStatementSection spec={spec} />);+ expect(mocks.revealLineInCenter).toHaveBeenLastCalledWith(3);+ expect(mocks.clearThreadFocus).toHaveBeenCalledWith(8);+});diff --git a/frontend/src/routes/project/plan-detail/components/PlanDetailStatementSection.tsx b/frontend/src/routes/project/plan-detail/components/PlanDetailStatementSection.tsxindex 0ea474b88f..66d2b0ecbd 100644--- a/frontend/src/routes/project/plan-detail/components/PlanDetailStatementSection.tsx+++ b/frontend/src/routes/project/plan-detail/components/PlanDetailStatementSection.tsx@@ -50,6 +50,7 @@ import {getSheetStatement,setSheetStatement,} from "@/utils/v1/sheet";+import { usePlanDetailStore } from "../shared/stores/usePlanDetailStore";import { usePlanDetailContext } from "../shell/PlanDetailContext";import {createEmptyLocalSheet,@@ -134,9 +135,36 @@ export function PlanDetailStatementSection({editor: IStandaloneCodeEditor;monaco: MonacoModule;}>();+ const [editingEditor, setEditingEditor] = useState<IStandaloneCodeEditor>();+ const threadFocus = usePlanDetailStore((state) => state.threadFocus);+ const clearThreadFocus = usePlanDetailStore(+ (state) => state.clearThreadFocus+ );useEffect(() => {if (!showsReadonlyEditor) setReadonlyEditor(undefined);}, [showsReadonlyEditor]);+ useEffect(() => {+ if (!isEditing) setEditingEditor(undefined);+ }, [isEditing]);+ useEffect(() => {+ if (+ !isEditing ||+ !editingEditor ||+ !threadFocus ||+ threadFocus.specId !== spec.id ||+ !threadFocus.lineNumber+ )+ return;+ const line = Math.min(+ threadFocus.lineNumber,+ editingEditor.getModel()?.getLineCount() ?? threadFocus.lineNumber+ );+ editingEditor.setPosition({ lineNumber: line, column: 1 });+ editingEditor.revealLineInCenter(line);+ editingEditor.focus();+ editingEditor.getDomNode()?.scrollIntoView({ block: "nearest" });+ clearThreadFocus(threadFocus.nonce);+ }, [clearThreadFocus, editingEditor, isEditing, spec.id, threadFocus]);const editingScope = useMemo(() => `statement:${spec.id}`, [spec.id]);const targetDatabaseName = useMemo(() => {@@ -637,6 +665,7 @@ export function PlanDetailStatementSection({content={editorContent}language={language}options={STATEMENT_EDITOR_OPTIONS}+ onReady={(_monaco, editor) => setEditingEditor(editor)}onChange={(nextStatement) => {if (page.isCreating) {updateLocalStatement(nextStatement);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.tsxindex c4378ec5c6..8a723a265d 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@@ -2,8 +2,9 @@ import { create } from "@bufbuild/protobuf";import { timestampFromMs } from "@bufbuild/protobuf/wkt";import { act, type ReactNode } from "react";import { createRoot } from "react-dom/client";-import { describe, expect, test, vi } from "vitest";+import { afterEach, describe, expect, test, vi } from "vitest";import { shownTimestampModes } from "@/test-utils/humanizeTs";+import { PositionSchema } from "@/types/proto-es/v1/common_pb";import {IssueComment_ReviewSubmissionSchema,IssueComment_ThreadState,@@ -11,7 +12,18 @@ import {IssueSchema,StatementAnchorSchema,} from "@/types/proto-es/v1/issue_service_pb";-import { PlanSchema } from "@/types/proto-es/v1/plan_service_pb";+import {+ Plan_ChangeDatabaseConfigSchema,+ Plan_SpecSchema,+ PlanSchema,+} from "@/types/proto-es/v1/plan_service_pb";++const mocks = vi.hoisted(() => ({+ requestThreadFocus: vi.fn(),+ expandPhase: vi.fn(),+ placements: new Map<string, unknown>(),+ placementTargets: new Map<string, string>(),+}));vi.mock("react-i18next", () => ({initReactI18next: { type: "3rdParty", init: () => {} },@@ -104,12 +116,12 @@ vi.mock("@/app/router", () => ({vi.mock("../../shared/stores/usePlanDetailStore", () => ({usePlanDetailStore: (selector: (state: unknown) => unknown) =>selector({- selectedSpecId: undefined,- placements: new Map(),- placementTargets: new Map(),+ selectedSpecId: "spec-1",+ placements: mocks.placements,+ placementTargets: mocks.placementTargets,}),usePlanDetailStoreApi: () => ({- getState: () => ({ requestThreadFocus: vi.fn() }),+ getState: () => ({ requestThreadFocus: mocks.requestThreadFocus }),}),}));@@ -132,7 +144,11 @@ vi.mock("../threads/CommentThreadCard", () => ({}));vi.mock("../threads/StatementAnchorContext", () => ({- StatementAnchorContext: () => <div data-testid="anchor-context" />,+ StatementAnchorContext: ({ onViewInStatement }: { onViewInStatement: () => void }) => (+ <button data-testid="anchor-context" onClick={onViewInStatement}>+ View in Statement+ </button>+ ),}));vi.mock("@/stores", () => ({@@ -161,7 +177,11 @@ vi.mock("../../hooks/usePlanChangeReferenceData", () => ({}));vi.mock("../../shell/PlanDetailContext", () => ({- usePlanDetailContext: () => ({ projectId: "p1" }),+ usePlanDetailContext: () => ({+ projectId: "p1",+ planId: "1",+ expandPhase: mocks.expandPhase,+ }),}));vi.mock("../PlanChangeReference", () => ({@@ -189,6 +209,74 @@ const reviewSubmission = (name: string) =>});describe("ReviewActivityTimeline", () => {+ afterEach(() => {+ vi.clearAllMocks();+ mocks.placements.clear();+ mocks.placementTargets.clear();+ });++ test.each([+ { mapped: false, expectedLine: 12 },+ { mapped: true, expectedLine: 20 },+ ])("passes the $expectedLine saved statement line to the editor", ({ mapped, expectedLine }) => {+ const currentSha = "c".repeat(64);+ const commentName = "projects/p1/issues/1/issueComments/root";+ const plan = create(PlanSchema, {+ name: "projects/p1/plans/1",+ specs: [+ create(Plan_SpecSchema, {+ id: "spec-1",+ config: {+ case: "changeDatabaseConfig",+ value: create(Plan_ChangeDatabaseConfigSchema, {+ sheet: `projects/p1/sheets/${currentSha}`,+ }),+ },+ }),+ ],+ });+ if (mapped) {+ mocks.placementTargets.set("spec-1", currentSha);+ mocks.placements.set(commentName, {+ state: "CURRENT",+ range: { startLine: 20, endLine: 21 },+ });+ }+ const container = document.createElement("div");+ const root = createRoot(container);+ act(() => {+ root.render(+ <ReviewActivityTimeline+ comments={[+ create(IssueCommentSchema, {+ name: commentName,+ comment: "Review this line",+ threadState: IssueComment_ThreadState.OPEN,+ statementAnchor: create(StatementAnchorSchema, {+ spec: "spec-1",+ sheetSha256: mapped ? "d".repeat(64) : currentSha,+ startPosition: create(PositionSchema, { line: 12, column: 0 }),+ endPosition: create(PositionSchema, { line: 12, column: 0 }),+ }),+ }),+ ]}+ issue={create(IssueSchema, { name: "projects/p1/issues/1" })}+ plan={plan}+ />+ );+ });+ act(() => {+ container.querySelector<HTMLButtonElement>("[data-testid='anchor-context']")?.click();+ });+ expect(mocks.requestThreadFocus).toHaveBeenCalledWith({+ commentName,+ specId: "spec-1",+ lineNumber: expectedLine,+ });+ expect(mocks.expandPhase).toHaveBeenCalledWith("changes");+ act(() => root.unmount());+ });+test("times an activity entry in the work-queue form", () => {// A feed is read for what just happened, so its entries age with the// clock rather than naming a date.diff --git a/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsx b/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsxindex 9951deb1ba..90bba00a7a 100644--- a/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsx+++ b/frontend/src/routes/project/plan-detail/components/review/ReviewActivityTimeline.tsx@@ -518,9 +518,14 @@ function ThreadActivityRow({const viewInStatement = () => {const specId = anchor?.spec;if (!specId) return;+ const lineNumber =+ placement?.state === "CURRENT"+ ? placement.range.startLine+ : anchor?.startPosition?.line;storeApi.getState().requestThreadFocus({commentName: thread.root.name,specId,+ lineNumber,});focusPlanPhase("changes", page.expandPhase);if (selectedSpecId !== specId) {diff --git a/frontend/src/routes/project/plan-detail/components/threads/StatementThreadWalker.tsx b/frontend/src/routes/project/plan-detail/components/threads/StatementThreadWalker.tsxindex 80cf06d74b..c2b0d8ccb3 100644--- a/frontend/src/routes/project/plan-detail/components/threads/StatementThreadWalker.tsx+++ b/frontend/src/routes/project/plan-detail/components/threads/StatementThreadWalker.tsx@@ -1,6 +1,7 @@import { ChevronDown, ChevronUp, MessagesSquare } from "lucide-react";import { useTranslation } from "react-i18next";import { Button } from "@/components/ui/button";+import { Tooltip } from "@/components/ui/tooltip";// Touch has no hover and keeps focus on the tapped arrow, so coarse pointers// get no ring: the flash on the target card is the feedback there.@@ -14,12 +15,14 @@ const ARROW_CLASS =export function StatementThreadWalker({announcement,count,+ position,onNext,onPrevious,remainder,}: {announcement: string;count: number;+ position: number;onNext: () => void;onPrevious: () => void;remainder: number;@@ -37,12 +40,20 @@ export function StatementThreadWalker({<divclassName="flex items-stretch overflow-hidden rounded-sm border border-control-border bg-background text-xs shadow-sm pointer-coarse:shadow-none"data-testid="thread-walker"- title={title}>- <span className="inline-flex items-center gap-1 px-2 font-medium text-accent tabular-nums">+ <Tooltip+ content={title}+ render={+ <span+ aria-label={title}+ className="inline-flex items-center gap-1 px-2 font-medium text-accent tabular-nums"+ tabIndex={0}+ />+ }+ ><MessagesSquare className="size-3.5" />- {count}- </span>+ {position}/{count}+ </Tooltip><Buttonappearance="secondary"aria-label={t("plan.review.thread.walker.previous")}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 1f8009de1e..1a6a1eb765 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@@ -404,6 +404,8 @@ beforeEach(() => {mocks.findController = null;vi.clearAllMocks();mocks.threadFocus = undefined;+ mocks.placements = new Map();+ mocks.placementTargets = new Map();mocks.hasPermission.mockReturnValue(true);container = document.createElement("div");root = createRoot(container);@@ -454,6 +456,13 @@ const hosted = (const cardRoot = (widgets: Set<{ getDomNode: () => HTMLElement }>) =>hosted(widgets, "[data-testid='thread-card']")?.getAttribute("data-root");+const cardRoots = (widgets: Set<{ getDomNode: () => HTMLElement }>) =>+ Array.from(widgets)+ .flatMap((widget) =>+ Array.from(widget.getDomNode().querySelectorAll("[data-testid='thread-card']"))+ )+ .map((card) => card.getAttribute("data-root"));+const classesOf = (decorations: monaco.editor.IModelDeltaDecoration[],line: number@@ -500,7 +509,7 @@ describe("StatementThreadsLayer", () => {expect(classesOf(fake.decorations.current, 4)).toEqual([]);expect(classesOf(fake.decorations.current, 6)).toEqual([]);expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/visible`);- expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.getAttribute("title")).toBe(+ expect(hosted(fake.widgets, "[data-testid='thread-walker'] [aria-label]")?.getAttribute("aria-label")).toBe("plan.review.thread.walker.count:1 · plan.review.thread.walker.remainder:2");fake.fire("move", 2, MouseTargetType.GUTTER_LINE_NUMBERS);@@ -544,7 +553,9 @@ describe("StatementThreadsLayer", () => {const picker = hosted(fake.widgets, "[data-testid='thread-picker']");act(() => picker?.querySelectorAll("[data-testid='pick-thread']")[1].dispatchEvent(new MouseEvent("click", { bubbles: true })));expect(highlighted()).toEqual([1, 2]);- act(() => hosted(fake.widgets, "[data-testid='close-thread']")?.dispatchEvent(new MouseEvent("click", { bubbles: true })));+ act(() => picker?.querySelectorAll("[data-testid='close-thread']")[1].dispatchEvent(new MouseEvent("click", { bubbles: true })));+ expect(highlighted()).toEqual([2]);+ act(() => picker?.querySelector("[data-testid='close-thread']")?.dispatchEvent(new MouseEvent("click", { bubbles: true })));expect(highlighted()).toEqual([]);expect(fake.decorations.current.filter((d) => d.options.className === "bb-thread-line--passive").map((d) => d.range.startLineNumber)).toEqual([1, 2]);expect(fake.decorations.current.filter((d) => d.options.glyphMarginClassName?.includes("bb-thread-glyph--count-2"))).toHaveLength(1);@@ -648,7 +659,7 @@ describe("StatementThreadsLayer", () => {expect(composer()?.getAttribute("data-draft")).toBe("Draft 3-4");});- test("a marker opens its thread, a combined marker offers a picker, and closing returns to markers", () => {+ test("markers open independent lines and combined threads", () => {mocks.comments = [threadRoot("first", 3, 4, { createdAt: 2 }),threadRoot("a", 6, 9, { createdAt: 5 }),@@ -663,7 +674,8 @@ describe("StatementThreadsLayer", () => {expect(classesOf(fake.decorations.current, 9)).toContain("bb-thread-add-glyph");fake.fire("down", 9, MouseTargetType.GUTTER_GLYPH_MARGIN);expect(hosted(fake.widgets, "[data-testid='composer']")).toBeNull();- expect(zoneAfter(fake.zones)).toEqual([9]);+ expect(zoneAfter(fake.zones)).toEqual([4, 9]);+ expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.textContent).toContain("2/3");const picker = hosted(fake.widgets, "[data-testid='thread-picker']");const pick = picker?.querySelectorAll("[data-testid='pick-thread']");expect(Array.from(pick ?? []).map((node) => node.textContent)).toEqual([@@ -673,13 +685,20 @@ describe("StatementThreadsLayer", () => {act(() => {pick?.[1].dispatchEvent(new MouseEvent("click", { bubbles: true }));});- expect(zoneAfter(fake.zones)).toEqual([9]);+ expect(zoneAfter(fake.zones)).toEqual([4, 9]);+ expect(pick?.[1].getAttribute("data-expanded")).toBe("true");+ expect(pick?.[0].getAttribute("data-expanded")).toBe("true");+ expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.textContent).toContain("3/3");+ act(() => {+ picker?.querySelectorAll("[data-testid='close-thread']")[0].dispatchEvent(new MouseEvent("click", { bubbles: true }));+ });+ expect(pick?.[0].getAttribute("data-expanded")).toBe("false");expect(pick?.[1].getAttribute("data-expanded")).toBe("true");- // The marker of the expanded thread toggles it closed.- fake.fire("down", 4, MouseTargetType.GUTTER_GLYPH_MARGIN);- expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/first`);+ // Each marker closes only its own stack.fake.fire("down", 4, MouseTargetType.GUTTER_GLYPH_MARGIN);+ expect(zoneAfter(fake.zones)).toEqual([9]);+ fake.fire("down", 9, MouseTargetType.GUTTER_GLYPH_MARGIN);expect(fake.zones.size).toBe(0);});@@ -881,6 +900,28 @@ describe("StatementThreadsLayer", () => {expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/first`);});+ test("moves an expanded thread when its placement changes lines", () => {+ const name = `${ISSUE}/issueComments/shifted`;+ mocks.comments = [+ threadRoot("shifted", 1, 1, { sheetSha256: "d".repeat(64) }),+ ];+ mocks.placementTargets.set("spec-1", SHA);+ mocks.placements.set(name, {+ state: "CURRENT",+ range: { startLine: 2, endLine: 2 },+ });+ const fake = createFakeEditor();+ mount(fake.editor);+ expect(zoneAfter(fake.zones)).toEqual([2]);++ mocks.placements = new Map([+ [name, { state: "CURRENT", range: { startLine: 5, endLine: 5 } }],+ ]);+ mount(fake.editor);+ expect(zoneAfter(fake.zones)).toEqual([5]);+ expect(cardRoot(fake.widgets)).toBe(name);+ });+test("keeps reply drafts when the entire gutter group closes and reopens", () => {mocks.comments = [threadRoot("first", 3, 4)];const fake = createFakeEditor();@@ -908,8 +949,11 @@ describe("StatementThreadsLayer", () => {const fake = createFakeEditor();fake.scroll.top = 600;mount(fake.editor);- expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/target`);- expect(fake.setScrollTop).toHaveBeenCalledExactlyOnceWith(lineTop(10) - 8);+ expect(cardRoots(fake.widgets)).toEqual([+ `${ISSUE}/issueComments/first`,+ `${ISSUE}/issueComments/target`,+ ]);+ expect(fake.setScrollTop).toHaveBeenCalledExactlyOnceWith(lineTop(10) + 1 - 8);expect(mocks.clearThreadFocus).toHaveBeenCalledWith(7);});test("the walker steps through unresolved threads in editor order and wraps", () => {@@ -923,9 +967,9 @@ describe("StatementThreadsLayer", () => {mount(fake.editor);expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/a`);const control = walkerNode(fake.widgets);- expect(control?.textContent).toContain("2");+ expect(control?.textContent).toContain("1/2");expect([control?.style.top, control?.style.right]).toEqual(["8px", "22px"]);- expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.getAttribute("title")).toBe(+ expect(hosted(fake.widgets, "[data-testid='thread-walker'] [aria-label]")?.getAttribute("aria-label")).toBe("plan.review.thread.walker.count:2");@@ -934,25 +978,35 @@ describe("StatementThreadsLayer", () => {fake.scroll.top = 600;fake.setScrollTop.mockClear();pressWalker(fake.widgets, "next");- expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/c`);- expect(zoneAfter(fake.zones)).toEqual([8]);- expect(fake.setScrollTop).toHaveBeenCalledExactlyOnceWith(lineTop(7) - 8);+ expect(cardRoots(fake.widgets)).toEqual([+ `${ISSUE}/issueComments/a`,+ `${ISSUE}/issueComments/c`,+ ]);+ expect(zoneAfter(fake.zones)).toEqual([2, 8]);+ expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.textContent).toContain("2/2");+ expect(fake.setScrollTop).toHaveBeenCalledExactlyOnceWith(lineTop(7) + 1 - 8);expect(fake.editor.getDomNode()?.scrollIntoView).toHaveBeenCalledWith({ block: "nearest" });+ fake.scroll.top = 500;+ expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.textContent).toContain("2/2");fake.setScrollTop.mockClear();pressWalker(fake.widgets, "next");- expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/a`);+ expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.textContent).toContain("1/2");expect(fake.setScrollTop).toHaveBeenCalledExactlyOnceWith(lineTop(2) - 8);// Stepping onto a thread already in view leaves the scroll alone.fake.setScrollTop.mockClear();pressWalker(fake.widgets, "previous");- expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/c`);+ expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.textContent).toContain("2/2");expect(fake.setScrollTop).not.toHaveBeenCalled();- // Closing the open line leaves no current thread: down starts over, up ends.+ // Closing the selected line leaves the other open, and up still wraps.fake.fire("down", 8, MouseTargetType.GUTTER_GLYPH_MARGIN);- expect(fake.zones.size).toBe(0);+ expect(zoneAfter(fake.zones)).toEqual([2]);+ expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.textContent).toContain("0/2");pressWalker(fake.widgets, "previous");- expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/c`);+ expect(cardRoots(fake.widgets)).toEqual([+ `${ISSUE}/issueComments/a`,+ `${ISSUE}/issueComments/c`,+ ]);});test("the walker is absent without unresolved placed threads and reports unplaced ones", () => {@@ -966,7 +1020,7 @@ describe("StatementThreadsLayer", () => {threadRoot("elsewhere", 4, 4, { sheetSha256: "d".repeat(64) }),];mount(fake.editor);- expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.getAttribute("title")).toBe(+ expect(hosted(fake.widgets, "[data-testid='thread-walker'] [aria-label]")?.getAttribute("aria-label")).toBe("plan.review.thread.walker.count:1 · plan.review.thread.walker.remainder:1");pressWalker(fake.widgets, "next");@@ -980,9 +1034,13 @@ describe("StatementThreadsLayer", () => {expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/a`);mocks.comments = [threadRoot("a", 2, 2, { createdAt: 1, resolved: true }), threadRoot("b", 5, 5, { createdAt: 2 })];mount(fake.editor);- expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.textContent).toContain("1");+ expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.textContent).toContain("0/1");pressWalker(fake.widgets, "next");- expect(cardRoot(fake.widgets)).toBe(`${ISSUE}/issueComments/b`);+ expect(hosted(fake.widgets, "[data-testid='thread-walker']")?.textContent).toContain("1/1");+ expect(cardRoots(fake.widgets)).toEqual([+ `${ISSUE}/issueComments/a`,+ `${ISSUE}/issueComments/b`,+ ]);mocks.comments = [threadRoot("a", 2, 2, { createdAt: 1, resolved: true }), threadRoot("b", 5, 5, { createdAt: 2, resolved: true })];mount(fake.editor);expect(hosted(fake.widgets, "[data-testid='thread-walker']")).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 f3da84a7a6..f9445c8ca5 100644--- a/frontend/src/routes/project/plan-detail/components/threads/StatementThreadsLayer.tsx+++ b/frontend/src/routes/project/plan-detail/components/threads/StatementThreadsLayer.tsx@@ -138,46 +138,104 @@ export function StatementThreadsLayer({return [...lines].sort((a, b) => a - b);}, [editorThreads]);- // Which line's threads are open, and which of them are expanded. By- // default the first line with an unresolved thread opens with its first- // unresolved thread expanded and the others collapsed; the user's choices- // win once they open or close anything.- const [openLine, setOpenLine] = useState<number | undefined>();+ // Open lines and expanded roots are independent: opening another thread+ // leaves the others in place. The first unresolved thread opens by default.+ const [openLines, setOpenLines] = useState<ReadonlySet<number>>(+ () => new Set()+ );const [expandedRoots, setExpandedRoots] = useState<ReadonlySet<string>>(() => new Set());+ const [selectedRoot, setSelectedRoot] = useState<string>();const expandedThreadRef = useRef<HTMLDivElement>(null);const initialExpansionAppliedRef = useRef(false);+ // Only the line targeted by a gesture reveals its zone again.+ const [revealRequest, setRevealRequest] = useState<{+ line: number;+ rootName: string;+ nonce: number;+ }>();useEffect(() => {if (initialExpansionAppliedRef.current) return;- const line = defaultExpandedThread(editorThreads)?.range.endLine;- if (line === undefined) return;+ const entry = defaultExpandedThread(editorThreads);+ if (!entry) return;+ const line = entry.range.endLine;initialExpansionAppliedRef.current = true;- setOpenLine(line);- setExpandedRoots(new Set(firstToExpand(markersByLine.get(line))));- }, [editorThreads, markersByLine]);+ setOpenLines(new Set([line]));+ setExpandedRoots(new Set([entry.thread.root.name]));+ setSelectedRoot(entry.thread.root.name);+ setRevealRequest({ line, rootName: entry.thread.root.name, nonce: 0 });+ }, [editorThreads]);- // Bumped by every open gesture, so the zone reveals the thread again even- // when the same one is reopened.- const [openNonce, setOpenNonce] = useState(0);- const openThreads = useCallback(- (line: number | undefined, roots: Iterable<string>) => {+ const expandThread = useCallback(+ (line: number, rootName: string) => {initialExpansionAppliedRef.current = true;- setOpenLine(line);- setExpandedRoots(new Set(roots));- setOpenNonce((nonce) => nonce + 1);+ setOpenLines((previous) => new Set(previous).add(line));+ setExpandedRoots((previous) => new Set(previous).add(rootName));+ const entry = markersByLine+ .get(line)+ ?.find((candidate) => candidate.thread.root.name === rootName);+ if (entry && !entry.thread.resolved) setSelectedRoot(rootName);+ setRevealRequest((previous) => ({+ line,+ rootName,+ nonce: (previous?.nonce ?? 0) + 1,+ }));},- []+ [markersByLine]);- const openEntries = useMemo(- () => (openLine !== undefined ? (markersByLine.get(openLine) ?? []) : []),- [markersByLine, openLine]+ const collapseThread = useCallback((rootName: string) => {+ setExpandedRoots((previous) => {+ const next = new Set(previous);+ next.delete(rootName);+ return next;+ });+ setSelectedRoot((current) => (current === rootName ? undefined : current));+ }, []);+ const toggleLine = useCallback(+ (line: number) => {+ if (!openLines.has(line)) {+ const rootName = firstToExpand(markersByLine.get(line))[0];+ if (rootName) expandThread(line, rootName);+ return;+ }+ const names = new Set(+ markersByLine.get(line)?.map((entry) => entry.thread.root.name) ?? []+ );+ setOpenLines((previous) => {+ const next = new Set(previous);+ next.delete(line);+ return next;+ });+ setExpandedRoots(+ (previous) =>+ new Set([...previous].filter((rootName) => !names.has(rootName)))+ );+ setSelectedRoot((current) =>+ current && names.has(current) ? undefined : current+ );+ },+ [expandThread, markersByLine, openLines]);- const expandedEntry = useMemo(+ const expandedEntries = useMemo(() =>- openEntries.find((entry) => expandedRoots.has(entry.thread.root.name)),- [expandedRoots, openEntries]+ editorThreads.filter((entry) =>+ expandedRoots.has(entry.thread.root.name)+ ),+ [editorThreads, expandedRoots]);+ useEffect(() => {+ setOpenLines((previous) => {+ const next = new Set(+ [...previous].filter((line) => markersByLine.has(line))+ );+ for (const entry of expandedEntries) next.add(entry.range.endLine);+ return next.size === previous.size &&+ [...next].every((line) => previous.has(line))+ ? previous+ : next;+ });+ }, [expandedEntries, markersByLine]);// Keep drafts across card collapses and closing/reopening a gutter group.const [replyDrafts, setReplyDrafts] = useState<Record<string, string>>({});@@ -207,9 +265,8 @@ export function StatementThreadsLayer({Readonly<Record<number, string>>>({});- // Walker: the current thread is the expanded one when it is unresolved.- // Stepping wraps; with nothing open, down starts at the first and up at- // the last.+ // Walker selection follows explicit thread opens and arrow clicks, never+ // manual scrolling. Stepping wraps between the first and last thread.const [walkerAnnouncement, setWalkerAnnouncement] = useState("");const [flashRoot, setFlashRoot] = useState<string | undefined>();const findWidgetVisible = useMonacoFindWidgetVisible(editor);@@ -217,10 +274,10 @@ export function StatementThreadsLayer({() =>visitableThreads.findIndex((entry) =>- entry.range.endLine === openLine &&+ entry.thread.root.name === selectedRoot &&expandedRoots.has(entry.thread.root.name)),- [expandedRoots, openLine, visitableThreads]+ [expandedRoots, selectedRoot, visitableThreads]);const walk = (step: 1 | -1) => {const count = visitableThreads.length;@@ -229,7 +286,7 @@ export function StatementThreadsLayer({currentVisitableIndex === -1 && step < 0 ? count : currentVisitableIndex;const index = (from + step + count) % count;const target = visitableThreads[index];- openThreads(target.range.endLine, [target.thread.root.name]);+ expandThread(target.range.endLine, target.thread.root.name);setSelection(undefined);setFlashRoot(target.thread.root.name);// The thread's zone scrolls the editor when it opens; this only brings@@ -260,7 +317,7 @@ export function StatementThreadsLayer({if (comments.length > 0) clearThreadFocus(threadFocus.nonce);return;}- openThreads(target.range.endLine, [target.thread.root.name]);+ expandThread(target.range.endLine, target.thread.root.name);editor.getDomNode()?.scrollIntoView({ behavior: "smooth", block: "center" });@@ -270,7 +327,7 @@ export function StatementThreadsLayer({comments.length,editor,editorThreads,- openThreads,+ expandThread,spec.id,threadFocus,]);@@ -309,8 +366,10 @@ export function StatementThreadsLayer({lineClasses.set(line, className);}};- if (expandedEntry && !pendingSelection) {- paint(expandedEntry.range, "bb-thread-line");+ if (!pendingSelection) {+ for (const entry of expandedEntries) {+ paint(entry.range, "bb-thread-line");+ }}for (const composer of activeComposers.values()) {paint(composer.range, "bb-thread-line--selecting");@@ -341,7 +400,7 @@ export function StatementThreadsLayer({if (threads.every((entry) => entry.thread.resolved)) {classes.push("bb-thread-glyph--resolved");}- if (line === openLine) classes.push("bb-thread-glyph--active");+ if (openLines.has(line)) classes.push("bb-thread-glyph--active");decorations.push({range: new monacoModule.Range(line, 1, line, 1),options: {@@ -378,10 +437,10 @@ export function StatementThreadsLayer({canCreate,commentedLines,editor,- expandedEntry,+ expandedEntries,markersByLine,monacoModule,- openLine,+ openLines,selection,t,]);@@ -521,11 +580,7 @@ export function StatementThreadsLayer({e.event.preventDefault();editor.setPosition({ lineNumber: line, column: 1 });setSelection(undefined);- if (openLine === line) {- openThreads(undefined, []);- } else {- openThreads(line, firstToExpand(threads));- }+ toggleLine(line);return;}if (!canCreate) return;@@ -552,9 +607,8 @@ export function StatementThreadsLayer({markersByLine,monacoModule,openComposer,- openLine,- openThreads,selection,+ toggleLine,]);// Keyboard and context-menu path: comment on the selected lines.@@ -610,7 +664,7 @@ export function StatementThreadsLayer({);if (!created) return;closeComposer(line);- openThreads(line, [created.name]);+ expandThread(line, created.name);};return (@@ -620,43 +674,54 @@ export function StatementThreadsLayer({<StatementThreadWalkerannouncement={walkerAnnouncement}count={visitableThreads.length}+ position={currentVisitableIndex + 1}onNext={() => walk(1)}onPrevious={() => walk(-1)}remainder={unplacedUnresolved}/></MonacoOverlayWidget>)}- {openLine !== undefined && openEntries.length > 0 && (- <MonacoViewZone- afterLineNumber={openLine}- editor={editor}- revealFromLine={expandedEntry?.range.startLine}- revealKey={expandedEntry ? openNonce : undefined}- revealTarget={expandedThreadRef}- >- <div className="py-2 pr-2">- <ThreadStack- key={openLine}- expandedRoots={expandedRoots}- expandedThreadRef={expandedThreadRef}- flashRoot={flashRoot}- onFlashEnd={() => setFlashRoot(undefined)}- issue={issue}- onCollapse={(rootName) =>- openThreads(- openLine,- Array.from(expandedRoots).filter((r) => r !== rootName)- )+ {[...openLines]+ .sort((a, b) => a - b)+ .map((line) => {+ const entries = markersByLine.get(line);+ if (!entries?.length) return null;+ const revealEntry = entries.find(+ (entry) =>+ revealRequest?.line === line &&+ entry.thread.root.name === revealRequest.rootName &&+ expandedRoots.has(entry.thread.root.name)+ );+ return (+ <MonacoViewZone+ afterLineNumber={line}+ editor={editor}+ key={line}+ revealFromLine={revealEntry?.range.startLine}+ revealKey={+ revealRequest?.line === line ? revealRequest.nonce : undefined}- onExpand={(rootName) => openThreads(openLine, [rootName])}- replyDrafts={replyDrafts}- onReplyDraftChange={updateReplyDraft}- project={project}- threads={openEntries}- />- </div>- </MonacoViewZone>- )}+ revealTarget={revealEntry ? expandedThreadRef : undefined}+ >+ <div className="py-2 pr-2">+ <ThreadStack+ expandedRoots={expandedRoots}+ expandedThreadRef={expandedThreadRef}+ flashRoot={flashRoot}+ onFlashEnd={() => setFlashRoot(undefined)}+ issue={issue}+ onCollapse={collapseThread}+ onExpand={(rootName) => expandThread(line, rootName)}+ replyDrafts={replyDrafts}+ onReplyDraftChange={updateReplyDraft}+ project={project}+ revealRoot={revealEntry?.thread.root.name}+ threads={entries}+ />+ </div>+ </MonacoViewZone>+ );+ })}{Array.from(activeComposers, ([line, composer]) => (<MonacoViewZoneafterLineNumber={line}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 7b39ca88f0..f2d21a5f67 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@@ -19,15 +19,15 @@ vi.mock("@/stores/app", () => ({selector({ getUserByIdentifier: () => ({ email: "[email protected]", title: "Aurora" }) }),}));vi.mock("./CommentThreadCard", () => ({- CommentThreadCard: ({ thread, onThreadStateChanged, replyDraft, onReplyDraftChange }: {+ CommentThreadCard: ({ thread, onClose, replyDraft, onReplyDraftChange }: {thread: EditorThread["thread"];- onThreadStateChanged: (resolved: boolean) => void;+ onClose: () => void;replyDraft: string;onReplyDraftChange: (draft: string) => void;}) => (<div data-thread-name={thread.root.name} data-resolved={String(thread.resolved)}><input aria-label="Reply draft" value={replyDraft} onChange={(e) => onReplyDraftChange(e.target.value)} />- <button onClick={() => onThreadStateChanged(!thread.resolved)}>Change state</button>+ <button onClick={onClose}>Close</button></div>),}));@@ -82,47 +82,43 @@ describe("ThreadStack", () => {expect(order(container)).toEqual(["a", "b"]);});- test.each([- { current: "a", states: [false, true, false], next: "c" },- { current: "c", states: [false, true, false], next: "a" },- { current: "a", states: [false, true, true], next: undefined },- ])("advances after resolving $current, skipping resolved and wrapping within the stack", ({ current, states, next }) => {- const threads = states.map((resolved, index) => entry(["a", "b", "c"][index], resolved, index));- const { getByText } = render(<ThreadStack {...props} expandedRoots={new Set([current])} threads={threads} />);- fireEvent.click(getByText("Change state"));- if (next) expect(props.onExpand).toHaveBeenCalledWith(next);- else {- expect(props.onCollapse).toHaveBeenCalledWith(current);- expect(props.onExpand).not.toHaveBeenCalled();- }- });-- test("reopens the current thread in place", () => {- const { getByText } = render(<ThreadStack {...props} expandedRoots={new Set(["a"])} threads={[entry("a", true, 1), entry("b", false, 2)]} />);- fireEvent.click(getByText("Change state"));- expect(props.onExpand).toHaveBeenCalledWith("a");- expect(props.onCollapse).not.toHaveBeenCalled();+ test("keeps multiple threads expanded and closes only the chosen one", () => {+ const threads = [entry("a", false, 1), entry("b", false, 2)];+ const { container } = render(+ <ThreadStack {...props} expandedRoots={new Set(["a", "b"])} threads={threads} />+ );+ expect(container.querySelectorAll("input")).toHaveLength(2);+ fireEvent.click(container.querySelector('[data-thread-name="a"] button')!);+ expect(props.onCollapse).toHaveBeenCalledWith("a");+ expect(props.onExpand).not.toHaveBeenCalled();});- test("preserves a reply draft when advancing and returning to a collapsed thread", () => {+ test("preserves a reply draft when another thread opens", () => {function Harness() {const [expanded, setExpanded] = useState(new Set(["a"]));const [drafts, setDrafts] = useState<Record<string, string>>({});return <ThreadStack {...props}threads={[entry("a", false, 1), entry("b", false, 2)]}expandedRoots={expanded}- onExpand={(name) => setExpanded(new Set([name]))}- onCollapse={() => setExpanded(new Set())}+ onExpand={(name) => setExpanded((previous) => new Set(previous).add(name))}+ onCollapse={(name) => setExpanded((previous) => {+ const next = new Set(previous);+ next.delete(name);+ return next;+ })}replyDrafts={drafts}onReplyDraftChange={(name, draft) => setDrafts((previous) => ({...previous, [name]: typeof draft === "function" ? draft(previous[name] ?? "") : draft}))}/>;}- const { container, getByLabelText, getByText } = render(<Harness />);- fireEvent.change(getByLabelText("Reply draft"), { target: { value: "unfinished reply" } });- fireEvent.click(getByText("Change state"));+ const { container } = render(<Harness />);+ fireEvent.change(container.querySelector('[data-thread-name="a"] input')!, { target: { value: "unfinished reply" } });+ fireEvent.click(container.querySelector('[data-thread-name="b"]')!);+ expect(container.querySelectorAll("input")).toHaveLength(2);+ expect((container.querySelector('[data-thread-name="a"] input') as HTMLInputElement).value).toBe("unfinished reply");+ fireEvent.click(container.querySelector('[data-thread-name="a"] button')!);expect(container.querySelector('[data-thread-name="b"] input')).not.toBeNull();fireEvent.click(container.querySelector('[data-thread-name="a"]')!);- expect((getByLabelText("Reply draft") as HTMLInputElement).value).toBe("unfinished reply");+ expect((container.querySelector('[data-thread-name="a"] input') as HTMLInputElement).value).toBe("unfinished reply");});test("shows new threads and removes missing ones without remounting retained rows", () => {@@ -139,8 +135,8 @@ describe("ThreadStack", () => {test("exposes the expanded card for editor reveal", () => {const ref = createRef<HTMLDivElement>();const threads = [entry("a", false, 1), entry("b", false, 2)];- const {rerender} = render(<ThreadStack {...props} threads={threads} expandedRoots={new Set(["a"])} expandedThreadRef={ref} />);+ const {rerender} = render(<ThreadStack {...props} threads={threads} expandedRoots={new Set(["a"])} expandedThreadRef={ref} revealRoot="a" />);expect(ref.current?.querySelector('[data-thread-name="a"]')).not.toBeNull();- rerender(<ThreadStack {...props} threads={threads} expandedRoots={new Set(["b"])} expandedThreadRef={ref} />);+ rerender(<ThreadStack {...props} threads={threads} expandedRoots={new Set(["a", "b"])} expandedThreadRef={ref} revealRoot="b" />);expect(ref.current?.querySelector('[data-thread-name="b"]')).not.toBeNull();});diff --git a/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsx b/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsxindex 7c45d43b13..8cc2fc6788 100644--- a/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsx+++ b/frontend/src/routes/project/plan-detail/components/threads/ThreadStack.tsx@@ -60,6 +60,7 @@ export function ThreadStack({replyDrafts,onReplyDraftChange,project,+ revealRoot,threads,}: {expandedRoots: ReadonlySet<string>;@@ -73,6 +74,7 @@ export function ThreadStack({replyDrafts: Readonly<Record<string, string>>;onReplyDraftChange: (rootName: string, draft: SetStateAction<string>) => void;project: Project | undefined;+ revealRoot?: string;threads: EditorThread[];}) {const { t } = useTranslation();@@ -92,19 +94,6 @@ export function ThreadStack({const open = currentEntries(nextGroups.open);const resolved = currentEntries(nextGroups.resolved);const ordered = [...open, ...resolved];- const handleStateChanged = (name: string, resolved: boolean) => {- if (!expandedRoots.has(name)) return;- if (!resolved) {- onExpand(name);- return;- }- const index = ordered.findIndex((entry) => entry.thread.root.name === name);- const next = [...ordered.slice(index + 1), ...ordered.slice(0, index)].find(- (entry) => entry.thread.root.name !== name && !entry.thread.resolved- );- if (next) onExpand(next.thread.root.name);- else onCollapse(name);- };// Threads ending on the same line may cover different ranges; label each// with its range only when they differ.const showRanges =@@ -130,6 +119,7 @@ export function ThreadStack({flashRoot === entry.thread.root.name ? onFlashEnd : undefined}ref={+ revealRoot === entry.thread.root.name &&expandedRoots.has(entry.thread.root.name)? expandedThreadRef: undefined@@ -142,9 +132,6 @@ export function ThreadStack({issue={issue}label={rangeLabel(entry)}onClose={() => onCollapse(entry.thread.root.name)}- onThreadStateChanged={(resolved) =>- handleStateChanged(entry.thread.root.name, resolved)- }replyDraft={replyDrafts[entry.thread.root.name] ?? ""}onReplyDraftChange={(draft) =>onReplyDraftChange(entry.thread.root.name, draft)diff --git a/frontend/src/routes/project/plan-detail/shared/stores/types.ts b/frontend/src/routes/project/plan-detail/shared/stores/types.tsindex d57051e7aa..d9130e9ae2 100644--- a/frontend/src/routes/project/plan-detail/shared/stores/types.ts+++ b/frontend/src/routes/project/plan-detail/shared/stores/types.ts@@ -68,10 +68,12 @@ export type PollingSlice = {};export interface ThreadFocusRequest {- // Root comment name of the thread to expand.+ // Root comment name of the thread to locate.commentName: string;- // Spec the thread anchors to; the editor of this spec consumes the request.+ // Spec whose statement editor consumes the request.specId: string;+ // Current saved statement line to reveal when the spec is being edited.+ lineNumber?: number;nonce: number;}