Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

MUL-9442: complete Copy link with title in issue and project menus (#10769)

Multica Eve4c691ba31c70
diff --git a/packages/ui/lib/clipboard.test.ts b/packages/ui/lib/clipboard.test.ts
index dffa5bc4c7..f74ff5e50e 100644
--- a/packages/ui/lib/clipboard.test.ts
+++ b/packages/ui/lib/clipboard.test.ts
@@ -1,5 +1,5 @@
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
-import { copyText } from "./clipboard";
+import { copyText, copyTextAndHtml } from "./clipboard";
const clipboardDescriptor = Object.getOwnPropertyDescriptor(navigator, "clipboard");
@@ -140,3 +140,69 @@ describe("copyText selection preservation", () => {
expect(document.querySelector("textarea")).toBeNull();
});
});
+
+describe("copyTextAndHtml", () => {
+ class FakeClipboardItem {
+ constructor(readonly data: Record<string, Blob>) {}
+ }
+
+ afterEach(() => {
+ vi.unstubAllGlobals();
+ });
+
+ it("writes the plain-text and HTML channels in one clipboard item", async () => {
+ const write = vi.fn().mockResolvedValue(undefined);
+ Object.defineProperty(navigator, "clipboard", {
+ value: { write },
+ configurable: true,
+ });
+ vi.stubGlobal("ClipboardItem", FakeClipboardItem);
+
+ expect(
+ await copyTextAndHtml(
+ "[TES-1 Example](https://app.example/test/issues/TES-1)",
+ '<a href="https://app.example/test/issues/TES-1">TES-1 Example</a>',
+ ),
+ ).toBe(true);
+
+ expect(write).toHaveBeenCalledTimes(1);
+ const items = (write.mock.calls[0] as [FakeClipboardItem[]])[0]!;
+ expect(items).toHaveLength(1);
+ const item = items[0]!;
+ const plain = item.data["text/plain"]!;
+ const html = item.data["text/html"]!;
+ expect(plain.type).toBe("text/plain");
+ expect(await plain.text()).toBe(
+ "[TES-1 Example](https://app.example/test/issues/TES-1)",
+ );
+ expect(html.type).toBe("text/html");
+ expect(await html.text()).toBe(
+ '<a href="https://app.example/test/issues/TES-1">TES-1 Example</a>',
+ );
+ });
+
+ it("falls back to the plain-text channel when the rich write is rejected", async () => {
+ const write = vi.fn().mockRejectedValue(new Error("synthetic denial"));
+ Object.defineProperty(navigator, "clipboard", {
+ value: { write },
+ configurable: true,
+ });
+ vi.stubGlobal("ClipboardItem", FakeClipboardItem);
+
+ expect(await copyTextAndHtml("plain", "<b>rich</b>")).toBe(true);
+ expect(document.execCommand).toHaveBeenCalledWith("copy");
+ });
+
+ it("falls back to the plain-text channel when ClipboardItem is unavailable", async () => {
+ const write = vi.fn();
+ Object.defineProperty(navigator, "clipboard", {
+ value: { write, writeText: vi.fn().mockResolvedValue(undefined) },
+ configurable: true,
+ });
+ vi.stubGlobal("ClipboardItem", undefined);
+
+ expect(await copyTextAndHtml("plain", "<b>rich</b>")).toBe(true);
+ expect(write).not.toHaveBeenCalled();
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith("plain");
+ });
+});
diff --git a/packages/ui/lib/clipboard.ts b/packages/ui/lib/clipboard.ts
index 347811e0a5..48fc6c7005 100644
--- a/packages/ui/lib/clipboard.ts
+++ b/packages/ui/lib/clipboard.ts
@@ -94,6 +94,41 @@ export async function copyText(text: string): Promise<boolean> {
}
}
+/**
+ * Copy text in two clipboard channels: a plain-text rendering and an HTML one.
+ *
+ * Used by "Copy link with title", where rich targets (docs, email, chat) should
+ * paste the anchor while plain-text targets get the Markdown link. Targets
+ * that only understand plain text, and browsers without the async Clipboard
+ * API or `ClipboardItem`, receive the plain-text channel through `copyText`.
+ *
+ * @returns `true` on success, `false` on failure.
+ */
+export async function copyTextAndHtml(
+ text: string,
+ html: string,
+): Promise<boolean> {
+ if (
+ typeof navigator !== "undefined" &&
+ navigator.clipboard?.write &&
+ typeof ClipboardItem !== "undefined"
+ ) {
+ try {
+ await navigator.clipboard.write([
+ new ClipboardItem({
+ "text/plain": new Blob([text], { type: "text/plain" }),
+ "text/html": new Blob([html], { type: "text/html" }),
+ }),
+ ]);
+ return true;
+ } catch {
+ // Permission denied / document not focused / item rejected — fall back
+ // to plain text so the link still lands on the clipboard.
+ }
+ }
+ return copyText(text);
+}
+
/**
* Copy the image at `url` to the clipboard as a PNG.
*
diff --git a/packages/views/common/title-link.test.ts b/packages/views/common/title-link.test.ts
new file mode 100644
index 0000000000..64067494a6
--- /dev/null
+++ b/packages/views/common/title-link.test.ts
@@ -0,0 +1,54 @@
+// @vitest-environment node
+import { describe, expect, it } from "vitest";
+import { createElement } from "react";
+import { renderToStaticMarkup } from "react-dom/server";
+import Markdown from "react-markdown";
+import rehypeRaw from "rehype-raw";
+import { titleLinkPayload } from "./title-link";
+
+describe("titleLinkPayload", () => {
+ it("builds a Markdown link and an HTML anchor with the same label and URL", () => {
+ expect(
+ titleLinkPayload(
+ "TES-1 Example",
+ "https://app.example/test/issues/TES-1",
+ ),
+ ).toEqual({
+ text: "[TES-1 Example](https://app.example/test/issues/TES-1)",
+ html: '<a href="https://app.example/test/issues/TES-1">TES-1 Example</a>',
+ });
+ });
+
+ it("escapes Markdown link syntax in the label", () => {
+ expect(titleLinkPayload("Fix [draft] (v2)", "https://x.test/i/1").text).toBe(
+ "[Fix \\[draft\\] \\(v2\\)](https://x.test/i/1)",
+ );
+ });
+
+ it("escapes HTML text and attribute content", () => {
+ const { html } = titleLinkPayload(
+ 'Ship <b>"fast"</b> & safe',
+ 'https://x.test/i/1?a=1&b="2"',
+ );
+ expect(html).toBe(
+ '<a href="https://x.test/i/1?a=1&amp;b=&quot;2&quot;">Ship &lt;b&gt;&quot;fast&quot;&lt;/b&gt; &amp; safe</a>',
+ );
+ });
+
+ it.each(["details", "Enter"])(
+ "renders <%s> in the Markdown link as literal title text",
+ (tag) => {
+ const { text } = titleLinkPayload(
+ `MUL-1 Support <${tag}> & text`,
+ "https://x.test/i/1",
+ );
+ const rendered = renderToStaticMarkup(
+ createElement(Markdown, { rehypePlugins: [rehypeRaw], children: text }),
+ );
+
+ expect(rendered).toBe(
+ `<p><a href="https://x.test/i/1">MUL-1 Support &lt;${tag}&gt; &amp; text</a></p>`,
+ );
+ },
+ );
+});
diff --git a/packages/views/common/title-link.ts b/packages/views/common/title-link.ts
new file mode 100644
index 0000000000..f4b0b090ea
--- /dev/null
+++ b/packages/views/common/title-link.ts
@@ -0,0 +1,30 @@
+import { escapeMarkdownLabel } from "../editor/utils/escape-markdown-label";
+
+/**
+ * The two clipboard representations of a title link: Markdown for plain-text
+ * targets, and an HTML anchor for rich-text targets. Both carry the same
+ * visible label and destination.
+ */
+export interface TitleLinkPayload {
+ text: string;
+ html: string;
+}
+
+export function titleLinkPayload(label: string, url: string): TitleLinkPayload {
+ return {
+ text: `[${escapeMarkdownLabel(label).replace(/</g, "\\<")}](${url})`,
+ html: `<a href="${escapeHtmlAttribute(url)}">${escapeHtmlText(label)}</a>`,
+ };
+}
+
+function escapeHtmlText(value: string): string {
+ return value
+ .replace(/&/g, "&amp;")
+ .replace(/</g, "&lt;")
+ .replace(/>/g, "&gt;")
+ .replace(/"/g, "&quot;");
+}
+
+function escapeHtmlAttribute(value: string): string {
+ return escapeHtmlText(value).replace(/'/g, "&#39;");
+}
diff --git a/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx b/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx
index f38568004a..f47aa84757 100644
--- a/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx
+++ b/packages/views/issues/actions/__tests__/issue-actions-menu.test.tsx
@@ -134,7 +134,7 @@ vi.mock("sonner", () => ({
toast: { success: toastSuccessMock, error: toastErrorMock, info: vi.fn() },
}));
-const { apiMocks, copyTextMock } = vi.hoisted(() => ({
+const { apiMocks, copyTextMock, copyTextAndHtmlMock } = vi.hoisted(() => ({
apiMocks: {
listTasksByIssue: vi.fn(),
listIssueWorkflows: vi.fn(),
@@ -147,6 +147,7 @@ const { apiMocks, copyTextMock } = vi.hoisted(() => ({
runQuickAction: vi.fn(),
},
copyTextMock: vi.fn(),
+ copyTextAndHtmlMock: vi.fn(),
}));
vi.mock("@multica/core/api", () => ({
@@ -156,6 +157,7 @@ vi.mock("@multica/core/api", () => ({
vi.mock("@multica/ui/lib/clipboard", () => ({
copyText: copyTextMock,
+ copyTextAndHtml: copyTextAndHtmlMock,
}));
vi.mock("../../../common/actor-avatar", () => ({
@@ -222,6 +224,8 @@ beforeEach(() => {
navState.hash = "";
copyTextMock.mockReset();
copyTextMock.mockResolvedValue(true);
+ copyTextAndHtmlMock.mockReset();
+ copyTextAndHtmlMock.mockResolvedValue(true);
toastSuccessMock.mockReset();
toastErrorMock.mockReset();
apiMocks.listQuickActions.mockReset();
@@ -267,6 +271,7 @@ describe("IssueActionsDropdown", () => {
expect(screen.getByText("Rename issue")).toBeInTheDocument();
expect(screen.getByText("Open in new tab")).toBeInTheDocument();
expect(screen.getByText("Copy link")).toBeInTheDocument();
+ expect(screen.getByText("Copy link with title")).toBeInTheDocument();
expect(screen.getByText("Create sub-issue")).toBeInTheDocument();
expect(screen.getByText("Relations")).toBeInTheDocument();
expect(screen.getByText("Delete issue")).toBeInTheDocument();
@@ -275,6 +280,25 @@ describe("IssueActionsDropdown", () => {
expect(screen.queryByText("Add sub-issue...")).not.toBeInTheDocument();
});
+ it("copies the identifier and title as a rich link", async () => {
+ render(
+ wrap(
+ <IssueActionsDropdown
+ issue={mockIssue}
+ trigger={<button data-testid="trigger">Menu</button>}
+ />,
+ ),
+ );
+
+ fireEvent.click(screen.getByTestId("trigger"));
+ fireEvent.click(await screen.findByText("Copy link with title"));
+
+ expect(copyTextAndHtmlMock).toHaveBeenCalledWith(
+ "[TES-1 Example](https://app.example/test/issues/TES-1)",
+ '<a href="https://app.example/test/issues/TES-1">TES-1 Example</a>',
+ );
+ });
+
it("lists Create sub-issue directly below Rename issue", async () => {
render(
wrap(
@@ -805,6 +829,7 @@ describe("Sidebar variant (MUL-8425)", () => {
"Pin to sidebar",
"Mark as unread",
"Copy link",
+ "Copy link with title",
"Copy identifier",
]);
expect(screen.getByTestId("row")).toHaveAttribute("data-popup-open");
diff --git a/packages/views/issues/actions/__tests__/use-issue-actions.test.tsx b/packages/views/issues/actions/__tests__/use-issue-actions.test.tsx
index 9fa4bb286a..4ee57ddd33 100644
--- a/packages/views/issues/actions/__tests__/use-issue-actions.test.tsx
+++ b/packages/views/issues/actions/__tests__/use-issue-actions.test.tsx
@@ -1,9 +1,10 @@
-import { describe, it, expect, vi, beforeEach } from "vitest";
+import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
import { renderHook, act, waitFor } from "@testing-library/react";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { buildIssueStatusCatalog } from "@multica/core/issue-statuses";
import { statusCategoryOfKey } from "@multica/core/issues";
import type { Issue, IssueStatusEntry } from "@multica/core/types";
+import * as clipboard from "@multica/ui/lib/clipboard";
vi.mock("@multica/core/hooks", () => ({
useWorkspaceId: () => "ws-1",
@@ -163,6 +164,10 @@ beforeEach(() => {
});
});
+afterEach(() => {
+ vi.restoreAllMocks();
+});
+
describe("useIssueActions", () => {
it("updateField dispatches useUpdateIssue.mutate with the correct payload", () => {
const { result } = renderHook(() => useIssueActions(mockIssue), { wrapper });
@@ -298,6 +303,30 @@ describe("useIssueActions", () => {
);
});
+ it("copyTitleAsLink copies the identifier and title as a Markdown link", async () => {
+ const { result } = renderHook(() => useIssueActions(mockIssue), { wrapper });
+
+ await act(async () => {
+ await result.current.copyTitleAsLink();
+ });
+
+ expect(navigator.clipboard.writeText).toHaveBeenCalledWith(
+ "[TES-1 Example](https://app.multica.com/test/issues/TES-1)",
+ );
+ });
+
+ it("copyTitleAsLink reports a failed copy without a success toast", async () => {
+ vi.spyOn(clipboard, "copyTextAndHtml").mockResolvedValueOnce(false);
+ const { result } = renderHook(() => useIssueActions(mockIssue), { wrapper });
+
+ await act(async () => {
+ await result.current.copyTitleAsLink();
+ });
+
+ expect(toast.error).toHaveBeenCalledOnce();
+ expect(toast.success).not.toHaveBeenCalled();
+ });
+
it("copyCommentLink writes the issue's shareable URL anchored at the comment", async () => {
const { result } = renderHook(() => useIssueActions(mockIssue), { wrapper });
diff --git a/packages/views/issues/actions/issue-actions-menu-items.tsx b/packages/views/issues/actions/issue-actions-menu-items.tsx
index ff38a927d8..88c3a5cf75 100644
--- a/packages/views/issues/actions/issue-actions-menu-items.tsx
+++ b/packages/views/issues/actions/issue-actions-menu-items.tsx
@@ -25,6 +25,7 @@ import {
Plus,
Square,
Trash2,
+ Type,
Unlink,
UserMinus,
Zap,
@@ -132,6 +133,7 @@ export function IssueActionsMenuItems({
openInDesktop,
togglePin,
copyLink,
+ copyTitleAsLink,
openCreateSubIssue,
openRename,
openSetParent,
@@ -435,6 +437,10 @@ export function IssueActionsMenuItems({
<Link2 className="h-3.5 w-3.5" />
{t(($) => $.actions.copy_link)}
</P.Item>
+ <P.Item onClick={copyTitleAsLink}>
+ <Type className="h-3.5 w-3.5" />
+ {t(($) => $.actions.copy_title_as_link)}
+ </P.Item>
{sidebar ? (
<P.Item onClick={copyIdentifier}>
<Hash className="h-3.5 w-3.5" />
diff --git a/packages/views/issues/actions/use-issue-actions.ts b/packages/views/issues/actions/use-issue-actions.ts
index d18050b4a2..5da4bdd932 100644
--- a/packages/views/issues/actions/use-issue-actions.ts
+++ b/packages/views/issues/actions/use-issue-actions.ts
@@ -13,9 +13,10 @@ import { useUpdateIssue } from "@multica/core/issues/mutations";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
import { errorCode } from "@multica/core/api";
import { pinListOptions, useCreatePin, useDeletePin } from "@multica/core/pins";
-import { copyText } from "@multica/ui/lib/clipboard";
+import { copyText, copyTextAndHtml } from "@multica/ui/lib/clipboard";
import { useNavigation } from "../../navigation";
import { useT } from "../../i18n";
+import { titleLinkPayload } from "../../common/title-link";
import { runConfirmIntent } from "./run-confirm-gate";
import { useIssueSurfaceActionsOptional } from "../surface/actions-context";
import type { IssueSurfaceMutationOptions } from "../surface/actions-context";
@@ -31,6 +32,7 @@ export interface UseIssueActionsResult {
openInNewWindow?: () => void;
togglePin: () => void;
copyLink: () => Promise<void>;
+ copyTitleAsLink: () => Promise<void>;
copyCommentLink: (commentId: string) => Promise<void>;
openCreateSubIssue: () => void;
openRename: () => void;
@@ -192,6 +194,20 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {
}
}, [paths, issueId, issueIdentifier, navigation, t]);
+ const copyTitleAsLink = useCallback(async () => {
+ if (!issueId) return;
+ const url = navigation.getShareableUrl(paths.issueDetail(issueIdentifier || issueId));
+ // Keep the identifier in front of the title, matching how the issue reads
+ // in lists and activity feeds, so the pasted link stays recognizable.
+ const label = [issueIdentifier, issueTitle].filter(Boolean).join(" ");
+ const { text, html } = titleLinkPayload(label, url);
+ if (await copyTextAndHtml(text, html)) {
+ toast.success(t(($) => $.detail.title_link_copied));
+ } else {
+ toast.error(t(($) => $.detail.link_copy_failed));
+ }
+ }, [paths, issueId, issueIdentifier, issueTitle, navigation, t]);
+
// Built during render so `copyCommentLink` depends on this string alone:
// `paths` is rebuilt on every render, and the handler is passed to every
// memoized comment card, so depending on it would re-render all of them on
@@ -322,6 +338,7 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {
openInNewWindow: navigation.openIssueInNewWindow ? openInNewWindow : undefined,
togglePin,
copyLink,
+ copyTitleAsLink,
copyCommentLink,
openCreateSubIssue,
openRename,
diff --git a/packages/views/layout/panels/work-tree.test.tsx b/packages/views/layout/panels/work-tree.test.tsx
index 21f25a6b2f..171566abc6 100644
--- a/packages/views/layout/panels/work-tree.test.tsx
+++ b/packages/views/layout/panels/work-tree.test.tsx
@@ -227,6 +227,7 @@ describe("ProjectsSection", () => {
"Open in new tab",
"Pin to sidebar",
"Copy link",
+ "Copy link with title",
"Archive",
]);
diff --git a/packages/views/locales/en/issues.json b/packages/views/locales/en/issues.json
index 1224f4bd43..822bf44e55 100644
--- a/packages/views/locales/en/issues.json
+++ b/packages/views/locales/en/issues.json
@@ -600,6 +600,7 @@
},
"update_failed": "Failed to update issue",
"link_copied": "Link copied",
+ "title_link_copied": "Link copied with title",
"link_copy_failed": "Failed to copy link",
"workdir_path_copied": "Workdir path copied",
"project_directory_path_copied": "Project directory path copied",
@@ -1079,6 +1080,7 @@
"mark_read": "Mark as read",
"mark_unread": "Mark as unread",
"copy_link": "Copy link",
+ "copy_title_as_link": "Copy link with title",
"copy_workdir_path": "Copy local workdir path",
"copy_project_directory_path": "Copy project directory path",
"copy_identifier": "Copy identifier",
diff --git a/packages/views/locales/en/projects.json b/packages/views/locales/en/projects.json
index 5e5dd7af04..4dfc7ac630 100644
--- a/packages/views/locales/en/projects.json
+++ b/packages/views/locales/en/projects.json
@@ -80,6 +80,7 @@
"sidebar_tooltip": "Toggle right sidebar",
"rename_action": "Rename project",
"copy_link": "Copy link",
+ "copy_title_as_link": "Copy link with title",
"delete_action": "Delete project",
"section_properties": "Properties",
"section_progress": "Progress",
@@ -96,6 +97,8 @@
"empty_issues_add_existing": "Add existing issue",
"no_issues_yet": "No issues yet",
"toast_link_copied": "Link copied",
+ "toast_title_link_copied": "Link copied with title",
+ "toast_title_link_copy_failed": "Failed to copy link",
"toast_project_deleted": "Project deleted",
"toast_move_issue_failed": "Failed to move issue",
"archive_action": "Archive project",
diff --git a/packages/views/locales/es/issues.json b/packages/views/locales/es/issues.json
index 9405785e30..a3d07ee7ec 100644
--- a/packages/views/locales/es/issues.json
+++ b/packages/views/locales/es/issues.json
@@ -563,6 +563,7 @@
},
"update_failed": "No se ha podido actualizar la tarea",
"link_copied": "Enlace copiado",
+ "title_link_copied": "Enlace copiado con título",
"link_copy_failed": "No se ha podido copiar el enlace",
"workdir_path_copied": "Ruta del directorio de trabajo copiada",
"project_directory_path_copied": "Ruta del directorio del proyecto copiada",
@@ -989,6 +990,7 @@
"locate_in_sidebar": "Mostrar en la barra lateral",
"unpin_from_sidebar": "Dejar de fijar de la barra lateral",
"copy_link": "Copiar enlace",
+ "copy_title_as_link": "Copiar enlace con título",
"copy_workdir_path": "Copiar ruta del directorio de trabajo local",
"copy_project_directory_path": "Copiar ruta del directorio del proyecto",
"relations": "Relaciones",
diff --git a/packages/views/locales/es/projects.json b/packages/views/locales/es/projects.json
index 2e69deda30..79213b9313 100644
--- a/packages/views/locales/es/projects.json
+++ b/packages/views/locales/es/projects.json
@@ -78,6 +78,7 @@
"sidebar_tooltip": "Mostrar u ocultar la barra lateral derecha",
"rename_action": "Renombrar proyecto",
"copy_link": "Copiar enlace",
+ "copy_title_as_link": "Copiar enlace con título",
"delete_action": "Eliminar proyecto",
"section_properties": "Propiedades",
"section_progress": "Progreso",
@@ -93,6 +94,8 @@
"empty_issues_new_button": "Nueva tarea",
"no_issues_yet": "Aún no hay tareas",
"toast_link_copied": "Enlace copiado",
+ "toast_title_link_copied": "Enlace copiado con título",
+ "toast_title_link_copy_failed": "No se ha podido copiar el enlace",
"toast_project_deleted": "Proyecto eliminado",
"toast_move_issue_failed": "No se ha podido mover la tarea",
"not_found_description": "Puede haberse eliminado o puede que no tengas acceso.",
diff --git a/packages/views/locales/fr/issues.json b/packages/views/locales/fr/issues.json
index a7e6b9fbd6..b51836c8b6 100644
--- a/packages/views/locales/fr/issues.json
+++ b/packages/views/locales/fr/issues.json
@@ -600,6 +600,7 @@
},
"update_failed": "Échec de la mise à jour de la tâche",
"link_copied": "Lien copié",
+ "title_link_copied": "Lien copié avec le titre",
"link_copy_failed": "Échec de la copie du lien",
"workdir_path_copied": "Chemin du répertoire de travail copié",
"project_directory_path_copied": "Chemin du répertoire du projet copié",
@@ -1079,6 +1080,7 @@
"mark_read": "Marquer comme lu",
"mark_unread": "Marquer comme non lu",
"copy_link": "Copier le lien",
+ "copy_title_as_link": "Copier le lien avec le titre",
"copy_workdir_path": "Copier le chemin du répertoire de travail local",
"copy_project_directory_path": "Copier le chemin du répertoire du projet",
"copy_identifier": "Copier l'identifiant",
diff --git a/packages/views/locales/fr/projects.json b/packages/views/locales/fr/projects.json
index 0348a1fd95..bf46d1b61d 100644
--- a/packages/views/locales/fr/projects.json
+++ b/packages/views/locales/fr/projects.json
@@ -80,6 +80,7 @@
"sidebar_tooltip": "Afficher ou masquer la barre latérale droite",
"rename_action": "Renommer le projet",
"copy_link": "Copier le lien",
+ "copy_title_as_link": "Copier le lien avec le titre",
"delete_action": "Supprimer le projet",
"section_properties": "Propriétés",
"section_progress": "Avancement",
@@ -96,6 +97,8 @@
"empty_issues_add_existing": "Ajouter une tâche existante",
"no_issues_yet": "Aucune tâche pour l'instant",
"toast_link_copied": "Lien copié",
+ "toast_title_link_copied": "Lien copié avec le titre",
+ "toast_title_link_copy_failed": "Échec de la copie du lien",
"toast_project_deleted": "Projet supprimé",
"toast_move_issue_failed": "Échec du déplacement de la tâche",
"archive_action": "Archiver le projet",
diff --git a/packages/views/locales/ja/issues.json b/packages/views/locales/ja/issues.json
index 0e01e05cb8..e3c2ca4cfa 100644
--- a/packages/views/locales/ja/issues.json
+++ b/packages/views/locales/ja/issues.json
@@ -591,6 +591,7 @@
},
"update_failed": "タスクを更新できませんでした",
"link_copied": "リンクをコピーしました",
+ "title_link_copied": "タイトル付きリンクをコピーしました",
"link_copy_failed": "リンクをコピーできませんでした",
"workdir_path_copied": "作業ディレクトリのパスをコピーしました",
"project_directory_path_copied": "プロジェクトディレクトリのパスをコピーしました",
@@ -1025,6 +1026,7 @@
"mark_read": "既読にする",
"mark_unread": "未読にする",
"copy_link": "リンクをコピー",
+ "copy_title_as_link": "タイトル付きリンクをコピー",
"copy_workdir_path": "ローカルの作業ディレクトリのパスをコピー",
"copy_project_directory_path": "プロジェクトディレクトリのパスをコピー",
"copy_identifier": "識別子をコピー",
diff --git a/packages/views/locales/ja/projects.json b/packages/views/locales/ja/projects.json
index 8181417a89..562fca0c14 100644
--- a/packages/views/locales/ja/projects.json
+++ b/packages/views/locales/ja/projects.json
@@ -80,6 +80,7 @@
"sidebar_tooltip": "右サイドバーの開閉",
"rename_action": "プロジェクト名を変更",
"copy_link": "リンクをコピー",
+ "copy_title_as_link": "タイトル付きリンクをコピー",
"delete_action": "プロジェクトを削除",
"section_properties": "プロパティ",
"section_progress": "進捗",
@@ -96,6 +97,8 @@
"empty_issues_add_existing": "既存のタスクを追加",
"no_issues_yet": "タスクはまだありません",
"toast_link_copied": "リンクをコピーしました",
+ "toast_title_link_copied": "タイトル付きリンクをコピーしました",
+ "toast_title_link_copy_failed": "リンクをコピーできませんでした",
"toast_project_deleted": "プロジェクトを削除しました",
"toast_move_issue_failed": "タスクを移動できませんでした",
"archive_action": "プロジェクトをアーカイブ",
diff --git a/packages/views/locales/ko/issues.json b/packages/views/locales/ko/issues.json
index f861b57816..e7ca694c28 100644
--- a/packages/views/locales/ko/issues.json
+++ b/packages/views/locales/ko/issues.json
@@ -591,6 +591,7 @@
},
"update_failed": "태스크를 업데이트하지 못했습니다",
"link_copied": "링크를 복사했습니다",
+ "title_link_copied": "제목이 포함된 링크를 복사했습니다",
"link_copy_failed": "링크를 복사하지 못했습니다",
"workdir_path_copied": "작업 디렉터리 경로를 복사했습니다",
"project_directory_path_copied": "프로젝트 디렉터리 경로를 복사했습니다",
@@ -1025,6 +1026,7 @@
"mark_read": "읽음으로 표시",
"mark_unread": "읽지 않음으로 표시",
"copy_link": "링크 복사",
+ "copy_title_as_link": "제목이 포함된 링크 복사",
"copy_workdir_path": "로컬 작업 디렉터리 경로 복사",
"copy_project_directory_path": "프로젝트 디렉터리 경로 복사",
"copy_identifier": "식별자 복사",
diff --git a/packages/views/locales/ko/projects.json b/packages/views/locales/ko/projects.json
index 807b86a756..8c5fc54948 100644
--- a/packages/views/locales/ko/projects.json
+++ b/packages/views/locales/ko/projects.json
@@ -80,6 +80,7 @@
"sidebar_tooltip": "오른쪽 사이드바 열기/닫기",
"rename_action": "프로젝트 이름 변경",
"copy_link": "링크 복사",
+ "copy_title_as_link": "제목이 포함된 링크 복사",
"delete_action": "프로젝트 삭제",
"section_properties": "속성",
"section_progress": "진행률",
@@ -96,6 +97,8 @@
"empty_issues_add_existing": "기존 태스크 추가",
"no_issues_yet": "아직 태스크가 없습니다",
"toast_link_copied": "링크를 복사했습니다",
+ "toast_title_link_copied": "제목이 포함된 링크를 복사했습니다",
+ "toast_title_link_copy_failed": "링크를 복사하지 못했습니다",
"toast_project_deleted": "프로젝트를 삭제했습니다",
"toast_move_issue_failed": "태스크를 이동하지 못했습니다",
"archive_action": "프로젝트 보관",
diff --git a/packages/views/locales/ru/issues.json b/packages/views/locales/ru/issues.json
index a055caa19a..d277c89998 100644
--- a/packages/views/locales/ru/issues.json
+++ b/packages/views/locales/ru/issues.json
@@ -610,6 +610,7 @@
},
"update_failed": "Не удалось обновить задачу",
"link_copied": "Ссылка скопирована",
+ "title_link_copied": "Ссылка с заголовком скопирована",
"link_copy_failed": "Не удалось скопировать ссылку",
"workdir_path_copied": "Путь к рабочей директории скопирован",
"project_directory_path_copied": "Путь к директории проекта скопирован",
@@ -1184,6 +1185,7 @@
"mark_read": "Отметить как прочитанное",
"mark_unread": "Отметить как непрочитанное",
"copy_link": "Копировать ссылку",
+ "copy_title_as_link": "Копировать ссылку с заголовком",
"copy_workdir_path": "Копировать путь к локальной рабочей директории",
"copy_project_directory_path": "Копировать путь к директории проекта",
"copy_identifier": "Копировать идентификатор",
diff --git a/packages/views/locales/ru/projects.json b/packages/views/locales/ru/projects.json
index ba08cb5c8e..d2f940b72f 100644
--- a/packages/views/locales/ru/projects.json
+++ b/packages/views/locales/ru/projects.json
@@ -78,6 +78,7 @@
"sidebar_tooltip": "Показать/скрыть правую панель",
"rename_action": "Переименовать проект",
"copy_link": "Скопировать ссылку",
+ "copy_title_as_link": "Копировать ссылку с заголовком",
"delete_action": "Удалить проект",
"section_properties": "Свойства",
"section_progress": "Прогресс",
@@ -93,6 +94,8 @@
"empty_issues_new_button": "Новая задача",
"no_issues_yet": "Пока нет задач",
"toast_link_copied": "Ссылка скопирована",
+ "toast_title_link_copied": "Ссылка с заголовком скопирована",
+ "toast_title_link_copy_failed": "Не удалось скопировать ссылку",
"toast_project_deleted": "Проект удалён",
"toast_move_issue_failed": "Не удалось переместить задачу",
"not_found_description": "Возможно, он удалён или у вас нет доступа.",
diff --git a/packages/views/locales/zh-Hans/issues.json b/packages/views/locales/zh-Hans/issues.json
index a18c7ba6b0..14ed839785 100644
--- a/packages/views/locales/zh-Hans/issues.json
+++ b/packages/views/locales/zh-Hans/issues.json
@@ -589,6 +589,7 @@
},
"update_failed": "更新任务失败",
"link_copied": "已复制链接",
+ "title_link_copied": "已复制带标题的链接",
"link_copy_failed": "复制链接失败",
"workdir_path_copied": "已复制本地 workdir 路径",
"project_directory_path_copied": "已复制项目目录路径",
@@ -1025,6 +1026,7 @@
"mark_read": "标为已读",
"mark_unread": "标为未读",
"copy_link": "复制链接",
+ "copy_title_as_link": "复制带标题的链接",
"copy_workdir_path": "复制本地 workdir 路径",
"copy_project_directory_path": "复制项目目录路径",
"copy_identifier": "复制标识符",
diff --git a/packages/views/locales/zh-Hans/projects.json b/packages/views/locales/zh-Hans/projects.json
index 7770c0aba0..f2481a4251 100644
--- a/packages/views/locales/zh-Hans/projects.json
+++ b/packages/views/locales/zh-Hans/projects.json
@@ -80,6 +80,7 @@
"sidebar_tooltip": "切换右侧边栏",
"rename_action": "重命名项目",
"copy_link": "复制链接",
+ "copy_title_as_link": "复制带标题的链接",
"delete_action": "删除项目",
"section_properties": "属性",
"section_progress": "进度",
@@ -96,6 +97,8 @@
"empty_issues_add_existing": "添加已有任务",
"no_issues_yet": "目前还没有任务",
"toast_link_copied": "已复制链接",
+ "toast_title_link_copied": "已复制带标题的链接",
+ "toast_title_link_copy_failed": "复制链接失败",
"toast_project_deleted": "已删除项目",
"toast_move_issue_failed": "移动任务失败",
"archive_action": "归档项目",
diff --git a/packages/views/locales/zh-Hant/issues.json b/packages/views/locales/zh-Hant/issues.json
index 28c022bec6..221e72d7f7 100644
--- a/packages/views/locales/zh-Hant/issues.json
+++ b/packages/views/locales/zh-Hant/issues.json
@@ -589,6 +589,7 @@
},
"update_failed": "更新任務失敗",
"link_copied": "已複製連結",
+ "title_link_copied": "已複製帶標題的連結",
"link_copy_failed": "複製連結失敗",
"workdir_path_copied": "已複製本地 workdir 路徑",
"project_directory_path_copied": "已複製專案目錄路徑",
@@ -1025,6 +1026,7 @@
"mark_read": "標為已讀",
"mark_unread": "標為未讀",
"copy_link": "複製連結",
+ "copy_title_as_link": "複製帶標題的連結",
"copy_workdir_path": "複製本地 workdir 路徑",
"copy_project_directory_path": "複製專案目錄路徑",
"copy_identifier": "複製識別符號",
diff --git a/packages/views/locales/zh-Hant/projects.json b/packages/views/locales/zh-Hant/projects.json
index 2b0b7a462e..c88b5eea44 100644
--- a/packages/views/locales/zh-Hant/projects.json
+++ b/packages/views/locales/zh-Hant/projects.json
@@ -80,6 +80,7 @@
"sidebar_tooltip": "切換右側邊欄",
"rename_action": "重新命名專案",
"copy_link": "複製連結",
+ "copy_title_as_link": "複製帶標題的連結",
"delete_action": "刪除專案",
"section_properties": "屬性",
"section_progress": "進度",
@@ -96,6 +97,8 @@
"empty_issues_add_existing": "加入既有任務",
"no_issues_yet": "目前還沒有任務",
"toast_link_copied": "已複製連結",
+ "toast_title_link_copied": "已複製帶標題的連結",
+ "toast_title_link_copy_failed": "複製連結失敗",
"toast_project_deleted": "已刪除專案",
"toast_move_issue_failed": "移動任務失敗",
"archive_action": "歸檔專案",
diff --git a/packages/views/projects/components/project-detail.test.tsx b/packages/views/projects/components/project-detail.test.tsx
index d4778178ec..f8c1f6c54b 100644
--- a/packages/views/projects/components/project-detail.test.tsx
+++ b/packages/views/projects/components/project-detail.test.tsx
@@ -15,6 +15,7 @@ import { ProjectDetail } from "./project-detail";
const mocks = vi.hoisted(() => ({
role: "admin",
copyText: vi.fn(),
+ copyTextAndHtml: vi.fn(),
deleteProject: vi.fn(),
getProject: vi.fn(),
getProjectSubscription: vi.fn(),
@@ -28,6 +29,7 @@ const mocks = vi.hoisted(() => ({
vi.mock("@multica/ui/lib/clipboard", () => ({
copyText: mocks.copyText,
+ copyTextAndHtml: mocks.copyTextAndHtml,
}));
vi.mock("../../workflows/project-workflow-sheet", () => ({
@@ -272,6 +274,7 @@ beforeEach(() => {
qc.setQueryData(["pins"], []);
pending = deferred();
mocks.copyText.mockReset().mockResolvedValue(true);
+ mocks.copyTextAndHtml.mockReset().mockResolvedValue(true);
mocks.deleteProject.mockReset().mockReturnValue(pending.promise);
mocks.getProject.mockReset().mockResolvedValue(PROJECT);
mocks.getProjectSubscription.mockReset().mockResolvedValue(false);
@@ -369,6 +372,32 @@ describe("ProjectDetail subscription", () => {
});
});
+describe("ProjectDetail copy link with title", () => {
+ it("copies the project title as a Markdown link and an HTML anchor", async () => {
+ const user = userEvent.setup();
+ renderProjectDetail();
+
+ await user.click(screen.getByRole("button", { name: "Copy link with title" }));
+
+ expect(mocks.copyTextAndHtml).toHaveBeenCalledWith(
+ "[Launch Plan](https://app.example/test-workspace/projects/project-1)",
+ '<a href="https://app.example/test-workspace/projects/project-1">Launch Plan</a>',
+ );
+ expect(mocks.toastSuccess).toHaveBeenCalledWith("Link copied with title");
+ });
+
+ it("reports a failed copy without a success toast", async () => {
+ mocks.copyTextAndHtml.mockResolvedValueOnce(false);
+ const user = userEvent.setup();
+ renderProjectDetail();
+
+ await user.click(screen.getByRole("button", { name: "Copy link with title" }));
+
+ expect(mocks.toastError).toHaveBeenCalledWith("Failed to copy link");
+ expect(mocks.toastSuccess).not.toHaveBeenCalled();
+ });
+});
+
describe("ProjectDetail project deletion", () => {
it("allows cancelling an offline detail deletion without executing it on reconnect", async () => {
onlineManager.setOnline(false);
diff --git a/packages/views/projects/components/project-detail.tsx b/packages/views/projects/components/project-detail.tsx
index 8fcaeb82f9..d9d2f49d4c 100644
--- a/packages/views/projects/components/project-detail.tsx
+++ b/packages/views/projects/components/project-detail.tsx
@@ -3,10 +3,10 @@
import { useMemo, useState, useCallback, useRef, useEffect } from "react";
import { useRegisterCommandBarContext } from "../../search/register-context";
import { useDefaultLayout, usePanelRef } from "react-resizable-panels";
-import { Archive, ArchiveRestore, BellOff, BellRing, Check, ChevronRight, FileQuestion, Link2, PanelRight, Pencil, Pin, PinOff, Trash2 } from "@multica/ui/icons";
+import { Archive, ArchiveRestore, BellOff, BellRing, Check, ChevronRight, FileQuestion, Link2, PanelRight, Pencil, Pin, PinOff, Trash2, Type } from "@multica/ui/icons";
import { useQuery } from "@tanstack/react-query";
import { cn } from "@multica/ui/lib/utils";
-import { copyText } from "@multica/ui/lib/clipboard";
+import { copyText, copyTextAndHtml } from "@multica/ui/lib/clipboard";
import { toast } from "sonner";
import type { Project, ProjectStatus, ProjectPriority } from "@multica/core/types";
import { useAuthStore } from "@multica/core/auth";
@@ -81,6 +81,7 @@ import {
AlertDialogTitle,
} from "@multica/ui/components/ui/alert-dialog";
import { useT } from "../../i18n";
+import { titleLinkPayload } from "../../common/title-link";
import { useProjectStatusLabels, useProjectPriorityLabels, useFormatRelativeDate } from "./labels";
import {
ArchivedProjectNotice,
@@ -560,6 +561,22 @@ export function ProjectDetail({ projectId }: { projectId: string }) {
<Link2 className="h-3.5 w-3.5" />
{t(($) => $.detail.copy_link)}
</DropdownMenuItem>
+ <DropdownMenuItem onClick={() => {
+ const { text, html } = titleLinkPayload(
+ project.title,
+ router.getShareableUrl(currentPath(router)),
+ );
+ void copyTextAndHtml(text, html).then((ok) => {
+ if (ok) {
+ toast.success(t(($) => $.detail.toast_title_link_copied));
+ } else {
+ toast.error(t(($) => $.detail.toast_title_link_copy_failed));
+ }
+ });
+ }}>
+ <Type className="h-3.5 w-3.5" />
+ {t(($) => $.detail.copy_title_as_link)}
+ </DropdownMenuItem>
<DropdownMenuItem onClick={() => {
if (isPinned) {
deletePinMut.mutate({ itemType: "project", itemId: projectId });
diff --git a/packages/views/projects/components/project-row-actions.tsx b/packages/views/projects/components/project-row-actions.tsx
index 87facea500..cfbb32e133 100644
--- a/packages/views/projects/components/project-row-actions.tsx
+++ b/packages/views/projects/components/project-row-actions.tsx
@@ -3,8 +3,8 @@
import { useState, type ReactNode } from "react";
import { useQuery } from "@tanstack/react-query";
import { toast } from "sonner";
-import { Archive, ArchiveRestore, ExternalLink, Link2, Pencil, Pin, PinOff, Trash2 } from "@multica/ui/icons";
-import { copyText } from "@multica/ui/lib/clipboard";
+import { Archive, ArchiveRestore, ExternalLink, Link2, Pencil, Pin, PinOff, Trash2, Type } from "@multica/ui/icons";
+import { copyText, copyTextAndHtml } from "@multica/ui/lib/clipboard";
import { Button } from "@multica/ui/components/ui/button";
import { Spinner } from "@multica/ui/components/ui/spinner";
import {
@@ -31,6 +31,7 @@ import { agentListOptions, memberListOptions } from "@multica/core/workspace/que
import { useT } from "../../i18n";
import { useIntentNavigate, useNavigation } from "../../navigation";
import { CollectionRowMenu } from "../../layout/collection-list";
+import { titleLinkPayload } from "../../common/title-link";
import { useArchiveProjects, useRestoreProjects } from "./project-archive";
export function DeleteProjectsDialog({
@@ -180,6 +181,17 @@ export function ProjectRowActions({
toast.success(tLayout(($) => $.rail.link_copied));
}
};
+ const copyTitleAsLink = async () => {
+ const { text, html } = titleLinkPayload(
+ project.title,
+ getShareableUrl(wsPaths.projectDetail(project.id)),
+ );
+ if (await copyTextAndHtml(text, html)) {
+ toast.success(t(($) => $.detail.toast_title_link_copied));
+ } else {
+ toast.error(t(($) => $.detail.toast_title_link_copy_failed));
+ }
+ };
return (
<>
@@ -230,6 +242,10 @@ export function ProjectRowActions({
<Link2 className="size-3.5" />
{tLayout(($) => $.rail.copy_link)}
</DropdownMenuItem>
+ <DropdownMenuItem onClick={() => void copyTitleAsLink()}>
+ <Type className="size-3.5" />
+ {t(($) => $.detail.copy_title_as_link)}
+ </DropdownMenuItem>
<DropdownMenuSeparator />
{project.archived_at ? (
<DropdownMenuItem onClick={() => restore(project)}>
diff --git a/packages/views/projects/components/projects-page.test.tsx b/packages/views/projects/components/projects-page.test.tsx
index b160846fa8..0744ada78b 100644
--- a/packages/views/projects/components/projects-page.test.tsx
+++ b/packages/views/projects/components/projects-page.test.tsx
@@ -17,6 +17,10 @@ const mocks = vi.hoisted(() => ({
createPin: vi.fn(),
deletePin: vi.fn(),
openModal: vi.fn(),
+ copyText: vi.fn(),
+ copyTextAndHtml: vi.fn(),
+ toastSuccess: vi.fn(),
+ toastError: vi.fn(),
savePrefs: vi.fn(),
projectViewState: {
layout: "table",
@@ -38,6 +42,15 @@ const mocks = vi.hoisted(() => ({
},
}));
+vi.mock("@multica/ui/lib/clipboard", () => ({
+ copyText: mocks.copyText,
+ copyTextAndHtml: mocks.copyTextAndHtml,
+}));
+
+vi.mock("sonner", () => ({
+ toast: { success: mocks.toastSuccess, error: mocks.toastError },
+}));
+
vi.mock("@tanstack/react-query", () => ({
queryOptions: (options: unknown) => options,
useQuery: (options: { queryKey?: readonly unknown[] }) => {
@@ -298,6 +311,10 @@ beforeEach(() => {
mocks.createPin.mockClear();
mocks.deletePin.mockClear();
mocks.openModal.mockClear();
+ mocks.copyText.mockReset().mockResolvedValue(true);
+ mocks.copyTextAndHtml.mockReset().mockResolvedValue(true);
+ mocks.toastSuccess.mockReset();
+ mocks.toastError.mockReset();
mocks.savePrefs.mockClear();
mocks.projectViewState.setLayout.mockClear();
mocks.projectViewState.setGroupBy.mockClear();
@@ -370,6 +387,47 @@ describe("ProjectsPage rename", () => {
);
});
+describe("ProjectsPage sharing", () => {
+ it.each(["table", "board"])(
+ "copies the title link immediately after Copy link in the %s row menu",
+ async (layout) => {
+ mocks.projectViewState.layout = layout;
+ const user = userEvent.setup();
+ const adapter = renderProjects(makeAdapter({
+ getShareableUrl: (path) => `https://app.example${path}`,
+ }));
+ const copyLink = screen.getByRole("button", { name: "Copy link" });
+ const copyTitle = screen.getByRole("button", { name: "Copy link with title" });
+ expect(copyLink.nextElementSibling).toBe(copyTitle);
+
+ await user.click(copyTitle);
+
+ expect(mocks.copyTextAndHtml).toHaveBeenCalledWith(
+ "[Launch Plan](https://app.example/test-workspace/projects/project-1)",
+ '<a href="https://app.example/test-workspace/projects/project-1">Launch Plan</a>',
+ );
+ expect(mocks.toastSuccess).toHaveBeenCalledWith("Link copied with title");
+ expect(adapter.push).not.toHaveBeenCalled();
+
+ await user.click(copyLink);
+ expect(mocks.copyText).toHaveBeenCalledWith(
+ "https://app.example/test-workspace/projects/project-1",
+ );
+ },
+ );
+
+ it("reports a failed title-link copy without a success toast", async () => {
+ mocks.copyTextAndHtml.mockResolvedValueOnce(false);
+ const user = userEvent.setup();
+ renderProjects();
+
+ await user.click(screen.getByRole("button", { name: "Copy link with title" }));
+
+ expect(mocks.toastError).toHaveBeenCalledWith("Failed to copy link");
+ expect(mocks.toastSuccess).not.toHaveBeenCalled();
+ });
+});
+
describe("ProjectsPage table row navigation", () => {
it("renders the project name as text, not a title link", () => {
renderProjects();