Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8179 fix(issues): clear sub-issue selection after a batch action applies (#9449)
Jiayuan Zhangc57aa87a6fa8
diff --git a/packages/views/issues/components/batch-action-toolbar.confirm.test.tsx b/packages/views/issues/components/batch-action-toolbar.confirm.test.tsxindex 6401ba6835..97cc77452c 100644--- a/packages/views/issues/components/batch-action-toolbar.confirm.test.tsx+++ b/packages/views/issues/components/batch-action-toolbar.confirm.test.tsx@@ -108,6 +108,7 @@ beforeEach(() => {batchUpdate.mockClear();batchDelete.mockClear();openModal.mockClear();+ selection.clear.mockClear();toast.success.mockClear();toast.warning.mockClear();});@@ -164,3 +165,41 @@ describe("BatchActionToolbar status routing (MUL-4155)", () => {expect(batchDelete).not.toHaveBeenCalled();});});++describe("BatchActionToolbar selection after apply (MUL-8179)", () => {+ it("keeps the selection after an update by default, so edits can be chained", async () => {+ render(<BatchActionToolbar issues={[makeIssue()]} />);+ fireEvent.click(screen.getByTestId("status-done"));+ await waitFor(() => expect(toast.success).toHaveBeenCalled());+ expect(selection.clear).not.toHaveBeenCalled();+ });++ it("clears the selection once an update fully applies when opted in", async () => {+ render(<BatchActionToolbar issues={[makeIssue()]} clearSelectionOnApply />);+ fireEvent.click(screen.getByTestId("status-done"));+ await waitFor(() => expect(selection.clear).toHaveBeenCalledTimes(1));+ });++ it("keeps the selection after a partial update so it can be retried", async () => {+ selection.selectedIds = new Set(["a", "b"]);+ batchUpdate.mockResolvedValueOnce({ updated: 1 });+ render(+ <BatchActionToolbar+ issues={[makeIssue({ id: "a" }), makeIssue({ id: "b" })]}+ clearSelectionOnApply+ />,+ );+ fireEvent.click(screen.getByTestId("status-done"));+ await waitFor(() => expect(toast.warning).toHaveBeenCalled());+ expect(selection.clear).not.toHaveBeenCalled();+ });++ it("hands the run-confirm modal a clear callback instead of clearing up front", () => {+ render(<BatchActionToolbar issues={[makeIssue({ status: "todo" })]} clearSelectionOnApply />);+ fireEvent.click(screen.getByTestId("assign-agent"));+ expect(selection.clear).not.toHaveBeenCalled();+ const data = openModal.mock.calls[0]![1] as { onApplied?: () => void };+ data.onApplied?.();+ expect(selection.clear).toHaveBeenCalledTimes(1);+ });+});diff --git a/packages/views/issues/components/batch-action-toolbar.tsx b/packages/views/issues/components/batch-action-toolbar.tsxindex 40c68da9ba..d104b29a09 100644--- a/packages/views/issues/components/batch-action-toolbar.tsx+++ b/packages/views/issues/components/batch-action-toolbar.tsx@@ -36,6 +36,7 @@ import { useIssueSurfaceSelection } from "../surface/selection-context";export function BatchActionToolbar({issues,placement = "fixed-bottom",+ clearSelectionOnApply = false,}: {/*** The universe of selectable issues at this call site (the same list the@@ -51,6 +52,14 @@ export function BatchActionToolbar({* the selected rows (used inside scrollable sections like sub-issues).*/placement?: "fixed-bottom" | "inline";+ /**+ * Drop the selection once a status / priority / assignee change fully+ * applies. Off for full-screen lists, where the selection stays so several+ * edits can be chained; on for sub-issues, where a batch edit is a one-shot+ * dispatch and a lingering inline toolbar reads as unfinished. A partial or+ * failed write keeps the selection so the user can retry.+ */+ clearSelectionOnApply?: boolean;}) {const { t } = useT("issues");const selection = useIssueSurfaceSelection();@@ -120,6 +129,7 @@ export function BatchActionToolbar({if (updated < count) {toast.warning(t(($) => $.batch.update_partial, { updated, count }));} else {+ if (clearSelectionOnApply) clear();toast.success(t(($) => $.batch.update_success, { count }));}} catch (err) {@@ -160,6 +170,7 @@ export function BatchActionToolbar({mode: "assign",assigneeType: updates.assignee_type,assigneeId: updates.assignee_id,+ onApplied: clearSelectionOnApply ? clear : undefined,});return;}diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsxindex 58a22fa744..ba9fea2aa3 100644--- a/packages/views/issues/components/issue-detail.tsx+++ b/packages/views/issues/components/issue-detail.tsx@@ -3602,7 +3602,11 @@ export function IssueDetail({ issueId, onDelete, onDone, defaultSidebarOpen = tr{/* Inline batch toolbar — appears next to the rows whenselections exist, instead of as a far-away fixed bar. */}- <BatchActionToolbar issues={childIssues} placement="inline" />+ <BatchActionToolbar+ issues={childIssues}+ placement="inline"+ clearSelectionOnApply+ />{/* List */}{!subIssuesCollapsed && (() => {diff --git a/packages/views/modals/run-confirm.test.tsx b/packages/views/modals/run-confirm.test.tsxindex 8672bd263a..3a14cec581 100644--- a/packages/views/modals/run-confirm.test.tsx+++ b/packages/views/modals/run-confirm.test.tsx@@ -64,6 +64,7 @@ vi.mock("../i18n", () => ({// useStatusLabel resolves BUILT-IN keys through i18n and custom ones// through the catalog, so the promote headline needs both sources.status: { todo: "Todo" },+ batch: { update_partial: "updated {{updated}} of {{count}}" },};return sel(labels).replace(/\{\{(\w+)\}\}/g, (_m, k) => String(vars?.[k] ?? ""));},@@ -92,7 +93,7 @@ vi.mock("@multica/ui/components/ui/spinner", () => ({}));// vi.hoisted: vi.mock factories run before module-level consts initialize.// Only error is used now — completion is silent (no result toast).-const mockToast = vi.hoisted(() => ({ error: vi.fn(), success: vi.fn() }));+const mockToast = vi.hoisted(() => ({ error: vi.fn(), success: vi.fn(), warning: vi.fn() }));vi.mock("sonner", () => ({ toast: mockToast }));beforeEach(() => {@@ -100,6 +101,7 @@ beforeEach(() => {mockBatch.mockClear().mockResolvedValue({ updated: 2 });mockToast.error.mockClear();mockToast.success.mockClear();+ mockToast.warning.mockClear();// The real shortcut store drives both the submit chord and the keycap hint,// and jsdom's platform follows the host OS — pin it so the chord is ⌘+Enter// everywhere, not Ctrl+Enter on a Linux CI runner.@@ -304,4 +306,43 @@ describe("RunConfirmModal", () => {expect(onClose).not.toHaveBeenCalled();expect(mockToast.success).not.toHaveBeenCalled();});++ it("runs onApplied only after the write succeeds (MUL-8179)", async () => {+ const onApplied = vi.fn();+ mockBatch.mockRejectedValueOnce(new Error("boom"));+ render(+ <RunConfirmModal+ onClose={vi.fn()}+ data={{ ...single, issueIds: ["i1", "i2"], onApplied }}+ />,+ );+ fireEvent.click(confirmButton());+ await waitFor(() => expect(mockToast.error).toHaveBeenCalledWith("boom"));+ expect(onApplied).not.toHaveBeenCalled();++ fireEvent.click(confirmButton());+ await waitFor(() => expect(onApplied).toHaveBeenCalledTimes(1));+ });++ for (const updated of [0, 1]) {+ for (const button of ["Confirm assignment", "Don't start yet"]) {+ it(`a partial batch (${updated}/2, "${button}") warns and skips onApplied`, async () => {+ const onApplied = vi.fn();+ const onClose = vi.fn();+ mockBatch.mockResolvedValueOnce({ updated });+ render(+ <RunConfirmModal+ onClose={onClose}+ data={{ ...single, issueIds: ["i1", "i2"], onApplied }}+ />,+ );+ fireEvent.click(screen.getByRole("button", { name: button }));+ await waitFor(() =>+ expect(mockToast.warning).toHaveBeenCalledWith(`updated ${updated} of 2`),+ );+ expect(onApplied).not.toHaveBeenCalled();+ expect(onClose).toHaveBeenCalled();+ });+ }+ }});diff --git a/packages/views/modals/run-confirm.tsx b/packages/views/modals/run-confirm.tsxindex 245c5e16fc..f96bf954e0 100644--- a/packages/views/modals/run-confirm.tsx+++ b/packages/views/modals/run-confirm.tsx@@ -67,6 +67,8 @@ interface RunConfirmData {assigneeId?: string;assigneeName?: string;issueRevision?: number;+ /** Runs after every write applies; never on dismiss, failure, or a partial batch. */+ onApplied?: () => void;}/**@@ -82,7 +84,8 @@ interface RunConfirmData {** Completion is silent: the assignee/status change and any run it starts* surface through the issue's normal updates, so the confirm adds no result- * toast. Whether a run starts stays the server's existing decision at write+ * toast; only a batch the server applied partially warns with the real count.+ * Whether a run starts stays the server's existing decision at write* time. Dismissing the dialog (X / Esc / click-outside) cancels without any* write. Shared by single assign (1 id), batch assign (N ids), and the* single-issue promotion out of backlog.@@ -150,8 +153,19 @@ export function RunConfirmModal({...payload,});} else {- await batchUpdate.mutateAsync({ ids: issueIds, updates: payload });+ const { updated } = await batchUpdate.mutateAsync({ ids: issueIds, updates: payload });+ // A partial batch still closes (the applied writes are real), but it+ // warns with the real count and skips onApplied so the caller keeps+ // its selection for a retry.+ if (updated < issueIds.length) {+ toast.warning(+ tIssues(($) => $.batch.update_partial, { updated, count: issueIds.length }),+ );+ onClose();+ return;+ }}+ d.onApplied?.();onClose();} catch (err) {toast.error(