Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-7914 feat(issues): add a rename entry to the issue actions menu (#9119)
Basuotianc4a7724afe01
diff --git a/packages/core/modals/store.ts b/packages/core/modals/store.tsindex 5711839f0d..53d680c2ca 100644--- a/packages/core/modals/store.ts+++ b/packages/core/modals/store.ts@@ -11,6 +11,7 @@ type ModalType =| "issue-set-parent"| "issue-mark-duplicate"| "issue-add-child"+ | "issue-rename"| "issue-delete-confirm"| "issue-run-confirm"| "issue-workflow-handoff"diff --git a/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx b/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsxindex 121857a1b3..9333f3c4fd 100644--- a/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx+++ b/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx@@ -211,6 +211,7 @@ describe("IssueActionsDropdown", () => {expect(screen.getByText("Priority")).toBeInTheDocument();expect(screen.getByText("Assignee")).toBeInTheDocument();expect(screen.getByText("Due date")).toBeInTheDocument();+ expect(screen.getByText("Rename issue")).toBeInTheDocument();expect(screen.getByText("Open in new tab")).toBeInTheDocument();expect(screen.getByText("Copy link")).toBeInTheDocument();expect(screen.getByText("Relations")).toBeInTheDocument();@@ -301,6 +302,26 @@ describe("IssueActionsDropdown", () => {});});+ it("clicking Rename issue opens the rename modal with the current title", async () => {+ render(+ wrap(+ <IssueActionsDropdown+ issue={mockIssue}+ trigger={<button data-testid="trigger">Menu</button>}+ />,+ ),+ );++ fireEvent.click(screen.getByTestId("trigger"));+ fireEvent.click(await screen.findByText("Rename issue"));++ expect(mockOpenModal).toHaveBeenCalledWith("issue-rename", {+ issueId: "issue-1",+ identifier: "TES-1",+ title: "Example",+ });+ });+it("copies the durable local project path for a worktree task", async () => {listTasksByIssueMock.mockResolvedValue([{@@ -435,6 +456,7 @@ describe("IssueActionsContextMenu", () => {expect(await screen.findByText("Status")).toBeInTheDocument();// The right-click surface is what list rows, board cards, gantt bars and// sub-issue rows all share, so this one assertion covers them together.+ expect(screen.getByText("Rename issue")).toBeInTheDocument();expect(screen.getByText("Open in new tab")).toBeInTheDocument();expect(screen.getByText("Delete issue")).toBeInTheDocument();});diff --git a/packages/views/issues/actions/issue-actions-menu-items.tsx b/packages/views/issues/actions/issue-actions-menu-items.tsxindex 142ba3234f..a1a390d1f8 100644--- a/packages/views/issues/actions/issue-actions-menu-items.tsx+++ b/packages/views/issues/actions/issue-actions-menu-items.tsx@@ -15,6 +15,7 @@ import {Network,Pin,PinOff,+ Pencil,Plus,Trash2,Unlink,@@ -129,6 +130,7 @@ export function IssueActionsMenuItems({togglePin,copyLink,openCreateSubIssue,+ openRename,openSetParent,removeParent,openAddChild,@@ -185,6 +187,16 @@ export function IssueActionsMenuItems({return (<>+ {/* Rename leads the menu: it is the only entry that changes what the+ issue *is* rather than a property of it, and on list/board rows it is+ the only way to reach the title at all. */}+ <P.Item onClick={openRename}>+ <Pencil className="h-3.5 w-3.5" />+ {t(($) => $.actions.rename_issue)}+ </P.Item>++ <P.Separator />+{/* Status */}<P.Sub><P.SubTrigger>diff --git a/packages/views/issues/actions/use-issue-actions.ts b/packages/views/issues/actions/use-issue-actions.tsindex d5eafd6007..4fbd83ac28 100644--- a/packages/views/issues/actions/use-issue-actions.ts+++ b/packages/views/issues/actions/use-issue-actions.ts@@ -30,6 +30,7 @@ export interface UseIssueActionsResult {copyLink: () => Promise<void>;copyCommentLink: (commentId: string) => Promise<void>;openCreateSubIssue: () => void;+ openRename: () => void;openSetParent: () => void;removeParent: () => void;openAddChild: () => void;@@ -69,6 +70,7 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {const issueId = issue?.id ?? null;const issueIdentifier = issue?.identifier ?? null;+ const issueTitle = issue?.title ?? "";const issueProjectId = issue?.project_id ?? null;const issueAssigneeType = issue?.assignee_type ?? null;const issueAssigneeId = issue?.assignee_id ?? null;@@ -221,6 +223,19 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {openModal("issue-set-parent", { issueId });}, [openModal, issueId]);+ // Rename entry point for every surface that renders the actions menu. The+ // issue detail page can also activate its inline title editor by clicking the+ // title, but list, board, gantt and sub-issue rows have no such affordance —+ // one shared modal keeps the write path identical everywhere.+ const openRename = useCallback(() => {+ if (!issueId) return;+ openModal("issue-rename", {+ issueId,+ identifier: issueIdentifier,+ title: issueTitle,+ });+ }, [openModal, issueId, issueIdentifier, issueTitle]);+const openMarkDuplicate = useCallback(() => {if (!issueId) return;openModal("issue-mark-duplicate", { issueId });@@ -295,6 +310,7 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {copyLink,copyCommentLink,openCreateSubIssue,+ openRename,openSetParent,removeParent,openAddChild,diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.jsonindex 48f80793fd..7fb289d620 100644--- a/packages/views/locales/en/issues.json+++ b/packages/views/locales/en/issues.json@@ -871,6 +871,7 @@"updated_ago": "Updated {{time}}"},"actions": {+ "rename_issue": "Rename issue","status": "Status","priority": "Priority","assignee": "Assignee",diff --git a/packages/views/locales/en/modals.json b/packages/views/locales/en/modals.jsonindex 501fda546e..f2efc39d61 100644--- a/packages/views/locales/en/modals.json+++ b/packages/views/locales/en/modals.json@@ -19,6 +19,16 @@"toast_deleted": "Issue deleted","toast_delete_failed": "Failed to delete issue"},+ "rename_issue": {+ "title": "Rename issue",+ "placeholder": "Issue title",+ "input_aria_label": "Rename {{identifier}}",+ "submit": "Save",+ "saving": "Saving...",+ "title_required": "Enter a title",+ "toast_renamed": "Issue renamed",+ "toast_failed": "Failed to rename issue"+ },"feedback": {"title": "Feedback","placeholder": "Tell us about your experience, bugs you've found, or features you'd like to see…",diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.jsonindex 3f67e79f02..df4e37ae88 100644--- a/packages/views/locales/fr/issues.json+++ b/packages/views/locales/fr/issues.json@@ -871,6 +871,7 @@"updated_ago": "Mis à jour {{time}}"},"actions": {+ "rename_issue": "Renommer la tâche","status": "Statut","priority": "Priorité","assignee": "Assigné à",diff --git a/packages/views/locales/fr/modals.json b/packages/views/locales/fr/modals.jsonindex b26c1d6b39..605160001e 100644--- a/packages/views/locales/fr/modals.json+++ b/packages/views/locales/fr/modals.json@@ -19,6 +19,16 @@"toast_deleted": "Tâche supprimée","toast_delete_failed": "Échec de la suppression de la tâche"},+ "rename_issue": {+ "title": "Renommer la tâche",+ "placeholder": "Titre de la tâche",+ "input_aria_label": "Renommer {{identifier}}",+ "submit": "Enregistrer",+ "saving": "Enregistrement...",+ "title_required": "Saisissez un titre",+ "toast_renamed": "Tâche renommée",+ "toast_failed": "Échec du renommage de la tâche"+ },"feedback": {"title": "Faire un retour","placeholder": "Parlez-nous de votre expérience, des bugs rencontrés ou des fonctionnalités que vous aimeriez voir…",diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.jsonindex 81a7b3657b..27bd7c8981 100644--- a/packages/views/locales/ja/issues.json+++ b/packages/views/locales/ja/issues.json@@ -829,6 +829,7 @@"updated_ago": "{{time}} に更新"},"actions": {+ "rename_issue": "タスク名を変更","status": "ステータス","priority": "優先度","assignee": "担当者",diff --git a/packages/views/locales/ja/modals.json b/packages/views/locales/ja/modals.jsonindex f30875d7a7..8ac7639f19 100644--- a/packages/views/locales/ja/modals.json+++ b/packages/views/locales/ja/modals.json@@ -19,6 +19,16 @@"toast_deleted": "タスクを削除しました","toast_delete_failed": "タスクを削除できませんでした"},+ "rename_issue": {+ "title": "タスク名を変更",+ "placeholder": "タスク名",+ "input_aria_label": "{{identifier}} の名前を変更",+ "submit": "保存",+ "saving": "保存中...",+ "title_required": "タイトルを入力してください",+ "toast_renamed": "タスク名を変更しました",+ "toast_failed": "タスク名を変更できませんでした"+ },"feedback": {"title": "フィードバック","placeholder": "使用感、見つけたバグ、追加してほしい機能などをお聞かせください…",diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.jsonindex 7d1f031824..1f1f3b9504 100644--- a/packages/views/locales/ko/issues.json+++ b/packages/views/locales/ko/issues.json@@ -829,6 +829,7 @@"updated_ago": "{{time}} 수정됨"},"actions": {+ "rename_issue": "태스크 이름 변경","status": "상태","priority": "우선순위","assignee": "담당자",diff --git a/packages/views/locales/ko/modals.json b/packages/views/locales/ko/modals.jsonindex 6b41ccb593..81d3bd7edb 100644--- a/packages/views/locales/ko/modals.json+++ b/packages/views/locales/ko/modals.json@@ -19,6 +19,16 @@"toast_deleted": "태스크를 삭제했습니다","toast_delete_failed": "태스크를 삭제하지 못했습니다"},+ "rename_issue": {+ "title": "태스크 이름 변경",+ "placeholder": "태스크 제목",+ "input_aria_label": "{{identifier}} 이름 변경",+ "submit": "저장",+ "saving": "저장 중...",+ "title_required": "제목을 입력하세요",+ "toast_renamed": "태스크 이름이 변경되었습니다",+ "toast_failed": "태스크 이름을 변경하지 못했습니다"+ },"feedback": {"title": "피드백","placeholder": "사용 경험, 발견한 버그, 필요한 기능을 알려주세요...",diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.jsonindex d236b33bff..14411a42e1 100644--- a/packages/views/locales/zh-Hans/issues.json+++ b/packages/views/locales/zh-Hans/issues.json@@ -829,6 +829,7 @@"updated_ago": "更新于 {{time}}"},"actions": {+ "rename_issue": "重命名任务","status": "状态","priority": "优先级","assignee": "负责人",diff --git a/packages/views/locales/zh-Hans/modals.json b/packages/views/locales/zh-Hans/modals.jsonindex 61b1e92817..8af5f2bbdd 100644--- a/packages/views/locales/zh-Hans/modals.json+++ b/packages/views/locales/zh-Hans/modals.json@@ -19,6 +19,16 @@"toast_deleted": "已删除任务","toast_delete_failed": "删除任务失败"},+ "rename_issue": {+ "title": "重命名任务",+ "placeholder": "任务标题",+ "input_aria_label": "重命名 {{identifier}}",+ "submit": "保存",+ "saving": "保存中...",+ "title_required": "请输入标题",+ "toast_renamed": "任务名称已更新",+ "toast_failed": "重命名任务失败"+ },"feedback": {"title": "反馈","placeholder": "聊聊你的体验、遇到的 bug,或想看到的功能...",diff --git a/packages/views/modals/registry.tsx b/packages/views/modals/registry.tsxindex 94773bf220..2a70e00971 100644--- a/packages/views/modals/registry.tsx+++ b/packages/views/modals/registry.tsx@@ -9,6 +9,7 @@ import { FeedbackModal } from "./feedback";import { SetParentIssueModal } from "./set-parent-issue";import { MarkDuplicateIssueModal } from "./mark-duplicate-issue";import { AddChildIssueModal } from "./add-child-issue";+import { RenameIssueModal } from "./rename-issue";import { DeleteIssueConfirmModal } from "./delete-issue-confirm";import { RunConfirmModal } from "./run-confirm";import { WorkflowHandoffModal } from "./workflow-handoff";@@ -59,6 +60,9 @@ export function ModalRegistry() {case "issue-add-child":activeModal = <AddChildIssueModal onClose={close} data={data} />;break;+ case "issue-rename":+ activeModal = <RenameIssueModal onClose={close} data={data} />;+ break;case "issue-delete-confirm":activeModal = <DeleteIssueConfirmModal onClose={close} data={data} />;break;diff --git a/packages/views/modals/rename-issue.test.tsx b/packages/views/modals/rename-issue.test.tsxnew file mode 100644index 0000000000..5a51f229ef--- /dev/null+++ b/packages/views/modals/rename-issue.test.tsx@@ -0,0 +1,182 @@+import { describe, it, expect, vi, beforeEach } from "vitest";+import { render, screen, fireEvent, waitFor } from "@testing-library/react";+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";+import { ApiError } from "@multica/core/api";+import { issueKeys } from "@multica/core/issues/queries";+import type { Issue, UpdateIssueRequest } from "@multica/core/types";+import { RenameIssueModal } from "./rename-issue";++const { mockUpdate, toastErrorMock, toastSuccessMock } = vi.hoisted(() => ({+ mockUpdate: vi.fn(),+ toastErrorMock: vi.fn(),+ toastSuccessMock: vi.fn(),+}));++vi.mock("@multica/core/api", async (importOriginal) => ({+ ...(await importOriginal<typeof import("@multica/core/api")>()),+ api: { updateIssue: mockUpdate },+}));++vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws-1" }));++vi.mock("sonner", () => ({+ toast: { success: toastSuccessMock, error: toastErrorMock },+}));++vi.mock("../i18n", () => ({+ useT: () => ({+ t: (sel: (x: Record<string, Record<string, string>>) => string) =>+ sel({+ common: { cancel: "Cancel" },+ revision: { conflict: "The title changed. Compare before saving again." },+ rename_issue: {+ title: "Rename issue",+ placeholder: "Issue title",+ input_aria_label: "Rename {{identifier}}",+ submit: "Save",+ saving: "Saving...",+ title_required: "Enter a title",+ toast_renamed: "Issue renamed",+ toast_failed: "Failed to rename issue",+ },+ }),+ }),+}));++function renderModal(data: Record<string, unknown> | null) {+ const onClose = vi.fn();+ const queryClient = new QueryClient({+ defaultOptions: { queries: { retry: false }, mutations: { retry: false } },+ });+ queryClient.setQueryData(issueKeys.detail("ws-1", issue.id), issue);+ render(+ <QueryClientProvider client={queryClient}>+ <RenameIssueModal onClose={onClose} data={data} />+ </QueryClientProvider>,+ );+ return { onClose, input: screen.getByRole("textbox"), queryClient };+}++const issue: Issue = {+ id: "issue-1",+ workspace_id: "ws-1",+ number: 1,+ identifier: "TES-1",+ title: "Old name",+ revision: 1,+ description: null,+ status: "todo",+ priority: "none",+ assignee_type: null,+ assignee_id: null,+ creator_type: "member",+ creator_id: "user-1",+ parent_issue_id: null,+ project_id: null,+ position: 0,+ stage: null,+ start_date: null,+ due_date: null,+ labels: [],+ metadata: {},+ properties: {},+ created_at: "2026-10-19T00:00:00Z",+ updated_at: "2026-10-19T00:00:00Z",+};++const data = { issueId: "issue-1", identifier: "TES-1", title: "Old name" };++describe("RenameIssueModal", () => {+ beforeEach(() => {+ vi.clearAllMocks();+ mockUpdate.mockImplementation(async (_id: string, updates: UpdateIssueRequest) => ({+ ...issue,+ ...updates,+ revision: 2,+ }));+ });++ it("writes the trimmed name and closes on success", async () => {+ const { onClose, input } = renderModal(data);++ fireEvent.change(input, { target: { value: " New name " } });+ fireEvent.click(screen.getByText("Save"));++ await waitFor(() =>+ expect(mockUpdate).toHaveBeenCalledWith("issue-1", {+ title: "New name",+ title_base: "Old name",+ }),+ );+ await waitFor(() => expect(onClose).toHaveBeenCalled());+ expect(toastSuccessMock).toHaveBeenCalledWith("Issue renamed");+ });++ // Submitting the unchanged name must not fire a pointless write; the user+ // opened the dialog, agreed with the existing title, and wants out.+ it("closes without a write when the name is unchanged", async () => {+ const { onClose } = renderModal(data);++ fireEvent.click(screen.getByText("Save"));++ expect(mockUpdate).not.toHaveBeenCalled();+ expect(onClose).toHaveBeenCalled();+ });++ it("refuses an empty name and keeps the dialog open", async () => {+ const { onClose, input } = renderModal(data);++ fireEvent.change(input, { target: { value: " " } });+ fireEvent.click(screen.getByText("Save"));++ expect(mockUpdate).not.toHaveBeenCalled();+ expect(onClose).not.toHaveBeenCalled();+ expect(toastErrorMock).toHaveBeenCalledWith("Enter a title");+ });++ it("keeps the dialog open when the write fails", async () => {+ mockUpdate.mockRejectedValueOnce(new Error("boom"));+ const { onClose, input } = renderModal(data);++ fireEvent.change(input, { target: { value: "New name" } });+ fireEvent.click(screen.getByText("Save"));++ await waitFor(() => expect(toastErrorMock).toHaveBeenCalledWith("boom"));+ expect(onClose).not.toHaveBeenCalled();+ });++ it("protects a concurrent rename and preserves the draft and original baseline on retry", async () => {+ let serverIssue = { ...issue, title: "Someone else's name", revision: 2 };+ mockUpdate.mockImplementation(async (_id: string, updates: UpdateIssueRequest) => {+ if (updates.title_base !== undefined && updates.title_base !== serverIssue.title) {+ throw new ApiError("raw server conflict", 409, "Conflict", {+ code: "revision_conflict",+ });+ }+ serverIssue = { ...serverIssue, ...updates, revision: serverIssue.revision + 1 };+ return serverIssue;+ });+ const { onClose, input, queryClient } = renderModal(data);++ fireEvent.change(input, { target: { value: "My draft" } });+ fireEvent.click(screen.getByText("Save"));++ await waitFor(() =>+ expect(toastErrorMock).toHaveBeenCalledWith("The title changed. Compare before saving again."),+ );+ expect(serverIssue.title).toBe("Someone else's name");+ expect(input).toHaveValue("My draft");+ expect(onClose).not.toHaveBeenCalled();+ expect(toastSuccessMock).not.toHaveBeenCalled();++ // A refreshed cache must not silently approve overwriting the remote edit.+ queryClient.setQueryData(issueKeys.detail("ws-1", issue.id), serverIssue);+ fireEvent.click(screen.getByText("Save"));++ await waitFor(() => expect(toastErrorMock).toHaveBeenCalledTimes(2));+ expect(serverIssue.title).toBe("Someone else's name");+ expect(input).toHaveValue("My draft");+ expect(onClose).not.toHaveBeenCalled();+ expect(toastSuccessMock).not.toHaveBeenCalled();+ });+});diff --git a/packages/views/modals/rename-issue.tsx b/packages/views/modals/rename-issue.tsxnew file mode 100644index 0000000000..0e4cca59f9--- /dev/null+++ b/packages/views/modals/rename-issue.tsx@@ -0,0 +1,151 @@+"use client";++import { useEffect, useRef, useState } from "react";+import { toast } from "sonner";+import {+ Dialog,+ DialogContent,+ DialogFooter,+ DialogHeader,+ DialogTitle,+} from "@multica/ui/components/ui/dialog";+import { Button } from "@multica/ui/components/ui/button";+import { Input } from "@multica/ui/components/ui/input";+import { errorCode } from "@multica/core/api";+import { useUpdateIssue } from "@multica/core/issues/mutations";+import { useT } from "../i18n";++/**+ * Rename an issue from any surface.+ *+ * The issue detail page lets you click the title itself, but list, board,+ * gantt and sub-issue rows only offer the 3-dot / right-click menu — with no+ * way to change the title. This modal is that missing entry point: the actions+ * menu opens it with the issue's current title, and it writes through the same+ * `useUpdateIssue` mutation every other field edit uses (so lists, board and+ * the detail projection all reconcile from one code path).+ */+export function RenameIssueModal({+ onClose,+ data,+}: {+ onClose: () => void;+ data: Record<string, unknown> | null;+}) {+ const { t } = useT("modals");+ const { t: tIssues } = useT("issues");+ const issueId = typeof data?.issueId === "string" ? data.issueId : "";+ const seedTitle = typeof data?.title === "string" ? data.title : "";+ const seedIdentifier =+ typeof data?.identifier === "string" ? data.identifier : "";+ const [title, setTitle] = useState(seedTitle);+ const inputRef = useRef<HTMLInputElement>(null);+ const updateIssue = useUpdateIssue();+ const pending = updateIssue.isPending;++ // Focus + select on open so the current name is replaced by the first+ // keystroke — the shape every rename affordance has.+ useEffect(() => {+ const input = inputRef.current;+ if (!input) return;+ input.focus();+ input.select();+ }, []);++ const trimmed = title.trim();+ const unchanged = trimmed === seedTitle.trim();+ // Deliberately not gated on "nothing changed" or "empty": both cases route+ // through handleSubmit, which either closes or explains itself. A disabled+ // button would leave the user clicking a dead control with no reason why.+ const canSubmit = !!issueId && !pending;++ const handleSubmit = async () => {+ if (pending || !issueId) return;+ // An empty name is rejected rather than silently treated as a no-op: the+ // user cleared the field on purpose and needs to know it was not applied.+ if (!trimmed) {+ toast.error(t(($) => $.rename_issue.title_required));+ return;+ }+ if (unchanged) {+ onClose();+ return;+ }+ try {+ await updateIssue.mutateAsync({+ id: issueId,+ title: trimmed,+ title_base: seedTitle,+ });+ toast.success(t(($) => $.rename_issue.toast_renamed));+ onClose();+ } catch (err) {+ toast.error(+ errorCode(err) === "revision_conflict"+ ? tIssues(($) => $.revision.conflict)+ : err instanceof Error && err.message+ ? err.message+ : t(($) => $.rename_issue.toast_failed),+ );+ }+ };++ return (+ <Dialog+ open+ onOpenChange={(v) => {+ // Never dismiss mid-write: the mutation has already been sent, and+ // closing here would leave the user with no feedback either way.+ if (!v && !pending) onClose();+ }}+ >+ <DialogContent className="sm:max-w-md">+ <DialogHeader>+ <DialogTitle>{t(($) => $.rename_issue.title)}</DialogTitle>+ </DialogHeader>+ <form+ onSubmit={(event) => {+ event.preventDefault();+ void handleSubmit();+ }}+ >+ <Input+ ref={inputRef}+ value={title}+ disabled={pending}+ placeholder={t(($) => $.rename_issue.placeholder)}+ aria-label={+ seedIdentifier+ ? t(($) => $.rename_issue.input_aria_label, {+ identifier: seedIdentifier,+ })+ : t(($) => $.rename_issue.title)+ }+ onChange={(event) => setTitle(event.target.value)}+ />+ </form>+ <DialogFooter>+ <Button+ type="button"+ variant="outline"+ size="sm"+ disabled={pending}+ onClick={onClose}+ >+ {t(($) => $.common.cancel)}+ </Button>+ <Button+ type="button"+ size="sm"+ disabled={!canSubmit}+ onClick={() => void handleSubmit()}+ >+ {pending+ ? t(($) => $.rename_issue.saving)+ : t(($) => $.rename_issue.submit)}+ </Button>+ </DialogFooter>+ </DialogContent>+ </Dialog>+ );+}