Skip to content

⭐️⭐️⭐️ Open-source, self-hosted alternative to Linear and Plane. Project management and issue tracking where teams and AI agents work side by side to plan and ship products.

improvement(web): browser tabs name the screen they show (#594)

Nekrasov Ilyac66a061a1f93
diff --git a/apps/web/AGENTS.md b/apps/web/AGENTS.md
index cf52e0dc..174ea714 100644
--- a/apps/web/AGENTS.md
+++ b/apps/web/AGENTS.md
@@ -123,6 +123,12 @@ next-intl, language from the `NEXT_LOCALE` cookie — no `[locale]` route segmen
- Prefer Server Components and server-side data fetching; reach for client components only for
interactivity/hooks.
+- **A screen names itself in the browser tab with `useDocumentTitle`.** The shell names the
+ section (`useShellTitle`), a detail page its entity, and an issue side panel its issue over
+ both; `titlePath(...)` builds `Project › Section` and gives null while a part is missing. An
+ entity read that failed passes null, so the tab never names what the screen cannot show.
+ A server-rendered page renders `components/common/DocumentTitle`. Never set `metadata.title`
+ per route: the hook owns `document.title`.
- A screen that has to stay live calls `useLiveRefresh({ scope, targets })` with a scope from
`@/utils/revScopes` — never its own polling. `SyncProvider` polls every registered scope in one
request and invalidates the targets of the ones that moved.
diff --git a/apps/web/messages/ar/meta.json b/apps/web/messages/ar/meta.json
index 3e660a7f..59f8ce69 100644
--- a/apps/web/messages/ar/meta.json
+++ b/apps/web/messages/ar/meta.json
@@ -1,4 +1,14 @@
{
- "title": "It's a Plan: تتبّع المهام للأشخاص والوكلاء",
- "description": "متتبّع مهام مفتوح المصدر ذاتي الاستضافة مع وكلاء ذكاء اصطناعي مدمجين. أسنِد العمل إلى أشخاص أو وكلاء، وقُده عبر واجهة البرمجة وخطافات الويب وMCP."
+ "description": "متتبّع مهام مفتوح المصدر ذاتي الاستضافة مع وكلاء ذكاء اصطناعي مدمجين. أسنِد العمل إلى أشخاص أو وكلاء، وقُده عبر واجهة البرمجة وخطافات الويب وMCP.",
+ "screens": {
+ "signIn": "تسجيل الدخول",
+ "signUp": "إنشاء حساب",
+ "forgotPassword": "نسيت كلمة المرور",
+ "resetPassword": "إعادة تعيين كلمة المرور",
+ "account": "الحساب",
+ "settings": "الإعدادات",
+ "teamSettings": "إعدادات الفريق",
+ "invitation": "دعوة",
+ "authorizeApp": "تفويض التطبيق"
+ }
}
diff --git a/apps/web/messages/en/meta.json b/apps/web/messages/en/meta.json
index 07a2c4aa..70bb6503 100644
--- a/apps/web/messages/en/meta.json
+++ b/apps/web/messages/en/meta.json
@@ -1,4 +1,14 @@
{
- "title": "It's a Plan: issue tracking for people and agents",
- "description": "A self-hosted, open-source issue tracker with AI agents built in. Assign work to people or agents, and drive it through the API, webhooks and MCP."
+ "description": "A self-hosted, open-source issue tracker with AI agents built in. Assign work to people or agents, and drive it through the API, webhooks and MCP.",
+ "screens": {
+ "signIn": "Sign in",
+ "signUp": "Sign up",
+ "forgotPassword": "Forgot password",
+ "resetPassword": "Reset password",
+ "account": "Account",
+ "settings": "Settings",
+ "teamSettings": "Team settings",
+ "invitation": "Invitation",
+ "authorizeApp": "Authorize app"
+ }
}
diff --git a/apps/web/messages/es-ES/meta.json b/apps/web/messages/es-ES/meta.json
index 8a09bf71..27e1708f 100644
--- a/apps/web/messages/es-ES/meta.json
+++ b/apps/web/messages/es-ES/meta.json
@@ -1,4 +1,14 @@
{
- "title": "It's a Plan: seguimiento de tickets para personas y agentes",
- "description": "Un gestor de tickets autogestionado y de código abierto con agentes de IA integrados. Asigna trabajo a personas o agentes, y gestiona todo a través de la API, webhooks y MCP."
+ "description": "Un gestor de tickets autogestionado y de código abierto con agentes de IA integrados. Asigna trabajo a personas o agentes, y gestiona todo a través de la API, webhooks y MCP.",
+ "screens": {
+ "signIn": "Iniciar sesión",
+ "signUp": "Registrarse",
+ "forgotPassword": "Contraseña olvidada",
+ "resetPassword": "Restablecer contraseña",
+ "account": "Cuenta",
+ "settings": "Ajustes",
+ "teamSettings": "Ajustes del equipo",
+ "invitation": "Invitación",
+ "authorizeApp": "Autorizar aplicación"
+ }
}
diff --git a/apps/web/messages/fa/meta.json b/apps/web/messages/fa/meta.json
index f82f4869..1610a4e7 100644
--- a/apps/web/messages/fa/meta.json
+++ b/apps/web/messages/fa/meta.json
@@ -1,4 +1,14 @@
{
- "title": "It's a Plan: ردیابی تسک برای افراد و ایجنت‌ها",
- "description": "یک ردیاب تسک خودمیزبان و متن‌باز با ایجنت‌های هوش مصنوعی به‌صورت داخلی. کار را به افراد یا ایجنت‌ها بسپارید و آن را از طریق API، وب‌هوک‌ها و MCP پیش ببرید."
+ "description": "یک ردیاب تسک خودمیزبان و متن‌باز با ایجنت‌های هوش مصنوعی به‌صورت داخلی. کار را به افراد یا ایجنت‌ها بسپارید و آن را از طریق API، وب‌هوک‌ها و MCP پیش ببرید.",
+ "screens": {
+ "signIn": "ورود",
+ "signUp": "ثبت‌نام",
+ "forgotPassword": "فراموشی رمز عبور",
+ "resetPassword": "بازنشانی رمز عبور",
+ "account": "حساب",
+ "settings": "تنظیمات",
+ "teamSettings": "تنظیمات تیم",
+ "invitation": "دعوت‌نامه",
+ "authorizeApp": "مجوز برنامه"
+ }
}
diff --git a/apps/web/messages/fr/meta.json b/apps/web/messages/fr/meta.json
index 9c39d792..6edd03ca 100644
--- a/apps/web/messages/fr/meta.json
+++ b/apps/web/messages/fr/meta.json
@@ -1,4 +1,14 @@
{
- "title": "It's a Plan : le suivi de tickets pour les humains et les agents",
- "description": "Un gestionnaire de tickets open source et auto-hébergé, avec des agents IA intégrés. Confiez le travail à des humains ou à des agents, et pilotez-le via l'API, les webhooks et MCP."
+ "description": "Un gestionnaire de tickets open source et auto-hébergé, avec des agents IA intégrés. Confiez le travail à des humains ou à des agents, et pilotez-le via l'API, les webhooks et MCP.",
+ "screens": {
+ "signIn": "Connexion",
+ "signUp": "Inscription",
+ "forgotPassword": "Mot de passe oublié",
+ "resetPassword": "Réinitialiser le mot de passe",
+ "account": "Compte",
+ "settings": "Paramètres",
+ "teamSettings": "Paramètres de l’équipe",
+ "invitation": "Invitation",
+ "authorizeApp": "Autoriser l’application"
+ }
}
diff --git a/apps/web/messages/id/meta.json b/apps/web/messages/id/meta.json
index d7db2374..c0d71a03 100644
--- a/apps/web/messages/id/meta.json
+++ b/apps/web/messages/id/meta.json
@@ -1,4 +1,14 @@
{
- "title": "It's a Plan: pelacakan issue untuk orang dan agen",
- "description": "Pelacak issue sumber terbuka yang di-host sendiri dengan agen AI bawaan. Tetapkan pekerjaan kepada orang atau agen, lalu jalankan melalui API, webhook, dan MCP."
+ "description": "Pelacak issue sumber terbuka yang di-host sendiri dengan agen AI bawaan. Tetapkan pekerjaan kepada orang atau agen, lalu jalankan melalui API, webhook, dan MCP.",
+ "screens": {
+ "signIn": "Masuk",
+ "signUp": "Daftar",
+ "forgotPassword": "Lupa kata sandi",
+ "resetPassword": "Atur ulang kata sandi",
+ "account": "Akun",
+ "settings": "Pengaturan",
+ "teamSettings": "Pengaturan tim",
+ "invitation": "Undangan",
+ "authorizeApp": "Otorisasi aplikasi"
+ }
}
diff --git a/apps/web/messages/ko/meta.json b/apps/web/messages/ko/meta.json
index 7c8c6773..82e94a86 100644
--- a/apps/web/messages/ko/meta.json
+++ b/apps/web/messages/ko/meta.json
@@ -1,4 +1,14 @@
{
- "title": "It's a Plan: 사람과 에이전트를 위한 이슈 트래킹",
- "description": "AI 에이전트가 내장된 셀프 호스팅 오픈 소스 이슈 트래커입니다. 사람이나 에이전트에게 작업을 할당하고 API, 웹훅, MCP를 통해 작업을 진행할 수 있습니다."
+ "description": "AI 에이전트가 내장된 셀프 호스팅 오픈 소스 이슈 트래커입니다. 사람이나 에이전트에게 작업을 할당하고 API, 웹훅, MCP를 통해 작업을 진행할 수 있습니다.",
+ "screens": {
+ "signIn": "로그인",
+ "signUp": "회원가입",
+ "forgotPassword": "비밀번호 찾기",
+ "resetPassword": "비밀번호 재설정",
+ "account": "계정",
+ "settings": "설정",
+ "teamSettings": "팀 설정",
+ "invitation": "초대",
+ "authorizeApp": "앱 승인"
+ }
}
diff --git a/apps/web/messages/pt-BR/meta.json b/apps/web/messages/pt-BR/meta.json
index ec152c2b..311d92da 100644
--- a/apps/web/messages/pt-BR/meta.json
+++ b/apps/web/messages/pt-BR/meta.json
@@ -1,4 +1,14 @@
{
- "title": "It's a Plan: rastreamento de issues para pessoas e agentes",
- "description": "Um rastreador de issues open-source e self-hosted com agentes de IA integrados. Atribua trabalho a pessoas ou agentes e conduza-o pela API, webhooks e MCP."
+ "description": "Um rastreador de issues open-source e self-hosted com agentes de IA integrados. Atribua trabalho a pessoas ou agentes e conduza-o pela API, webhooks e MCP.",
+ "screens": {
+ "signIn": "Entrar",
+ "signUp": "Criar conta",
+ "forgotPassword": "Esqueci a senha",
+ "resetPassword": "Redefinir senha",
+ "account": "Conta",
+ "settings": "Configurações",
+ "teamSettings": "Configurações da equipe",
+ "invitation": "Convite",
+ "authorizeApp": "Autorizar aplicativo"
+ }
}
diff --git a/apps/web/messages/ru/meta.json b/apps/web/messages/ru/meta.json
index 90f31278..228b6497 100644
--- a/apps/web/messages/ru/meta.json
+++ b/apps/web/messages/ru/meta.json
@@ -1,4 +1,14 @@
{
- "title": "It's a Plan: трекер задач для людей и агентов",
- "description": "Self-hosted трекер задач с открытым кодом и встроенными AI-агентами. Назначайте работу людям или агентам и управляйте ей через API, вебхуки и MCP."
+ "description": "Self-hosted трекер задач с открытым кодом и встроенными AI-агентами. Назначайте работу людям или агентам и управляйте ей через API, вебхуки и MCP.",
+ "screens": {
+ "signIn": "Вход",
+ "signUp": "Регистрация",
+ "forgotPassword": "Восстановление пароля",
+ "resetPassword": "Новый пароль",
+ "account": "Аккаунт",
+ "settings": "Настройки",
+ "teamSettings": "Настройки команды",
+ "invitation": "Приглашение",
+ "authorizeApp": "Доступ приложения"
+ }
}
diff --git a/apps/web/messages/uk/meta.json b/apps/web/messages/uk/meta.json
index c470807d..a2e45daf 100644
--- a/apps/web/messages/uk/meta.json
+++ b/apps/web/messages/uk/meta.json
@@ -1,4 +1,14 @@
{
- "title": "It's a Plan: трекер задач для людей і агентів",
- "description": "Self-hosted трекер задач з відкритим кодом і вбудованими AI-агентами. Призначайте роботу людям або агентам і керуйте нею через API, вебхуки та MCP."
+ "description": "Self-hosted трекер задач з відкритим кодом і вбудованими AI-агентами. Призначайте роботу людям або агентам і керуйте нею через API, вебхуки та MCP.",
+ "screens": {
+ "signIn": "Вхід",
+ "signUp": "Реєстрація",
+ "forgotPassword": "Відновлення пароля",
+ "resetPassword": "Новий пароль",
+ "account": "Обліковий запис",
+ "settings": "Налаштування",
+ "teamSettings": "Налаштування команди",
+ "invitation": "Запрошення",
+ "authorizeApp": "Доступ застосунку"
+ }
}
diff --git a/apps/web/messages/zh-CN/meta.json b/apps/web/messages/zh-CN/meta.json
index c874c254..9725f1e0 100644
--- a/apps/web/messages/zh-CN/meta.json
+++ b/apps/web/messages/zh-CN/meta.json
@@ -1,4 +1,14 @@
{
- "title": "It's a Plan:面向人员和 AI 代理的工作项管理",
- "description": "自托管的开源项目管理和工作项跟踪工具,内置 AI 代理。你可以将工作指派给人员或代理,也可以通过 API、Webhook 和 MCP 进行管理。"
+ "description": "自托管的开源项目管理和工作项跟踪工具,内置 AI 代理。你可以将工作指派给人员或代理,也可以通过 API、Webhook 和 MCP 进行管理。",
+ "screens": {
+ "signIn": "登录",
+ "signUp": "注册",
+ "forgotPassword": "忘记密码",
+ "resetPassword": "重置密码",
+ "account": "账户",
+ "settings": "设置",
+ "teamSettings": "团队设置",
+ "invitation": "邀请",
+ "authorizeApp": "授权应用"
+ }
}
diff --git a/apps/web/src/app/account/layout.tsx b/apps/web/src/app/account/layout.tsx
new file mode 100644
index 00000000..8d0b58f2
--- /dev/null
+++ b/apps/web/src/app/account/layout.tsx
@@ -0,0 +1,11 @@
+import type { ReactNode } from 'react';
+import AccountTitle from '@/features/account/components/AccountTitle';
+
+export default function Layout({ children }: { children: ReactNode }) {
+ return (
+ <>
+ <AccountTitle />
+ {children}
+ </>
+ );
+}
diff --git a/apps/web/src/app/layout.tsx b/apps/web/src/app/layout.tsx
index e009ec3c..461284c0 100644
--- a/apps/web/src/app/layout.tsx
+++ b/apps/web/src/app/layout.tsx
@@ -6,14 +6,15 @@ import { Providers } from '@/components/providers';
import RuntimeEnvScript from '@/components/runtime-env-script';
import WhatsNew from '@/features/whats-new/WhatsNew';
import { localeDirection, type Locale } from '@/i18n/locales';
+import { APP_NAME } from '@/utils/app';
import './globals.css';
export async function generateMetadata(): Promise<Metadata> {
const t = await getTranslations('meta');
return {
- title: t('title'),
+ title: APP_NAME,
description: t('description'),
- appleWebApp: { title: "It's a Plan", capable: true, statusBarStyle: 'default' },
+ appleWebApp: { title: APP_NAME, capable: true, statusBarStyle: 'default' },
};
}
diff --git a/apps/web/src/components/common/DocumentTitle.tsx b/apps/web/src/components/common/DocumentTitle.tsx
new file mode 100644
index 00000000..d21cc921
--- /dev/null
+++ b/apps/web/src/components/common/DocumentTitle.tsx
@@ -0,0 +1,9 @@
+'use client';
+
+import { useDocumentTitle } from '@/hooks/useDocumentTitle';
+
+// The tab title of a server-rendered page, which cannot call the hook itself.
+export default function DocumentTitle({ title }: { title: string }) {
+ useDocumentTitle(title);
+ return null;
+}
diff --git a/apps/web/src/components/layout/GodShell.tsx b/apps/web/src/components/layout/GodShell.tsx
index 1ba2de1a..a7a2ddaf 100644
--- a/apps/web/src/components/layout/GodShell.tsx
+++ b/apps/web/src/components/layout/GodShell.tsx
@@ -2,7 +2,11 @@
import { useEffect, useState, type ReactNode } from 'react';
import { useTranslations } from 'next-intl';
+import { usePathname } from 'next/navigation';
import { useSession } from '@/lib/auth-client';
+import { GOD_SECTIONS } from '@/utils/godSections';
+import { useGodSectionText } from '@/hooks/useSectionLabels';
+import { titlePath, useDocumentTitle } from '@/hooks/useDocumentTitle';
import { SidebarInset, SidebarProvider, SidebarTrigger } from '@/components/ui/sidebar';
import { Separator } from '@/components/ui/separator';
import { ThemeToggle } from '@/components/theme-toggle';
@@ -34,6 +38,10 @@ export default function GodShell({
useEffect(() => setMounted(true), []);
const isGod = mounted && session?.user.role === 'god';
const sessionSettled = mounted && !isPending;
+ const god = useGodSectionText();
+ const slug = usePathname().split('/')[2];
+ const section = GOD_SECTIONS.find((entry) => entry.slug === slug);
+ useDocumentTitle(titlePath(t('godMode'), section && god.section(section.slug).label));
return (
<SidebarProvider defaultOpen={defaultSidebarOpen} className="h-svh overflow-hidden">
diff --git a/apps/web/src/components/layout/Shell.tsx b/apps/web/src/components/layout/Shell.tsx
index ba387767..4f925cee 100644
--- a/apps/web/src/components/layout/Shell.tsx
+++ b/apps/web/src/components/layout/Shell.tsx
@@ -13,6 +13,7 @@ import { usePermissions } from '@/hooks/usePermissions';
import { useSettingsNavGroups } from '@/hooks/useSettingsNavGroups';
import { useShellProject } from '@/hooks/useShellProject';
import { useShellRoute } from '@/hooks/useShellRoute';
+import { useShellTitle } from '@/hooks/useShellTitle';
import { useAppBadge } from '@/hooks/useAppBadge';
import { useProjectRouteSync } from '@/hooks/useProjectRouteSync';
import { projectPath, issuePath } from '@/utils/paths';
@@ -53,6 +54,7 @@ export default function Shell({
project,
filteredProject,
views,
+ viewsFailed,
editor,
customFields,
canCreateIssue,
@@ -60,6 +62,15 @@ export default function Shell({
forbidden,
} = useShellProject(projectKey, route.activeViewId);
useAppBadge(projects.map((item) => item.id));
+ const projectName = project?.project.name ?? t('project');
+ // A failed read keeps the last data, so a project that became unreadable is named
+ // generically.
+ const unreadable = forbidden || !!errorMsg;
+ useShellTitle(
+ route,
+ unreadable ? t('project') : projectName,
+ unreadable || viewsFailed ? [] : views,
+ );
const teamId = project?.project.teamId;
const issueRefs = useMemo(
() => projects.filter((item) => item.teamId === teamId).map((item) => item.ref),
@@ -173,7 +184,7 @@ export default function Shell({
title={
<ShellHeaderTitle
route={route}
- projectName={project?.project.name ?? t('project')}
+ projectName={projectName}
issueIdentifier={issueQuery.data?.identifier ?? null}
issueParent={issueQuery.data?.parent ?? null}
/>
diff --git a/apps/web/src/features/account/components/AccountTitle.tsx b/apps/web/src/features/account/components/AccountTitle.tsx
new file mode 100644
index 00000000..e6688ac3
--- /dev/null
+++ b/apps/web/src/features/account/components/AccountTitle.tsx
@@ -0,0 +1,18 @@
+'use client';
+
+import { usePathname } from 'next/navigation';
+import { useTranslations } from 'next-intl';
+import { ACCOUNT_SECTIONS } from '@/utils/accountSections';
+import { useAccountSectionLabel } from '@/hooks/useSectionLabels';
+import { titlePath, useDocumentTitle } from '@/hooks/useDocumentTitle';
+
+// The tab title of an account page, `Account › Security`. The teams pages under
+// /account name themselves.
+export default function AccountTitle() {
+ const t = useTranslations('meta.screens');
+ const sectionLabel = useAccountSectionLabel();
+ const slug = usePathname().split('/')[2];
+ const section = ACCOUNT_SECTIONS.find((entry) => entry.slug === slug);
+ useDocumentTitle(titlePath(t('account'), section && sectionLabel(section.slug)));
+ return null;
+}
diff --git a/apps/web/src/features/auth/AuthForgotPasswordPage.tsx b/apps/web/src/features/auth/AuthForgotPasswordPage.tsx
index 496fb8c5..27724c41 100644
--- a/apps/web/src/features/auth/AuthForgotPasswordPage.tsx
+++ b/apps/web/src/features/auth/AuthForgotPasswordPage.tsx
@@ -3,7 +3,7 @@ import AuthForgotPasswordForm from './components/forgot-password/AuthForgotPassw
export default function AuthForgotPasswordPage() {
return (
- <AuthCard>
+ <AuthCard screen="forgotPassword">
<AuthForgotPasswordForm />
</AuthCard>
);
diff --git a/apps/web/src/features/auth/AuthLoginPage.tsx b/apps/web/src/features/auth/AuthLoginPage.tsx
index 053391cb..c79c0edd 100644
--- a/apps/web/src/features/auth/AuthLoginPage.tsx
+++ b/apps/web/src/features/auth/AuthLoginPage.tsx
@@ -3,7 +3,7 @@ import AuthLoginForm from './components/login/AuthLoginForm';
export default function AuthLoginPage() {
return (
- <AuthCard>
+ <AuthCard screen="signIn">
<AuthLoginForm />
</AuthCard>
);
diff --git a/apps/web/src/features/auth/AuthRegisterPage.tsx b/apps/web/src/features/auth/AuthRegisterPage.tsx
index 7af3c9ad..87908397 100644
--- a/apps/web/src/features/auth/AuthRegisterPage.tsx
+++ b/apps/web/src/features/auth/AuthRegisterPage.tsx
@@ -3,7 +3,7 @@ import AuthRegisterForm from './components/register/AuthRegisterForm';
export default function AuthRegisterPage() {
return (
- <AuthCard>
+ <AuthCard screen="signUp">
<AuthRegisterForm />
</AuthCard>
);
diff --git a/apps/web/src/features/auth/AuthResetPasswordPage.tsx b/apps/web/src/features/auth/AuthResetPasswordPage.tsx
index 507864b4..58e6dc63 100644
--- a/apps/web/src/features/auth/AuthResetPasswordPage.tsx
+++ b/apps/web/src/features/auth/AuthResetPasswordPage.tsx
@@ -3,7 +3,7 @@ import AuthResetPasswordForm from './components/reset-password/AuthResetPassword
export default function AuthResetPasswordPage() {
return (
- <AuthCard>
+ <AuthCard screen="resetPassword">
<AuthResetPasswordForm />
</AuthCard>
);
diff --git a/apps/web/src/features/auth/components/AuthCard.tsx b/apps/web/src/features/auth/components/AuthCard.tsx
index ebbeedc2..7274e4b1 100644
--- a/apps/web/src/features/auth/components/AuthCard.tsx
+++ b/apps/web/src/features/auth/components/AuthCard.tsx
@@ -1,5 +1,7 @@
import { Suspense } from 'react';
import type { ReactNode } from 'react';
+import { useTranslations } from 'next-intl';
+import DocumentTitle from '@/components/common/DocumentTitle';
import { Card, CardContent } from '@/components/ui/card';
import BrandPanel from '@/components/common/page/BrandPanel';
import AuthLegalNotice from './AuthLegalNotice';
@@ -7,7 +9,14 @@ import AuthLegalNotice from './AuthLegalNotice';
// The card shared by every logged-out screen. The forms read the URL (an invite
// parameter, a reset token, a "just confirmed" flag), so they render inside a
// Suspense boundary — useSearchParams needs one for these pages to prerender.
-export default function AuthCard({ children }: { children: ReactNode }) {
+export default function AuthCard({
+ screen,
+ children,
+}: {
+ screen: 'signIn' | 'signUp' | 'forgotPassword' | 'resetPassword';
+ children: ReactNode;
+}) {
+ const t = useTranslations('meta.screens');
return (
<div className="flex min-h-svh flex-col items-center justify-center bg-muted p-6 md:p-10">
<div className="flex w-full max-w-sm flex-col gap-4 md:max-w-4xl">
@@ -18,6 +27,7 @@ export default function AuthCard({ children }: { children: ReactNode }) {
</CardContent>
</Card>
<AuthLegalNotice />
+ <DocumentTitle title={t(screen)} />
</div>
</div>
);
diff --git a/apps/web/src/features/cycles/CycleDetailPage.tsx b/apps/web/src/features/cycles/CycleDetailPage.tsx
index 00565142..b5ec02bf 100644
--- a/apps/web/src/features/cycles/CycleDetailPage.tsx
+++ b/apps/web/src/features/cycles/CycleDetailPage.tsx
@@ -4,6 +4,7 @@ import { useTranslations } from 'next-intl';
import { useShell } from '@/context/shellContext';
import { Skeleton } from '@/components/ui/skeleton';
import { useCycleQuery } from '@/services/cycles.service';
+import { titlePath, useDocumentTitle } from '@/hooks/useDocumentTitle';
import CycleHeader from './components/detail/CycleHeader';
import CycleIssuesBoard from './components/detail/CycleIssuesBoard';
@@ -14,6 +15,7 @@ export default function CycleDetailPage({ cycleId }: { cycleId: number }) {
const projectKey = project?.project.ref ?? null;
const query = useCycleQuery(cycleId);
const cycle = query.data;
+ useDocumentTitle(titlePath(project?.project.name, !query.isError && cycle?.name));
if (!project || !projectKey) return null;
if (!cycle)
diff --git a/apps/web/src/features/dashboards/DashboardsPage.tsx b/apps/web/src/features/dashboards/DashboardsPage.tsx
index d5874d61..9767933d 100644
--- a/apps/web/src/features/dashboards/DashboardsPage.tsx
+++ b/apps/web/src/features/dashboards/DashboardsPage.tsx
@@ -6,6 +6,7 @@ import { useShellRoute } from '@/hooks/useShellRoute';
import { useTranslations } from 'next-intl';
import { useShell } from '@/context/shellContext';
import { usePermissions } from '@/hooks/usePermissions';
+import { titlePath, useDocumentTitle } from '@/hooks/useDocumentTitle';
import { dashboardPath, dashboardsPath } from '@/utils/paths';
import { Button } from '@/components/ui/button';
import { Skeleton } from '@/components/ui/skeleton';
@@ -38,6 +39,12 @@ export default function DashboardsPage() {
? parsedRouteId
: null;
const activeDashboardId = routeId;
+ useDocumentTitle(
+ titlePath(
+ project?.project.name,
+ isSuccess && list.find((dashboard) => dashboard.id === routeId)?.name,
+ ),
+ );
const missingDashboard =
isSuccess &&
!isFetching &&
diff --git a/apps/web/src/features/documents/DocumentsPage.tsx b/apps/web/src/features/documents/DocumentsPage.tsx
index 054ef605..c00530e6 100644
--- a/apps/web/src/features/documents/DocumentsPage.tsx
+++ b/apps/web/src/features/documents/DocumentsPage.tsx
@@ -25,6 +25,7 @@ import DocumentsIndex from './components/DocumentsIndex';
import { documentBelongsToTab, type DocumentListTab } from './utils/documentList';
import { documentAncestors } from './utils/documentTree';
import { useDebouncedValue } from '@/hooks/useDebouncedValue';
+import { titlePath, useDocumentTitle } from '@/hooks/useDocumentTitle';
import { useDocumentNavigation, useRecentDocuments } from '@/hooks/useDocumentNavigation';
import { useTranslations } from 'next-intl';
@@ -85,6 +86,11 @@ export default function DocumentsPage() {
: document,
);
const documentQuery = useDocumentQuery(projectKey, documentId);
+ const documentTitle =
+ !documentQuery.isError &&
+ documentQuery.data &&
+ (documentQuery.data.title.trim() || t('untitled'));
+ useDocumentTitle(titlePath(project?.project.name, documentTitle));
const createDocument = useCreateDocument(projectKey);
const deleteDocument = useDeleteDocument(projectKey);
const duplicateDocument = useDuplicateDocument(projectKey);
diff --git a/apps/web/src/features/initiatives/InitiativeDetailPage.tsx b/apps/web/src/features/initiatives/InitiativeDetailPage.tsx
index 404d2b60..ab7db846 100644
--- a/apps/web/src/features/initiatives/InitiativeDetailPage.tsx
+++ b/apps/web/src/features/initiatives/InitiativeDetailPage.tsx
@@ -8,6 +8,7 @@ import { revScope } from '@/utils/revScopes';
import { initiativePath, type InitiativeTab } from '@/utils/paths';
import { qk } from '@/services/queryKeys';
import { useInitiativeQuery } from '@/services/initiatives.service';
+import { titlePath, useDocumentTitle } from '@/hooks/useDocumentTitle';
import { Tabs, TabsList, TabsTrigger, TabsContent } from '@/components/ui/tabs';
import PageSkeleton from '@/components/common/skeleton/PageSkeleton';
import InitiativeHeader from './components/detail/InitiativeHeader';
@@ -32,6 +33,9 @@ export default function InitiativeDetailPage({
const query = useInitiativeQuery(initiativeId);
const projectKey = project?.project.ref ?? '';
+ useDocumentTitle(
+ titlePath(project?.project.name, !query.isError && query.data?.title, t(`detailTabs.${tab}`)),
+ );
// Refetch the initiative (progress/health), its files, its linked Docs, its feed
// and the board issues when its linked issues or its own fields change.
diff --git a/apps/web/src/features/invite/InviteAcceptPage.tsx b/apps/web/src/features/invite/InviteAcceptPage.tsx
index 55997ed9..8e62eedf 100644
--- a/apps/web/src/features/invite/InviteAcceptPage.tsx
+++ b/apps/web/src/features/invite/InviteAcceptPage.tsx
@@ -2,6 +2,7 @@
import Link from 'next/link';
import { useTranslations } from 'next-intl';
+import { useDocumentTitle } from '@/hooks/useDocumentTitle';
import BrandPanel from '@/components/common/page/BrandPanel';
import ListSkeleton from '@/components/common/skeleton/ListSkeleton';
import { Button } from '@/components/ui/button';
@@ -17,6 +18,8 @@ import InviteStep from './components/InviteStep';
export default function InviteAcceptPage({ token }: { token: string }) {
const t = useTranslations('invite');
const inviteQuery = useInviteQuery(token);
+ const tScreens = useTranslations('meta.screens');
+ useDocumentTitle(tScreens('invitation'));
const invite = inviteQuery.data;
// The heading reflects the invite state so the copy never contradicts the body
diff --git a/apps/web/src/features/issue/IssueViewPage.tsx b/apps/web/src/features/issue/IssueViewPage.tsx
index f319cea2..19bd8279 100644
--- a/apps/web/src/features/issue/IssueViewPage.tsx
+++ b/apps/web/src/features/issue/IssueViewPage.tsx
@@ -11,6 +11,7 @@ import { useIssueBySeqQuery } from '@/services/issues.service';
import { useProjectsQuery } from '@/services/projects.service';
import IssueDetailContent from './components/detail/IssueDetailContent';
import IssueDetailSkeleton from './components/detail/IssueDetailSkeleton';
+import { useIssueTitle } from './hooks/useIssueTitle';
import { useTranslations } from 'next-intl';
// The full-page issue view (/:team/issue/:identifier), rendered inside the Shell
@@ -38,6 +39,7 @@ export default function IssueViewPage() {
if (movedTo && issueQuery.data)
router.replace(issuePath(movedTo.ref, issueQuery.data.sequenceNumber));
}, [movedTo, issueQuery.data, router]);
+ useIssueTitle(moved || issueQuery.isError ? null : (issueQuery.data?.id ?? null), 'page');
if (!project) return null;
diff --git a/apps/web/src/features/issue/PublicIssuePage.tsx b/apps/web/src/features/issue/PublicIssuePage.tsx
index 47226d12..2155946c 100644
--- a/apps/web/src/features/issue/PublicIssuePage.tsx
+++ b/apps/web/src/features/issue/PublicIssuePage.tsx
@@ -2,6 +2,7 @@
import { useQuery } from '@tanstack/react-query';
import { getSharedIssue } from '@/lib/api/endpoints/share';
+import { useDocumentTitle } from '@/hooks/useDocumentTitle';
import PublicShareFrame from '@/components/common/page/PublicShareFrame';
import PublicShareHeader from '@/components/common/page/PublicShareHeader';
import IssueDetailSkeleton from './components/detail/IssueDetailSkeleton';
@@ -18,6 +19,8 @@ export default function PublicIssuePage({ token }: { token: string }) {
queryFn: () => getSharedIssue(token),
retry: false,
});
+ const issue = query.isError ? undefined : query.data?.issue;
+ useDocumentTitle(issue ? `${issue.identifier} ${issue.title}` : null);
if (query.isLoading) {
return (
diff --git a/apps/web/src/features/issue/components/detail/IssueDetail.tsx b/apps/web/src/features/issue/components/detail/IssueDetail.tsx
index bcd6be5c..7f9b7976 100644
--- a/apps/web/src/features/issue/components/detail/IssueDetail.tsx
+++ b/apps/web/src/features/issue/components/detail/IssueDetail.tsx
@@ -6,6 +6,7 @@ import IssueDetailContent from './IssueDetailContent';
import IssueActionsBar from '../actions/IssueActionsBar';
import { useExitOnEscape } from '@/hooks/useExitOnEscape';
import { useExitOnClickOutside } from '../../hooks/useExitOnClickOutside';
+import { useIssueTitle } from '../../hooks/useIssueTitle';
import { Button } from '@/components/ui/button';
import { useTranslations } from 'next-intl';
@@ -31,6 +32,7 @@ export default function IssueDetail({
useExitOnEscape(onClose);
useExitOnClickOutside(panelRef, onClose);
+ useIssueTitle(issueId, 'panel');
return (
<div
diff --git a/apps/web/src/features/issue/hooks/useIssueTitle.ts b/apps/web/src/features/issue/hooks/useIssueTitle.ts
new file mode 100644
index 00000000..5f38868e
--- /dev/null
+++ b/apps/web/src/features/issue/hooks/useIssueTitle.ts
@@ -0,0 +1,10 @@
+import { useIssueQuery } from '@/services/issues.service';
+import { useDocumentTitle } from '@/hooks/useDocumentTitle';
+
+// The tab title of an open issue, `MKT-42 Fix the login`. A failed read keeps the
+// last data, so it gives no title then, as while the issue loads.
+export function useIssueTitle(issueId: number | null, layer: 'page' | 'panel') {
+ const query = useIssueQuery(issueId);
+ const issue = query.isError ? undefined : query.data;
+ useDocumentTitle(issue ? `${issue.identifier} ${issue.title}` : null, layer);
+}
diff --git a/apps/web/src/features/mcp/components/OAuthConsentPage.tsx b/apps/web/src/features/mcp/components/OAuthConsentPage.tsx
index 9e98f17d..7a9b1758 100644
--- a/apps/web/src/features/mcp/components/OAuthConsentPage.tsx
+++ b/apps/web/src/features/mcp/components/OAuthConsentPage.tsx
@@ -3,12 +3,15 @@
import { useSearchParams } from 'next/navigation';
import { useState } from 'react';
import { useTranslations } from 'next-intl';
+import { useDocumentTitle } from '@/hooks/useDocumentTitle';
import { authClient, useSession } from '@/lib/auth-client';
import { useOAuthClientNameQuery } from '../services/oauthClients.service';
import { consentRequest } from '../utils/consentRequest';
export default function OAuthConsentPage() {
const t = useTranslations('mcp');
+ const tScreens = useTranslations('meta.screens');
+ useDocumentTitle(tScreens('authorizeApp'));
const searchParams = useSearchParams();
// The signed authorization request the server sent the person here with.
const signed = searchParams.has('sig');
diff --git a/apps/web/src/features/notes/NotesPage.tsx b/apps/web/src/features/notes/NotesPage.tsx
index 22a006aa..a6b250d3 100644
--- a/apps/web/src/features/notes/NotesPage.tsx
+++ b/apps/web/src/features/notes/NotesPage.tsx
@@ -9,6 +9,7 @@ import { ReactFlowProvider } from '@xyflow/react';
import { useShell } from '@/context/shellContext';
import { ApiError } from '@/lib/api/core/client';
import { usePermissions } from '@/hooks/usePermissions';
+import { titlePath, useDocumentTitle } from '@/hooks/useDocumentTitle';
import { notePath, notesPath } from '@/utils/paths';
import { qk } from '@/services/queryKeys';
import { Skeleton } from '@/components/ui/skeleton';
@@ -66,6 +67,7 @@ export default function NotesPage() {
const activeBoardId = routeId ?? tabs[0]?.id ?? null;
const { data: activeBoard, isError, error } = useNoteBoardQuery(projectKey, activeBoardId);
+ useDocumentTitle(titlePath(project?.project.name, !isError && activeBoard?.name));
// Record the opened board as most-recent once it loads. Also refreshes its cached
// tab label and visibility, healing a stale MRU entry (renamed elsewhere).
diff --git a/apps/web/src/features/teams/ManageTeamsLayout.tsx b/apps/web/src/features/teams/ManageTeamsLayout.tsx
index 6a40d964..a9052e9e 100644
--- a/apps/web/src/features/teams/ManageTeamsLayout.tsx
+++ b/apps/web/src/features/teams/ManageTeamsLayout.tsx
@@ -6,6 +6,7 @@ import { useTranslations } from 'next-intl';
import { teamPath } from '@/utils/paths';
import { useTeamsQuery } from '@/services/teams.service';
import { useWorkspacesQuery } from '@/services/workspaces.service';
+import { useDocumentTitle } from '@/hooks/useDocumentTitle';
import NewTeamModal from './components/NewTeamModal';
import TeamsPageView from './components/TeamsPageView';
import TeamsRail from './components/TeamsRail';
@@ -30,6 +31,7 @@ export default function ManageTeamsLayout({ children }: { children: ReactNode })
const workspace = workspaces.find((entry) => entry.id === routeWorkspaceId) ?? workspaces[0];
const teams = data ?? [];
const [creating, setCreating] = useState(false);
+ useDocumentTitle(t('label'), 'section');
return (
<TeamsPageView
diff --git a/apps/web/src/features/teams/components/TeamSectionNav.tsx b/apps/web/src/features/teams/components/TeamSectionNav.tsx
index 3e2e0139..f553d6a0 100644
--- a/apps/web/src/features/teams/components/TeamSectionNav.tsx
+++ b/apps/web/src/features/teams/components/TeamSectionNav.tsx
@@ -25,6 +25,7 @@ import type { Team } from '@/lib/api/endpoints/teams';
import { cn } from '@/lib/utils';
import { teamSectionPath, type TeamSection } from '@/utils/paths';
import { useTeamQuery } from '@/services/teams.service';
+import { titlePath, useDocumentTitle } from '@/hooks/useDocumentTitle';
import {
SectionNav,
sectionNavIdleClass,
@@ -54,6 +55,7 @@ export default function TeamSectionNav({
}) {
const t = useTranslations('teams.sections');
const tNav = useTranslations('nav');
+ const tScreens = useTranslations('meta.screens');
const pathname = usePathname();
const permissions = useTeamQuery(team.id).data?.permissions;
@@ -106,7 +108,9 @@ export default function TeamSectionNav({
...(team.role === 'owner' ? [section('notifications', t('notifications.title'), Bell)] : []),
];
- const activeId = [...top, ...ai, ...bottom].find((entry) => entry.href === pathname)?.id ?? null;
+ const active = [...top, ...ai, ...bottom].find((entry) => entry.href === pathname);
+ const activeId = active?.id ?? null;
+ useDocumentTitle(titlePath(team.name, tScreens('teamSettings'), active?.label));
const aiActive = ai.some((entry) => entry.id === activeId);
// Null until the user opens or closes the group themselves; until then it follows
// whichever section is open.
diff --git a/apps/web/src/features/teams/components/workspace/WorkspaceSectionNav.tsx b/apps/web/src/features/teams/components/workspace/WorkspaceSectionNav.tsx
index 0c5f2487..6665b56a 100644
--- a/apps/web/src/features/teams/components/workspace/WorkspaceSectionNav.tsx
+++ b/apps/web/src/features/teams/components/workspace/WorkspaceSectionNav.tsx
@@ -7,6 +7,7 @@ import { ChevronRight, Settings } from 'lucide-react';
import type { WorkspaceSummary } from '@/lib/api/endpoints/workspaces';
import { cn } from '@/lib/utils';
import { workspacePath } from '@/utils/paths';
+import { titlePath, useDocumentTitle } from '@/hooks/useDocumentTitle';
import { useWorkspaceSettingsSections } from '../../hooks/useWorkspaceSettingsSections';
import type { WorkspaceSectionGroup } from '../../types/workspaceSection';
import {
@@ -36,7 +37,12 @@ export default function WorkspaceSectionNav({ workspace }: { workspace: Workspac
}));
const overview = items('overview');
const settings = items('settings');
- const activeId = [...overview, ...settings].find((entry) => entry.href === pathname)?.id ?? null;
+ const entries = [...overview, ...settings];
+ const active = entries.find((entry) => entry.href === pathname);
+ const activeId = active?.id ?? null;
+ // The workspace's own path opens the first entry of the menu.
+ const shown = active ?? (pathname === workspacePath(workspace.id) ? entries[0] : undefined);
+ useDocumentTitle(titlePath(workspace.name, shown?.label));
// Null until the user opens or closes the group themselves; until then it follows
// whichever section is open.
const [toggled, setToggled] = useState<boolean | null>(null);
diff --git a/apps/web/src/features/work-items/PublicBoardPage.tsx b/apps/web/src/features/work-items/PublicBoardPage.tsx
index 83b87162..d37cd0ee 100644
--- a/apps/web/src/features/work-items/PublicBoardPage.tsx
+++ b/apps/web/src/features/work-items/PublicBoardPage.tsx
@@ -4,6 +4,7 @@ import { useState } from 'react';
import { useQuery } from '@tanstack/react-query';
import { useTranslations } from 'next-intl';
import { getSharedView } from '@/lib/api/endpoints/share';
+import { titlePath, useDocumentTitle } from '@/hooks/useDocumentTitle';
import PublicShareFrame from '@/components/common/page/PublicShareFrame';
import ListSkeleton from '@/components/common/skeleton/ListSkeleton';
import ReadOnlyBoard from './components/public/ReadOnlyBoard';
@@ -20,6 +21,8 @@ export default function PublicBoardPage({ token }: { token: string }) {
queryFn: () => getSharedView(token),
retry: false,
});
+ const shared = query.isError ? undefined : query.data;
+ useDocumentTitle(titlePath(shared?.project.project.name, shared?.view.name));
if (query.isLoading) {
return (
diff --git a/apps/web/src/features/work-items/components/public/PublicIssueOverlay.tsx b/apps/web/src/features/work-items/components/public/PublicIssueOverlay.tsx
index e6591daf..24c8d362 100644
--- a/apps/web/src/features/work-items/components/public/PublicIssueOverlay.tsx
+++ b/apps/web/src/features/work-items/components/public/PublicIssueOverlay.tsx
@@ -3,6 +3,7 @@
import { useQuery } from '@tanstack/react-query';
import { useTranslations } from 'next-intl';
import { getSharedViewIssue } from '@/lib/api/endpoints/share';
+import { useDocumentTitle } from '@/hooks/useDocumentTitle';
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
import IssueDetailSkeleton from '@/features/issue/components/detail/IssueDetailSkeleton';
import ReadOnlyIssueDetail from '@/features/issue/components/detail/ReadOnlyIssueDetail';
@@ -35,6 +36,8 @@ export default function PublicIssueOverlay({
enabled: issueId != null,
retry: false,
});
+ const issue = issueId != null && !query.isError ? query.data?.issue : undefined;
+ useDocumentTitle(issue ? `${issue.identifier} ${issue.title}` : null, 'panel');
return (
<Dialog open={issueId != null} onOpenChange={(open) => !open && onClose()}>
diff --git a/apps/web/src/hooks/useDocumentTitle.test.tsx b/apps/web/src/hooks/useDocumentTitle.test.tsx
new file mode 100644
index 00000000..829d500a
--- /dev/null
+++ b/apps/web/src/hooks/useDocumentTitle.test.tsx
@@ -0,0 +1,103 @@
+import assert from 'node:assert/strict';
+import { afterEach, beforeEach, describe, it } from 'node:test';
+import { act } from 'react';
+import { createRoot, type Root } from 'react-dom/client';
+import { JSDOM } from 'jsdom';
+import { APP_NAME } from '@/utils/app';
+import { titlePath, useDocumentTitle } from './useDocumentTitle';
+
+const replacedGlobals = ['window', 'document', 'IS_REACT_ACT_ENVIRONMENT'];
+
+let dom: JSDOM;
+let root: Root;
+let saved: Map<string, PropertyDescriptor | undefined>;
+
+type Titles = { section: string | null; page?: string | null; panel?: string | null };
+
+function Panel({ title }: { title: string | null }) {
+ useDocumentTitle(title, 'panel');
+ return null;
+}
+
+function Page({ title }: { title: string | null }) {
+ useDocumentTitle(title);
+ return null;
+}
+
+function Section({ section, page, panel }: Titles) {
+ useDocumentTitle(section, 'section');
+ return (
+ <>
+ {page !== undefined && <Page title={page} />}
+ {panel !== undefined && <Panel title={panel} />}
+ </>
+ );
+}
+
+function setGlobal(name: string, value: unknown) {
+ Object.defineProperty(globalThis, name, { configurable: true, writable: true, value });
+}
+
+async function render(titles: Titles | null) {
+ await act(async () => root.render(titles && <Section {...titles} />));
+}
+
+beforeEach(() => {
+ saved = new Map(
+ replacedGlobals.map((name) => [name, Object.getOwnPropertyDescriptor(globalThis, name)]),
+ );
+ dom = new JSDOM('<!doctype html><html><head><title>Server</title></head><body></body></html>');
+ setGlobal('window', dom.window);
+ setGlobal('document', dom.window.document);
+ setGlobal('IS_REACT_ACT_ENVIRONMENT', true);
+ root = createRoot(dom.window.document.body);
+});
+
+afterEach(async () => {
+ await act(async () => root.unmount());
+ dom.window.close();
+ for (const [name, descriptor] of saved) {
+ if (descriptor) Object.defineProperty(globalThis, name, descriptor);
+ else Reflect.deleteProperty(globalThis, name);
+ }
+});
+
+describe('useDocumentTitle', () => {
+ it('shows the highest layer and falls back as layers go away', async () => {
+ await render({ section: 'Acme › Inbox', page: 'Acme › Guide', panel: 'ACME-1 Fix' });
+ assert.equal(document.title, 'ACME-1 Fix');
+
+ await render({ section: 'Acme › Inbox', page: 'Acme › Guide' });
+ assert.equal(document.title, 'Acme › Guide');
+
+ await render({ section: 'Acme › Inbox', page: null });
+ assert.equal(document.title, 'Acme › Inbox');
+
+ await render(null);
+ assert.equal(document.title, APP_NAME);
+ });
+
+ it('keeps its title when a <title> is inserted into the head later', async () => {
+ await render({ section: 'Account › Profile' });
+ const late = document.createElement('title');
+ late.textContent = APP_NAME;
+ await act(async () => {
+ document.head.insertBefore(late, document.head.firstChild);
+ await new Promise((resolve) => setTimeout(resolve, 0));
+ });
+ assert.equal(document.title, 'Account › Profile');
+ });
+
+ it('follows a renamed entity without leaving the old title behind', async () => {
+ await render({ section: 'Acme', page: 'Acme › Old' });
+ await render({ section: 'Acme', page: 'Acme › New' });
+ assert.equal(document.title, 'Acme › New');
+ });
+});
+
+describe('titlePath', () => {
+ it('joins the parts, or gives null while one is missing', () => {
+ assert.equal(titlePath('Acme', 'Settings', 'Labels'), 'Acme › Settings › Labels');
+ assert.equal(titlePath('Acme', undefined), null);
+ });
+});
diff --git a/apps/web/src/hooks/useDocumentTitle.ts b/apps/web/src/hooks/useDocumentTitle.ts
new file mode 100644
index 00000000..a8d05b86
--- /dev/null
+++ b/apps/web/src/hooks/useDocumentTitle.ts
@@ -0,0 +1,56 @@
+'use client';
+
+import { useEffect } from 'react';
+import { APP_NAME } from '@/utils/app';
+
+// The layers a screen's title can come from. A higher one wins while it is mounted:
+// the shell names the section, the page inside it names its entity, and a side panel
+// names what it shows over the page. Within a layer the latest registration wins.
+const RANK = { section: 0, page: 1, panel: 2 } as const;
+type TitleLayer = keyof typeof RANK;
+
+type Entry = { title: string; rank: number };
+const entries = new Set<Entry>();
+
+let headObserver: MutationObserver | null = null;
+let observedHead: HTMLHeadElement | null = null;
+
+function apply() {
+ let top: Entry | null = null;
+ for (const entry of entries) if (!top || entry.rank >= top.rank) top = entry;
+ const title = top?.title ?? APP_NAME;
+ if (window.document.title !== title) window.document.title = title;
+ // Next streams the metadata, and React can insert its <title> into the head after
+ // a page has set its own; the browser shows the first one, so the title is set again.
+ if (observedHead !== window.document.head) {
+ headObserver?.disconnect();
+ observedHead = window.document.head;
+ headObserver = new window.MutationObserver(apply);
+ headObserver.observe(window.document.head, {
+ childList: true,
+ subtree: true,
+ characterData: true,
+ });
+ }
+}
+
+// The breadcrumb form of a title, `Project › Section`. Null while any part is
+// missing, so a screen never shows a title with a hole in it.
+export function titlePath(...parts: (string | false | null | undefined)[]): string | null {
+ return parts.every(Boolean) ? parts.join(' › ') : null;
+}
+
+// Sets the browser tab title while the calling component is mounted. Null registers
+// nothing, which leaves the title of the layer below.
+export function useDocumentTitle(title: string | null, layer: TitleLayer = 'page') {
+ useEffect(() => {
+ if (!title) return;
+ const entry = { title, rank: RANK[layer] };
+ entries.add(entry);
+ apply();
+ return () => {
+ entries.delete(entry);
+ apply();
+ };
+ }, [title, layer]);
+}
diff --git a/apps/web/src/hooks/useShellProject.ts b/apps/web/src/hooks/useShellProject.ts
index 51c3daf5..6cefb0fe 100644
--- a/apps/web/src/hooks/useShellProject.ts
+++ b/apps/web/src/hooks/useShellProject.ts
@@ -103,6 +103,7 @@ export function useShellProject(projectKey: string | null, activeViewId: number
project,
filteredProject,
views,
+ viewsFailed: viewsQuery.isError,
editor,
customFields,
canCreateIssue,
diff --git a/apps/web/src/hooks/useShellTitle.ts b/apps/web/src/hooks/useShellTitle.ts
new file mode 100644
index 00000000..17f68a57
--- /dev/null
+++ b/apps/web/src/hooks/useShellTitle.ts
@@ -0,0 +1,49 @@
+import { useTranslations } from 'next-intl';
+import type { View } from '@/lib/api/endpoints/views';
+import { AI_AGENTS_SECTION, SETTINGS_SECTIONS } from '@/utils/settingsSections';
+import type { ShellRoute } from '@/hooks/useShellRoute';
+import { useSettingsSectionText } from '@/hooks/useSectionLabels';
+import { titlePath, useDocumentTitle } from '@/hooks/useDocumentTitle';
+
+const SECTION_LABELS = {
+ inbox: 'inbox',
+ dashboards: 'dashboards',
+ initiatives: 'initiatives',
+ cycles: 'cycles',
+ docs: 'documents',
+ notes: 'notes',
+ members: 'members',
+ notifications: 'notifications',
+ api: 'apiDocs',
+ mcp: 'mcpServer',
+} as const;
+
+// The tab title of a project route: the project and the section the route opens. A
+// detail page names its entity over it, so this is also what the tab shows while that
+// entity loads or when it cannot be read.
+export function useShellTitle(route: ShellRoute, projectName: string, views: View[]) {
+ const t = useTranslations('nav');
+ const tScreens = useTranslations('meta.screens');
+ const sectionText = useSettingsSectionText();
+ const known = (slug: string | null): slug is string =>
+ SETTINGS_SECTIONS.some((s) => s.slug === slug);
+
+ function sectionParts(): string[] {
+ const { sub, section, aiTeamSection } = route;
+ if (sub === 'settings')
+ return [tScreens('settings'), ...(known(section) ? [sectionText(section).label] : [])];
+ if (sub === 'agents') {
+ if (!aiTeamSection) return [sectionText(AI_AGENTS_SECTION.slug).label];
+ return [known(aiTeamSection) ? sectionText(aiTeamSection).label : t('aiTeam')];
+ }
+ if (sub === 'view') {
+ const view = views.find((v) => v.id === route.activeViewId);
+ return view ? [view.name] : [];
+ }
+ if (sub && sub in SECTION_LABELS)
+ return [t(SECTION_LABELS[sub as keyof typeof SECTION_LABELS])];
+ return [];
+ }
+
+ useDocumentTitle(titlePath(projectName, ...sectionParts()), 'section');
+}