Skip to content

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

Go

fix(desktop): localize window titles via the tab title contract (MUL-9772) (#11116)

Jiayuan Zhang6097a7c8b01a
diff --git a/apps/desktop/src/renderer/src/components/document-title-sync.test.tsx b/apps/desktop/src/renderer/src/components/document-title-sync.test.tsx
new file mode 100644
index 0000000000..67280e9463
--- /dev/null
+++ b/apps/desktop/src/renderer/src/components/document-title-sync.test.tsx
@@ -0,0 +1,67 @@
+import { render, waitFor } from "@testing-library/react";
+import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
+import { MemoryRouter } from "react-router-dom";
+import { beforeEach, describe, expect, it } from "vitest";
+import { I18nProvider } from "@multica/core/i18n/react";
+import type { SupportedLocale } from "@multica/core/i18n";
+import { WorkspaceSlugProvider } from "@multica/core/paths";
+import { workspaceListOptions } from "@multica/core/workspace";
+import { issueDetailOptions } from "@multica/core/issues/queries";
+import { RESOURCES } from "@multica/views/locales";
+import { DocumentTitleSync } from "./document-title-sync";
+
+function makeClient() {
+ const qc = new QueryClient({ defaultOptions: { queries: { retry: false } } });
+ qc.setQueryData(workspaceListOptions().queryKey, [
+ { id: "ws1", slug: "acme" },
+ ] as never);
+ return qc;
+}
+
+function tree(qc: QueryClient, locale: SupportedLocale, url: string) {
+ return (
+ <I18nProvider locale={locale} resources={RESOURCES}>
+ <QueryClientProvider client={qc}>
+ <WorkspaceSlugProvider slug="acme">
+ <MemoryRouter initialEntries={[url]}>
+ <DocumentTitleSync />
+ </MemoryRouter>
+ </WorkspaceSlugProvider>
+ </QueryClientProvider>
+ </I18nProvider>
+ );
+}
+
+beforeEach(() => {
+ document.title = "";
+});
+
+describe("DocumentTitleSync", () => {
+ it("writes the localized page title and follows a language switch", async () => {
+ const qc = makeClient();
+ const { rerender } = render(tree(qc, "zh-Hans", "/acme/projects"));
+ await waitFor(() => expect(document.title).toBe("项目"));
+
+ rerender(tree(qc, "ja", "/acme/projects"));
+ await waitFor(() => expect(document.title).toBe("プロジェクト"));
+ });
+
+ it("uses the localized type label while a resource loads, then its name", async () => {
+ const qc = makeClient();
+ render(tree(qc, "zh-Hans", "/acme/issues/MUL-1"));
+ await waitFor(() => expect(document.title).toBe("任务"));
+
+ qc.setQueryData(issueDetailOptions("ws1", "MUL-1").queryKey, {
+ id: "i1",
+ identifier: "MUL-1",
+ title: "Fix login",
+ status: "todo",
+ } as never);
+ await waitFor(() => expect(document.title).toBe("MUL-1: Fix login"));
+ });
+
+ it("localizes creation flows", async () => {
+ render(tree(makeClient(), "zh-Hans", "/acme/agents/new/manual"));
+ await waitFor(() => expect(document.title).toBe("创建智能体"));
+ });
+});
diff --git a/apps/desktop/src/renderer/src/components/document-title-sync.tsx b/apps/desktop/src/renderer/src/components/document-title-sync.tsx
new file mode 100644
index 0000000000..80aaa86414
--- /dev/null
+++ b/apps/desktop/src/renderer/src/components/document-title-sync.tsx
@@ -0,0 +1,22 @@
+import { useEffect } from "react";
+import { useLocation } from "react-router-dom";
+import { useTabPresentation } from "@multica/views/layout";
+
+/**
+ * Desktop's writer of document.title (the OS window title); shared pages only
+ * refine it (the attachment preview fills in a filename the URL lacks). It
+ * resolves the current URL through the same contract as the tab strip, so the window title
+ * matches the active tab, is localized, and re-resolves when the interface
+ * language changes or the resource finishes loading. Must render inside a
+ * WorkspaceSlugProvider so resource names can resolve.
+ */
+export function DocumentTitleSync() {
+ const { pathname, search } = useLocation();
+ const { title } = useTabPresentation(pathname + search);
+
+ useEffect(() => {
+ document.title = title;
+ }, [title]);
+
+ return null;
+}
diff --git a/apps/desktop/src/renderer/src/components/issue-window.test.tsx b/apps/desktop/src/renderer/src/components/issue-window.test.tsx
index 882f84ad4d..ffc65e9527 100644
--- a/apps/desktop/src/renderer/src/components/issue-window.test.tsx
+++ b/apps/desktop/src/renderer/src/components/issue-window.test.tsx
@@ -57,6 +57,10 @@ vi.mock("@multica/views/layout", () => ({
WorkspacePresencePrefetch: () => null,
}));
+vi.mock("./document-title-sync", () => ({
+ DocumentTitleSync: () => null,
+}));
+
vi.mock("@multica/views/voice", () => ({
VoiceWorkspaceWords: () => null,
}));
diff --git a/apps/desktop/src/renderer/src/components/issue-window.tsx b/apps/desktop/src/renderer/src/components/issue-window.tsx
index 006e2ed849..7991387934 100644
--- a/apps/desktop/src/renderer/src/components/issue-window.tsx
+++ b/apps/desktop/src/renderer/src/components/issue-window.tsx
@@ -21,6 +21,7 @@ import type { IssueWindowContext } from "../../../shared/issue-window";
import { DesktopAuthRecoveryPage } from "../pages/auth-recovery";
import { IssueDetailPage } from "../pages/issue-detail-page";
import { IssueWindowNavigationProvider } from "../platform/issue-window-navigation";
+import { DocumentTitleSync } from "./document-title-sync";
import { TRAFFIC_LIGHT_CLEARANCE } from "./window-toolbar";
export function IssueWindow({ context }: { context: IssueWindowContext }) {
@@ -83,6 +84,7 @@ function IssueWindowRoute() {
return (
<WorkspaceSlugProvider slug={workspaceSlug}>
<IssueWindowNavigationProvider>
+ <DocumentTitleSync />
<WorkspacePresencePrefetch />
<VoiceWorkspaceWords />
<IssueWindowFrame pageOwnsTitleBar>
diff --git a/apps/desktop/src/renderer/src/components/tab-bar.tsx b/apps/desktop/src/renderer/src/components/tab-bar.tsx
index 3178c2fa20..ad32e414ec 100644
--- a/apps/desktop/src/renderer/src/components/tab-bar.tsx
+++ b/apps/desktop/src/renderer/src/components/tab-bar.tsx
@@ -196,7 +196,7 @@ function SortableTabItem({
// session's first-frame fallback. The tab strip itself always renders the
// live resolved `title`; `tab.title` is just the persisted seed. This
// replaces the old document.title → MutationObserver → tab.title path (the OS
- // window title stays page-driven via useDocumentTitle).
+ // window title resolves from the same URL via DocumentTitleSync).
useEffect(() => {
if (!titleResolved) return;
if (tab.title !== title) updateTab(tab.id, { title });
@@ -526,7 +526,7 @@ function NewTabButton() {
const activeSlug = useTabStore.getState().activeWorkspaceSlug;
if (!activeSlug) return;
const path = paths.workspace(activeSlug).issues();
- const tabId = addTab(path, "Issues");
+ const tabId = addTab(path, "");
if (tabId) setActiveTab(tabId);
};
diff --git a/apps/desktop/src/renderer/src/components/tab-content.tsx b/apps/desktop/src/renderer/src/components/tab-content.tsx
index 12f4e5d383..86b6253397 100644
--- a/apps/desktop/src/renderer/src/components/tab-content.tsx
+++ b/apps/desktop/src/renderer/src/components/tab-content.tsx
@@ -48,13 +48,6 @@ export function TabContent() {
registerCoordinatorQueryClient(qc);
}, [qc]);
- // Sync document.title when switching tabs within the active workspace.
- useEffect(() => {
- if (!group) return;
- const tab = group.tabs.find((t) => t.id === group.activeTabId);
- if (tab) document.title = tab.title;
- }, [group?.activeTabId, group?.tabs]);
-
if (!group) return null;
return (
diff --git a/apps/desktop/src/renderer/src/components/workspace-route-layout.test.tsx b/apps/desktop/src/renderer/src/components/workspace-route-layout.test.tsx
index ec3db73bdc..f73131f952 100644
--- a/apps/desktop/src/renderer/src/components/workspace-route-layout.test.tsx
+++ b/apps/desktop/src/renderer/src/components/workspace-route-layout.test.tsx
@@ -93,6 +93,10 @@ vi.mock("@multica/views/layout", () => ({
WorkspacePresencePrefetch: () => null,
}));
+vi.mock("./document-title-sync", () => ({
+ DocumentTitleSync: () => null,
+}));
+
vi.mock("@multica/views/voice", () => ({
VoiceWorkspaceWords: () => null,
}));
diff --git a/apps/desktop/src/renderer/src/components/workspace-route-layout.tsx b/apps/desktop/src/renderer/src/components/workspace-route-layout.tsx
index 8c7ad257c7..cca135f7a9 100644
--- a/apps/desktop/src/renderer/src/components/workspace-route-layout.tsx
+++ b/apps/desktop/src/renderer/src/components/workspace-route-layout.tsx
@@ -15,6 +15,7 @@ import { VoiceWorkspaceWords } from "@multica/views/voice";
import { SourceBackfillModal } from "@multica/views/onboarding";
import { useTabStore } from "@/stores/tab-store";
import { useWindowOverlayStore } from "@/stores/window-overlay-store";
+import { DocumentTitleSync } from "./document-title-sync";
/**
* Which mounted layout instance currently owns the platform workspace
@@ -176,6 +177,7 @@ export function WorkspaceRouteLayout() {
return (
<WorkspaceSlugProvider slug={workspaceSlug}>
+ <DocumentTitleSync />
<WorkspacePresencePrefetch />
<VoiceWorkspaceWords />
<Outlet />
diff --git a/apps/desktop/src/renderer/src/hooks/use-document-title.ts b/apps/desktop/src/renderer/src/hooks/use-document-title.ts
deleted file mode 100644
index 28429568be..0000000000
--- a/apps/desktop/src/renderer/src/hooks/use-document-title.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-import { useEffect } from "react";
-
-/** Sets document.title. The tab system observes this automatically. */
-export function useDocumentTitle(title: string) {
- useEffect(() => {
- if (title) document.title = title;
- }, [title]);
-}
diff --git a/apps/desktop/src/renderer/src/pages/agent-detail-page.tsx b/apps/desktop/src/renderer/src/pages/agent-detail-page.tsx
index 4ba7235729..ecc771f789 100644
--- a/apps/desktop/src/renderer/src/pages/agent-detail-page.tsx
+++ b/apps/desktop/src/renderer/src/pages/agent-detail-page.tsx
@@ -1,17 +1,8 @@
import { useParams } from "react-router-dom";
-import { useQuery } from "@tanstack/react-query";
import { AgentDetailPage as SharedAgentDetailPage } from "@multica/views/agents";
-import { useWorkspaceId } from "@multica/core/hooks";
-import { agentListOptions } from "@multica/core/workspace/queries";
-import { useDocumentTitle } from "@/hooks/use-document-title";
export function AgentDetailPage() {
const { id } = useParams<{ id: string }>();
- const wsId = useWorkspaceId();
- const { data: agents = [] } = useQuery(agentListOptions(wsId));
- const agent = agents.find((a) => a.id === id) ?? null;
-
- useDocumentTitle(agent?.name ?? "Agent");
if (!id) return null;
return <SharedAgentDetailPage agentId={id} />;
diff --git a/apps/desktop/src/renderer/src/pages/autopilot-detail-page.tsx b/apps/desktop/src/renderer/src/pages/autopilot-detail-page.tsx
index 633d9f2392..a8a3d0c55e 100644
--- a/apps/desktop/src/renderer/src/pages/autopilot-detail-page.tsx
+++ b/apps/desktop/src/renderer/src/pages/autopilot-detail-page.tsx
@@ -1,17 +1,8 @@
import { useParams } from "react-router-dom";
-import { useQuery } from "@tanstack/react-query";
import { AutopilotDetailPage as AutopilotDetail } from "@multica/views/autopilots/components";
-import { useWorkspaceId } from "@multica/core/hooks";
-import { autopilotDetailOptions } from "@multica/core/autopilots/queries";
-import { useDocumentTitle } from "@/hooks/use-document-title";
export function AutopilotDetailPage() {
const { id } = useParams<{ id: string }>();
- const wsId = useWorkspaceId();
- const { data } = useQuery(autopilotDetailOptions(wsId, id!));
-
- // Plain text only — no leading ⚡ glyph in the title (MUL-4370).
- useDocumentTitle(data ? data.autopilot.title : "Autopilot");
if (!id) return null;
return <AutopilotDetail autopilotId={id} />;
diff --git a/apps/desktop/src/renderer/src/pages/issue-detail-page.tsx b/apps/desktop/src/renderer/src/pages/issue-detail-page.tsx
index e148bb1995..debfe077a3 100644
--- a/apps/desktop/src/renderer/src/pages/issue-detail-page.tsx
+++ b/apps/desktop/src/renderer/src/pages/issue-detail-page.tsx
@@ -1,20 +1,10 @@
import { useParams } from "react-router-dom";
import { IssueDetailRoute } from "@multica/views/issues/components";
-import { useWorkspaceId } from "@multica/core/hooks";
-import { useCanonicalIssue } from "@multica/core/issues/canonical-id";
-import { useDocumentTitle } from "@/hooks/use-document-title";
export function IssueDetailPage({ onDelete }: { onDelete?: () => void }) {
// React Router hands `name` over decoded; on the plain issue route it is
// undefined.
const { id, name } = useParams<{ id: string; name?: string }>();
- const wsId = useWorkspaceId();
- // `id` may be an identifier (`MUL-123`); resolving here means the title
- // watches the same UUID-keyed entry realtime events patch. Shares its
- // queries with the IssueDetailRoute below, so it costs no extra request.
- const { issue } = useCanonicalIssue(wsId, id ?? "");
-
- useDocumentTitle(issue ? `${issue.identifier}: ${issue.title}` : "Issue");
if (!id) return null;
// Render errors bubble to the root route errorElement (DesktopRouteErrorPage),
diff --git a/apps/desktop/src/renderer/src/pages/member-detail-page.tsx b/apps/desktop/src/renderer/src/pages/member-detail-page.tsx
index 21c9ab2f92..35db77d594 100644
--- a/apps/desktop/src/renderer/src/pages/member-detail-page.tsx
+++ b/apps/desktop/src/renderer/src/pages/member-detail-page.tsx
@@ -1,17 +1,8 @@
import { useParams } from "react-router-dom";
-import { useQuery } from "@tanstack/react-query";
import { MemberDetailPage as SharedMemberDetailPage } from "@multica/views/members";
-import { useWorkspaceId } from "@multica/core/hooks";
-import { memberListOptions } from "@multica/core/workspace/queries";
-import { useDocumentTitle } from "@/hooks/use-document-title";
export function MemberDetailPage() {
const { id } = useParams<{ id: string }>();
- const wsId = useWorkspaceId();
- const { data: members = [] } = useQuery(memberListOptions(wsId));
- const member = members.find((m) => m.user_id === id) ?? null;
-
- useDocumentTitle(member?.name ?? "Member");
if (!id) return null;
return <SharedMemberDetailPage userId={id} />;
diff --git a/apps/desktop/src/renderer/src/pages/project-detail-page.tsx b/apps/desktop/src/renderer/src/pages/project-detail-page.tsx
index 7c31d7ba1c..7276b1dd3e 100644
--- a/apps/desktop/src/renderer/src/pages/project-detail-page.tsx
+++ b/apps/desktop/src/renderer/src/pages/project-detail-page.tsx
@@ -1,19 +1,9 @@
import { useParams } from "react-router-dom";
-import { useQuery } from "@tanstack/react-query";
import { ProjectDetail } from "@multica/views/projects/components";
-import { useWorkspaceId } from "@multica/core/hooks";
-import { projectDetailOptions } from "@multica/core/projects/queries";
-import { useDocumentTitle } from "@/hooks/use-document-title";
import { IssueViewUrlSync } from "@/platform/issue-view-tabs";
export function ProjectDetailPage() {
const { id } = useParams<{ id: string }>();
- const wsId = useWorkspaceId();
- const { data: project } = useQuery(projectDetailOptions(wsId, id!));
-
- // Plain text only — the project's icon is shown by the tab's leading visual,
- // not concatenated into the title (MUL-4370).
- useDocumentTitle(project ? project.title : "Project");
if (!id) return null;
return (
diff --git a/apps/desktop/src/renderer/src/pages/runtime-detail-page.tsx b/apps/desktop/src/renderer/src/pages/runtime-detail-page.tsx
index b77313c263..af494e7062 100644
--- a/apps/desktop/src/renderer/src/pages/runtime-detail-page.tsx
+++ b/apps/desktop/src/renderer/src/pages/runtime-detail-page.tsx
@@ -1,25 +1,15 @@
import { useParams } from "react-router-dom";
-import { useQuery } from "@tanstack/react-query";
import {
RuntimeDetailPage as SharedRuntimeDetailPage,
RuntimeSettingsPage as SharedRuntimeSettingsPage,
} from "@multica/views/runtimes";
-import { useWorkspaceId } from "@multica/core/hooks";
-import { runtimeDisplayLabel } from "@multica/core/runtimes";
-import { runtimeListOptions } from "@multica/core/runtimes/queries";
-import { useDocumentTitle } from "@/hooks/use-document-title";
import { DaemonRuntimeActions } from "../components/daemon-runtime-card";
import { useDesktopRuntimeContext } from "../components/use-desktop-runtime-context";
export function RuntimeDetailPage() {
const { id } = useParams<{ id: string }>();
- const wsId = useWorkspaceId();
- const { data: runtimes } = useQuery(runtimeListOptions(wsId));
- const runtime = runtimes?.find((candidate) => candidate.id === id);
const context = useDesktopRuntimeContext();
- useDocumentTitle(runtime ? runtimeDisplayLabel(runtime) : "Runtimes");
-
if (!id) return null;
return (
<SharedRuntimeDetailPage
@@ -38,11 +28,6 @@ export function RuntimeSettingsPage() {
id: string;
runtimeId: string;
}>();
- const wsId = useWorkspaceId();
- const { data: runtimes } = useQuery(runtimeListOptions(wsId));
- const runtime = runtimes?.find((candidate) => candidate.id === runtimeId);
-
- useDocumentTitle(runtime ? runtimeDisplayLabel(runtime) : "Runtime");
if (!id || !runtimeId) return null;
return <SharedRuntimeSettingsPage machineId={id} runtimeId={runtimeId} />;
diff --git a/apps/desktop/src/renderer/src/pages/skill-detail-page.tsx b/apps/desktop/src/renderer/src/pages/skill-detail-page.tsx
index 706450ed19..4aff63b8e2 100644
--- a/apps/desktop/src/renderer/src/pages/skill-detail-page.tsx
+++ b/apps/desktop/src/renderer/src/pages/skill-detail-page.tsx
@@ -1,16 +1,8 @@
import { useParams } from "react-router-dom";
-import { useQuery } from "@tanstack/react-query";
import { SkillDetailPage as SharedSkillDetailPage } from "@multica/views/skills";
-import { useWorkspaceId } from "@multica/core/hooks";
-import { skillDetailOptions } from "@multica/core/workspace/queries";
-import { useDocumentTitle } from "@/hooks/use-document-title";
export function SkillDetailPage() {
const { id } = useParams<{ id: string }>();
- const wsId = useWorkspaceId();
- const { data: skill } = useQuery(skillDetailOptions(wsId, id ?? ""));
-
- useDocumentTitle(skill?.name ?? "Skill");
if (!id) return null;
return <SharedSkillDetailPage skillId={id} />;
diff --git a/apps/desktop/src/renderer/src/platform/issue-window-navigation.tsx b/apps/desktop/src/renderer/src/platform/issue-window-navigation.tsx
index 67311b739b..ed9678791d 100644
--- a/apps/desktop/src/renderer/src/platform/issue-window-navigation.tsx
+++ b/apps/desktop/src/renderer/src/platform/issue-window-navigation.tsx
@@ -9,6 +9,7 @@ import {
type LinkClickIntent,
type NavigationAdapter,
} from "@multica/views/navigation";
+import { useT } from "@multica/views/i18n";
import { parseIssueWindowPath } from "../../../shared/issue-window";
/**
@@ -42,6 +43,7 @@ function openInBrowser(
function useContentLinkHandler(
navigate: ReturnType<typeof useNavigate>,
runtimeConfig: typeof window.desktopAPI.runtimeConfig,
+ issueWindowTitle: string,
) {
useEffect(() => {
const handler = (e: Event) => {
@@ -58,7 +60,7 @@ function useContentLinkHandler(
// thing the adapter's openInNewTab produces.
void window.desktopAPI.openIssueWindow({
path: issuePath.path,
- title: "Issue",
+ title: issueWindowTitle,
});
return;
}
@@ -69,7 +71,7 @@ function useContentLinkHandler(
};
window.addEventListener("multica:navigate", handler);
return () => window.removeEventListener("multica:navigate", handler);
- }, [navigate, runtimeConfig]);
+ }, [navigate, runtimeConfig, issueWindowTitle]);
}
/**
@@ -87,6 +89,9 @@ export function IssueWindowNavigationProvider({
const navigate = useNavigate();
const runtimeConfig = window.desktopAPI.runtimeConfig;
const currentPath = `${location.pathname}${location.search}${location.hash}`;
+ const { t } = useT("layout");
+ // Seed title for a new issue window; its page replaces it once it loads.
+ const issueWindowTitle = t(($) => $.tab.issue);
useEffect(() => {
// Both freeze observers need the route: main for a hang this window never
@@ -102,7 +107,7 @@ export function IssueWindowNavigationProvider({
});
}, [currentPath]);
- useContentLinkHandler(navigate, runtimeConfig);
+ useContentLinkHandler(navigate, runtimeConfig, issueWindowTitle);
const adapter = useMemo<NavigationAdapter>(() => {
// Another issue opens in place; any other page goes to the browser, the
@@ -126,7 +131,7 @@ export function IssueWindowNavigationProvider({
openInNewTab: (path, title) => {
void window.desktopAPI.openIssueWindow({
path,
- title: title ?? "Issue",
+ title: title?.trim() || issueWindowTitle,
});
},
getShareableUrl: (path) =>
@@ -138,6 +143,7 @@ export function IssueWindowNavigationProvider({
location.hash,
navigate,
runtimeConfig,
+ issueWindowTitle,
]);
return <NavigationProvider value={adapter}>{children}</NavigationProvider>;
diff --git a/apps/desktop/src/renderer/src/routes.test.ts b/apps/desktop/src/renderer/src/routes.test.ts
new file mode 100644
index 0000000000..69a744f5c8
--- /dev/null
+++ b/apps/desktop/src/renderer/src/routes.test.ts
@@ -0,0 +1,32 @@
+import type { RouteObject } from "react-router-dom";
+import { describe, expect, it } from "vitest";
+import { parseTabSubject } from "@multica/core/paths";
+import { appRoutes } from "./routes";
+
+function collect(routes: RouteObject[]): RouteObject[] {
+ return routes.flatMap((route) => [route, ...collect(route.children ?? [])]);
+}
+
+const workspaceRoute = collect(appRoutes).find(
+ (route) => route.path === ":workspaceSlug",
+);
+const workspacePaths = (workspaceRoute?.children ?? [])
+ .map((route) => route.path)
+ .filter((path): path is string => !!path);
+
+describe("appRoutes titles", () => {
+ it("carries no route-level titles", () => {
+ for (const route of collect(appRoutes)) {
+ expect(route.handle, route.path ?? "(index)").toBeUndefined();
+ }
+ });
+
+ it.each(workspacePaths)("resolves /:slug/%s to a localized tab subject", (path) => {
+ const url = `/acme/${path.replace(/:[A-Za-z]+/g, "x1")}`;
+ expect(parseTabSubject(url).kind).not.toBe("unknown");
+ });
+
+ it("finds the workspace routes", () => {
+ expect(workspacePaths.length).toBeGreaterThan(20);
+ });
+});
diff --git a/apps/desktop/src/renderer/src/routes.tsx b/apps/desktop/src/renderer/src/routes.tsx
index 2f7e62c0a5..8f4bd56e32 100644
--- a/apps/desktop/src/renderer/src/routes.tsx
+++ b/apps/desktop/src/renderer/src/routes.tsx
@@ -1,7 +1,7 @@
import { DocsHomePage } from "@multica/views/docs";
import { DocRoute, DocHistoryRoute, DocFolderRoute } from "./pages/doc-pages";
-import { useEffect, useLayoutEffect } from "react";
-import { createMemoryRouter, Outlet, useLocation, useMatches } from "react-router-dom";
+import { useLayoutEffect } from "react";
+import { createMemoryRouter, Outlet, useLocation } from "react-router-dom";
import type { RouteObject } from "react-router-dom";
import { IssueDetailPage } from "./pages/issue-detail-page";
import { ProjectDetailPage } from "./pages/project-detail-page";
@@ -70,26 +70,6 @@ function DesktopSettingsRoute() {
);
}
-/**
- * Sets document.title from the deepest matched route's handle.title.
- * The tab system observes document.title via MutationObserver.
- * Pages with dynamic titles (e.g. issue detail) override by setting
- * document.title directly via useDocumentTitle().
- */
-function TitleSync() {
- const matches = useMatches();
- const title = [...matches]
- .reverse()
- .find((m) => (m.handle as { title?: string })?.title)
- ?.handle as { title?: string } | undefined;
-
- useEffect(() => {
- if (title?.title) document.title = title.title;
- }, [title?.title]);
-
- return null;
-}
-
/**
* Publishes the committed pathname. A layout effect, so the shell's update
* lands in the same frame as the page it describes.
@@ -103,11 +83,9 @@ function RenderedPathnameSync() {
return null;
}
-/** Wrapper that renders route children + TitleSync */
function PageShell() {
return (
<>
- <TitleSync />
<RenderedPathnameSync />
<Outlet />
</>
@@ -130,6 +108,10 @@ function PageShell() {
* router.navigate from unforeseen code), the index falls back to null
* rather than 404; App.tsx's bootstrap repoints activeWorkspaceSlug on the
* next render pass.
+ *
+ * Routes carry no titles. Tab and window titles are resolved from the URL by
+ * `parseTabSubject` (@multica/core/paths), so a new route segment needs a case
+ * there or it renders as "Unknown page" (routes.test.ts enforces this).
*/
export const appRoutes: RouteObject[] = [
{
@@ -154,39 +136,17 @@ export const appRoutes: RouteObject[] = [
<IssuesPage />
</IssueViewUrlSync>
),
- handle: { title: "Issues" },
- },
- {
- path: "issues/:id",
- element: <IssueDetailPage />,
- handle: { title: "Issue" },
},
+ { path: "issues/:id", element: <IssueDetailPage /> },
{
// The issue, opened on the newest version of one deliverable.
path: "issues/:id/deliverables/:name",
element: <IssueDetailPage />,
- handle: { title: "Issue" },
- },
- {
- path: "projects",
- element: <ProjectsPage />,
- handle: { title: "Projects" },
- },
- {
- path: "projects/:id",
- element: <ProjectDetailPage />,
- handle: { title: "Project" },
- },
- {
- path: "autopilots",
- element: <AutopilotsPage />,
- handle: { title: "Autopilot" },
- },
- {
- path: "autopilots/:id",
- element: <AutopilotDetailPage />,
- handle: { title: "Autopilot" },
},
+ { path: "projects", element: <ProjectsPage /> },
+ { path: "projects/:id", element: <ProjectDetailPage /> },
+ { path: "autopilots", element: <AutopilotsPage /> },
+ { path: "autopilots/:id", element: <AutopilotDetailPage /> },
{
path: "my-issues",
element: (
@@ -194,88 +154,34 @@ export const appRoutes: RouteObject[] = [
<MyIssuesPage />
</IssueViewUrlSync>
),
- handle: { title: "My Issues" },
- },
- {
- path: "runtimes",
- element: <DesktopRuntimesPage />,
- handle: { title: "Runtimes" },
- },
- {
- path: "runtimes/:id",
- element: <RuntimeDetailPage />,
- handle: { title: "Machine" },
},
+ { path: "runtimes", element: <DesktopRuntimesPage /> },
+ { path: "runtimes/:id", element: <RuntimeDetailPage /> },
{
path: "runtimes/:id/runtime/:runtimeId",
element: <RuntimeSettingsPage />,
- handle: { title: "Runtime" },
- },
- {path: "docs", element: <DocsHomePage />, handle: {title: "Docs"}},
- {path: "docs/folders/:id", element: <DocFolderRoute />, handle: {title: "Folder"}},
- {path: "docs/:id", element: <DocRoute />, handle: {title: "Doc"}},
- {path: "docs/:id/history", element: <DocHistoryRoute />, handle: {title: "History"}},
- { path: "skills", element: <SkillsPage />, handle: { title: "Skills" } },
- {
- path: "skills/:id",
- element: <SkillDetailPage />,
- handle: { title: "Skill" },
- },
- { path: "agents", element: <DesktopAgentsPage />, handle: { title: "Agents" } },
- {
- path: "agents/new",
- element: <DesktopChooseRuntimePage />,
- handle: { title: "Create Agent" },
- },
- {
- path: "agents/new/done/:agentId",
- element: <AgentCreatedPage />,
- handle: { title: "Create Agent" },
- },
- {
- path: "agents/new/manual",
- element: <ManualCreateAgentPage />,
- handle: { title: "Create Agent" },
- },
- {
- path: "agents/new/ai/:sessionId",
- element: <AiBuilderSessionPage />,
- handle: { title: "Create Agent" },
- },
- {
- path: "agents/:id",
- element: <AgentDetailPage />,
- handle: { title: "Agent" },
- },
- {
- path: "members/:id",
- element: <MemberDetailPage />,
- handle: { title: "Member" },
- },
- { path: "squads", element: <SquadsPage />, handle: { title: "Squads" } },
- { path: "views", element: <AllViewsPage />, handle: { title: "Views" } },
- {
- path: "squads/:id",
- element: <SquadDetailPageView />,
- handle: { title: "Squad" },
- },
- { path: "inbox", element: <InboxPage />, handle: { title: "Inbox" } },
- { path: "chat", element: <ChatPage />, handle: { title: "Chat" } },
- {
- path: "attachments/:id/preview",
- element: <AttachmentPreviewRoute />,
- handle: { title: "Attachment" },
- },
- {
- path: "usage",
- element: <DashboardPage />,
- handle: { title: "Usage" },
- },
- {
- path: "settings",
- element: <DesktopSettingsRoute />,
- handle: { title: "Settings" },
},
+ { path: "docs", element: <DocsHomePage /> },
+ { path: "docs/folders/:id", element: <DocFolderRoute /> },
+ { path: "docs/:id", element: <DocRoute /> },
+ { path: "docs/:id/history", element: <DocHistoryRoute /> },
+ { path: "skills", element: <SkillsPage /> },
+ { path: "skills/:id", element: <SkillDetailPage /> },
+ { path: "agents", element: <DesktopAgentsPage /> },
+ { path: "agents/new", element: <DesktopChooseRuntimePage /> },
+ { path: "agents/new/done/:agentId", element: <AgentCreatedPage /> },
+ { path: "agents/new/manual", element: <ManualCreateAgentPage /> },
+ { path: "agents/new/ai/:sessionId", element: <AiBuilderSessionPage /> },
+ { path: "agents/:id", element: <AgentDetailPage /> },
+ { path: "members/:id", element: <MemberDetailPage /> },
+ { path: "squads", element: <SquadsPage /> },
+ { path: "views", element: <AllViewsPage /> },
+ { path: "squads/:id", element: <SquadDetailPageView /> },
+ { path: "inbox", element: <InboxPage /> },
+ { path: "chat", element: <ChatPage /> },
+ { path: "attachments/:id/preview", element: <AttachmentPreviewRoute /> },
+ { path: "usage", element: <DashboardPage /> },
+ { path: "settings", element: <DesktopSettingsRoute /> },
],
},
],
diff --git a/packages/views/attachments/attachment-preview-page.tsx b/packages/views/attachments/attachment-preview-page.tsx
index 74c11b74ad..52cf36d75a 100644
--- a/packages/views/attachments/attachment-preview-page.tsx
+++ b/packages/views/attachments/attachment-preview-page.tsx
@@ -76,8 +76,8 @@ export function AttachmentPreviewPage({
getPreviewKind(attachment.content_type, attachment.filename) === "image";
const imagePending = isImage && query.fetchStatus !== "idle";
- // Set document.title so desktop's MutationObserver-based tab title picks
- // up the filename. Web shows the same string in the browser tab.
+ // Web shows this in the browser tab; on desktop it refines the window title
+ // when the URL carries no `?name=` filename.
const title = attachment?.filename || filename;
useEffect(() => {
if (title) document.title = title;
diff --git a/packages/views/layout/tab-presentation.test.tsx b/packages/views/layout/tab-presentation.test.tsx
index 66c585ba1b..b5b1a3c561 100644
--- a/packages/views/layout/tab-presentation.test.tsx
+++ b/packages/views/layout/tab-presentation.test.tsx
@@ -99,7 +99,8 @@ function seed(qc: QueryClient) {
{ id: "ag1", name: "Robby", avatar_url: null },
] as never);
qc.setQueryData(runtimeListOptions("ws1").queryKey, [
- { id: "rt1", name: "Claude (host)", custom_name: "Prod Box", status: "online" },
+ { id: "rt1", name: "Claude (host)", custom_name: "Prod Box", provider: "claude", status: "online" },
+ { id: "rt2", name: "Codex (host)", custom_name: null, provider: "codex", status: "online" },
] as never);
}
@@ -170,13 +171,21 @@ describe("useTabPresentation — live from cache", () => {
});
});
- it("machine tab uses the runtime's custom name over the raw daemon name", () => {
+ it("machine tab shows the runtime's alias with its provider", () => {
expect(presentationOf("/acme/runtimes/rt1")).toEqual({
visual: { kind: "icon", icon: "Monitor" },
- title: "Prod Box",
+ title: "Prod Box (Claude)",
});
});
+ it("runtime tab without an alias keeps the daemon name", () => {
+ expect(presentationOf("/acme/runtimes/m1/runtime/rt2").title).toBe("Codex (host)");
+ });
+
+ it("runtime tab with an alias shows the provider", () => {
+ expect(presentationOf("/acme/runtimes/m1/runtime/rt1").title).toBe("Prod Box (Claude)");
+ });
+
it("chat container: MessageSquare icon + session title", () => {
expect(presentationOf("/acme/chat?session=s1")).toEqual({
visual: { kind: "icon", icon: "MessageSquare" },
diff --git a/packages/views/layout/tab-presentation.tsx b/packages/views/layout/tab-presentation.tsx
index 1b9f79006e..7bd99a4f6c 100644
--- a/packages/views/layout/tab-presentation.tsx
+++ b/packages/views/layout/tab-presentation.tsx
@@ -24,7 +24,7 @@ import {
squadListOptions,
} from "@multica/core/workspace/queries";
import { runtimeListOptions } from "@multica/core/runtimes/queries";
-import { runtimeDisplayName } from "@multica/core/runtimes";
+import { runtimeDisplayLabel } from "@multica/core/runtimes";
import { chatSessionsOptions } from "@multica/core/chat/queries";
import {
inboxListOptions,
@@ -197,12 +197,12 @@ function useTabEntityData(subject: TabSubject, wsId: string, fetch: boolean): Re
}
case "machine": {
const rt = runtimes?.find((r) => r.id === subject.machineId);
- if (rt) data.machine = { name: runtimeDisplayName(rt) };
+ if (rt) data.machine = { name: runtimeDisplayLabel(rt) };
break;
}
case "runtime": {
const rt = runtimes?.find((r) => r.id === subject.runtimeId);
- if (rt) data.runtime = { name: runtimeDisplayName(rt) };
+ if (rt) data.runtime = { name: runtimeDisplayLabel(rt) };
break;
}
case "chat":