Skip to content

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

Go

perf(issues): link Snoozed rows by identifier and type-guard issue links against bare UUIDs (MUL-9810) (#11158)

Jiayuan Zhang3c2416db2d55
diff --git a/AGENTS.md b/AGENTS.md
index 32c39a332f..fd335bf606 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -123,6 +123,7 @@ Workspace-scoped queries filter by `workspace_id`; membership gates access and `
- Import icons from `@multica/ui/icons`; no icon library is installed. If the icon you need is missing, draw it by following `.agents/skills/multica-icons/SKILL.md`. Do not substitute an inline SVG or an emoji. Rewrite icon imports in `ui:add` output before committing. Exception: proportional-width optical keycap glyphs live exclusively in `KBD_GLYPHS` inside `packages/ui/components/ui/kbd.tsx` and are only for `<Kbd>`.
- Use shared semantic tokens in `packages/ui/styles/`. Typography uses the role-named `--text-*` scale in `packages/ui/styles/tokens.css`, not Tailwind's default size ramp.
- Selected states remain identifiable on hover. Handle overflow, long text, and scrolling deliberately; avoid unnecessary local state and dividers.
+- Issue links use the identifier (`MUL-123`): `paths.issueDetail` takes an `IssueRouteRef` from `issueRouteRef(issue)`. With only a UUID, use `useIssueRouteRef` (or `cachedIssueRouteRef` in event handlers). A UUID URL is rewritten to the identifier after load, which mounts the issue page a second time on web.
## Testing
diff --git a/apps/desktop/src/renderer/src/components/window-overlay.tsx b/apps/desktop/src/renderer/src/components/window-overlay.tsx
index c37501f1bd..3e20276312 100644
--- a/apps/desktop/src/renderer/src/components/window-overlay.tsx
+++ b/apps/desktop/src/renderer/src/components/window-overlay.tsx
@@ -71,7 +71,7 @@ function WindowOverlayInner() {
if (ws && destination?.kind === "chat") {
push(paths.workspace(ws.slug).chatSession(destination.sessionId));
} else if (ws && destination?.kind === "issue") {
- push(paths.workspace(ws.slug).issueDetail(destination.issueId));
+ push(paths.workspace(ws.slug).issueDetail(destination.issueRef));
} else if (ws) {
push(paths.workspace(ws.slug).issues());
}
@@ -94,7 +94,7 @@ function WindowOverlayInner() {
);
} else if (ws && destination?.kind === "issue") {
push(
- paths.workspace(ws.slug).issueDetail(destination.issueId),
+ paths.workspace(ws.slug).issueDetail(destination.issueRef),
);
} else if (ws) {
push(paths.workspace(ws.slug).issues());
diff --git a/apps/web/app/(auth)/onboarding/page.tsx b/apps/web/app/(auth)/onboarding/page.tsx
index 00c9a4e219..48a85f81cb 100644
--- a/apps/web/app/(auth)/onboarding/page.tsx
+++ b/apps/web/app/(auth)/onboarding/page.tsx
@@ -78,7 +78,7 @@ export default function OnboardingPage() {
);
} else if (ws && destination?.kind === "issue") {
router.push(
- paths.workspace(ws.slug).issueDetail(destination.issueId),
+ paths.workspace(ws.slug).issueDetail(destination.issueRef),
);
} else if (ws) {
router.push(paths.workspace(ws.slug).issues());
diff --git a/apps/web/app/(auth)/workspaces/new/page.tsx b/apps/web/app/(auth)/workspaces/new/page.tsx
index b0a071605e..3a849f5e87 100644
--- a/apps/web/app/(auth)/workspaces/new/page.tsx
+++ b/apps/web/app/(auth)/workspaces/new/page.tsx
@@ -52,7 +52,7 @@ export default function Page() {
);
} else if (ws && destination?.kind === "issue") {
router.push(
- paths.workspace(ws.slug).issueDetail(destination.issueId),
+ paths.workspace(ws.slug).issueDetail(destination.issueRef),
);
} else if (ws) {
router.push(paths.workspace(ws.slug).issues());
diff --git a/apps/web/app/[workspaceSlug]/(dashboard)/issues/[id]/deliverables/[name]/page.test.tsx b/apps/web/app/[workspaceSlug]/(dashboard)/issues/[id]/deliverables/[name]/page.test.tsx
index 8c71eb5bdd..65568154a4 100644
--- a/apps/web/app/[workspaceSlug]/(dashboard)/issues/[id]/deliverables/[name]/page.test.tsx
+++ b/apps/web/app/[workspaceSlug]/(dashboard)/issues/[id]/deliverables/[name]/page.test.tsx
@@ -4,7 +4,7 @@ import { beforeEach, describe, expect, it, vi } from "vitest";
import { getRouteRegex } from "next/dist/shared/lib/router/utils/route-regex";
import { getRouteMatcher } from "next/dist/shared/lib/router/utils/route-matcher";
import { getDynamicParam } from "next/dist/shared/lib/router/utils/get-dynamic-param";
-import { paths } from "@multica/core/paths";
+import { paths, type IssueRouteRef } from "@multica/core/paths";
const routeProps = vi.hoisted(() => ({
last: null as { routeId: string; deliverable?: string } | null,
@@ -32,7 +32,7 @@ function pageParam(matched: Parameters<typeof getDynamicParam>[0], key: string):
}
async function renderLink(filename: string) {
- const href = paths.workspace("acme").issueDeliverable("MUL-1", filename);
+ const href = paths.workspace("acme").issueDeliverable("MUL-1" as IssueRouteRef, filename);
const matched = matchRoute(href);
if (!matched) throw new Error(`route did not match ${href}`);
const params = { id: pageParam(matched, "id"), name: pageParam(matched, "name") };
diff --git a/packages/core/api/schemas.test.ts b/packages/core/api/schemas.test.ts
index 0f38e98172..eb913b219e 100644
--- a/packages/core/api/schemas.test.ts
+++ b/packages/core/api/schemas.test.ts
@@ -42,10 +42,12 @@ import {
EMPTY_CREATE_FEEDBACK_RESPONSE,
EMPTY_INBOX_ITEMS,
EMPTY_INBOX_UNREAD_SUMMARY,
+ EMPTY_SNOOZED_INBOX,
EMPTY_SEARCH_PROJECTS_RESPONSE,
EMPTY_USER,
InboxItemListSchema,
InboxUnreadSummarySchema,
+ SnoozedInboxListSchema,
IssueTriggerPreviewSchema,
ListIssuesResponseSchema,
ListPropertiesResponseSchema,
@@ -1525,6 +1527,28 @@ describe("InboxUnreadSummarySchema", () => {
});
});
+describe("SnoozedInboxListSchema", () => {
+ const ENDPOINT = { endpoint: "GET /api/inbox/snoozed" };
+ const row = (overrides: Record<string, unknown> = {}) => ({
+ issue_id: "issue-1",
+ item_id: "inbox-1",
+ snoozed_until: "2026-06-16T08:00:00Z",
+ snoozed_at: "2026-06-15T08:00:00Z",
+ updates: 0,
+ ...overrides,
+ });
+
+ it("keeps a row whose issue identifier is missing or unusable", () => {
+ const parsed = parseWithFallback(
+ [row(), row({ issue_id: "issue-2", issue_identifier: 7 }), row({ issue_id: "issue-3", issue_identifier: "MUL-3" })],
+ SnoozedInboxListSchema,
+ EMPTY_SNOOZED_INBOX,
+ ENDPOINT,
+ );
+ expect(parsed.map((item) => item.issue_identifier)).toEqual([undefined, null, "MUL-3"]);
+ });
+});
+
describe("InboxItemListSchema", () => {
const ENDPOINT = { endpoint: "GET /api/inbox/archived" };
diff --git a/packages/core/api/schemas.ts b/packages/core/api/schemas.ts
index 3457ce3ef7..cfc756b93e 100644
--- a/packages/core/api/schemas.ts
+++ b/packages/core/api/schemas.ts
@@ -3381,6 +3381,8 @@ export const SnoozedInboxListSchema = z.array(
z
.object({
issue_id: z.string(),
+ // Older servers omit it; the row then links by issue_id.
+ issue_identifier: z.string().min(1).nullish().catch(null),
item_id: z.string(),
snoozed_until: z.string(),
snoozed_at: z.string(),
diff --git a/packages/core/diagnostics/diagnostic-context.test.ts b/packages/core/diagnostics/diagnostic-context.test.ts
index 8625fc1dec..dba59b2180 100644
--- a/packages/core/diagnostics/diagnostic-context.test.ts
+++ b/packages/core/diagnostics/diagnostic-context.test.ts
@@ -130,7 +130,7 @@ describe("route coverage stays in step with paths.ts", () => {
const RAW_SECOND_ID = "second-raw-identifier-value";
function buildAll(): string[] {
- const scoped = paths.workspace(SLUG) as Record<string, (...args: string[]) => string>;
+ const scoped = paths.workspace(SLUG) as unknown as Record<string, (...args: string[]) => string>;
const global = {
login: paths.login,
newWorkspace: paths.newWorkspace,
diff --git a/packages/core/issues/canonical-id.ts b/packages/core/issues/canonical-id.ts
index a80ace8efd..da81cd4bec 100644
--- a/packages/core/issues/canonical-id.ts
+++ b/packages/core/issues/canonical-id.ts
@@ -1,5 +1,6 @@
import { useEffect } from "react";
import { useQuery, useQueryClient, type QueryClient } from "@tanstack/react-query";
+import { issueRouteRef, type IssueRouteRef } from "../paths/paths";
import type { Issue } from "../types";
import { issueDetailOptions, issueKeys } from "./queries";
import { useIssueReadState } from "./read-state";
@@ -17,9 +18,15 @@ export function isIssueUuid(value: string): boolean {
* issue page rewrites a UUID address to the identifier after load, and on web
* that rewrite mounts the page a second time.
*/
-export function useIssueRouteRef(wsId: string, issueId: string): string {
+export function useIssueRouteRef(wsId: string, issueId: string): IssueRouteRef {
const { data } = useQuery({ ...issueDetailOptions(wsId, issueId), enabled: false });
- return data?.identifier || issueId;
+ return issueRouteRef({ id: issueId, identifier: data?.identifier });
+}
+
+/** `useIssueRouteRef` for event handlers: reads the cache once, without subscribing. */
+export function cachedIssueRouteRef(qc: QueryClient, wsId: string, issueId: string): IssueRouteRef {
+ const data = qc.getQueryData<Issue>(issueKeys.detail(wsId, issueId));
+ return issueRouteRef({ id: issueId, identifier: data?.identifier });
}
/** An issue cached under its UUID whose identifier is `identifier`. */
diff --git a/packages/core/paths/index.ts b/packages/core/paths/index.ts
index d9c853b58a..d0f0572445 100644
--- a/packages/core/paths/index.ts
+++ b/packages/core/paths/index.ts
@@ -2,9 +2,10 @@ export {
paths,
isGlobalPath,
isMyAgentsSearch,
+ issueRouteRef,
AGENT_FOCUS_CONVERSATION_STARTERS,
} from "./paths";
-export type { WorkspacePaths } from "./paths";
+export type { IssueRouteRef, WorkspacePaths } from "./paths";
export { RESERVED_SLUGS, isReservedSlug } from "./reserved-slugs";
export {
WORKSPACE_PAGES,
diff --git a/packages/core/paths/paths.test.ts b/packages/core/paths/paths.test.ts
index 289efd88f0..f8d4279834 100644
--- a/packages/core/paths/paths.test.ts
+++ b/packages/core/paths/paths.test.ts
@@ -1,5 +1,5 @@
import { describe, it, expect } from "vitest";
-import { paths, isGlobalPath } from "./paths";
+import { paths, isGlobalPath, issueRouteRef, type IssueRouteRef } from "./paths";
describe("paths.workspace(slug)", () => {
const ws = paths.workspace("acme");
@@ -7,7 +7,7 @@ describe("paths.workspace(slug)", () => {
it("builds workspace paths with slug prefix", () => {
expect(ws.usage()).toBe("/acme/usage");
expect(ws.issues()).toBe("/acme/issues");
- expect(ws.issueDetail("abc-123")).toBe("/acme/issues/abc-123");
+ expect(ws.issueDetail("abc-123" as IssueRouteRef)).toBe("/acme/issues/abc-123");
expect(ws.projects()).toBe("/acme/projects");
expect(ws.projectDetail("p1")).toBe("/acme/projects/p1");
expect(ws.autopilots()).toBe("/acme/autopilots");
@@ -38,17 +38,31 @@ describe("paths.workspace(slug)", () => {
});
it("URL-encodes special characters in ids", () => {
- expect(ws.issueDetail("id with space")).toBe("/acme/issues/id%20with%20space");
+ expect(ws.issueDetail("id with space" as IssueRouteRef)).toBe("/acme/issues/id%20with%20space");
});
it("builds a deliverable link with the filename as one encoded segment", () => {
- expect(ws.issueDeliverable("MUL-1", "report.html")).toBe(
+ expect(ws.issueDeliverable("MUL-1" as IssueRouteRef, "report.html")).toBe(
"/acme/issues/MUL-1/deliverables/report.html",
);
- expect(ws.issueDeliverable("MUL-1", "Q3 调研/报告 #2?.html")).toBe(
+ expect(ws.issueDeliverable("MUL-1" as IssueRouteRef, "Q3 调研/报告 #2?.html")).toBe(
"/acme/issues/MUL-1/deliverables/Q3%20%E8%B0%83%E7%A0%94%2F%E6%8A%A5%E5%91%8A%20%232%3F.html",
);
});
+
+ it("links an issue by its identifier, and by its UUID only without one", () => {
+ const issue = { id: "2f0c9b1e-6a4d-4c1b-9e7a-1d2c3b4a5f60", identifier: "MUL-7" };
+ expect(ws.issueDetail(issueRouteRef(issue))).toBe("/acme/issues/MUL-7");
+ expect(ws.issueDetail(issueRouteRef({ id: issue.id, identifier: null }))).toBe(`/acme/issues/${issue.id}`);
+ // A bare string reaches the issue page as a second navigation when it is a
+ // UUID, so the builders only take a ref.
+ // @ts-expect-error -- `issue.id` is not an IssueRouteRef
+ ws.issueDetail(issue.id);
+ // @ts-expect-error -- neither is `issue.identifier`; go through issueRouteRef
+ ws.issueDeliverable(issue.identifier, "report.html");
+ // @ts-expect-error -- `identifier` must be stated, even as null
+ issueRouteRef({ id: issue.id });
+ });
});
describe("paths (global)", () => {
diff --git a/packages/core/paths/paths.ts b/packages/core/paths/paths.ts
index 9a8dd63c98..39d2c4737f 100644
--- a/packages/core/paths/paths.ts
+++ b/packages/core/paths/paths.ts
@@ -14,6 +14,28 @@
const encode = (id: string) => encodeURIComponent(id);
+declare const issueRouteRefBrand: unique symbol;
+
+/**
+ * The `{segment}` of an `/{ws}/issues/{segment}` link: the issue's identifier
+ * (`MUL-123`), or its UUID only when the identifier is unknown. The issue page
+ * rewrites a UUID address to the identifier once the issue loads, and on web
+ * that rewrite mounts the page and refetches the issue a second time.
+ *
+ * Branded so a bare `issue.id` cannot reach `issueDetail`: build one with
+ * `issueRouteRef`, or with `useIssueRouteRef` (`@multica/core/issues/canonical-id`)
+ * when only the UUID is at hand.
+ */
+export type IssueRouteRef = string & { readonly [issueRouteRefBrand]: true };
+
+/**
+ * The route segment for an issue. `identifier` is a required key so a caller
+ * that has none says so with `identifier: null`.
+ */
+export function issueRouteRef(issue: { id: string; identifier: string | null | undefined }): IssueRouteRef {
+ return (issue.identifier || issue.id) as IssueRouteRef;
+}
+
/**
* `?focus=` token that scrolls the agent's General settings to its
* conversation-starters editor and flashes it. Lives here because it is URL
@@ -41,12 +63,12 @@ function workspaceScoped(slug: string) {
root: () => `${ws}/issues`,
usage: () => `${ws}/usage`,
issues: () => `${ws}/issues`,
- issueDetail: (id: string) => `${ws}/issues/${encode(id)}`,
+ issueDetail: (ref: IssueRouteRef) => `${ws}/issues/${encode(ref)}`,
// Opens the newest upload of the deliverable named `filename` on this
// issue. Addresses the file by name, not by attachment id, so the link
// keeps pointing at the latest version as new ones are uploaded.
- issueDeliverable: (id: string, filename: string) =>
- `${ws}/issues/${encode(id)}/deliverables/${encode(filename)}`,
+ issueDeliverable: (ref: IssueRouteRef, filename: string) =>
+ `${ws}/issues/${encode(ref)}/deliverables/${encode(filename)}`,
projects: () => `${ws}/projects`,
projectDetail: (id: string) => `${ws}/projects/${encode(id)}`,
autopilots: () => `${ws}/autopilots`,
diff --git a/packages/core/paths/spaces.test.ts b/packages/core/paths/spaces.test.ts
index fffee5f7d5..e57d785274 100644
--- a/packages/core/paths/spaces.test.ts
+++ b/packages/core/paths/spaces.test.ts
@@ -1,6 +1,6 @@
// @vitest-environment node
import { describe, expect, it } from "vitest";
-import { paths } from "./paths";
+import { paths, type IssueRouteRef } from "./paths";
import { WORKSPACE_PAGES, type WorkspacePageKey } from "./route-icons";
import { spaceForPath } from "./spaces";
@@ -18,7 +18,7 @@ describe("spaceForPath", () => {
[ws.inbox(), "work"],
[ws.myIssues(), "work"],
[ws.issues(), "work"],
- [ws.issueDetail("MUL-1"), "work"],
+ [ws.issueDetail("MUL-1" as IssueRouteRef), "work"],
[ws.projectDetail("p-1"), "work"],
[ws.agentDetail("a-1"), "team"],
[ws.squadDetail("s-1"), "team"],
diff --git a/packages/core/types/inbox.ts b/packages/core/types/inbox.ts
index a5e01e0817..a5fd593129 100644
--- a/packages/core/types/inbox.ts
+++ b/packages/core/types/inbox.ts
@@ -114,6 +114,8 @@ export interface InboxItem {
/** One snoozed issue in the viewer's inbox (`GET /api/inbox/snoozed`). */
export interface SnoozedInboxIssue {
issue_id: string;
+ /** The issue's identifier (MUL-123) to link to; absent from older servers. */
+ issue_identifier?: string | null;
/** The issue's newest notification: the id the snooze endpoints take. */
item_id: string;
snoozed_until: string;
diff --git a/packages/views/agents/components/agent-live-peek-card.test.tsx b/packages/views/agents/components/agent-live-peek-card.test.tsx
index f48523426f..bd11b12108 100644
--- a/packages/views/agents/components/agent-live-peek-card.test.tsx
+++ b/packages/views/agents/components/agent-live-peek-card.test.tsx
@@ -17,6 +17,7 @@ vi.mock("@multica/core/hooks", () => ({
// Paths only needs issueDetail for the "Now on" link. A simple stub keeps the
// test free of WorkspaceSlugProvider wiring.
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useWorkspacePaths: () => ({
issueDetail: (id: string) => `/test/issues/${id}`,
}),
diff --git a/packages/views/agents/components/agent-live-peek-card.tsx b/packages/views/agents/components/agent-live-peek-card.tsx
index a3ab09b0df..dd645795f4 100644
--- a/packages/views/agents/components/agent-live-peek-card.tsx
+++ b/packages/views/agents/components/agent-live-peek-card.tsx
@@ -5,7 +5,7 @@ import { ActorAvatar as ActorAvatarBase } from "@multica/ui/components/common/ac
import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { TruncatedTooltip } from "@multica/ui/components/common/truncated-tooltip";
import { useWorkspaceId } from "@multica/core/hooks";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef, type IssueRouteRef } from "@multica/core/paths";
import { agentListOptions } from "@multica/core/workspace/queries";
import { resolvePublicFileUrl } from "@multica/core/workspace/avatar-url";
import {
@@ -174,7 +174,7 @@ function CurrentIssueRow({
issueId: string | null;
label: string;
emptyLabel: string;
- issueHref: (ref: string) => string;
+ issueHref: (ref: IssueRouteRef) => string;
}) {
// Lazy issue detail — only enabled while the card is mounted AND we have
// a running issue id. snapshot already gives us the id; this hook just
@@ -191,7 +191,7 @@ function CurrentIssueRow({
issue ? (
<TruncatedTooltip content={`${issue.identifier} ${issue.title}`}>
<AppLink
- href={issueHref(issue.identifier)}
+ href={issueHref(issueRouteRef(issue))}
className="min-w-0 truncate text-brand hover:underline"
>
<span className="mr-1 font-mono text-micro">{issue.identifier}</span>
diff --git a/packages/views/agents/components/tabs/activity-tab.tsx b/packages/views/agents/components/tabs/activity-tab.tsx
index 50c1311e59..200e52a47b 100644
--- a/packages/views/agents/components/tabs/activity-tab.tsx
+++ b/packages/views/agents/components/tabs/activity-tab.tsx
@@ -30,7 +30,7 @@ import {
} from "@multica/core/agents";
import { api } from "@multica/core/api";
import { useWorkspaceId } from "@multica/core/hooks";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef, type IssueRouteRef } from "@multica/core/paths";
import { issueDetailOptions } from "@multica/core/issues/queries";
import { AppLink } from "../../../navigation";
import { TranscriptButton, type TimelineItem } from "../../../common/task-transcript";
@@ -556,7 +556,7 @@ function useTaskRowModel(task: AgentTask) {
cfg,
hasIssue,
issue,
- issueRef: issue?.identifier || task.issue_identifier || task.issue_id,
+ issueRef: issueRouteRef({ id: task.issue_id, identifier: issue?.identifier || task.issue_identifier }),
title,
SourceIcon,
sourceLabel,
@@ -592,7 +592,7 @@ function TaskTitle({ task, title }: { task: AgentTask; title: string }) {
);
}
-function OpenIssueIconLink({ issueRef }: { issueRef: string }) {
+function OpenIssueIconLink({ issueRef }: { issueRef: IssueRouteRef }) {
const { t } = useT("agents");
const paths = useWorkspacePaths();
return (
diff --git a/packages/views/autopilots/components/workspace-wakeups.test.tsx b/packages/views/autopilots/components/workspace-wakeups.test.tsx
index 2a098dd60b..fd1d8d192b 100644
--- a/packages/views/autopilots/components/workspace-wakeups.test.tsx
+++ b/packages/views/autopilots/components/workspace-wakeups.test.tsx
@@ -31,6 +31,7 @@ vi.mock("@multica/core/api", () => ({
vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws" }));
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useWorkspacePaths: () => ({
issueDetail: (id: string) => `/ws/issues/${id}`,
}),
diff --git a/packages/views/autopilots/components/workspace-wakeups.tsx b/packages/views/autopilots/components/workspace-wakeups.tsx
index caa81efbb4..449c09cf74 100644
--- a/packages/views/autopilots/components/workspace-wakeups.tsx
+++ b/packages/views/autopilots/components/workspace-wakeups.tsx
@@ -5,7 +5,7 @@ import { useInfiniteQuery, useQuery } from "@tanstack/react-query";
import { AlarmClock, Bell, Clock3, AlertCircle, ListChecks, TriangleAlert } from "@multica/ui/icons";
import { toast } from "sonner";
import { useWorkspaceId } from "@multica/core/hooks";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import {
workspaceWakeupsInfiniteOptions,
useDisableWorkspaceWakeups,
@@ -523,7 +523,7 @@ export function WorkspaceWakeups() {
columns={columns}
rows={rows}
getRowId={rowId}
- getRowHref={(row) => paths.issueDetail(row.issue_identifier || row.issue_id)}
+ getRowHref={(row) => paths.issueDetail(issueRouteRef({ id: row.issue_id, identifier: row.issue_identifier }))}
getRowTitle={(row) => `${row.issue_identifier} ${row.issue_title}`}
selection={{
selectedIds: selected,
diff --git a/packages/views/dev-toolbar/dev-toolbar.tsx b/packages/views/dev-toolbar/dev-toolbar.tsx
index 4f9d6f6f04..573e1785fb 100644
--- a/packages/views/dev-toolbar/dev-toolbar.tsx
+++ b/packages/views/dev-toolbar/dev-toolbar.tsx
@@ -5,6 +5,7 @@ import { useIsFetching, useQuery, useQueryClient } from "@tanstack/react-query";
import { agentTaskSnapshotOptions } from "@multica/core/agents/queries";
import { useAuthStore } from "@multica/core/auth";
import { paths } from "@multica/core/paths";
+import { cachedIssueRouteRef } from "@multica/core/issues/canonical-id";
import {
getCurrentSlug,
getCurrentWsId,
@@ -148,7 +149,10 @@ export function DevToolbar({ build, apiUrl, route, onNavigate }: DevToolbarProps
const fetching = useIsFetching();
const online = runtimes?.filter((r) => r.status === "online").length ?? 0;
const running = activeTasks(tasks ?? []).filter((t) => t.status === "running").length;
- const openIssue = slug ? (issueId: string) => onNavigate(paths.workspace(slug).issueDetail(issueId)) : null;
+ const openIssue =
+ slug && wsId
+ ? (issueId: string) => onNavigate(paths.workspace(slug).issueDetail(cachedIssueRouteRef(queryClient, wsId, issueId)))
+ : null;
const syncDot = (
<span className={cn("size-1.5 shrink-0 rounded-full", SYNC_DOT_CLASS[sync])} />
diff --git a/packages/views/editor/extensions/mention-context-menu.test.tsx b/packages/views/editor/extensions/mention-context-menu.test.tsx
index 697b7a6016..481a5b6bd1 100644
--- a/packages/views/editor/extensions/mention-context-menu.test.tsx
+++ b/packages/views/editor/extensions/mention-context-menu.test.tsx
@@ -6,6 +6,7 @@ import { IssueMentionCard } from "../../issues/components/issue-mention-card";
import { ProjectMentionCard } from "../../projects/components/project-mention-card";
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useWorkspacePaths: () => ({ issueDetail: (id: string) => `/acme/issues/${id}`, projectDetail: (id: string) => `/acme/projects/${id}` }),
}));
vi.mock("../../issues/components/issue-chip", () => ({
diff --git a/packages/views/editor/extensions/mention-view.test.tsx b/packages/views/editor/extensions/mention-view.test.tsx
index 16bf722aac..948372ad04 100644
--- a/packages/views/editor/extensions/mention-view.test.tsx
+++ b/packages/views/editor/extensions/mention-view.test.tsx
@@ -21,6 +21,7 @@ vi.mock("@tiptap/react", () => ({
}));
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useWorkspacePaths: () => ({
issueDetail: (id: string) => `/acme/issues/${id}`,
projectDetail: (id: string) => `/acme/projects/${id}`,
diff --git a/packages/views/inbox/components/inbox-display.ts b/packages/views/inbox/components/inbox-display.ts
index bc9ad4e9ab..8d421ffdf7 100644
--- a/packages/views/inbox/components/inbox-display.ts
+++ b/packages/views/inbox/components/inbox-display.ts
@@ -1,4 +1,4 @@
-import type { WorkspacePaths } from "@multica/core/paths";
+import { issueRouteRef, type IssueRouteRef, type WorkspacePaths } from "@multica/core/paths";
import type { InboxItem } from "@multica/core/types";
function singleLine(value: string | null | undefined): string {
@@ -97,8 +97,8 @@ export function resolveDetailItem(
* server sent one, so the issue route opens without rewriting its URL (a
* rewrite mounts the whole issue page again on web), else the UUID.
*/
-export function inboxIssueRef(item: Pick<InboxItem, "issue_identifier">, issueId: string): string {
- return item.issue_identifier || issueId;
+export function inboxIssueRef(item: Pick<InboxItem, "issue_identifier">, issueId: string): IssueRouteRef {
+ return issueRouteRef({ id: issueId, identifier: item.issue_identifier });
}
/**
diff --git a/packages/views/inbox/components/inbox-page.test.tsx b/packages/views/inbox/components/inbox-page.test.tsx
index 647570c808..091f38cafd 100644
--- a/packages/views/inbox/components/inbox-page.test.tsx
+++ b/packages/views/inbox/components/inbox-page.test.tsx
@@ -28,7 +28,7 @@ const lookupState = { isLoading: false, isError: false, refetch: vi.fn() };
// The active list as a read that failed before anything loaded, and is
// possibly being tried again.
const activeFailure = { failed: false, retrying: false, refetch: vi.fn() };
-const queryClient = vi.hoisted(() => ({ setQueryData: vi.fn() }));
+const queryClient = vi.hoisted(() => ({ setQueryData: vi.fn(), getQueryData: vi.fn() }));
vi.mock("@tanstack/react-query", () => ({
queryOptions: (options: unknown) => options,
useQueryClient: () => queryClient,
@@ -64,6 +64,7 @@ vi.mock("@multica/core/hooks", () => ({
}));
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useWorkspacePaths: () => ({
inbox: () => "/acme/inbox",
issueDetail: (id: string) => `/acme/issues/${id}`,
diff --git a/packages/views/inbox/components/inbox-page.tsx b/packages/views/inbox/components/inbox-page.tsx
index 43879e40ae..39a9ea256e 100644
--- a/packages/views/inbox/components/inbox-page.tsx
+++ b/packages/views/inbox/components/inbox-page.tsx
@@ -23,6 +23,7 @@ import {
} from "@multica/core/shortcuts";
import { isImeComposing } from "@multica/core/utils";
import { useIssueDraftStore } from "@multica/core/issues/stores/draft-store";
+import { cachedIssueRouteRef } from "@multica/core/issues/canonical-id";
import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";
import { inboxRowKey, nextInboxRow } from "@multica/core/inbox/open-row";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
@@ -403,7 +404,7 @@ export function InboxPage() {
setSelectedKey("");
return;
}
- replace(wsPaths.issueDetail(selectedKey));
+ replace(wsPaths.issueDetail(cachedIssueRouteRef(queryClient, wsId, selectedKey)));
}, [
viewLoading,
viewError,
@@ -415,6 +416,7 @@ export function InboxPage() {
replace,
wsPaths,
wsId,
+ queryClient,
setSelectedKey,
]);
diff --git a/packages/views/inbox/components/snoozed-inbox-page.test.tsx b/packages/views/inbox/components/snoozed-inbox-page.test.tsx
index e761ec182d..38b58b6a29 100644
--- a/packages/views/inbox/components/snoozed-inbox-page.test.tsx
+++ b/packages/views/inbox/components/snoozed-inbox-page.test.tsx
@@ -60,13 +60,14 @@ function renderPage(snoozed: SnoozedInboxIssue[]) {
hash: "",
getShareableUrl: (path) => path,
};
- return renderWithI18n(
+ renderWithI18n(
<QueryClientProvider client={client}>
<NavigationProvider value={nav}>
<SnoozedInboxPage />
</NavigationProvider>
</QueryClientProvider>,
);
+ return nav;
}
beforeEach(() => {
@@ -91,6 +92,20 @@ describe("SnoozedInboxPage", () => {
expect(state.unsnooze).toHaveBeenCalledWith({ id: "item-issue-1" });
});
+ // A UUID address is rewritten to the identifier once the issue loads, which
+ // mounts the issue page a second time on web.
+ it("opens an issue at its identifier", () => {
+ const nav = renderPage([{ ...entry("issue-1", new Date(Date.now() + HOUR)), issue_identifier: "MUL-41" }]);
+ fireEvent.click(screen.getByText("Issue issue-1"));
+ expect(nav.push).toHaveBeenCalledWith("/acme/issues/MUL-41");
+ });
+
+ it("takes the identifier from the loaded issue when the server sent none", () => {
+ const nav = renderPage([entry("issue-2", new Date(Date.now() + HOUR))]);
+ fireEvent.click(screen.getByText("Issue issue-2"));
+ expect(nav.push).toHaveBeenCalledWith("/acme/issues/MUL-2");
+ });
+
it("says when nothing is snoozed", () => {
renderPage([]);
expect(screen.getByText("Nothing snoozed")).toBeInTheDocument();
diff --git a/packages/views/inbox/components/snoozed-inbox-page.tsx b/packages/views/inbox/components/snoozed-inbox-page.tsx
index 7d282b33db..b0119a604c 100644
--- a/packages/views/inbox/components/snoozed-inbox-page.tsx
+++ b/packages/views/inbox/components/snoozed-inbox-page.tsx
@@ -1,14 +1,15 @@
"use client";
import { useMemo, useState } from "react";
-import { useQuery } from "@tanstack/react-query";
+import { useQuery, useQueryClient } from "@tanstack/react-query";
import { AlarmClock, Undo2 } from "@multica/ui/icons";
import { Button } from "@multica/ui/components/ui/button";
import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { useWorkspaceId } from "@multica/core/hooks";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { issueRouteRef, useWorkspacePaths } from "@multica/core/paths";
import { snoozedInboxOptions } from "@multica/core/inbox/queries";
import { issueDetailOptions } from "@multica/core/issues/queries";
+import { cachedIssueRouteRef } from "@multica/core/issues/canonical-id";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
import type { SnoozedInboxIssue } from "@multica/core/types";
import { CollectionPageHeader, CollectionPageState } from "../../layout/collection-page";
@@ -55,6 +56,7 @@ export function SnoozedInboxPage() {
const { t } = useT("inbox");
const wsId = useWorkspaceId();
const p = useWorkspacePaths();
+ const qc = useQueryClient();
const locale = useLocale();
const title = useBuiltinViewLabel()("snoozed");
const { data: snoozed, isLoading } = useQuery(snoozedInboxOptions(wsId));
@@ -136,7 +138,15 @@ export function SnoozedInboxPage() {
columns={columns}
groups={groups}
getRowId={(row) => row.issue_id}
- getRowHref={(row) => p.issueDetail(row.issue_id)}
+ // Older servers send no identifier. The cache supplies it when the
+ // issue was loaded before this list last rendered; else the UUID.
+ getRowHref={(row) =>
+ p.issueDetail(
+ row.issue_identifier
+ ? issueRouteRef({ id: row.issue_id, identifier: row.issue_identifier })
+ : cachedIssueRouteRef(qc, wsId, row.issue_id),
+ )
+ }
empty={
<CollectionPageState
icon={AlarmClock}
diff --git a/packages/views/issues/actions/use-issue-actions.ts b/packages/views/issues/actions/use-issue-actions.ts
index 841baf2c19..de09716747 100644
--- a/packages/views/issues/actions/use-issue-actions.ts
+++ b/packages/views/issues/actions/use-issue-actions.ts
@@ -7,7 +7,7 @@ import { toast } from "sonner";
import type { Issue, UpdateIssueRequest } from "@multica/core/types";
import { useAuthStore } from "@multica/core/auth";
import { useWorkspaceId } from "@multica/core/hooks";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { useModalStore } from "@multica/core/modals";
import { useUpdateIssue } from "@multica/core/issues/mutations";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
@@ -143,7 +143,7 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {
// tab at the shareable URL, so it is a link the user sees and may copy out
// of the address bar. Opening on the UUID would also make the route
// immediately rewrite the fresh tab's URL.
- const path = paths.issueDetail(issueIdentifier || issueId);
+ const path = paths.issueDetail(issueRouteRef({ id: issueId, identifier: issueIdentifier }));
if (navigation.openInNewTab) {
navigation.openInNewTab(path, issueIdentifier ?? undefined, {
activate: true,
@@ -160,17 +160,17 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {
const openInNewWindow = useCallback(() => {
if (!issueId) return;
navigation.openIssueInNewWindow?.(
- paths.issueDetail(issueIdentifier || issueId),
+ paths.issueDetail(issueRouteRef({ id: issueId, identifier: issueIdentifier })),
issueIdentifier ? `${issueIdentifier} ${issueTitle}` : issueTitle,
);
}, [issueId, issueIdentifier, issueTitle, navigation, paths]);
const openInDesktop = useCallback(() => {
if (!issueId) return;
- const path = paths.issueDetail(issueIdentifier || issueId);
+ const path = paths.issueDetail(issueRouteRef({ id: issueId, identifier: issueIdentifier }));
const isCurrentIssue =
navigation.pathname === path ||
- navigation.pathname === paths.issueDetail(issueId);
+ navigation.pathname === paths.issueDetail(issueRouteRef({ id: issueId, identifier: null }));
navigation.openInDesktop?.(path + (isCurrentIssue ? navigation.hash : ""));
}, [issueId, issueIdentifier, navigation, paths]);
@@ -188,7 +188,7 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {
// Share the identifier form (`/{ws}/issues/MUL-123`): a pasted link should
// say which issue it points at. The UUID form stays valid, so links copied
// before this still resolve.
- const url = navigation.getShareableUrl(paths.issueDetail(issueIdentifier || issueId));
+ const url = navigation.getShareableUrl(paths.issueDetail(issueRouteRef({ id: issueId, identifier: issueIdentifier })));
if (await copyText(url)) {
toast.success(t(($) => $.detail.link_copied));
} else {
@@ -198,7 +198,7 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {
const copyTitleAsLink = useCallback(async () => {
if (!issueId) return;
- const url = navigation.getShareableUrl(paths.issueDetail(issueIdentifier || issueId));
+ const url = navigation.getShareableUrl(paths.issueDetail(issueRouteRef({ id: issueId, identifier: issueIdentifier })));
// 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(" ");
@@ -215,7 +215,7 @@ export function useIssueActions(issue: Issue | null): UseIssueActionsResult {
// memoized comment card, so depending on it would re-render all of them on
// any unrelated page update. Identifier form for the same reason as `copyLink`.
const issueShareUrl = issueId
- ? navigation.getShareableUrl(paths.issueDetail(issueIdentifier || issueId))
+ ? navigation.getShareableUrl(paths.issueDetail(issueRouteRef({ id: issueId, identifier: issueIdentifier })))
: null;
const copyCommentLink = useCallback(async (commentId: string) => {
if (!issueShareUrl) return;
diff --git a/packages/views/issues/components/batch-menu-items.tsx b/packages/views/issues/components/batch-menu-items.tsx
index 4977a9873b..71d3dac4a0 100644
--- a/packages/views/issues/components/batch-menu-items.tsx
+++ b/packages/views/issues/components/batch-menu-items.tsx
@@ -20,7 +20,7 @@ import {
} from "@multica/ui/icons";
import { copyText } from "@multica/ui/lib/clipboard";
import { useWorkspaceId } from "@multica/core/hooks";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { PRIORITY_CONFIG, PRIORITY_DISPLAY_ORDER } from "@multica/core/issues/config";
import { addDaysDateOnly, todayDateOnly } from "@multica/core/issues/date";
import type { CommonIssueFields } from "@multica/core/issues/batch";
@@ -123,7 +123,7 @@ export function BatchMenuItems({
const maxStage = issues.reduce((max, issue) => Math.max(max, issue.stage ?? 0), 0);
const copyLinks = () => {
- const links = issues.map((issue) => getShareableUrl(paths.issueDetail(issue.identifier || issue.id)));
+ const links = issues.map((issue) => getShareableUrl(paths.issueDetail(issueRouteRef(issue))));
void copyText(links.join("\n")).then((ok) => {
if (ok) toast.success(t(($) => $.batch.links_copied, { count }));
});
diff --git a/packages/views/issues/components/board-card-peek.test.tsx b/packages/views/issues/components/board-card-peek.test.tsx
index b318eb792f..af1a39021c 100644
--- a/packages/views/issues/components/board-card-peek.test.tsx
+++ b/packages/views/issues/components/board-card-peek.test.tsx
@@ -27,6 +27,7 @@ vi.mock("@multica/core/properties", () => ({
}));
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useWorkspacePaths: () => ({ issueDetail: (id: string) => `/acme/issues/${id}` }),
}));
diff --git a/packages/views/issues/components/board-card.tsx b/packages/views/issues/components/board-card.tsx
index 56f435908f..e0bc63bf4a 100644
--- a/packages/views/issues/components/board-card.tsx
+++ b/packages/views/issues/components/board-card.tsx
@@ -18,7 +18,7 @@ import { CalendarClock, CalendarDays } from "@multica/ui/icons";
import { ActorAvatar } from "../../common/actor-avatar";
import { CardControl } from "../../common/card-control";
import { PropertyIcon } from "../../common/property-icon";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { useActorName } from "@multica/core/workspace/hooks";
import { useLocale, useT, useTimeAgo } from "../../i18n";
import { ProjectIcon } from "../../projects/components/project-icon";
@@ -420,7 +420,7 @@ export const DraggableBoardCard = memo(function DraggableBoardCard({
}
>
<AppLink
- href={p.issueDetail(issue.identifier)}
+ href={p.issueDetail(issueRouteRef(issue))}
newTabTitle={issue.identifier}
className={`group block transition-colors ${isDragging ? "pointer-events-none" : ""}`}
{...peekLinkProps}
diff --git a/packages/views/issues/components/deliverables/deliverable-link.test.tsx b/packages/views/issues/components/deliverables/deliverable-link.test.tsx
index 816510f657..b53b074032 100644
--- a/packages/views/issues/components/deliverables/deliverable-link.test.tsx
+++ b/packages/views/issues/components/deliverables/deliverable-link.test.tsx
@@ -31,6 +31,7 @@ vi.mock("@multica/core/paths", async () => {
});
import { OpenDeliverableOnLoad, useCopyDeliverableLink } from "./deliverable-link";
+import type { IssueRouteRef } from "@multica/core/paths";
function attachment(over: Partial<Attachment> & { id: string }): Attachment {
return {
@@ -161,7 +162,7 @@ describe("OpenDeliverableOnLoad", () => {
describe("useCopyDeliverableLink", () => {
it("copies the latest-version link, not a link to one upload", async () => {
- const { result } = renderHook(() => useCopyDeliverableLink("MUL-1"), {
+ const { result } = renderHook(() => useCopyDeliverableLink("MUL-1" as IssueRouteRef), {
wrapper: ({ children }) => withNav(children),
});
result.current?.("调研 报告.html");
@@ -173,7 +174,7 @@ describe("useCopyDeliverableLink", () => {
it("reports a failed copy", async () => {
copyTextMock.mockResolvedValueOnce(false);
- const { result } = renderHook(() => useCopyDeliverableLink("MUL-1"), {
+ const { result } = renderHook(() => useCopyDeliverableLink("MUL-1" as IssueRouteRef), {
wrapper: ({ children }) => withNav(children),
});
result.current?.("report.html");
diff --git a/packages/views/issues/components/deliverables/deliverable-link.tsx b/packages/views/issues/components/deliverables/deliverable-link.tsx
index c25a1e932e..00e1efb31e 100644
--- a/packages/views/issues/components/deliverables/deliverable-link.tsx
+++ b/packages/views/issues/components/deliverables/deliverable-link.tsx
@@ -8,7 +8,7 @@ import {
type DeliverableFile,
} from "@multica/core/attachments/deliverables";
import { issueTimelineOptions } from "@multica/core/issues/queries";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, type IssueRouteRef } from "@multica/core/paths";
import { copyText } from "@multica/ui/lib/clipboard";
import { useNavigation } from "../../../navigation";
import { useT } from "../../../i18n";
@@ -25,7 +25,7 @@ import { useOpenAttachment } from "./use-open-attachment";
* UUID. Returns undefined without one, so callers render no button.
*/
export function useCopyDeliverableLink(
- issueRef: string | undefined,
+ issueRef: IssueRouteRef | undefined,
): ((filename: string) => void) | undefined {
const { t } = useT("issues");
const paths = useWorkspacePaths();
diff --git a/packages/views/issues/components/gantt-view.tsx b/packages/views/issues/components/gantt-view.tsx
index 5ffb825e2b..f56716fe71 100644
--- a/packages/views/issues/components/gantt-view.tsx
+++ b/packages/views/issues/components/gantt-view.tsx
@@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo, useRef } from "react";
import { useQuery } from "@tanstack/react-query";
import { useWorkspaceId } from "@multica/core/hooks";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { useViewStore, useViewStoreApi } from "@multica/core/issues/stores/view-store-context";
import type { GanttZoom } from "@multica/core/issues/stores/view-store";
import { projectListOptions } from "@multica/core/projects/queries";
@@ -369,7 +369,7 @@ function ScheduledRow({
{/* Sticky label cell — it also carries the peeked mark, since its
opaque background covers the row's own. */}
<AppLink
- href={p.issueDetail(issue.identifier)}
+ href={p.issueDetail(issueRouteRef(issue))}
newTabTitle={issue.identifier}
className={cn(
"sticky left-0 z-[1] flex shrink-0 items-center gap-2 border-r bg-background px-3 text-body min-w-0",
@@ -411,7 +411,7 @@ function ScheduledRow({
<TooltipTrigger
render={
<AppLink
- href={p.issueDetail(issue.identifier)}
+ href={p.issueDetail(issueRouteRef(issue))}
newTabTitle={issue.identifier}
{...peekLinkProps}
className={cn(
diff --git a/packages/views/issues/components/issue-detail-route.tsx b/packages/views/issues/components/issue-detail-route.tsx
index 0a5bd4ea4f..5aa862abf5 100644
--- a/packages/views/issues/components/issue-detail-route.tsx
+++ b/packages/views/issues/components/issue-detail-route.tsx
@@ -3,7 +3,7 @@
import { useCallback, useEffect, useRef } from "react";
import { useCanonicalIssue } from "@multica/core/issues/canonical-id";
import { useWorkspaceId } from "@multica/core/hooks";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { useInboxSelectionStore } from "@multica/core/inbox/selection-store";
import { useNavigation } from "../../navigation";
import { IssueDetail, IssueDetailSkeleton, IssueNotFound, IssueLoadError } from "./issue-detail";
@@ -41,8 +41,9 @@ export function useCanonicalIssueUrl(
const navigation = useNavigation();
// A deliverable link keeps its `/deliverables/{name}` tail: dropping it
// would turn the address into a plain issue link while the file is open.
- const canonicalHref = identifier
- ? `${deliverable ? paths.issueDeliverable(identifier, deliverable) : paths.issueDetail(identifier)}${hash}`
+ const canonicalRef = identifier ? issueRouteRef({ id: routeId, identifier }) : null;
+ const canonicalHref = canonicalRef
+ ? `${deliverable ? paths.issueDeliverable(canonicalRef, deliverable) : paths.issueDetail(canonicalRef)}${hash}`
: null;
// `useWorkspacePaths()` and the navigation adapter are both rebuilt on
// render, so this ref — not the dependency array — is what guarantees the
@@ -109,7 +110,7 @@ export function IssueDetailRoute({ routeId, onDelete, deliverable }: IssueDetail
// Once the link has opened its file and the viewer has closed (or the file
// is missing), the address becomes the plain issue page. A replace: Back
// should leave the issue, not re-open the file.
- const issueRef = issue?.identifier ?? routeId;
+ const issueRef = issueRouteRef({ id: routeId, identifier: issue?.identifier });
const latestNav = useRef({ paths, navigation });
latestNav.current = { paths, navigation };
const onDeliverableLinkDone = useCallback(() => {
diff --git a/packages/views/issues/components/issue-detail.tsx b/packages/views/issues/components/issue-detail.tsx
index abc2730f9f..c47f9432d5 100644
--- a/packages/views/issues/components/issue-detail.tsx
+++ b/packages/views/issues/components/issue-detail.tsx
@@ -152,7 +152,7 @@ import { useQuery } from "@tanstack/react-query";
import { useIssueReadState } from "@multica/core/issues/read-state";
import { useIssueRouteRef } from "@multica/core/issues/canonical-id";
import { useAuthStore } from "@multica/core/auth";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { useActorName } from "@multica/core/workspace/hooks";
import { useWorkspaceId } from "@multica/core/hooks";
import {
@@ -1052,7 +1052,7 @@ function SubIssueRow({
}
/>
<AppLink
- href={paths.issueDetail(child.identifier)}
+ href={paths.issueDetail(issueRouteRef(child))}
className="flex min-w-0 flex-1 items-center gap-2.5"
>
<span className="text-caption text-muted-foreground tabular-nums shrink-0">
@@ -2952,7 +2952,7 @@ export function IssueDetail({ issueId, onDelete, onArchive, onUnsubscribeArchive
// Identifier form, like the issue's own copy link: a pasted link should say
// which issue it points at.
- const copyDeliverableLink = useCopyDeliverableLink(issue?.identifier ?? id);
+ const copyDeliverableLink = useCopyDeliverableLink(issueRouteRef({ id, identifier: issue?.identifier }));
const describeDeliverable = useDeliverableDetails({
files: deliverableFiles,
commentById,
@@ -3525,7 +3525,7 @@ export function IssueDetail({ issueId, onDelete, onArchive, onUnsubscribeArchive
{parentIssueOpen && <div className="px-2">
<div className="flex items-center gap-0.5 rounded-md px-2 hover:bg-accent/50 transition-colors group">
<AppLink
- href={paths.issueDetail(parentIssue.identifier)}
+ href={paths.issueDetail(issueRouteRef(parentIssue))}
className="flex flex-1 min-w-0 items-center gap-1.5 py-2 text-label"
>
<StatusIcon
@@ -3569,7 +3569,7 @@ export function IssueDetail({ issueId, onDelete, onArchive, onUnsubscribeArchive
{sidebarChildIssues.map((child) => (
<li key={child.id}>
<AppLink
- href={paths.issueDetail(child.identifier)}
+ href={paths.issueDetail(issueRouteRef(child))}
title={`${child.identifier} ${child.title}`}
aria-label={`${child.identifier} ${child.title}, ${resolveStatusLabel(child.status)}`}
className="group flex min-w-0 items-center gap-1.5 rounded-md px-2 py-2 text-label transition-colors hover:bg-accent/50 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
@@ -3799,7 +3799,7 @@ export function IssueDetail({ issueId, onDelete, onArchive, onUnsubscribeArchive
// panel. The workspace name is intentionally absent — "all issues" is a view,
// not a container.
const breadcrumbSegments: BreadcrumbSegment[] = parentIssue
- ? [{ href: paths.issueDetail(parentIssue.identifier), label: parentIssue.identifier }]
+ ? [{ href: paths.issueDetail(issueRouteRef(parentIssue)), label: parentIssue.identifier }]
: breadcrumbProject
? [
{
@@ -3862,7 +3862,7 @@ export function IssueDetail({ issueId, onDelete, onArchive, onUnsubscribeArchive
// Below the trigger, since the header sits at the top of the page.
<TruncatedTooltip content={headerLeafLabel} side="bottom">
<AppLink
- href={paths.issueDetail(issue.identifier)}
+ href={paths.issueDetail(issueRouteRef(issue))}
className="flex min-w-0 transition-opacity hover:opacity-80"
>
<span className="truncate font-medium text-foreground">
@@ -4075,7 +4075,7 @@ export function IssueDetail({ issueId, onDelete, onArchive, onUnsubscribeArchive
{parentIssue && !issue.source_context && (
<AppLink
- href={paths.issueDetail(parentIssue.identifier)}
+ href={paths.issueDetail(issueRouteRef(parentIssue))}
className="mt-2 inline-flex max-w-full items-center gap-1.5 text-label text-muted-foreground hover:text-foreground transition-colors group/parent"
>
<span className="shrink-0">{t(($) => $.detail.sub_issue_of)}</span>
diff --git a/packages/views/issues/components/issue-duplicates.test.tsx b/packages/views/issues/components/issue-duplicates.test.tsx
index 73efb3526b..286137df60 100644
--- a/packages/views/issues/components/issue-duplicates.test.tsx
+++ b/packages/views/issues/components/issue-duplicates.test.tsx
@@ -20,6 +20,7 @@ vi.mock("@multica/core/hooks", () => ({
useWorkspaceId: () => "workspace-1",
}));
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useWorkspacePaths: () => ({ issueDetail: (id: string) => `/acme/issues/${id}` }),
}));
vi.mock("@multica/core/issue-statuses/hooks", () => ({
diff --git a/packages/views/issues/components/issue-duplicates.tsx b/packages/views/issues/components/issue-duplicates.tsx
index ea2f5f8f3b..8f076b0a9a 100644
--- a/packages/views/issues/components/issue-duplicates.tsx
+++ b/packages/views/issues/components/issue-duplicates.tsx
@@ -10,7 +10,7 @@ import { issueStatusCategory } from "@multica/core/issues";
import { issueDuplicatesOptions } from "@multica/core/issues/queries";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
import { useWorkspaceId } from "@multica/core/hooks";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { Button } from "@multica/ui/components/ui/button";
import { ActorAvatar } from "../../common/actor-avatar";
import { AppLink, resolveClickIntent, rowLinkInteractiveProps, useIntentNavigate } from "../../navigation";
@@ -52,7 +52,7 @@ export function IssueDuplicateBanner({
return (
<div className="mb-4 flex items-center gap-1 rounded-md border bg-muted/40 py-1 pl-3 pr-1 text-body">
<AppLink
- href={paths.issueDetail(original.identifier)}
+ href={paths.issueDetail(issueRouteRef(original))}
newTabTitle={original.identifier}
className="group flex min-w-0 flex-1 items-center gap-2 py-1"
>
@@ -107,7 +107,7 @@ export function IssueDuplicatesSection({ issueId }: { issueId: string }) {
{duplicates.map((duplicate) => (
<AppLink
key={duplicate.id}
- href={paths.issueDetail(duplicate.identifier)}
+ href={paths.issueDetail(issueRouteRef(duplicate))}
className="group flex items-center gap-1.5 rounded-md px-2 py-2 text-caption hover:bg-accent/50 transition-colors"
>
<ActorAvatar
@@ -177,7 +177,7 @@ function DuplicateOfAnchor({
const tooltip = useMarkerTooltip(original);
return (
<AppLink
- href={paths.issueDetail(original.identifier)}
+ href={paths.issueDetail(issueRouteRef(original))}
newTabTitle={original.identifier}
title={tooltip}
{...rowLinkInteractiveProps}
@@ -201,7 +201,7 @@ function DuplicateOfControl({
const paths = useWorkspacePaths();
const navigate = useIntentNavigate();
const tooltip = useMarkerTooltip(original);
- const href = paths.issueDetail(original.identifier);
+ const href = paths.issueDetail(issueRouteRef(original));
const stop = (e: React.SyntheticEvent) => {
e.preventDefault();
e.stopPropagation();
diff --git a/packages/views/issues/components/issue-mention-card.test.tsx b/packages/views/issues/components/issue-mention-card.test.tsx
index aaf15e5b83..fad255e12f 100644
--- a/packages/views/issues/components/issue-mention-card.test.tsx
+++ b/packages/views/issues/components/issue-mention-card.test.tsx
@@ -15,6 +15,7 @@ import {
} from "../surface/peek-context";
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useWorkspacePaths: () => ({
issueDetail: (id: string) => `/acme/issues/${id}`,
}),
diff --git a/packages/views/issues/components/issue-mention-card.tsx b/packages/views/issues/components/issue-mention-card.tsx
index f84d0212f4..280a1abc62 100644
--- a/packages/views/issues/components/issue-mention-card.tsx
+++ b/packages/views/issues/components/issue-mention-card.tsx
@@ -2,7 +2,7 @@
import { AppLink } from "../../navigation";
import { yieldsToTextMenu } from "../../common/point-menu";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { IssueChip, useChipIssue } from "./issue-chip";
import { IssueHoverCard } from "./issue-hover-card";
import { useT } from "../../i18n";
@@ -85,7 +85,7 @@ function IssueMentionLink({ issueId, fallbackLabel }: IssueMentionCardProps) {
: null;
return (
<AppLink
- href={p.issueDetail(issue?.identifier || issueId)}
+ href={p.issueDetail(issueRouteRef({ id: issueId, identifier: issue?.identifier }))}
newTabTitle={fallbackLabel}
className="issue-mention align-middle"
onContextMenu={
diff --git a/packages/views/issues/components/list-row-peek.test.tsx b/packages/views/issues/components/list-row-peek.test.tsx
index c33279143e..4b971ffd75 100644
--- a/packages/views/issues/components/list-row-peek.test.tsx
+++ b/packages/views/issues/components/list-row-peek.test.tsx
@@ -26,6 +26,7 @@ vi.mock("@multica/core/properties", () => ({
}));
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useWorkspacePaths: () => ({ issueDetail: (id: string) => `/acme/issues/${id}` }),
}));
diff --git a/packages/views/issues/components/list-row.tsx b/packages/views/issues/components/list-row.tsx
index 037fc45e3b..6f2e835f2b 100644
--- a/packages/views/issues/components/list-row.tsx
+++ b/packages/views/issues/components/list-row.tsx
@@ -11,7 +11,7 @@ import type { Issue, Project,
import { formatDateOnly } from "@multica/core/issues/date";
import { ActorAvatar } from "../../common/actor-avatar";
import { PropertyIcon } from "../../common/property-icon";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { useQuery } from "@tanstack/react-query";
import { useViewStore } from "@multica/core/issues/stores/view-store-context";
import { useWorkspaceId } from "@multica/core/hooks";
@@ -138,7 +138,7 @@ function ListRowContent({
/>
</div>
<AppLink
- href={p.issueDetail(issue.identifier)}
+ href={p.issueDetail(issueRouteRef(issue))}
newTabTitle={issue.identifier}
className={`flex flex-1 items-center gap-2 min-w-0 ${isDragging ? "pointer-events-none" : ""}`}
{...peekLinkProps}
diff --git a/packages/views/issues/components/source-context-viewer.test.tsx b/packages/views/issues/components/source-context-viewer.test.tsx
index 7b2fdc7b17..12e1486140 100644
--- a/packages/views/issues/components/source-context-viewer.test.tsx
+++ b/packages/views/issues/components/source-context-viewer.test.tsx
@@ -20,6 +20,7 @@ vi.mock("../../navigation", () => ({
}));
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useWorkspacePaths: () => ({ issueDetail: (id: string) => `/acme/issues/${id}` }),
}));
diff --git a/packages/views/issues/components/source-context-viewer.tsx b/packages/views/issues/components/source-context-viewer.tsx
index d91d335531..c727f0325b 100644
--- a/packages/views/issues/components/source-context-viewer.tsx
+++ b/packages/views/issues/components/source-context-viewer.tsx
@@ -10,7 +10,7 @@ import { Button } from "@multica/ui/components/ui/button";
import { IconButton } from "@multica/ui/components/common/icon-button";
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from "@multica/ui/components/ui/dialog";
import { cn } from "@multica/ui/lib/utils";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { AppLink, useNavigation } from "../../navigation";
import { useLocale, useT } from "../../i18n";
import { ProgressRing } from "./progress-ring";
@@ -71,7 +71,7 @@ export function SourceContextBadge({
const openCurrent = (value: IssueSourceContext) => {
if (value.anchor_comment_state !== "available" || !value.current_source || value.can_open_current_source !== true) return;
- navigation.push(`${paths.issueDetail(value.current_source.identifier || value.current_source.issue_id)}#comment-${value.current_source.anchor_comment_id}`);
+ navigation.push(`${paths.issueDetail(issueRouteRef({ id: value.current_source.issue_id, identifier: value.current_source.identifier }))}#comment-${value.current_source.anchor_comment_id}`);
};
const refresh = async () => {
try {
@@ -156,7 +156,7 @@ export function SourceContextBadge({
</span>
{parentIssue ? (
<AppLink
- href={paths.issueDetail(parentIssue.identifier)}
+ href={paths.issueDetail(issueRouteRef(parentIssue))}
aria-label={`${originIdentifier} ${originTitle}`}
className="group/source-parent flex min-w-0 items-center gap-1.5 rounded-sm font-medium text-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring"
>
diff --git a/packages/views/issues/components/swimlane-view.tsx b/packages/views/issues/components/swimlane-view.tsx
index 302e4ba845..51acd35473 100644
--- a/packages/views/issues/components/swimlane-view.tsx
+++ b/packages/views/issues/components/swimlane-view.tsx
@@ -39,7 +39,7 @@ import { useViewBaseline } from "../surface/view-baseline-context";
import { filterIssues, type IssueFilters } from "../utils/filter";
import { getMoveAnchors } from "../utils/drag-utils";
import type { SwimlaneGrouping } from "@multica/core/issues/stores/view-store";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { useWorkspaceId } from "@multica/core/hooks";
import type { IssueStatusCatalog } from "@multica/core/issue-statuses";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
@@ -1722,7 +1722,7 @@ function DraggableSwimLane({
content={t(($) => $.swimlane.open_parent)}
trigger={
<AppLink
- href={paths.issueDetail(lane.parentIssue.identifier || lane.parentIssue.id)}
+ href={paths.issueDetail(issueRouteRef(lane.parentIssue))}
aria-label={t(($) => $.swimlane.open_parent)}
className="inline-flex size-5 shrink-0 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground"
>
diff --git a/packages/views/issues/components/table-view.tsx b/packages/views/issues/components/table-view.tsx
index 232e69b9a0..d82022fcc7 100644
--- a/packages/views/issues/components/table-view.tsx
+++ b/packages/views/issues/components/table-view.tsx
@@ -94,7 +94,7 @@ import {
import { useViewStore } from "@multica/core/issues/stores/view-store-context";
import { propertyListOptions } from "@multica/core/properties";
import { projectListOptions } from "@multica/core/projects/queries";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { buildActorNameResolver, useActorName } from "@multica/core/workspace/hooks";
import {
agentListOptions,
@@ -2233,7 +2233,7 @@ export function TableView({
// middle clicks open tabs. Callbacks without an event (keyboard
// affordances) count as plain clicks.
intentNavigate(
- paths.issueDetail(issue.identifier),
+ paths.issueDetail(issueRouteRef(issue)),
event ? resolveClickIntent(event) : "push",
issue.identifier,
);
diff --git a/packages/views/issues/surface/issue-surface.tsx b/packages/views/issues/surface/issue-surface.tsx
index 24129b5b41..958cb5f764 100644
--- a/packages/views/issues/surface/issue-surface.tsx
+++ b/packages/views/issues/surface/issue-surface.tsx
@@ -9,7 +9,7 @@ import { Button } from "@multica/ui/components/ui/button";
import { Skeleton } from "@multica/ui/components/ui/skeleton";
import { cn } from "@multica/ui/lib/utils";
import { useWorkspaceId } from "@multica/core/hooks";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { useModalStore } from "@multica/core/modals";
import { useIsGuest } from "@multica/core/permissions";
import { useQuery } from "@tanstack/react-query";
@@ -281,7 +281,7 @@ function IssueSurfaceContent({
[clientFilter, controller.issues],
);
const firstIssue = issues[0] ?? tableLoadedIssues[0];
- useWarmRoute("issue", firstIssue ? paths.issueDetail(firstIssue.identifier) : null);
+ useWarmRoute("issue", firstIssue ? paths.issueDetail(issueRouteRef(firstIssue)) : null);
const swimlaneIssues = useMemo(
() =>
clientFilter
diff --git a/packages/views/issues/surface/peek-context.tsx b/packages/views/issues/surface/peek-context.tsx
index d6a3c054a9..dfd6c59642 100644
--- a/packages/views/issues/surface/peek-context.tsx
+++ b/packages/views/issues/surface/peek-context.tsx
@@ -2,7 +2,7 @@
import { createContext, useCallback, useContext, useMemo } from "react";
import { useIssueOpeningStore, type IssueOpenMode } from "@multica/core/issues/stores/issue-opening-store";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import type { Issue } from "@multica/core/types";
import { useNavigation } from "../../navigation";
@@ -167,7 +167,7 @@ export function useIssuePeekClick() {
// Shift+Click in preview mode opens the full page in place. Left alone,
// a link would hand Shift to the browser — a new window on web.
event.preventDefault();
- push(paths.issueDetail(issue.identifier));
+ push(paths.issueDetail(issueRouteRef(issue)));
return true;
}
return false;
diff --git a/packages/views/layout/panels/pinned-section.tsx b/packages/views/layout/panels/pinned-section.tsx
index 9179d9eb84..6fc9190a85 100644
--- a/packages/views/layout/panels/pinned-section.tsx
+++ b/packages/views/layout/panels/pinned-section.tsx
@@ -24,7 +24,7 @@ import { pinListOptions } from "@multica/core/pins/queries";
import { useSidebarTreeStore } from "@multica/core/issues/stores/sidebar-tree-store";
import { useDeletePin, useReorderPins } from "@multica/core/pins/mutations";
import { useIssueUnread } from "@multica/core/issues/unread";
-import { useWorkspacePaths, type WorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import type { Issue, PinnedItem } from "@multica/core/types";
import { AppLink } from "../../navigation";
import { IssueActionsContextMenu } from "../../issues/actions";
@@ -50,10 +50,6 @@ import {
// render while the query is disabled, which re-fires the sync effect below.
const EMPTY_PINS: PinnedItem[] = [];
-function pinHref(p: WorkspacePaths, pin: PinnedItem): string {
- return pin.item_type === "issue" ? p.issueDetail(pin.item_id) : p.projectDetail(pin.item_id);
-}
-
/**
* Pin list state for the Issues panel. Lifted out of the section so the
* panel can keep its plain rows unlit while a pinned item is the page on
@@ -100,7 +96,7 @@ export function usePanelPins(
const isPinActive = (pin: PinnedItem) =>
pin.item_type === "issue"
? pin.item_id === currentIssueId
- : isPathWithin(pathname, pinHref(p, pin));
+ : isPathWithin(pathname, p.projectDetail(pin.item_id));
// A collapsed section shows no rows, so it must not keep the tree unlit.
const pinnedCollapsed = useSidebarTreeStore((s) => s.pinnedCollapsed);
const isActivePinnedRoute = !pinnedCollapsed && displayed.some(isPinActive);
@@ -123,7 +119,6 @@ type PanelPins = ReturnType<typeof usePanelPins>;
export function PinnedSection({ pins, wsId }: { pins: PanelPins; wsId: string }) {
const { t } = useT("layout");
- const p = useWorkspacePaths();
const deletePin = useDeletePin();
const reorderPins = useReorderPins();
const sensors = useSensors(useSensor(PointerSensor, { activationConstraint: { distance: 5 } }));
@@ -179,7 +174,6 @@ export function PinnedSection({ pins, wsId }: { pins: PanelPins; wsId: string })
<PinRow
key={pin.id}
pin={pin}
- href={pinHref(p, pin)}
active={isPinActive(pin)}
onUnpin={() => deletePin.mutate({ itemType: pin.item_type, itemId: pin.item_id })}
wsId={wsId}
@@ -316,13 +310,11 @@ function SortablePinItem({
*/
function PinRow({
pin,
- href,
active,
onUnpin,
wsId,
}: {
pin: PinnedItem;
- href: string;
active: boolean;
onUnpin: () => void;
wsId: string;
@@ -356,7 +348,7 @@ function PinRow({
return (
<SortablePinItem
pin={pin}
- href={unreadIssueHref(p.issueDetail(issue.identifier), unread)}
+ href={unreadIssueHref(p.issueDetail(issueRouteRef(issue)), unread)}
onUnpin={onUnpin}
label={issue.title}
active={active}
@@ -383,7 +375,7 @@ function PinRow({
return (
<SortablePinItem
pin={pin}
- href={href}
+ href={p.projectDetail(pin.item_id)}
onUnpin={onUnpin}
label={project.title}
active={active}
diff --git a/packages/views/layout/panels/sidebar-tree.tsx b/packages/views/layout/panels/sidebar-tree.tsx
index 79571bc35a..ddce16e9ac 100644
--- a/packages/views/layout/panels/sidebar-tree.tsx
+++ b/packages/views/layout/panels/sidebar-tree.tsx
@@ -16,7 +16,7 @@ import { SIDEBAR_FIRST_PAGE, SIDEBAR_PAGE_STEP, type SidebarIssuesRequest } from
import { useSidebarKeptStore } from "@multica/core/issues/stores/sidebar-kept-store";
import { useSidebarTreeStore } from "@multica/core/issues/stores/sidebar-tree-store";
import { issueUnreadTarget, useIssueUnread } from "@multica/core/issues/unread";
-import { useWorkspacePaths } from "@multica/core/paths";
+import { useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { useActorName } from "@multica/core/workspace/hooks";
import type { AgentTask, Issue, IssueUnread } from "@multica/core/types";
import { AppLink, useWarmRoute } from "../../navigation";
@@ -343,7 +343,7 @@ export function SidebarIssueList({
placeholderData: keepPreviousData,
});
const listed = params ? (query.data?.issues ?? EMPTY_ISSUES) : EMPTY_ISSUES;
- useWarmRoute("issue", listed[0] ? p.issueDetail(listed[0].identifier) : null);
+ useWarmRoute("issue", listed[0] ? p.issueDetail(issueRouteRef(listed[0])) : null);
const total = params ? (query.data?.total ?? 0) : 0;
// The list no longer carries a kept issue; the detail cache follows its
// edits, and dropping it on delete ends the keep.
@@ -409,7 +409,7 @@ export function SidebarIssueList({
<SidebarIssueRow
wsId={wsId}
issue={issue}
- href={p.issueDetail(issue.identifier)}
+ href={p.issueDetail(issueRouteRef(issue))}
active={issue.id === activeIssueId}
locating={locating && issue.id === activeIssueId}
statusColor={statusCatalog.colorOf(issue.status)}
diff --git a/packages/views/layout/panels/team-panel.tsx b/packages/views/layout/panels/team-panel.tsx
index a9f2e099af..3341ce1ef7 100644
--- a/packages/views/layout/panels/team-panel.tsx
+++ b/packages/views/layout/panels/team-panel.tsx
@@ -14,7 +14,7 @@ import { useChatStore } from "@multica/core/chat";
import { canAssignAgentToIssue } from "@multica/core/permissions";
import { issueDetailOptions } from "@multica/core/issues/queries";
import { useSidebarTreeStore } from "@multica/core/issues/stores/sidebar-tree-store";
-import { useCurrentWorkspace, useWorkspacePaths } from "@multica/core/paths";
+import { useCurrentWorkspace, useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { runtimeListOptions } from "@multica/core/runtimes/queries";
import { memberListOptions, skillListOptions, squadListOptions } from "@multica/core/workspace/queries";
import { resolvePublicFileUrl } from "@multica/core/workspace/avatar-url";
@@ -167,7 +167,7 @@ function AgentPanelLink({
</DropdownMenuItem>
)}
{currentIssue && (
- <DropdownMenuItem onClick={() => push(p.issueDetail(currentIssue.identifier))}>
+ <DropdownMenuItem onClick={() => push(p.issueDetail(issueRouteRef(currentIssue)))}>
<ArrowUpRight className="h-3.5 w-3.5" />
{t(($) => $.panels.team.open_issue, { identifier: currentIssue.identifier })}
</DropdownMenuItem>
diff --git a/packages/views/modals/create-issue.test.tsx b/packages/views/modals/create-issue.test.tsx
index dca133cd42..2a1dc973e0 100644
--- a/packages/views/modals/create-issue.test.tsx
+++ b/packages/views/modals/create-issue.test.tsx
@@ -229,6 +229,7 @@ vi.mock("../navigation/context", () => ({
}));
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useCurrentWorkspace: () => ({ name: "Test Workspace" }),
useWorkspacePaths: () => ({
issueDetail: (id: string) => `/ws-test/issues/${id}`,
diff --git a/packages/views/modals/create-issue.tsx b/packages/views/modals/create-issue.tsx
index 6c0b7f0a5c..5353e65ed7 100644
--- a/packages/views/modals/create-issue.tsx
+++ b/packages/views/modals/create-issue.tsx
@@ -62,7 +62,7 @@ import { maxSiblingStage } from "../issues/components/pickers/stage-picker";
import { ProjectPicker } from "../projects/components/project-picker";
import { useIssueTriggerPreview } from "../issues/hooks/use-issue-trigger-preview";
import { useActorName } from "@multica/core/workspace/hooks";
-import { useCurrentWorkspace, useWorkspacePaths } from "@multica/core/paths";
+import { useCurrentWorkspace, useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { useWorkspaceId } from "@multica/core/hooks";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
import { useProjectWithWorkflow, useProjectWorkflow, workflowAllowsStatus, workflowStep } from "@multica/core/issue-workflows";
@@ -707,7 +707,7 @@ export function ManualCreatePanel({
type="button"
className="ml-7 mt-2 text-body text-primary hover:underline cursor-pointer"
onClick={() => {
- router.push(p.issueDetail(issue.identifier));
+ router.push(p.issueDetail(issueRouteRef(issue)));
toast.dismiss(toastId);
}}
>
@@ -818,7 +818,7 @@ export function ManualCreatePanel({
type="button"
className="ml-7 mt-2 text-body text-primary hover:underline cursor-pointer"
onClick={() => {
- router.push(p.issueDetail(dup.issue.identifier));
+ router.push(p.issueDetail(issueRouteRef(dup.issue)));
toast.dismiss(toastId);
}}
>
diff --git a/packages/views/onboarding/onboarding-flow-skip.test.tsx b/packages/views/onboarding/onboarding-flow-skip.test.tsx
index 817849b5c7..a89e178514 100644
--- a/packages/views/onboarding/onboarding-flow-skip.test.tsx
+++ b/packages/views/onboarding/onboarding-flow-skip.test.tsx
@@ -128,7 +128,7 @@ beforeEach(() => {
describe("OnboardingFlow — skipping runtime setup", () => {
it("creates the guide issue in the new workspace, then opens it", async () => {
- mockCreateIssue.mockResolvedValueOnce({ id: "issue-guide" });
+ mockCreateIssue.mockResolvedValueOnce({ id: "issue-guide", identifier: "NEW-2" });
mockCompleteOnboarding.mockResolvedValueOnce(undefined);
const { onComplete, skip } = renderAtRuntimeStep();
@@ -137,7 +137,7 @@ describe("OnboardingFlow — skipping runtime setup", () => {
await waitFor(() => {
expect(onComplete).toHaveBeenCalledWith(NEW_WORKSPACE, {
kind: "issue",
- issueId: "issue-guide",
+ issueRef: "NEW-2",
});
});
const [body, workspaceSlug] = mockCreateIssue.mock.calls[0]!;
@@ -162,7 +162,7 @@ describe("OnboardingFlow — skipping runtime setup", () => {
it("stays on the step when the guide cannot be created", async () => {
mockCreateIssue
.mockRejectedValueOnce(new Error("network down"))
- .mockResolvedValueOnce({ id: "issue-guide" });
+ .mockResolvedValueOnce({ id: "issue-guide", identifier: "NEW-2" });
mockCompleteOnboarding.mockResolvedValue(undefined);
const { onComplete, skip } = renderAtRuntimeStep();
@@ -175,13 +175,13 @@ describe("OnboardingFlow — skipping runtime setup", () => {
await waitFor(() => {
expect(onComplete).toHaveBeenCalledWith(NEW_WORKSPACE, {
kind: "issue",
- issueId: "issue-guide",
+ issueRef: "NEW-2",
});
});
});
it("reuses the guide issue when only completing onboarding failed", async () => {
- mockCreateIssue.mockResolvedValueOnce({ id: "issue-guide" });
+ mockCreateIssue.mockResolvedValueOnce({ id: "issue-guide", identifier: "NEW-2" });
mockCompleteOnboarding
.mockRejectedValueOnce(new Error("network down"))
.mockResolvedValueOnce(undefined);
@@ -195,7 +195,7 @@ describe("OnboardingFlow — skipping runtime setup", () => {
await waitFor(() => {
expect(onComplete).toHaveBeenCalledWith(NEW_WORKSPACE, {
kind: "issue",
- issueId: "issue-guide",
+ issueRef: "NEW-2",
});
});
expect(mockCreateIssue).toHaveBeenCalledTimes(1);
@@ -205,7 +205,7 @@ describe("OnboardingFlow — skipping runtime setup", () => {
// incomplete, so the next Skip hits the server's duplicate guard.
it("opens the existing guide after a reload between creating it and completing onboarding", async () => {
mockCreateIssue
- .mockResolvedValueOnce({ id: "issue-existing" })
+ .mockResolvedValueOnce({ id: "issue-existing", identifier: "NEW-1" })
.mockRejectedValueOnce(duplicateGuideConflict());
mockCompleteOnboarding
.mockRejectedValueOnce(new Error("network down"))
@@ -221,7 +221,7 @@ describe("OnboardingFlow — skipping runtime setup", () => {
await waitFor(() => {
expect(reloaded.onComplete).toHaveBeenCalledWith(NEW_WORKSPACE, {
kind: "issue",
- issueId: "issue-existing",
+ issueRef: "NEW-1",
});
});
expect(mockCompleteOnboarding).toHaveBeenCalledTimes(2);
@@ -243,7 +243,7 @@ describe("OnboardingFlow — skipping runtime setup", () => {
await waitFor(() => {
expect(onComplete).toHaveBeenCalledWith(NEW_WORKSPACE, {
kind: "issue",
- issueId: "issue-existing",
+ issueRef: "NEW-1",
});
});
});
diff --git a/packages/views/onboarding/onboarding-flow.tsx b/packages/views/onboarding/onboarding-flow.tsx
index e536aaa1d9..f3e161c24d 100644
--- a/packages/views/onboarding/onboarding-flow.tsx
+++ b/packages/views/onboarding/onboarding-flow.tsx
@@ -34,6 +34,7 @@ import {
pickContentLang,
} from "./templates";
import { useT } from "../i18n";
+import { issueRouteRef, type IssueRouteRef } from "@multica/core/paths";
const EMPTY_QUESTIONNAIRE: QuestionnaireAnswers = {
source: [],
@@ -169,7 +170,7 @@ export function OnboardingFlow({
const bootstrapMika = useBootstrapMika(workspace?.id ?? "");
// Keyed by workspace so retrying Skip after completeOnboarding failed reuses
// the guide issue instead of creating a second one.
- const guideIssueRef = useRef<{ workspaceId: string; issueId: string } | null>(
+ const guideIssueRef = useRef<{ workspaceId: string; issueRef: IssueRouteRef } | null>(
null,
);
@@ -300,11 +301,11 @@ export function OnboardingFlow({
}
return;
}
- let issueId =
+ let issueRef =
guideIssueRef.current?.workspaceId === workspace.id
- ? guideIssueRef.current.issueId
+ ? guideIssueRef.current.issueRef
: null;
- if (!issueId) {
+ if (!issueRef) {
const contentLang = pickContentLang(i18n.language);
try {
const issue = await api.createIssue(
@@ -318,7 +319,7 @@ export function OnboardingFlow({
},
workspace.slug,
);
- issueId = issue.id;
+ issueRef = issueRouteRef(issue);
} catch (err) {
// A reload, or a create whose response was lost, leaves the guide
// from an earlier attempt in place; the duplicate guard then
@@ -336,9 +337,9 @@ export function OnboardingFlow({
toast.error(t(($) => $.errors.guide_failed));
return;
}
- issueId = duplicate.issue.id;
+ issueRef = issueRouteRef(duplicate.issue);
}
- guideIssueRef.current = { workspaceId: workspace.id, issueId };
+ guideIssueRef.current = { workspaceId: workspace.id, issueRef };
}
try {
await completeOnboarding("runtime_skipped", workspace.id);
@@ -348,7 +349,7 @@ export function OnboardingFlow({
);
return;
}
- onComplete(workspace, { kind: "issue", issueId });
+ onComplete(workspace, { kind: "issue", issueRef });
},
[answers, bootstrapMika, i18n.language, workspace, onComplete, t, user.id],
);
@@ -479,7 +480,7 @@ export function OnboardingFlow({
export type OnboardingMode = "first_run" | "new_workspace";
export type OnboardingDestination =
- | { kind: "issue"; issueId: string }
+ | { kind: "issue"; issueRef: IssueRouteRef }
| {
kind: "chat";
sessionId: string;
diff --git a/packages/views/search/root-view.tsx b/packages/views/search/root-view.tsx
index 7613dded77..0a55911249 100644
--- a/packages/views/search/root-view.tsx
+++ b/packages/views/search/root-view.tsx
@@ -8,7 +8,7 @@ import { useWorkspaceId } from "@multica/core/hooks";
import { inboxUnreadSummaryOptions, unreadWorkspaceIds } from "@multica/core/inbox/queries";
import { useActiveIssueViewStore } from "@multica/core/issue-views/active-view-store";
import { issueViewTarget } from "@multica/core/issue-views/view-target";
-import { paths, useWorkspacePaths } from "@multica/core/paths";
+import { paths, useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { projectListOptions } from "@multica/core/projects/queries";
import type { InboxWorkspaceUnread } from "@multica/core/types";
import { openCreateIssueWithPreference } from "@multica/core/issues/stores";
@@ -275,7 +275,7 @@ export function RootView({ model, rawQuery }: { model: RootModel; rawQuery: stri
issue={issue}
query={server.results.query}
disabled={server.stale}
- onSelect={() => palette.navigate(p.issueDetail(issue.identifier))}
+ onSelect={() => palette.navigate(p.issueDetail(issueRouteRef(issue)))}
/>
))}
</PaletteGroup>
@@ -431,7 +431,7 @@ export function RootView({ model, rawQuery }: { model: RootModel; rawQuery: stri
issue={issue}
query={server.results.query}
disabled={server.stale}
- onSelect={() => palette.navigate(p.issueDetail(issue.identifier))}
+ onSelect={() => palette.navigate(p.issueDetail(issueRouteRef(issue)))}
/>
))}
</PaletteGroup>
@@ -777,7 +777,7 @@ function EmptyState({ model }: { model: RootModel }) {
key={`issue:${item.id}`}
issue={item.issue}
query=""
- onSelect={() => palette.navigate(p.issueDetail(item.issue.identifier))}
+ onSelect={() => palette.navigate(p.issueDetail(issueRouteRef(item.issue)))}
trailing={<RowHint>{t(($) => $.types.issue)}</RowHint>}
/>
);
diff --git a/packages/views/squads/components/squad-detail-page.test.tsx b/packages/views/squads/components/squad-detail-page.test.tsx
index 31e184ae71..0166235e42 100644
--- a/packages/views/squads/components/squad-detail-page.test.tsx
+++ b/packages/views/squads/components/squad-detail-page.test.tsx
@@ -47,6 +47,7 @@ vi.mock("@multica/core/auth", () => ({
}));
vi.mock("@multica/core/hooks", () => ({ useWorkspaceId: () => "ws-1" }));
vi.mock("@multica/core/paths", () => ({
+ issueRouteRef: (issue: { id: string; identifier?: string | null }) => issue.identifier || issue.id,
useCurrentWorkspace: () => ({ id: "ws-1", slug: "acme" }),
useWorkspacePaths: () => ({
squads: () => "/acme/squads",
diff --git a/packages/views/squads/components/squad-detail-page.tsx b/packages/views/squads/components/squad-detail-page.tsx
index 8b5adb7196..a895f0afcc 100644
--- a/packages/views/squads/components/squad-detail-page.tsx
+++ b/packages/views/squads/components/squad-detail-page.tsx
@@ -4,7 +4,7 @@ import { useEffect, useMemo, useRef, useState } from "react";
import { useQuery, useMutation, useQueryClient } from "@tanstack/react-query";
import { api } from "@multica/core/api";
import { useAuthStore } from "@multica/core/auth";
-import { useCurrentWorkspace, useWorkspacePaths } from "@multica/core/paths";
+import { useCurrentWorkspace, useWorkspacePaths, issueRouteRef } from "@multica/core/paths";
import { useWorkspaceId } from "@multica/core/hooks";
import { useModalStore } from "@multica/core/modals";
import { useIssueStatuses } from "@multica/core/issue-statuses/hooks";
@@ -673,7 +673,7 @@ function SquadMembersSection({
<>
<span className="shrink-0">{t(($) => $.detail.working_on)}</span>
<AppLink
- href={p.issueDetail(primaryIssue.identifier || primaryIssue.issue_id)}
+ href={p.issueDetail(issueRouteRef({ id: primaryIssue.issue_id, identifier: primaryIssue.identifier }))}
title={primaryIssue.title}
className="shrink-0 font-mono uppercase transition-colors hover:text-foreground"
>
@@ -885,7 +885,7 @@ function SquadRecentWorkSection({
{issues.map((issue) => (
<AppLink
key={issue.id}
- href={p.issueDetail(issue.identifier)}
+ href={p.issueDetail(issueRouteRef(issue))}
className="flex h-10 items-center gap-3 px-3 text-body transition-colors hover:bg-accent/50"
>
<StatusIcon
diff --git a/server/internal/handler/inbox_snooze.go b/server/internal/handler/inbox_snooze.go
index 970df1f63d..a58cf47680 100644
--- a/server/internal/handler/inbox_snooze.go
+++ b/server/internal/handler/inbox_snooze.go
@@ -15,8 +15,10 @@ import (
// SnoozedInboxResponse is one snoozed issue in the caller's inbox.
type SnoozedInboxResponse struct {
- IssueID string `json:"issue_id"`
- ItemID string `json:"item_id"`
+ IssueID string `json:"issue_id"`
+ // The identifier (MUL-123) the row links to; see InboxItemResponse.
+ IssueIdentifier *string `json:"issue_identifier"`
+ ItemID string `json:"item_id"`
SnoozedUntil string `json:"snoozed_until"`
SnoozedAt string `json:"snoozed_at"`
// Rows that arrived on the issue while it was snoozed.
@@ -56,14 +58,16 @@ func (h *Handler) ListSnoozedInbox(w http.ResponseWriter, r *http.Request) {
writeInboxReadError(w, err, "failed to list snoozed inbox")
return
}
+ issuePrefix := h.getIssuePrefix(r.Context(), wsUUID)
resp := make([]SnoozedInboxResponse, len(rows))
for i, row := range rows {
resp[i] = SnoozedInboxResponse{
- IssueID: uuidToString(row.IssueID),
- ItemID: uuidToString(row.ItemID),
- SnoozedUntil: timestampToString(row.SnoozedUntil),
- SnoozedAt: timestampToString(row.SnoozedAt),
- Updates: row.Updates,
+ IssueID: uuidToString(row.IssueID),
+ IssueIdentifier: inboxIssueIdentifier(issuePrefix, row.IssueNumber),
+ ItemID: uuidToString(row.ItemID),
+ SnoozedUntil: timestampToString(row.SnoozedUntil),
+ SnoozedAt: timestampToString(row.SnoozedAt),
+ Updates: row.Updates,
}
}
writeJSON(w, http.StatusOK, resp)
diff --git a/server/internal/handler/inbox_test.go b/server/internal/handler/inbox_test.go
index 5b293308b4..90a6bd48b0 100644
--- a/server/internal/handler/inbox_test.go
+++ b/server/internal/handler/inbox_test.go
@@ -441,6 +441,14 @@ func TestInboxItemsCarryIssueIdentifier(t *testing.T) {
t.Errorf("mark read issue_identifier = %s, want %s", got, want)
}
+ dbfx.Exec(t, `UPDATE inbox_item SET snoozed_until = now() + interval '1 day', snoozed_at = now() WHERE id = $1`, activeID)
+ var snoozed []SnoozedInboxResponse
+ testutil.Call(t, inboxWorkspaceHandler(testHandler.ListSnoozedInbox),
+ inboxRequest(http.MethodGet, "/api/inbox/snoozed", workspaceID)).Want(http.StatusOK).JSON(&snoozed)
+ if len(snoozed) != 1 || snoozed[0].IssueIdentifier == nil || *snoozed[0].IssueIdentifier != want {
+ t.Errorf("snoozed = %+v, want the issue with issue_identifier %s", snoozed, want)
+ }
+
// The archived views list an issue only while it has no active row.
dbfx.Exec(t, `UPDATE inbox_item SET archived = true WHERE workspace_id = $1`, workspaceID)
var archived []InboxItemResponse
diff --git a/server/pkg/db/generated/inbox.sql.go b/server/pkg/db/generated/inbox.sql.go
index fc81b2a95f..984f58a68c 100644
--- a/server/pkg/db/generated/inbox.sql.go
+++ b/server/pkg/db/generated/inbox.sql.go
@@ -1021,7 +1021,8 @@ SELECT g.issue_id::uuid AS issue_id,
newest.id AS item_id,
g.snoozed_until::timestamptz AS snoozed_until,
g.snoozed_at::timestamptz AS snoozed_at,
- g.updates::bigint AS updates
+ g.updates::bigint AS updates,
+ iss.number AS issue_number
FROM (
SELECT i.issue_id,
max(i.snoozed_until) AS snoozed_until,
@@ -1053,6 +1054,7 @@ JOIN LATERAL (
ORDER BY n.created_at DESC, n.id DESC
LIMIT 1
) newest ON true
+LEFT JOIN issue iss ON iss.id = g.issue_id
ORDER BY g.snoozed_until ASC, g.issue_id
`
@@ -1068,11 +1070,13 @@ type ListSnoozedInboxRow struct {
SnoozedUntil pgtype.Timestamptz `json:"snoozed_until"`
SnoozedAt pgtype.Timestamptz `json:"snoozed_at"`
Updates int64 `json:"updates"`
+ IssueNumber pgtype.Int4 `json:"issue_number"`
}
// The recipient's snoozed issues, soonest back first (MUL-9333). `updates` is
// how many rows arrived while snoozed; `item_id` is the issue's newest row,
-// the one the snooze endpoints take.
+// the one the snooze endpoints take. `issue_number` builds the identifier the
+// row links to.
func (q *Queries) ListSnoozedInbox(ctx context.Context, arg ListSnoozedInboxParams) ([]ListSnoozedInboxRow, error) {
rows, err := q.db.Query(ctx, listSnoozedInbox, arg.WorkspaceID, arg.RecipientID, arg.HiddenProjectIds)
if err != nil {
@@ -1088,6 +1092,7 @@ func (q *Queries) ListSnoozedInbox(ctx context.Context, arg ListSnoozedInboxPara
&i.SnoozedUntil,
&i.SnoozedAt,
&i.Updates,
+ &i.IssueNumber,
); err != nil {
return nil, err
}
diff --git a/server/pkg/db/queries/inbox.sql b/server/pkg/db/queries/inbox.sql
index 1fd5ece010..78126bc003 100644
--- a/server/pkg/db/queries/inbox.sql
+++ b/server/pkg/db/queries/inbox.sql
@@ -450,12 +450,14 @@ RETURNING item.*;
-- name: ListSnoozedInbox :many
-- The recipient's snoozed issues, soonest back first (MUL-9333). `updates` is
-- how many rows arrived while snoozed; `item_id` is the issue's newest row,
--- the one the snooze endpoints take.
+-- the one the snooze endpoints take. `issue_number` builds the identifier the
+-- row links to.
SELECT g.issue_id::uuid AS issue_id,
newest.id AS item_id,
g.snoozed_until::timestamptz AS snoozed_until,
g.snoozed_at::timestamptz AS snoozed_at,
- g.updates::bigint AS updates
+ g.updates::bigint AS updates,
+ iss.number AS issue_number
FROM (
SELECT i.issue_id,
max(i.snoozed_until) AS snoozed_until,
@@ -487,6 +489,7 @@ JOIN LATERAL (
ORDER BY n.created_at DESC, n.id DESC
LIMIT 1
) newest ON true
+LEFT JOIN issue iss ON iss.id = g.issue_id
ORDER BY g.snoozed_until ASC, g.issue_id;
-- name: InboxOverflows :one