Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.
feat(frontend): give the app shell titles, landmarks and focus that follow the page
spacesdrive73b370448ba5
diff --git a/docs/architecture/frontend/CONTEXTS.md b/docs/architecture/frontend/CONTEXTS.mdindex c9828da..5c8cbc7 100644--- a/docs/architecture/frontend/CONTEXTS.md+++ b/docs/architecture/frontend/CONTEXTS.md@@ -52,7 +52,7 @@ useEffect(() => {- `ProtectedRoute` - reads `session` to decide whether to redirect to `/login`- `Login.tsx` - calls `sendSignInCode()` and `verifySignInCode()` (the default email sign-in), `signIn()`, `signUp()`, `verifySignUpCode()`, `resendSignUpCode()`, `sendPasswordReset()`, `verifyPasswordResetCode()`, `updatePassword()` and `signInWithGoogle()`- `features/settings/PasswordSection.tsx` - calls `updatePassword()` and reads `user.email` for password managers-- `Header.tsx` - calls `signOut()`, shows `user.email`+- `layout/index.tsx` and `layout/Sidebar.tsx` - the shell calls `signOut()`; the sidebar user menu shows `user.email`- Do **not** use in page/feature components - they should never need auth state directly---@@ -80,7 +80,7 @@ The value is typed as `AppContextValue`, exported from `AppContext.tsx`. `useApp### Loading behavior-`loadAccounts()` is called automatically on mount. It does not set `loading = true` - it's a background load. Only `refreshAll()` sets `loading = true` (used to show a spinner in the Header).+`loadAccounts()` is called automatically on mount. It does not set `loading = true` - it's a background load. Only `refreshAll()` sets `loading = true` (pages that offer Refresh all, such as the Overview, show it as a busy state).### Where to use itdiff --git a/docs/architecture/frontend/REACT_ARCHITECTURE.md b/docs/architecture/frontend/REACT_ARCHITECTURE.mdindex 5edb487..d686859 100644--- a/docs/architecture/frontend/REACT_ARCHITECTURE.md+++ b/docs/architecture/frontend/REACT_ARCHITECTURE.md@@ -67,7 +67,7 @@ ThemeProvider (next-themes) <- OS/user theme preferenceAppProvider <- accounts[], loading, showToastAppShell (layout/index.tsx)AppSidebar <- navigation, accounts, categories, user menu- TopBar <- breadcrumb, refresh, theme+ TopBar <- page title or breadcrumb, search, help(lazy page)CommandPalette <- Ctrl+K / Cmd+KToaster (Sonner, bottom-right) <- toast notifications@@ -102,13 +102,19 @@ frontend/src/use-mobile.ts useIsMobile()use-command-palette-shortcut.ts Ctrl+K / Cmd+K toggleuse-smooth-theme.ts useSmoothTheme(), theme cross-fade+ use-document-title.ts useDocumentTitle(name): a detail page names the browser tab after what it showsuse-cloudinary-config.ts useCloudinaryConfig(reloadKey), shared by Publish and Tracked contentuse-account-analytics.ts useAccountAnalytics(account, fetchAnalytics, label), shared by Instagram and Reddit analyticslayout/index.tsx AppShell: SidebarProvider + AppSidebar + TopBar + Outlet + CommandPalette- navigation.ts NAV_GROUPS and route titles (single source for sidebar, top bar, palette)- Sidebar.tsx Collapsible sidebar: logo, search, nav groups, accounts, categories, user menu- Header.tsx TopBar: breadcrumb, refresh all, theme toggle+ navigation.ts NAV_GROUPS with icons, routeTitle() and currentNavPath() (single source for sidebar, top bar, palette)+ routes.ts Pure route matching: DETAIL_ROUTES, longest-match active link, tab titles (tested)+ routeFocus.ts Moves focus to the new page's heading after a navigation+ shortcuts.ts Keyboard shortcut labels (Ctrl or Cmd) for the sidebar, palette and tooltips+ shellContext.ts What the shell passes to pages through the outlet (openPalette)+ RedirectWithQuery.tsx Redirect from a moved path, keeping the query string and hash+ Sidebar.tsx Collapsible sidebar: logo, search, nav groups, capped account and category lists, user menu+ Header.tsx TopBar: page title or breadcrumb with a parent link, search, helpcomponents/ProtectedRoute.tsx Auth guard componentDocsRedirect.tsx /docs/* route: sends old docs links to the same page on the public site@@ -122,6 +128,7 @@ frontend/src/figures; aria-hidden and loaded with React.lazy so it never delays the cardLoginEmailStart.tsx The first view's email field, with a mail icon and the Continue arrow inside itLoginPasswordForm.tsx Email and password form, for signing in and for creating a password account+ NotFound.tsx The page for any unknown path inside the app: the path, a link to the overview, the search shortcutLoginCodeForm.tsx The 6-digit email code step (code sign-in, sign-up confirmation, and password reset with a new-password field), with Send a new codeLoginEmailForm.tsx The email-only Forgot password stepPasswordInput.tsx Password field with its show or hide button, used by the sign-in, sign-up and reset formsdiff --git a/docs/architecture/frontend/ROUTING.md b/docs/architecture/frontend/ROUTING.mdindex 4960227..b8fd174 100644--- a/docs/architecture/frontend/ROUTING.md+++ b/docs/architecture/frontend/ROUTING.md@@ -2,7 +2,7 @@## Router Configuration-The app uses React Router v6 in `frontend/src/App.tsx`. The router uses `BrowserRouter` with a nested layout route.+The app uses React Router 7 in `frontend/src/App.tsx`: a data router from `createBrowserRouter` with a nested layout route. The data router is what lets a page block navigation while it has unsaved changes (`useBlocker`).## Route Table@@ -23,10 +23,15 @@ The app uses React Router v6 in `frontend/src/App.tsx`. The router uses `Browser| `/reddit-tracked` | redirect | Redirects to `/tracked-content` || `/videos` | `VideoExplorer.tsx` | Every video from every YouTube channel || `/shorts` | `ShortsExplorer.tsx` | Videos of 60 seconds or less |-| `/reels` | `ReelsExplorer.tsx` | Instagram reels, posts and videos |-| `/upload` | `UploadContent.tsx` | Publish and schedule to Instagram, plus the scheduled post queue |+| `/instagram` | `ReelsExplorer.tsx` | Instagram reels, posts and videos (the Instagram content page) |+| `/reels` | redirect | Redirects to `/instagram`, keeping the query string and hash |+| `/publish` | `UploadContent.tsx` | Publish and schedule to Instagram, plus the scheduled post queue |+| `/upload` | redirect | Redirects to `/publish`, keeping the query string and hash || `/automations` | `features/automations/Automations.tsx` | Comment-to-DM rules, account controls and reply activity; in the sidebar under Publishing |+| `/automations/rules/new` | `features/automations/RuleEditorPage.tsx` | Create a rule on its own page, with a warning before leaving unsaved changes |+| `/automations/rules/:id` | `features/automations/RuleEditorPage.tsx` | Edit the rule with that id || `/settings` | `Settings.tsx` | User/platform settings |+| `*` | `pages/NotFound.tsx` | Any other path inside the app: "Page not found" with the requested path, a link to the overview and the search shortcut. Unknown paths no longer redirect silently to `/` |## Auth Guard@@ -42,7 +47,7 @@ const ChannelAnalytics = lazy(() => import('./features/analytics/channel/Channel// ... etc```-All lazy components are wrapped in `<Suspense>` with a shared fallback.+All lazy components are wrapped in `<Suspense>` with a shared fallback: `PageSkeleton` inside the app shell, and `LoadingState` ("Loading Twiligent") around the router. `ProtectedRoute` shows `LoadingState` ("Checking your sign-in") while the saved session is read, never a blank page.## Adding a New Route@@ -56,9 +61,11 @@ All lazy components are wrapped in `<Suspense>` with a shared fallback.{ path: 'my-page/:id', element: <MyPage /> }```-3. If the page appears in the sidebar, add it to `NAV_GROUPS` in `layout/navigation.ts`. The sidebar, top bar title and command palette all read from it. Detail routes get a title in `DETAIL_ROUTES` in the same file.+3. If the page appears in the sidebar, add it to `NAV_GROUPS` in `layout/navigation.ts` with its icon. The sidebar, top bar title, browser tab title and command palette all read from it. Detail routes get a title and a parent link in `DETAIL_ROUTES` in `layout/routes.ts` (pure, tested in `frontend/tests/layout/routes.test.ts`).-4. Update the Route Table in this file.+4. If a page moves, keep the old path as `<RedirectWithQuery to="/new-path" />` (`layout/RedirectWithQuery.tsx`) so bookmarks and shared links keep their filters.++5. Update the Route Table in this file.## URL Parameters@@ -79,6 +86,24 @@ Navigation between routes uses React Router's `<Link>` component or the `useNaviaccounts.map(account => ({ title: accountName(account), url: accountPath(account) }))```-The command palette (Ctrl+K or Cmd+K) searches pages, accounts, tracked categories and actions.-This means the sidebar updates automatically when accounts are added or removed.++The command palette (Ctrl+K or Cmd+K) searches pages, accounts, tracked categories and actions. Its footer lists the keyboard shortcuts (Ctrl+K search, Ctrl+B show or hide the sidebar), and the sidebar search button and its tooltip show the Ctrl+K shortcut.++### Sidebar order and the current page++The sidebar groups are Analytics, Publishing, Your accounts, Categories and Manage. Manage (Accounts, Settings) comes last, so Settings keeps its place at the end however many accounts or categories exist. Your accounts and Categories show six links each, plus the current page if it sits further down, and a "Show all N accounts" button for the rest.++Only the most specific matching link is the current page (`currentNavPath()` in `layout/navigation.ts`, longest match wins): on a category page the category is current, not Tracked content as well. The current link gets `data-active` for the styling and `aria-current="page"` for screen readers. The links sit in a `<nav aria-label="Main">` landmark.++### Top bar++The top bar shows the page title. On a detail page it is a breadcrumb whose parent is a real link (a category links back to Tracked content, a Reddit account's posts to Reddit posts, an account page to Overview). On the right are Search (on narrow screens, where the sidebar is hidden) and Help, which opens the documentation in a new tab. Refreshing and the theme live on the pages, in the user menu and in Settings, not in the top bar.++## Page titles and focus++Every route names the browser tab `<page> - Twiligent`, from the same titles as the top bar (`documentTitle()` in `layout/routes.ts`, set in `AppShell`). A detail page names the tab after what it shows by calling `useDocumentTitle(name)` from `hooks/use-document-title.ts`, for example the channel title or `u/name`. The shell sets the route title in a layout effect, so the page's own effect runs after it and wins.++After a client-side navigation the shell scrolls to the top, moves focus to `<main id="main-content">`, and asks the next `PageHeader` to focus its `h1` (`tabIndex={-1}`) once the page has loaded (`layout/routeFocus.ts`). A screen reader then announces the new page, as it would after a full page load. The first load does not move focus, and a page that loads late does not take focus back if the person has already moved it.++The shell's landmarks are the sidebar `<nav aria-label="Main">`, the top bar `<header>` and `<main id="main-content">`, with a Skip to content link first in the tab order. The mobile sidebar drawer is named Navigation; its trigger says Show navigation or Hide navigation and reports `aria-expanded`.diff --git a/frontend/index.html b/frontend/index.htmlindex c0f30e2..456e626 100644--- a/frontend/index.html+++ b/frontend/index.html@@ -5,7 +5,7 @@<meta charset="UTF-8" /><meta name="viewport" content="width=device-width, initial-scale=1.0" /><title>Twiligent</title>- <meta name="description" content="Analytics and publishing for your YouTube, Instagram and Reddit accounts." />+ <meta name="description" content="Analytics and publishing for your YouTube, Instagram and Reddit accounts, with automatic replies to Instagram comments." /><meta name="theme-color" content="#F7F3EF" media="(prefers-color-scheme: light)" /><meta name="theme-color" content="#140E10" media="(prefers-color-scheme: dark)" /><link rel="icon" type="image/svg+xml" href="/App%20icons/twiligent-favicon.svg" />diff --git a/frontend/src/App.tsx b/frontend/src/App.tsxindex b9cbdcb..1466e4b 100644--- a/frontend/src/App.tsx+++ b/frontend/src/App.tsx@@ -9,6 +9,8 @@ import ProtectedRoute from './components/ProtectedRoute';import MainLayout from './layout/index';import Login from './pages/Login';import DocsRedirect from './components/DocsRedirect';+import { LoadingState } from './components/StateViews';+import RedirectWithQuery from './layout/RedirectWithQuery';const Overview = lazy(() => import('./features/analytics/overview/Overview'));const ChannelAnalytics = lazy(() => import('./features/analytics/channel/ChannelAnalytics'));@@ -18,6 +20,7 @@ const ShortsExplorer = lazy(() => import('./features/analytics/shorts/Shortsconst ReelsExplorer = lazy(() => import('./features/analytics/reels/ReelsExplorer'));const UploadContent = lazy(() => import('./features/publishing/UploadContent'));const Automations = lazy(() => import('./features/automations/Automations'));+const RuleEditorPage = lazy(() => import('./features/automations/RuleEditorPage'));const AccountManager = lazy(() => import('./features/accounts/AccountManager'));const Settings = lazy(() => import('./features/settings/Settings'));const RedditAnalytics = lazy(() => import('./features/analytics/reddit/RedditAnalytics'));@@ -25,6 +28,7 @@ const RedditPosts = lazy(() => import('./features/analytics/reddit/Redditconst RedditPostsAll = lazy(() => import('./features/analytics/reddit/RedditPostsAll'));const TrackedContent = lazy(() => import('./features/analytics/tracked/TrackedContent'));const TrackedCategory = lazy(() => import('./features/analytics/tracked/TrackedCategory'));+const NotFound = lazy(() => import('./pages/NotFound'));const router = createBrowserRouter([{@@ -50,9 +54,13 @@ const router = createBrowserRouter([{ path: 'instagram/:id', element: <InstagramAnalytics /> },{ path: 'videos', element: <VideoExplorer /> },{ path: 'shorts', element: <ShortsExplorer /> },- { path: 'reels', element: <ReelsExplorer /> },- { path: 'upload', element: <UploadContent /> },+ { path: 'instagram', element: <ReelsExplorer /> },+ { path: 'reels', element: <RedirectWithQuery to="/instagram" /> },+ { path: 'publish', element: <UploadContent /> },+ { path: 'upload', element: <RedirectWithQuery to="/publish" /> },{ path: 'automations', element: <Automations /> },+ { path: 'automations/rules/new', element: <RuleEditorPage /> },+ { path: 'automations/rules/:id', element: <RuleEditorPage /> },{ path: 'accounts', element: <AccountManager /> },{ path: 'settings', element: <Settings /> },{ path: 'reddit/:id', element: <RedditAnalytics /> },@@ -61,7 +69,7 @@ const router = createBrowserRouter([{ path: 'tracked-content', element: <TrackedContent /> },{ path: 'tracked-content/category/:name', element: <TrackedCategory /> },{ path: 'reddit-tracked', element: <Navigate to="/tracked-content" replace /> },- { path: '*', element: <Navigate to="/" replace /> },+ { path: '*', element: <NotFound /> },],},]);@@ -71,7 +79,7 @@ export default function App() {<ThemeProvider attribute="class" defaultTheme="system" enableSystem disableTransitionOnChange><TooltipProvider><AuthProvider>- <Suspense fallback={null}>+ <Suspense fallback={<LoadingState label="Loading Twiligent" className="min-h-dvh" />}><RouterProvider router={router} /></Suspense><Toaster position="bottom-right" richColors closeButton duration={6000} />diff --git a/frontend/src/components/CommandPalette.tsx b/frontend/src/components/CommandPalette.tsxindex bf614ba..d2e0e01 100644--- a/frontend/src/components/CommandPalette.tsx+++ b/frontend/src/components/CommandPalette.tsx@@ -1,9 +1,6 @@import React, { useMemo, useState } from 'react';import { useNavigate } from 'react-router-dom';-import { useSmoothTheme } from '@/hooks/use-smooth-theme';-import {- LayoutDashboard, PlaySquare, Scissors, Clapperboard, MessagesSquare, Bookmark, Send,- Users, Settings, RefreshCw, Sun, Moon, Monitor, LogOut, Tag, Plus, BookOpen } from 'lucide-react';+import { RefreshCw, LogOut, Tag, Plus, BookOpen } from 'lucide-react';import type { LucideIcon } from 'lucide-react';import {Command, CommandEmpty, CommandGroup, CommandInput, CommandItem, CommandList, CommandShortcut,@@ -15,14 +12,9 @@ import { accountName, accountPath, PLATFORM_META, platformOf } from '@/lib/accouimport type { AccountFields } from '@/lib/accounts';import type { SearchCommand } from '@/lib/commandSearch';import { NAV_GROUPS } from '@/layout/navigation';+import { APP_SHORTCUTS } from '@/layout/shortcuts';import { docsUrl } from '@/lib/docs';-const PAGE_ICONS: Record<string, LucideIcon> = {- '/': LayoutDashboard, '/videos': PlaySquare, '/shorts': Scissors, '/reels': Clapperboard,- '/reddit-posts': MessagesSquare, '/tracked-content': Bookmark, '/upload': Send,- '/accounts': Users, '/settings': Settings,-};-export interface PaletteCommand extends SearchCommand {id: string;group: string;@@ -43,7 +35,6 @@ export interface CommandPaletteProps {export default function CommandPalette({ open, onOpenChange, accounts, categories, onRefreshAll, onSignOut }: CommandPaletteProps) {const navigate = useNavigate();- const { setTheme } = useSmoothTheme();const [query, setQuery] = useState('');const handleOpenChange = (next: boolean) => {@@ -54,7 +45,7 @@ export default function CommandPalette({ open, onOpenChange, accounts, categorieconst commands = useMemo((): PaletteCommand[] => [...NAV_GROUPS.flatMap(group => group.items.map(item => ({id: `page:${item.path}`, group: 'Pages', label: item.label, keywords: [group.label],- icon: PAGE_ICONS[item.path], run: () => navigate(item.path),+ icon: item.icon, run: () => navigate(item.path),}))),...accounts.map(account => ({id: `account:${account.id}`, group: 'Accounts', label: accountName(account),@@ -65,14 +56,11 @@ export default function CommandPalette({ open, onOpenChange, accounts, categorieid: `category:${category}`, group: 'Categories', label: category, keywords: ['tracked', 'category'],icon: Tag, run: () => navigate(`/tracked-content/category/${encodeURIComponent(category)}`),})),- { id: 'action:add-account', group: 'Actions', label: 'Add an account', keywords: ['connect', 'youtube', 'instagram', 'reddit'], icon: Plus, run: () => navigate('/accounts?add=1') },+ { id: 'action:add-account', group: 'Actions', label: 'Add account', keywords: ['connect', 'youtube', 'instagram', 'reddit'], icon: Plus, run: () => navigate('/accounts?add=1') },{ id: 'action:docs', group: 'Actions', label: 'Open documentation', keywords: ['help', 'guide', 'docs', 'setup', 'self-host'], icon: BookOpen, run: () => window.open(docsUrl(), '_blank', 'noopener') },{ id: 'action:refresh', group: 'Actions', label: 'Refresh all accounts', keywords: ['sync', 'update'], icon: RefreshCw, run: onRefreshAll },- { id: 'action:theme-light', group: 'Theme', label: 'Use light theme', keywords: ['appearance', 'paper'], icon: Sun, run: () => setTheme('light') },- { id: 'action:theme-dark', group: 'Theme', label: 'Use dark theme', keywords: ['appearance', 'dusk'], icon: Moon, run: () => setTheme('dark') },- { id: 'action:theme-system', group: 'Theme', label: 'Match system theme', keywords: ['appearance', 'auto'], icon: Monitor, run: () => setTheme('system') },{ id: 'action:sign-out', group: 'Account', label: 'Sign out', keywords: ['log out', 'logout'], icon: LogOut, run: onSignOut },- ], [accounts, categories, navigate, onRefreshAll, onSignOut, setTheme]);+ ], [accounts, categories, navigate, onRefreshAll, onSignOut]);const grouped = useMemo(() => groupCommands(filterCommands(commands, query)), [commands, query]);@@ -83,7 +71,7 @@ export default function CommandPalette({ open, onOpenChange, accounts, categoriereturn (<Dialog open={open} onOpenChange={handleOpenChange}>- <DialogContent showCloseButton={false} className="top-[18%] translate-y-0 gap-0 overflow-hidden p-0 sm:max-w-xl">+ <DialogContent showCloseButton={false} className="inset-x-2 top-2 bottom-auto w-auto gap-0 overflow-hidden rounded-dialog p-0 sm:top-[18%] sm:max-w-xl sm:translate-y-0"><DialogTitle className="sr-only">Command palette</DialogTitle><DialogDescription className="sr-only">Search pages, accounts and actions</DialogDescription><Command shouldFilter={false} loop>@@ -107,9 +95,11 @@ export default function CommandPalette({ open, onOpenChange, accounts, categorie</CommandGroup>))}</CommandList>- <div className="flex items-center justify-between gap-3 border-t border-line px-4 py-2.5 text-caption text-ink-faint">- <span>Use arrow keys to move, Enter to open</span>- <kbd className="font-mono">Esc</kbd>+ <div className="flex flex-wrap items-center gap-x-4 gap-y-1 border-t border-line px-4 py-2.5 text-caption text-ink-muted">+ <span>Arrow keys to move, Enter to open, <kbd className="font-mono">Esc</kbd> to close</span>+ {APP_SHORTCUTS.map(shortcut => (+ <span key={shortcut.keys}><kbd className="font-mono">{shortcut.keys}</kbd> {shortcut.action.toLowerCase()}</span>+ ))}</div></Command></DialogContent>diff --git a/frontend/src/components/InstagramTesterNotice.tsx b/frontend/src/components/InstagramTesterNotice.tsxindex 6a92657..14bd50b 100644--- a/frontend/src/components/InstagramTesterNotice.tsx+++ b/frontend/src/components/InstagramTesterNotice.tsx@@ -33,7 +33,7 @@ export default function InstagramTesterNotice({ compact = false, className }: Inbody: (<>Email the administrator at{' '}- <a href={adminMailto('Instagram tester request for Twiligent', REQUEST_BODY)} className="font-medium text-brand-text underline-offset-4 hover:underline">+ <a href={adminMailto('Instagram tester request for Twiligent', REQUEST_BODY)} className="font-medium text-brand-text underline underline-offset-4 hover:decoration-2">{ADMIN_EMAIL}</a>{' '}with your Instagram username. Only Business and Creator accounts can be added.@@ -45,8 +45,8 @@ export default function InstagramTesterNotice({ compact = false, className }: Inbody: (<>Once you are added, sign in to Instagram on the web and open{' '}- <a href={INSTAGRAM_TESTER_INVITES_URL} target="_blank" rel="noopener noreferrer" className="font-medium text-brand-text underline-offset-4 hover:underline">- Apps and websites, Tester invites+ <a href={INSTAGRAM_TESTER_INVITES_URL} target="_blank" rel="noopener noreferrer" className="font-medium text-brand-text underline underline-offset-4 hover:decoration-2">+ Apps and websites, Tester invites<span className="sr-only"> (opens in a new tab)</span></a>, then accept the Twiligent invite. In the Instagram app it is under Settings and privacy, Website permissions, Apps and websites, Tester invites.</>@@ -61,10 +61,10 @@ export default function InstagramTesterNotice({ compact = false, className }: Inreturn (<div className={cn('flex flex-col gap-3 rounded-field border border-info/30 bg-info-soft p-4', className)}><div className="flex items-start gap-2.5">- <UserCheck className="mt-0.5 size-4 shrink-0 stroke-[1.75] text-info" />+ <UserCheck className="mt-0.5 size-4 shrink-0 stroke-[1.75] text-info" aria-hidden="true" /><div className="flex flex-col gap-0.5"><p className="text-sm font-semibold text-ink">Your Instagram account needs tester access first</p>- <p className="text-small text-ink-muted">+ <p className="max-w-prose text-small text-ink-muted">The Twiligent Meta app is in development mode, so Instagram only lets accounts that are added as testers connect. Without it, Instagram shows an error or a blank page when you sign in.</p></div>@@ -87,7 +87,7 @@ export default function InstagramTesterNotice({ compact = false, className }: In<Mail data-icon="inline-start" />Email the administrator</Button><Button size="sm" variant="ghost" render={<a href={INSTAGRAM_TESTER_INVITES_URL} target="_blank" rel="noopener noreferrer" />}>- <ExternalLink data-icon="inline-start" />Open tester invites+ <ExternalLink data-icon="inline-start" />Open tester invites<span className="sr-only"> (opens in a new tab)</span></Button></div></div>diff --git a/frontend/src/components/PageHeader.tsx b/frontend/src/components/PageHeader.tsxindex 94155bc..943dc5a 100644--- a/frontend/src/components/PageHeader.tsx+++ b/frontend/src/components/PageHeader.tsx@@ -1,7 +1,8 @@-import React from 'react';+import React, { useEffect, useRef } from 'react';import { Link } from 'react-router-dom';import { ArrowLeft } from 'lucide-react';import { cn } from '@/lib/utils';+import { takeHeadingFocus } from '@/layout/routeFocus';export interface PageHeaderBack {to: string;@@ -30,6 +31,8 @@ export default function PageHeader({size = 'default',className,}: PageHeaderProps) {+ const headingRef = useRef<HTMLHeadingElement>(null);+ useEffect(() => { takeHeadingFocus(headingRef.current); }, []);return (<header className={cn('flex flex-col gap-4', className)}>{back && (@@ -47,14 +50,16 @@ export default function PageHeader({<div className="min-w-0">{eyebrow && <p className="eyebrow mb-2 text-brand-text">{eyebrow}</p>}<h1+ ref={headingRef}+ tabIndex={-1}className={cn(- 'font-heading font-semibold tracking-[-0.01em] text-ink',+ 'font-heading font-semibold text-ink focus-visible:outline-offset-4',size === 'display' ? 'text-display' : 'text-page-title',)}>{title}</h1>- {description && <div className="mt-1.5 text-sm text-ink-muted">{description}</div>}+ {description && <div className="mt-1.5 max-w-prose text-body text-ink-muted">{description}</div>}</div></div>{actions && <div className="flex flex-wrap items-center gap-2">{actions}</div>}diff --git a/frontend/src/components/ProtectedRoute.tsx b/frontend/src/components/ProtectedRoute.tsxindex 8722e0f..ae4959b 100644--- a/frontend/src/components/ProtectedRoute.tsx+++ b/frontend/src/components/ProtectedRoute.tsx@@ -1,6 +1,7 @@import type React from 'react';import { Navigate } from 'react-router-dom';import { useAuth } from '../context/AuthContext';+import { LoadingState } from './StateViews';export interface ProtectedRouteProps {children: React.ReactNode;@@ -8,7 +9,8 @@ export interface ProtectedRouteProps {export default function ProtectedRoute({ children }: ProtectedRouteProps) {const { session } = useAuth();- if (session === undefined) return null; // still loading session+ // the saved session is still being read; say so rather than show a blank page+ if (session === undefined) return <LoadingState label="Checking your sign-in" className="min-h-dvh" />;if (!session) return <Navigate to="/login" replace />;return children;}diff --git a/frontend/src/components/SectionHeader.tsx b/frontend/src/components/SectionHeader.tsxindex 78ea9b5..3a0065f 100644--- a/frontend/src/components/SectionHeader.tsx+++ b/frontend/src/components/SectionHeader.tsx@@ -13,9 +13,9 @@ export default function SectionHeader({ title, description, actions, className }<div className={cn('flex flex-wrap items-end justify-between gap-3', className)}><div className="min-w-0"><h2 className="font-heading text-section font-semibold text-ink">{title}</h2>- {description && <p className="mt-0.5 text-small text-ink-muted">{description}</p>}+ {description && <p className="mt-0.5 max-w-prose text-small text-ink-muted">{description}</p>}</div>- {actions && <div className="flex items-center gap-2">{actions}</div>}+ {actions && <div className="flex flex-wrap items-center gap-2">{actions}</div>}</div>);}diff --git a/frontend/src/components/StateViews.tsx b/frontend/src/components/StateViews.tsxindex 227d257..81a43b1 100644--- a/frontend/src/components/StateViews.tsx+++ b/frontend/src/components/StateViews.tsx@@ -82,7 +82,8 @@ export interface PageSkeletonProps {export function PageSkeleton({ metrics = 4 }: PageSkeletonProps) {return (- <div className="flex flex-col gap-8" aria-busy="true" aria-label="Loading page">+ <div role="status" className="flex flex-col gap-8">+ <span className="sr-only">Loading page</span><div className="flex flex-col gap-2"><Skeleton className="h-8 w-56" /><Skeleton className="h-4 w-80 max-w-full" />diff --git a/frontend/src/components/ui/alert-dialog.tsx b/frontend/src/components/ui/alert-dialog.tsxindex 8a5b45f..3dd222b 100644--- a/frontend/src/components/ui/alert-dialog.tsx+++ b/frontend/src/components/ui/alert-dialog.tsx@@ -32,7 +32,7 @@ function AlertDialogOverlay({<AlertDialogPrimitive.Backdropdata-slot="alert-dialog-overlay"className={cn(- "fixed inset-0 isolate z-50 bg-[#0C0809]/40 duration-(--duration-overlay) data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",+ "fixed inset-0 isolate z-50 bg-media-scrim/40 duration-(--duration-overlay) data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",className)}{...props} />@@ -53,7 +53,7 @@ function AlertDialogContent({data-slot="alert-dialog-content"data-size={size}className={cn(- "group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-5 rounded-dialog border border-line bg-popover p-8 text-popover-foreground shadow-lg duration-(--duration-overlay) outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",+ "group/alert-dialog-content fixed inset-x-0 bottom-0 z-50 grid max-h-[calc(100dvh-1rem)] w-full gap-5 overflow-y-auto rounded-t-dialog border border-line bg-popover p-5 text-popover-foreground shadow-lg duration-(--duration-overlay) outline-none sm:inset-x-auto sm:top-1/2 sm:bottom-auto sm:left-1/2 sm:w-[calc(100%-2rem)] sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-dialog sm:p-8 data-[size=sm]:sm:max-w-xs data-[size=default]:sm:max-w-sm data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",className)}{...props} />@@ -84,7 +84,7 @@ function AlertDialogFooter({<divdata-slot="alert-dialog-footer"className={cn(- "-mx-8 -mb-8 flex flex-col-reverse gap-2 border-t border-line px-8 py-5 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",+ "-mx-5 -mb-5 flex flex-col-reverse gap-2 border-t border-line px-5 py-4 sm:-mx-8 sm:-mb-8 sm:px-8 sm:py-5 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",className)}{...props} />@@ -114,7 +114,7 @@ function AlertDialogTitle({<AlertDialogPrimitive.Titledata-slot="alert-dialog-title"className={cn(- "font-heading text-lg font-semibold tracking-[-0.01em] sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",+ "font-heading text-section font-semibold sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",className)}{...props} />@@ -129,7 +129,7 @@ function AlertDialogDescription({<AlertDialogPrimitive.Descriptiondata-slot="alert-dialog-description"className={cn(- "text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",+ "text-body text-balance text-ink-muted md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-ink",className)}{...props} />diff --git a/frontend/src/components/ui/badge.tsx b/frontend/src/components/ui/badge.tsxindex f1681ca..737bf4a 100644--- a/frontend/src/components/ui/badge.tsx+++ b/frontend/src/components/ui/badge.tsx@@ -18,7 +18,7 @@ const badgeVariants = cva(info: "bg-info-soft text-info",outline: "border-line text-ink-muted",ghost: "text-ink-muted hover:bg-surface-hover",- link: "text-brand-text underline-offset-4 hover:underline",+ link: "text-brand-text underline underline-offset-4 hover:decoration-2",},},defaultVariants: {diff --git a/frontend/src/components/ui/button.tsx b/frontend/src/components/ui/button.tsxindex 789c8df..02887a5 100644--- a/frontend/src/components/ui/button.tsx+++ b/frontend/src/components/ui/button.tsx@@ -18,14 +18,14 @@ const buttonVariants = cva("text-ink-muted hover:bg-surface-hover hover:text-ink aria-expanded:bg-surface-hover aria-expanded:text-ink",destructive:"bg-danger-soft text-danger hover:bg-danger hover:text-on-brand",- link: "rounded-sm px-0! text-brand-text underline-offset-4 hover:underline",+ link: "rounded-sm px-0! text-brand-text underline underline-offset-4 hover:decoration-2",inverse: "bg-ink text-ink-inverse hover:bg-ink/85",},size: {default:"h-(--control-h) gap-2 px-3 text-sm has-data-[icon=inline-end]:pr-3 has-data-[icon=inline-start]:pl-3",- xs: "h-7 gap-1 px-2.5 text-xs [&_svg:not([class*='size-'])]:size-3.5",- sm: "h-(--control-h-sm) gap-1.5 px-2.5 text-[0.8125rem] has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5",+ xs: "h-7 gap-1 px-2.5 text-caption [&_svg:not([class*='size-'])]:size-3.5",+ sm: "h-(--control-h-sm) gap-1.5 px-2.5 text-small has-data-[icon=inline-end]:pr-2.5 has-data-[icon=inline-start]:pl-2.5",lg: "h-(--control-h-lg) gap-2 px-4 text-sm",icon: "size-(--control-h)","icon-xs": "size-7 [&_svg:not([class*='size-'])]:size-3.5",diff --git a/frontend/src/components/ui/checkbox.tsx b/frontend/src/components/ui/checkbox.tsxindex dd0fc23..6d7dc24 100644--- a/frontend/src/components/ui/checkbox.tsx+++ b/frontend/src/components/ui/checkbox.tsx@@ -11,7 +11,7 @@ function Checkbox({<CheckboxPrimitive.Rootdata-slot="checkbox"className={cn(- "peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",+ "peer relative flex size-4 shrink-0 items-center justify-center rounded-[4px] border border-input transition-colors outline-none group-has-disabled/field:opacity-50 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 aria-invalid:aria-checked:border-primary dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:border-primary data-checked:bg-primary data-checked:text-primary-foreground dark:data-checked:bg-primary",className)}{...props}>diff --git a/frontend/src/components/ui/dialog.tsx b/frontend/src/components/ui/dialog.tsxindex 037307a..a1da249 100644--- a/frontend/src/components/ui/dialog.tsx+++ b/frontend/src/components/ui/dialog.tsx@@ -37,7 +37,7 @@ function DialogOverlay({<DialogPrimitive.Backdropdata-slot="dialog-overlay"className={cn(- "fixed inset-0 isolate z-50 bg-[#0C0809]/40 duration-(--duration-overlay) data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",+ "fixed inset-0 isolate z-50 bg-media-scrim/40 duration-(--duration-overlay) data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",className)}{...props} />@@ -58,7 +58,7 @@ function DialogContent({<DialogPrimitive.Popupdata-slot="dialog-content"className={cn(- "fixed top-1/2 left-1/2 z-50 grid max-h-[calc(100dvh-2rem)] w-full max-w-[calc(100%-2rem)] -translate-x-1/2 -translate-y-1/2 gap-5 overflow-y-auto rounded-dialog border border-line bg-popover p-8 text-sm text-popover-foreground shadow-lg duration-(--duration-overlay) outline-none sm:max-w-md data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",+ "fixed inset-x-0 bottom-0 z-50 grid max-h-[calc(100dvh-1rem)] w-full gap-5 overflow-y-auto rounded-t-dialog border border-line bg-popover p-5 text-sm text-popover-foreground shadow-lg duration-(--duration-overlay) outline-none sm:inset-x-auto sm:top-1/2 sm:bottom-auto sm:left-1/2 sm:max-h-[calc(100dvh-2rem)] sm:max-w-md sm:w-[calc(100%-2rem)] sm:-translate-x-1/2 sm:-translate-y-1/2 sm:rounded-dialog sm:p-8 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",className)}{...props}>@@ -67,7 +67,7 @@ function DialogContent({<DialogPrimitive.Closedata-slot="dialog-close"render={- <Button variant="ghost" className="absolute top-5 right-5" size="icon-sm" />+ <Button variant="ghost" className="absolute top-3 right-3 sm:top-5 sm:right-5" size="icon-sm" />}><XIcon /><span className="sr-only">Close</span>@@ -102,7 +102,7 @@ function DialogFooter({<divdata-slot="dialog-footer"className={cn(- "-mx-8 -mb-8 flex flex-col-reverse gap-2 border-t border-line px-8 py-5 sm:flex-row sm:justify-end",+ "-mx-5 -mb-5 flex flex-col-reverse gap-2 border-t border-line px-5 py-4 sm:-mx-8 sm:-mb-8 sm:flex-row sm:justify-end sm:px-8 sm:py-5",className)}{...props}>@@ -123,7 +123,7 @@ function DialogTitle({return (<DialogPrimitive.Titledata-slot="dialog-title"- className={cn("pr-8 font-heading text-lg leading-7 font-semibold tracking-[-0.01em]", className)}+ className={cn("pr-8 font-heading text-section font-semibold", className)}{...props} />);}@@ -136,7 +136,7 @@ function DialogDescription({<DialogPrimitive.Descriptiondata-slot="dialog-description"className={cn(- "text-sm text-muted-foreground *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",+ "max-w-prose text-body text-ink-muted *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-ink",className)}{...props} />diff --git a/frontend/src/components/ui/input-group.tsx b/frontend/src/components/ui/input-group.tsxindex 5ad8649..6c99fb6 100644--- a/frontend/src/components/ui/input-group.tsx+++ b/frontend/src/components/ui/input-group.tsx@@ -17,7 +17,7 @@ function InputGroup({data-slot="input-group"role="group"className={cn(- "group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-3 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/50 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",+ "group/input-group relative flex h-8 w-full min-w-0 items-center rounded-lg border border-input transition-colors outline-none in-data-[slot=combobox-content]:focus-within:border-inherit in-data-[slot=combobox-content]:focus-within:ring-0 has-disabled:bg-input/50 has-disabled:opacity-50 has-[[data-slot=input-group-control]:focus-visible]:border-ring has-[[data-slot=input-group-control]:focus-visible]:ring-2 has-[[data-slot=input-group-control]:focus-visible]:ring-ring/15 has-[[data-slot][aria-invalid=true]]:border-destructive has-[[data-slot][aria-invalid=true]]:ring-3 has-[[data-slot][aria-invalid=true]]:ring-destructive/20 has-[>[data-align=block-end]]:h-auto has-[>[data-align=block-end]]:flex-col has-[>[data-align=block-start]]:h-auto has-[>[data-align=block-start]]:flex-col has-[>textarea]:h-auto dark:bg-input/30 dark:has-disabled:bg-input/80 dark:has-[[data-slot][aria-invalid=true]]:ring-destructive/40 has-[>[data-align=block-end]]:[&>input]:pt-3 has-[>[data-align=block-start]]:[&>input]:pb-3 has-[>[data-align=inline-end]]:[&>input]:pr-1.5 has-[>[data-align=inline-start]]:[&>input]:pl-1.5",className)}{...props} />diff --git a/frontend/src/components/ui/input.tsx b/frontend/src/components/ui/input.tsxindex f64eddc..392201e 100644--- a/frontend/src/components/ui/input.tsx+++ b/frontend/src/components/ui/input.tsx@@ -13,7 +13,7 @@ function Input({type={type}data-slot="input"className={cn(- "h-(--control-h) w-full min-w-0 rounded-field border border-input bg-surface-raised px-3 py-1 text-base text-ink transition-colors duration-(--duration-fast) outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-ink placeholder:text-ink-faint hover:border-ink-muted focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:opacity-60 aria-invalid:border-danger",+ "h-(--control-h) w-full min-w-0 rounded-field border border-input bg-surface-raised px-3 py-1 text-base text-ink transition-colors duration-(--duration-fast) outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-ink placeholder:text-ink-faint hover:border-ink-muted focus-visible:border-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/15 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:opacity-60 aria-invalid:border-danger",className)}{...props} />diff --git a/frontend/src/components/ui/select.tsx b/frontend/src/components/ui/select.tsxindex fa790e2..95ee8c3 100644--- a/frontend/src/components/ui/select.tsx+++ b/frontend/src/components/ui/select.tsx@@ -43,7 +43,7 @@ function SelectTrigger({data-slot="select-trigger"data-size={size}className={cn(- "flex w-fit items-center justify-between gap-1.5 rounded-field border border-input bg-surface-raised py-2 pr-2.5 pl-3 text-sm whitespace-nowrap text-ink transition-colors duration-(--duration-fast) outline-none select-none hover:border-ink-muted focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-danger data-placeholder:text-ink-faint data-[size=default]:h-(--control-h) data-[size=sm]:h-(--control-h-sm) *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ "flex w-fit items-center justify-between gap-1.5 rounded-field border border-input bg-surface-raised py-2 pr-2.5 pl-3 text-sm whitespace-nowrap text-ink transition-colors duration-(--duration-fast) outline-none select-none hover:border-ink-muted focus-visible:border-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/15 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-danger data-placeholder:text-ink-faint data-[size=default]:h-(--control-h) data-[size=sm]:h-(--control-h-sm) *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",className)}{...props}>diff --git a/frontend/src/components/ui/sheet.tsx b/frontend/src/components/ui/sheet.tsxindex 2723475..414b66d 100644--- a/frontend/src/components/ui/sheet.tsx+++ b/frontend/src/components/ui/sheet.tsx@@ -37,7 +37,7 @@ function SheetOverlay({<SheetPrimitive.Backdropdata-slot="sheet-overlay"className={cn(- "fixed inset-0 z-50 bg-black/10 transition-opacity duration-150 data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",+ "fixed inset-0 z-50 bg-media-scrim/40 transition-opacity duration-(--duration-overlay) data-ending-style:opacity-0 data-starting-style:opacity-0 supports-backdrop-filter:backdrop-blur-xs",className)}{...props} />@@ -112,7 +112,7 @@ function SheetTitle({return (<SheetPrimitive.Titledata-slot="sheet-title"- className={cn("font-heading text-base font-medium text-foreground", className)}+ className={cn("font-heading text-section font-semibold text-ink", className)}{...props} />);}@@ -124,7 +124,7 @@ function SheetDescription({return (<SheetPrimitive.Descriptiondata-slot="sheet-description"- className={cn("text-sm text-muted-foreground", className)}+ className={cn("text-body text-ink-muted", className)}{...props} />);}diff --git a/frontend/src/components/ui/sidebar.tsx b/frontend/src/components/ui/sidebar.tsxindex c1b04ef..9e14619 100644--- a/frontend/src/components/ui/sidebar.tsx+++ b/frontend/src/components/ui/sidebar.tsx@@ -12,7 +12,6 @@ import { Separator } from "@/components/ui/separator"import {Sheet,SheetContent,- SheetDescription,SheetHeader,SheetTitle,} from "@/components/ui/sheet"@@ -179,7 +178,7 @@ function Sidebar({data-sidebar="sidebar"data-slot="sidebar"data-mobile="true"- className={cn("w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground [&>button]:hidden", className)}+ className={cn("w-(--sidebar-width) bg-sidebar p-0 text-sidebar-foreground", className)}style={{"--sidebar-width": SIDEBAR_WIDTH_MOBILE@@ -187,8 +186,7 @@ function Sidebar({}side={side}><SheetHeader className="sr-only">- <SheetTitle>Sidebar</SheetTitle>- <SheetDescription>Displays the mobile sidebar.</SheetDescription>+ <SheetTitle>Navigation</SheetTitle></SheetHeader><div className="flex h-full w-full flex-col" {...props}>{children}</div></SheetContent>@@ -243,7 +241,8 @@ function SidebarTrigger({onClick,...props}: React.ComponentProps<typeof Button>) {- const { toggleSidebar } = useSidebar()+ const { toggleSidebar, isMobile, open, openMobile } = useSidebar()+ const expanded = isMobile ? openMobile : openreturn (<Button@@ -251,14 +250,15 @@ function SidebarTrigger({data-slot="sidebar-trigger"variant="ghost"size="icon-sm"- className={cn(className)}+ aria-expanded={expanded}+ className={cn("pointer-coarse:size-11", className)}onClick={(event) => {onClick?.(event)toggleSidebar()}}{...props}><PanelLeftIcon />- <span className="sr-only">Toggle Sidebar</span>+ <span className="sr-only">{expanded ? "Hide navigation" : "Show navigation"}</span></Button>);}@@ -273,10 +273,10 @@ function SidebarRail({<buttondata-sidebar="rail"data-slot="sidebar-rail"- aria-label="Toggle Sidebar"+ aria-label="Show or hide navigation"tabIndex={-1}onClick={toggleSidebar}- title="Toggle Sidebar"+ title="Show or hide navigation"className={cn("absolute inset-y-0 z-20 hidden w-4 transition-all ease-linear group-data-[side=left]:-right-4 group-data-[side=right]:left-0 after:absolute after:inset-y-0 after:start-1/2 after:w-[2px] hover:after:bg-sidebar-border sm:flex ltr:-translate-x-1/2 rtl:-translate-x-1/2","in-data-[side=left]:cursor-w-resize in-data-[side=right]:cursor-e-resize",@@ -290,12 +290,13 @@ function SidebarRail({);}+// a plain wrapper: the app shell puts its own <main> inside, after the top barfunction SidebarInset({className,...props-}: React.ComponentProps<"main">) {+}: React.ComponentProps<"div">) {return (- <main+ <divdata-slot="sidebar-inset"className={cn("relative flex w-full flex-1 flex-col bg-background md:peer-data-[variant=inset]:m-2 md:peer-data-[variant=inset]:ml-0 md:peer-data-[variant=inset]:rounded-xl md:peer-data-[variant=inset]:shadow-sm md:peer-data-[variant=inset]:peer-data-[state=collapsed]:ml-2",diff --git a/frontend/src/components/ui/switch.tsx b/frontend/src/components/ui/switch.tsxindex 91562c0..6821283 100644--- a/frontend/src/components/ui/switch.tsx+++ b/frontend/src/components/ui/switch.tsx@@ -14,7 +14,7 @@ function Switch({data-slot="switch"data-size={size}className={cn(- "peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",+ "peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",className)}{...props}>diff --git a/frontend/src/components/ui/tabs.tsx b/frontend/src/components/ui/tabs.tsxindex dd80ac6..72bc925 100644--- a/frontend/src/components/ui/tabs.tsx+++ b/frontend/src/components/ui/tabs.tsx@@ -24,7 +24,7 @@ const tabsListVariants = cva({variants: {variant: {- default: "h-[2.625rem] gap-4 border-b border-line bg-transparent",+ default: "h-10.5 gap-4 border-b border-line bg-transparent",segmented: "h-(--control-h) gap-0.5 rounded-control bg-surface-sunken p-1",none: "",},@@ -59,7 +59,7 @@ function TabsTrigger({className={cn("relative inline-flex items-center justify-center gap-1.5 text-sm font-medium whitespace-nowrap text-ink-muted transition-colors duration-(--duration-fast) outline-none hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-active:text-ink [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg]:stroke-[1.75] [&_svg:not([class*='size-'])]:size-4 group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start","group-data-[variant=default]/tabs-list:h-full group-data-[variant=default]/tabs-list:px-0.5 after:absolute after:inset-x-0 after:-bottom-px after:h-0.5 after:rounded-full after:bg-brand after:opacity-0 after:transition-opacity group-data-[variant=default]/tabs-list:data-active:after:opacity-100",- "group-data-[variant=segmented]/tabs-list:h-full group-data-[variant=segmented]/tabs-list:flex-1 group-data-[variant=segmented]/tabs-list:rounded-[8px] group-data-[variant=segmented]/tabs-list:px-3 group-data-[variant=segmented]/tabs-list:data-active:bg-surface-raised group-data-[variant=segmented]/tabs-list:data-active:shadow-sm",+ "group-data-[variant=segmented]/tabs-list:h-full group-data-[variant=segmented]/tabs-list:flex-1 group-data-[variant=segmented]/tabs-list:rounded-[calc(var(--radius-control)-2px)] group-data-[variant=segmented]/tabs-list:px-3 group-data-[variant=segmented]/tabs-list:data-active:bg-surface-raised group-data-[variant=segmented]/tabs-list:data-active:shadow-sm",className)}{...props} />diff --git a/frontend/src/components/ui/textarea.tsx b/frontend/src/components/ui/textarea.tsxindex 392d840..9343dd1 100644--- a/frontend/src/components/ui/textarea.tsx+++ b/frontend/src/components/ui/textarea.tsx@@ -10,7 +10,7 @@ function Textarea({<textareadata-slot="textarea"className={cn(- "flex field-sizing-content min-h-16 w-full rounded-field border border-input bg-surface-raised px-3 py-2 text-base text-ink transition-colors duration-(--duration-fast) outline-none placeholder:text-ink-faint hover:border-ink-muted focus-visible:border-ring focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-ring disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:opacity-60 aria-invalid:border-danger",+ "flex field-sizing-content min-h-16 w-full rounded-field border border-input bg-surface-raised px-3 py-2 text-base text-ink transition-colors duration-(--duration-fast) outline-none placeholder:text-ink-faint hover:border-ink-muted focus-visible:border-ring focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring/15 disabled:cursor-not-allowed disabled:bg-surface-sunken disabled:opacity-60 aria-invalid:border-danger",className)}{...props} />diff --git a/frontend/src/hooks/use-document-title.ts b/frontend/src/hooks/use-document-title.tsnew file mode 100644index 0000000..29ea4ea--- /dev/null+++ b/frontend/src/hooks/use-document-title.ts@@ -0,0 +1,10 @@+import { useEffect } from 'react';+import { documentTitle } from '@/layout/routes';++// a detail page names its tab after what it shows (a channel, an account, a category); the app shell sets the+// route's own title in a layout effect first, and this passive effect runs after it, so the page's name wins+export function useDocumentTitle(pageTitle: string | null | undefined): void {+ useEffect(() => {+ if (pageTitle) document.title = documentTitle(pageTitle);+ }, [pageTitle]);+}diff --git a/frontend/src/layout/Header.tsx b/frontend/src/layout/Header.tsxindex 8a24f4f..a53ac2a 100644--- a/frontend/src/layout/Header.tsx+++ b/frontend/src/layout/Header.tsx@@ -1,13 +1,12 @@import React from 'react';-import { useLocation } from 'react-router-dom';-import { useSmoothTheme } from '@/hooks/use-smooth-theme';-import { RefreshCw, Sun, Moon, Search } from 'lucide-react';+import { Link, useLocation } from 'react-router-dom';+import { CircleHelp, Search } from 'lucide-react';import { SidebarTrigger } from '@/components/ui/sidebar';import { Button } from '@/components/ui/button';import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';+import { docsUrl } from '@/lib/docs';import { routeTitle } from './navigation';-import { useAppContext } from '../context/AppContext';-import { cn } from '@/lib/utils';+import { shortcutLabel } from './shortcuts';export interface TopBarProps {onOpenPalette: () => void;@@ -15,49 +14,38 @@ export interface TopBarProps {export default function TopBar({ onOpenPalette }: TopBarProps) {const location = useLocation();- const { loading, refreshAll, accounts } = useAppContext();- const { resolvedTheme, setTheme } = useSmoothTheme();- const isDark = resolvedTheme === 'dark';const title = routeTitle(location.pathname);+ const searchLabel = `Search (${shortcutLabel('K')})`;return (<header className="sticky top-0 z-20 flex h-(--topbar-h) shrink-0 items-center gap-2 border-b border-line bg-surface/85 px-3 backdrop-blur-md sm:px-4"><SidebarTrigger className="text-ink-muted" />- {title && (- <nav aria-label="Breadcrumb" className="flex min-w-0 items-center gap-1.5 text-small">- {title.parent && (- <>- <span className="hidden truncate text-ink-faint sm:inline">{title.parent}</span>- <span className="hidden text-ink-faint sm:inline" aria-hidden="true">/</span>- </>- )}- <span className="truncate font-medium text-ink" aria-current="page">{title.label}</span>+ {title?.parent ? (+ <nav aria-label="Breadcrumb" className="min-w-0 text-small">+ <ol className="flex min-w-0 items-center gap-1.5">+ <li className="hidden min-w-0 sm:flex sm:items-center sm:gap-1.5">+ <Link to={title.parent.path} className="truncate rounded-row text-ink-muted underline-offset-4 hover:text-ink hover:underline">+ {title.parent.label}+ </Link>+ <span className="text-ink-faint" aria-hidden="true">/</span>+ </li>+ <li className="min-w-0">+ <span className="block truncate font-medium text-ink" aria-current="page">{title.label}</span>+ </li>+ </ol></nav>+ ) : (+ title && <p className="min-w-0 truncate text-small font-medium text-ink">{title.label}</p>)}<div className="ml-auto flex items-center gap-1">- <Tooltip>- <TooltipTrigger render={<Button variant="ghost" size="icon-sm" onClick={onOpenPalette} aria-label="Search" className="md:hidden" />}>- <Search />- </TooltipTrigger>- <TooltipContent>Search</TooltipContent>- </Tooltip>-<Tooltip><TooltipTrigger- render={- <Button- variant="ghost"- size="icon-sm"- onClick={refreshAll}- disabled={loading || accounts.length === 0}- aria-label="Refresh all accounts"- />- }+ render={<Button variant="ghost" size="icon-sm" onClick={onOpenPalette} aria-label={searchLabel} className="pointer-coarse:size-11 md:hidden" />}>- <RefreshCw className={cn(loading && 'animate-spin')} />+ <Search /></TooltipTrigger>- <TooltipContent>{loading ? 'Refreshing accounts' : 'Refresh all accounts'}</TooltipContent>+ <TooltipContent>{searchLabel}</TooltipContent></Tooltip><Tooltip>@@ -66,14 +54,14 @@ export default function TopBar({ onOpenPalette }: TopBarProps) {<Buttonvariant="ghost"size="icon-sm"- onClick={() => setTheme(isDark ? 'light' : 'dark')}- aria-label={isDark ? 'Switch to light theme' : 'Switch to dark theme'}+ className="pointer-coarse:size-11"+ render={<a href={docsUrl()} target="_blank" rel="noopener noreferrer" aria-label="Help and documentation (opens in a new tab)" />}/>}>- {isDark ? <Sun /> : <Moon />}+ <CircleHelp /></TooltipTrigger>- <TooltipContent>{isDark ? 'Light theme' : 'Dark theme'}</TooltipContent>+ <TooltipContent>Help and documentation</TooltipContent></Tooltip></div></header>diff --git a/frontend/src/layout/RedirectWithQuery.tsx b/frontend/src/layout/RedirectWithQuery.tsxnew file mode 100644index 0000000..5f8407b--- /dev/null+++ b/frontend/src/layout/RedirectWithQuery.tsx@@ -0,0 +1,12 @@+import React from 'react';+import { Navigate, useLocation } from 'react-router-dom';++export interface RedirectWithQueryProps {+ to: string;+}++// an old address keeps working, with its filters and tabs, after a page moves+export default function RedirectWithQuery({ to }: RedirectWithQueryProps) {+ const { search, hash } = useLocation();+ return <Navigate to={`${to}${search}${hash}`} replace />;+}diff --git a/frontend/src/layout/Sidebar.tsx b/frontend/src/layout/Sidebar.tsxindex e3ab6d2..72905a6 100644--- a/frontend/src/layout/Sidebar.tsx+++ b/frontend/src/layout/Sidebar.tsx@@ -1,8 +1,8 @@-import React from 'react';+import React, { useState } from 'react';import type { ReactNode } from 'react';import { Link, useLocation, useNavigate } from 'react-router-dom';import { useSmoothTheme } from '@/hooks/use-smooth-theme';-import { Search, Tag, Settings, LogOut, Sun, Moon, Monitor, ChevronsUpDown, BookOpen } from 'lucide-react';+import { Search, Tag, Settings, LogOut, Sun, Moon, Monitor, ChevronsUpDown, BookOpen, ChevronDown, ChevronUp } from 'lucide-react';import {Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupLabel, SidebarHeader,SidebarMenu, SidebarMenuButton, SidebarMenuItem, useSidebar,@@ -15,12 +15,15 @@ import { Avatar, AvatarFallback } from '@/components/ui/avatar';import { Logo } from '@/components/brand/Logo';import { AccountAvatar } from '@/components/platform';import { accountName, accountPath } from '@/lib/accounts';-import { NAV_GROUPS, isNavActive } from './navigation';+import { NAV_GROUPS, currentNavPath } from './navigation';+import type { NavGroup } from './navigation';+import { shortcutLabel } from './shortcuts';import { useAppContext } from '../context/AppContext';import { useAuth } from '../context/AuthContext';import { docsUrl } from '@/lib/docs';-const isMac = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform);+// long account or category lists would push Settings far down, so each shows this many until expanded+const LIST_CAP = 6;export interface AppSidebarProps {categories: string[];@@ -28,21 +31,70 @@ export interface AppSidebarProps {onSignOut: () => void;}+interface DynamicLink {+ key: string;+ path: string;+ label: string;+ icon: ReactNode;+}++type RenderNavLink = (path: string, label: string, children: ReactNode) => ReactNode;++function categoryPath(category: string): string {+ return `/tracked-content/category/${encodeURIComponent(category)}`;+}+export default function AppSidebar({ categories, onOpenPalette, onSignOut }: AppSidebarProps) {const location = useLocation();const { accounts } = useAppContext();const { setOpenMobile } = useSidebar();- const nav = (path: string, label: string, children: ReactNode, tooltip = label) => (+ const accountLinks: DynamicLink[] = accounts.map(account => ({+ key: account.id,+ path: accountPath(account),+ label: accountName(account),+ icon: <AccountAvatar account={account} size="xs" decorative />,+ }));+ const categoryLinks: DynamicLink[] = categories.map(category => ({+ key: category,+ path: categoryPath(category),+ label: category,+ icon: <Tag />,+ }));+ const activePath = currentNavPath([...accountLinks, ...categoryLinks].map(link => link.path), location.pathname);++ const nav: RenderNavLink = (path, label, children) => (<SidebarMenuButton- isActive={isNavActive(path, location.pathname)}- tooltip={tooltip}+ isActive={path === activePath}+ aria-current={path === activePath ? 'page' : undefined}+ tooltip={label}render={<Link to={path} onClick={() => setOpenMobile(false)} />}>{children}</SidebarMenuButton>);+ const staticGroup = (group: NavGroup) => (+ <SidebarGroup key={group.label} className="py-1">+ <SidebarGroupLabel>{group.label}</SidebarGroupLabel>+ <SidebarMenu className="gap-0.5">+ {group.items.map(item => {+ const Icon = item.icon;+ return (+ <SidebarMenuItem key={item.path}>+ {nav(item.path, item.label, <><Icon /><span>{item.label}</span></>)}+ </SidebarMenuItem>+ );+ })}+ </SidebarMenu>+ </SidebarGroup>+ );++ // Manage (Accounts, Settings) closes the list, after the lists that grow with the person's data+ const manageGroup = NAV_GROUPS[NAV_GROUPS.length - 1];+ const mainGroups = NAV_GROUPS.slice(0, -1);+ const searchLabel = `Search (${shortcutLabel('K')})`;+return (<Sidebar collapsible="icon" className="border-r border-line"><SidebarHeader className="gap-3 px-3 pt-4 pb-2">@@ -57,71 +109,25 @@ export default function AppSidebar({ categories, onOpenPalette, onSignOut }: App<SidebarMenu><SidebarMenuItem><SidebarMenuButton- tooltip="Search"+ tooltip={searchLabel}onClick={onOpenPalette}- className="border border-line bg-surface-raised text-ink-faint hover:text-ink group-data-[collapsible=icon]:border-0 group-data-[collapsible=icon]:bg-transparent"+ className="border border-line bg-surface-raised text-ink-muted hover:text-ink group-data-[collapsible=icon]:border-0 group-data-[collapsible=icon]:bg-transparent"><Search className="size-4!" /><span className="flex-1">Search</span>- <kbd className="font-mono text-caption text-ink-faint group-data-[collapsible=icon]:hidden">{isMac ? 'Cmd K' : 'Ctrl K'}</kbd>+ <kbd className="font-mono text-caption text-ink-faint group-data-[collapsible=icon]:hidden">{shortcutLabel('K')}</kbd></SidebarMenuButton></SidebarMenuItem></SidebarMenu></SidebarHeader><SidebarContent className="gap-1 px-1">- {NAV_GROUPS.map(group => (- <SidebarGroup key={group.label} className="py-1">- <SidebarGroupLabel>{group.label}</SidebarGroupLabel>- <SidebarMenu className="gap-0.5">- {group.items.map(item => {- const Icon = item.icon;- return (- <SidebarMenuItem key={item.path}>- {nav(item.path, item.label, <><Icon /><span>{item.label}</span></>)}- </SidebarMenuItem>- );- })}- </SidebarMenu>- </SidebarGroup>- ))}-- {accounts.length > 0 && (- <SidebarGroup className="py-1">- <SidebarGroupLabel>Accounts</SidebarGroupLabel>- <SidebarMenu className="gap-0.5">- {accounts.map(account => {- const path = accountPath(account);- return (- <SidebarMenuItem key={account.id}>- {nav(path, accountName(account), (- <>- <AccountAvatar account={account} size="xs" />- <span>{accountName(account)}</span>- </>- ))}- </SidebarMenuItem>- );- })}- </SidebarMenu>- </SidebarGroup>- )}-- {categories.length > 0 && (- <SidebarGroup className="py-1">- <SidebarGroupLabel>Categories</SidebarGroupLabel>- <SidebarMenu className="gap-0.5">- {categories.map(category => {- const path = `/tracked-content/category/${encodeURIComponent(category)}`;- return (- <SidebarMenuItem key={category}>- {nav(path, category, <><Tag /><span>{category}</span></>)}- </SidebarMenuItem>- );- })}- </SidebarMenu>- </SidebarGroup>- )}+ <nav aria-label="Main" className="flex flex-col gap-1">+ {mainGroups.map(staticGroup)}+ <CappedGroup label="Your accounts" noun="accounts" links={accountLinks} activePath={activePath} renderLink={nav} />+ <CappedGroup label="Categories" noun="categories" links={categoryLinks} activePath={activePath} renderLink={nav} />+ {staticGroup(manageGroup)}+ </nav></SidebarContent><SidebarFooter className="border-t border-line p-2">@@ -131,6 +137,46 @@ export default function AppSidebar({ categories, onOpenPalette, onSignOut }: App);}+interface CappedGroupProps {+ label: string;+ noun: string;+ links: DynamicLink[];+ activePath: string | null;+ renderLink: RenderNavLink;+}++// the current page stays visible even when it sits past the cap+function CappedGroup({ label, noun, links, activePath, renderLink }: CappedGroupProps) {+ const [expanded, setExpanded] = useState(false);+ if (links.length === 0) return null;+ const overCap = links.length > LIST_CAP;+ const shown = !overCap || expanded+ ? links+ : links.filter((link, index) => index < LIST_CAP || link.path === activePath);+ const toggleLabel = expanded ? `Show fewer ${noun}` : `Show all ${links.length} ${noun}`;++ return (+ <SidebarGroup className="py-1">+ <SidebarGroupLabel>{label}</SidebarGroupLabel>+ <SidebarMenu className="gap-0.5">+ {shown.map(link => (+ <SidebarMenuItem key={link.key}>+ {renderLink(link.path, link.label, <>{link.icon}<span>{link.label}</span></>)}+ </SidebarMenuItem>+ ))}+ {overCap && (+ <SidebarMenuItem>+ <SidebarMenuButton tooltip={toggleLabel} aria-expanded={expanded} onClick={() => setExpanded(value => !value)}>+ {expanded ? <ChevronUp /> : <ChevronDown />}+ <span>{toggleLabel}</span>+ </SidebarMenuButton>+ </SidebarMenuItem>+ )}+ </SidebarMenu>+ </SidebarGroup>+ );+}+function UserMenu({ onSignOut }: { onSignOut: () => void }) {const navigate = useNavigate();const { user } = useAuth();@@ -145,18 +191,18 @@ function UserMenu({ onSignOut }: { onSignOut: () => void }) {<DropdownMenuTriggerrender={<SidebarMenuButton size="lg" tooltip={email || 'Account'} className="data-popup-open:bg-surface-selected" />}>- <Avatar className="size-7">+ <Avatar className="size-7" aria-hidden="true"><AvatarFallback className="bg-brand text-caption font-semibold text-on-brand">{initial}</AvatarFallback></Avatar><span className="flex min-w-0 flex-1 flex-col text-left"><span className="truncate text-sm font-medium text-ink">{email.split('@')[0] || 'Account'}</span>- <span className="truncate text-caption font-normal text-ink-faint">{email}</span>+ <span className="truncate text-caption font-normal text-ink-muted">{email}</span></span><ChevronsUpDown className="size-4! text-ink-faint" /></DropdownMenuTrigger><DropdownMenuContent side="top" align="start" className="w-(--anchor-width) min-w-56"><DropdownMenuGroup>- <DropdownMenuLabel className="text-caption text-ink-faint">Theme</DropdownMenuLabel>+ <DropdownMenuLabel className="text-caption text-ink-muted">Theme</DropdownMenuLabel><DropdownMenuRadioGroup value={theme} onValueChange={setTheme}><DropdownMenuRadioItem value="light"><Sun />Light</DropdownMenuRadioItem><DropdownMenuRadioItem value="dark"><Moon />Dark</DropdownMenuRadioItem>@@ -165,7 +211,9 @@ function UserMenu({ onSignOut }: { onSignOut: () => void }) {</DropdownMenuGroup><DropdownMenuSeparator /><DropdownMenuItem onClick={() => navigate('/settings')}><Settings />Settings</DropdownMenuItem>- <DropdownMenuItem onClick={() => window.open(docsUrl(), '_blank', 'noopener')}><BookOpen />Documentation</DropdownMenuItem>+ <DropdownMenuItem onClick={() => window.open(docsUrl(), '_blank', 'noopener')}>+ <BookOpen />Documentation<span className="sr-only"> (opens in a new tab)</span>+ </DropdownMenuItem><DropdownMenuItem onClick={onSignOut}><LogOut />Sign out</DropdownMenuItem></DropdownMenuContent></DropdownMenu>diff --git a/frontend/src/layout/index.tsx b/frontend/src/layout/index.tsxindex de97401..460a86c 100644--- a/frontend/src/layout/index.tsx+++ b/frontend/src/layout/index.tsx@@ -1,11 +1,15 @@-import React, { Suspense, useCallback, useEffect, useState } from 'react';-import { Outlet, useNavigate } from 'react-router-dom';+import React, { Suspense, useCallback, useEffect, useLayoutEffect, useRef, useState } from 'react';+import { Outlet, useLocation, useNavigate } from 'react-router-dom';import { SidebarProvider, SidebarInset } from '@/components/ui/sidebar';import CommandPalette from '@/components/CommandPalette';import { useCommandPaletteShortcut } from '@/hooks/use-command-palette-shortcut';import { PageSkeleton } from '@/components/StateViews';import AppSidebar from './Sidebar';import TopBar from './Header';+import { routeTitle } from './navigation';+import { documentTitle } from './routes';+import { requestHeadingFocus } from './routeFocus';+import type { ShellOutletContext } from './shellContext';import { useAppContext } from '../context/AppContext';import { useAuth } from '../context/AuthContext';import { api } from '../services/api';@@ -18,6 +22,7 @@ export default function AppShell() {const [categories, setCategories] = useState<string[]>([]);useCommandPaletteShortcut(setPaletteOpen);+ useRouteAnnouncement();useEffect(() => {api.getTrackedContent()@@ -45,13 +50,13 @@ export default function AppShell() {<AppSidebar categories={categories} onOpenPalette={openPalette} onSignOut={handleSignOut} /><SidebarInset className="min-w-0"><TopBar onOpenPalette={openPalette} />- <div id="main-content" tabIndex={-1} className="flex-1 outline-none">+ <main id="main-content" tabIndex={-1} className="flex-1 outline-none"><div className="mx-auto w-full max-w-(--content-max) px-4 py-6 sm:px-5"><Suspense fallback={<PageSkeleton />}>- <Outlet />+ <Outlet context={{ openPalette } satisfies ShellOutletContext} /></Suspense></div>- </div>+ </main></SidebarInset><CommandPaletteopen={paletteOpen}@@ -64,3 +69,21 @@ export default function AppShell() {</SidebarProvider>);}++// each route names the browser tab, and a client-side navigation moves focus to the new page like a page load would+function useRouteAnnouncement() {+ const { pathname } = useLocation();+ const firstRender = useRef(true);++ // layout effects run before every passive effect, so the new page's heading (and useDocumentTitle) act after this+ useLayoutEffect(() => {+ document.title = documentTitle(routeTitle(pathname)?.label);+ if (firstRender.current) {+ firstRender.current = false;+ return;+ }+ requestHeadingFocus();+ document.getElementById('main-content')?.focus({ preventScroll: true });+ window.scrollTo({ top: 0 });+ }, [pathname]);+}diff --git a/frontend/src/layout/navigation.ts b/frontend/src/layout/navigation.tsindex 70d5bfd..8e1b95d 100644--- a/frontend/src/layout/navigation.ts+++ b/frontend/src/layout/navigation.ts@@ -2,6 +2,10 @@ import {LayoutDashboard, PlaySquare, Scissors, Clapperboard, MessagesSquare, Bookmark, Send, MessageSquareReply, Users, Settings,} from 'lucide-react';import type { LucideIcon } from 'lucide-react';+import { activeNavPath, routeTitle as titleForRoute } from './routes';+import type { RouteTitle } from './routes';++export type { RouteTitle } from './routes';export interface NavItem {path: string;@@ -14,18 +18,6 @@ export interface NavGroup {items: NavItem[];}-// parent is null for the overview, which sits at the top of the breadcrumb-export interface RouteTitle {- label: string;- parent: string | null;-}--interface DetailRoute {- prefix: string;- label: string;- parent: string;-}-// Single source for navigation: the sidebar, top bar title and command palette all read from here.export const NAV_GROUPS: NavGroup[] = [{@@ -34,7 +26,7 @@ export const NAV_GROUPS: NavGroup[] = [{ path: '/', label: 'Overview', icon: LayoutDashboard },{ path: '/videos', label: 'Videos', icon: PlaySquare },{ path: '/shorts', label: 'Shorts', icon: Scissors },- { path: '/reels', label: 'Instagram content', icon: Clapperboard },+ { path: '/instagram', label: 'Instagram content', icon: Clapperboard },{ path: '/reddit-posts', label: 'Reddit posts', icon: MessagesSquare },{ path: '/tracked-content', label: 'Tracked content', icon: Bookmark },],@@ -42,7 +34,7 @@ export const NAV_GROUPS: NavGroup[] = [{label: 'Publishing',items: [- { path: '/upload', label: 'Publish', icon: Send },+ { path: '/publish', label: 'Publish', icon: Send },{ path: '/automations', label: 'Automations', icon: MessageSquareReply },],},@@ -55,24 +47,12 @@ export const NAV_GROUPS: NavGroup[] = [},];-const DETAIL_ROUTES: DetailRoute[] = [- { prefix: '/channel/', label: 'YouTube channel', parent: 'Analytics' },- { prefix: '/instagram/', label: 'Instagram account', parent: 'Analytics' },- { prefix: '/reddit/', label: 'Reddit account', parent: 'Analytics' },- { prefix: '/reddit-posts/', label: 'Reddit posts', parent: 'Analytics' },- { prefix: '/tracked-content/category/', label: 'Category', parent: 'Tracked content' },-];--export function isNavActive(path: string, pathname: string): boolean {- if (path === '/') return pathname === '/';- return pathname === path || pathname.startsWith(`${path}/`);+export function routeTitle(pathname: string): RouteTitle | null {+ return titleForRoute(NAV_GROUPS, pathname);}-export function routeTitle(pathname: string): RouteTitle | null {- for (const group of NAV_GROUPS) {- const item = group.items.find(i => i.path === pathname);- if (item) return { label: item.label, parent: item.path === '/' ? null : group.label };- }- const detail = DETAIL_ROUTES.find(r => pathname.startsWith(r.prefix));- return detail ? { label: detail.label, parent: detail.parent } : null;+// every path the sidebar can link to, so only the most specific one is marked as the current page+export function currentNavPath(extraPaths: string[], pathname: string): string | null {+ const navPaths = NAV_GROUPS.flatMap(group => group.items.map(item => item.path));+ return activeNavPath([...navPaths, ...extraPaths], pathname);}diff --git a/frontend/src/layout/routeFocus.ts b/frontend/src/layout/routeFocus.tsnew file mode 100644index 0000000..18f7d59--- /dev/null+++ b/frontend/src/layout/routeFocus.ts@@ -0,0 +1,17 @@+// after a client-side navigation, focus moves to the new page's heading so a screen reader announces where the+// person landed; the heading may appear only once the page has loaded, so the request waits until then++let headingFocusPending = false;++export function requestHeadingFocus(): void {+ headingFocusPending = true;+}++// only the first heading to mount after a navigation takes focus, and only if the person has not moved it since+export function takeHeadingFocus(heading: HTMLElement | null): void {+ if (!headingFocusPending || !heading) return;+ headingFocusPending = false;+ const active = document.activeElement;+ const untouched = !active || active === document.body || active.id === 'main-content';+ if (untouched) heading.focus({ preventScroll: true });+}diff --git a/frontend/src/layout/routes.ts b/frontend/src/layout/routes.tsnew file mode 100644index 0000000..6d078a4--- /dev/null+++ b/frontend/src/layout/routes.ts@@ -0,0 +1,62 @@+// route matching for the navigation, kept free of React and icons so Node can test it++export interface RouteLink {+ path: string;+ label: string;+}++export interface RouteGroup {+ label: string;+ items: RouteLink[];+}++// parent is the page one level up, linked from the breadcrumb; null on top-level pages+export interface RouteTitle {+ label: string;+ parent: RouteLink | null;+}++export interface DetailRoute {+ prefix: string;+ label: string;+ parent: RouteLink;+}++export const DETAIL_ROUTES: DetailRoute[] = [+ { prefix: '/channel/', label: 'YouTube channel', parent: { path: '/', label: 'Overview' } },+ { prefix: '/instagram/', label: 'Instagram account', parent: { path: '/', label: 'Overview' } },+ { prefix: '/reddit/', label: 'Reddit account', parent: { path: '/', label: 'Overview' } },+ { prefix: '/reddit-posts/', label: 'Reddit posts', parent: { path: '/reddit-posts', label: 'Reddit posts' } },+ { prefix: '/tracked-content/category/', label: 'Category', parent: { path: '/tracked-content', label: 'Tracked content' } },+ { prefix: '/automations/rules/new', label: 'New rule', parent: { path: '/automations', label: 'Automations' } },+ { prefix: '/automations/rules/', label: 'Edit rule', parent: { path: '/automations', label: 'Automations' } },+];++export const APP_NAME = 'Twiligent';++export function matchesPath(path: string, pathname: string): boolean {+ if (path === '/') return pathname === '/';+ return pathname === path || pathname.startsWith(`${path}/`);+}++// the most specific link wins, so a category page marks the category and not Tracked content as well+export function activeNavPath(paths: string[], pathname: string): string | null {+ let best: string | null = null;+ for (const path of paths) {+ if (matchesPath(path, pathname) && (best === null || path.length > best.length)) best = path;+ }+ return best;+}++export function routeTitle(groups: RouteGroup[], pathname: string): RouteTitle | null {+ for (const group of groups) {+ const item = group.items.find(i => i.path === pathname);+ if (item) return { label: item.label, parent: null };+ }+ const detail = DETAIL_ROUTES.find(r => pathname.startsWith(r.prefix));+ return detail ? { label: detail.label, parent: detail.parent } : null;+}++export function documentTitle(pageTitle: string | null | undefined): string {+ return pageTitle ? `${pageTitle} - ${APP_NAME}` : APP_NAME;+}diff --git a/frontend/src/layout/shellContext.ts b/frontend/src/layout/shellContext.tsnew file mode 100644index 0000000..e773d65--- /dev/null+++ b/frontend/src/layout/shellContext.ts@@ -0,0 +1,4 @@+// what the app shell hands to every page through the router outlet+export interface ShellOutletContext {+ openPalette: () => void;+}diff --git a/frontend/src/layout/shortcuts.ts b/frontend/src/layout/shortcuts.tsnew file mode 100644index 0000000..76ea95d--- /dev/null+++ b/frontend/src/layout/shortcuts.ts@@ -0,0 +1,12 @@+// keyboard shortcuts are shown the way the person's own keyboard labels them++const isMac = typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform);++export function shortcutLabel(key: string): string {+ return `${isMac ? 'Cmd' : 'Ctrl'} ${key}`;+}++export const APP_SHORTCUTS: ReadonlyArray<{ keys: string; action: string }> = [+ { keys: shortcutLabel('K'), action: 'Search' },+ { keys: shortcutLabel('B'), action: 'Show or hide the sidebar' },+];diff --git a/frontend/src/lib/utils.ts b/frontend/src/lib/utils.tsindex 50b28b2..bc40d77 100644--- a/frontend/src/lib/utils.ts+++ b/frontend/src/lib/utils.ts@@ -1,6 +1,16 @@import { clsx } from "clsx";import type { ClassValue } from "clsx";-import { twMerge } from "tailwind-merge"+import { extendTailwindMerge } from "tailwind-merge"++// the design tokens' own sizes and radii must be known here, or text-small next to a colour class is dropped as a colour+const twMerge = extendTailwindMerge({+ extend: {+ theme: {+ text: ["display", "page-title", "section", "body", "small", "caption", "metric"],+ radius: ["row", "control", "field", "card", "panel", "dialog", "pill"],+ },+ },+})export function cn(...inputs: ClassValue[]): string {return twMerge(clsx(inputs));diff --git a/frontend/src/pages/NotFound.tsx b/frontend/src/pages/NotFound.tsxnew file mode 100644index 0000000..e8a8872--- /dev/null+++ b/frontend/src/pages/NotFound.tsx@@ -0,0 +1,40 @@+import React from 'react';+import { Link, useLocation, useOutletContext } from 'react-router-dom';+import { LayoutDashboard, Search } from 'lucide-react';+import PageHeader from '@/components/PageHeader';+import { Button } from '@/components/ui/button';+import { useDocumentTitle } from '@/hooks/use-document-title';+import { shortcutLabel } from '@/layout/shortcuts';+import type { ShellOutletContext } from '@/layout/shellContext';++// a mistyped or outdated link says what happened instead of silently landing on the overview+export default function NotFound() {+ const { pathname } = useLocation();+ const shell = useOutletContext<ShellOutletContext | undefined>();+ const onOpenSearch = shell?.openPalette;+ useDocumentTitle('Page not found');++ return (+ <div className="flex flex-col gap-6">+ <PageHeader+ title="Page not found"+ description={+ <>+ There is no page at <code className="rounded-row bg-surface-sunken px-1.5 py-0.5 font-mono text-small break-all">{pathname}</code>.+ The link may be mistyped, or the page may have moved.+ </>+ }+ />+ <div className="flex flex-wrap gap-2">+ <Button render={<Link to="/" />}>+ <LayoutDashboard data-icon="inline-start" />Go to the overview+ </Button>+ {onOpenSearch && (+ <Button variant="outline" onClick={onOpenSearch}>+ <Search data-icon="inline-start" />Search pages and accounts ({shortcutLabel('K')})+ </Button>+ )}+ </div>+ </div>+ );+}diff --git a/frontend/tests/layout/routes.test.ts b/frontend/tests/layout/routes.test.tsnew file mode 100644index 0000000..743ea12--- /dev/null+++ b/frontend/tests/layout/routes.test.ts@@ -0,0 +1,47 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { activeNavPath, documentTitle, matchesPath, routeTitle } from '../../src/layout/routes.ts';++const GROUPS = [+ { label: 'Analytics', items: [{ path: '/', label: 'Overview' }, { path: '/tracked-content', label: 'Tracked content' }] },+ { label: 'Publishing', items: [{ path: '/publish', label: 'Publish' }, { path: '/automations', label: 'Automations' }] },+];++test('the overview link matches only the overview itself', () => {+ assert.equal(matchesPath('/', '/'), true);+ assert.equal(matchesPath('/', '/videos'), false);+});++test('a section link matches its own pages but not a path that only starts with the same letters', () => {+ assert.equal(matchesPath('/reddit', '/reddit/abc'), true);+ assert.equal(matchesPath('/reddit', '/reddit-posts'), false);+});++test('only the most specific matching link is active', () => {+ const paths = ['/', '/tracked-content', '/tracked-content/category/travel'];+ assert.equal(activeNavPath(paths, '/tracked-content/category/travel'), '/tracked-content/category/travel');+ assert.equal(activeNavPath(paths, '/tracked-content'), '/tracked-content');+ assert.equal(activeNavPath(paths, '/settings'), null);+});++test('a top-level page has a title and no parent', () => {+ assert.deepEqual(routeTitle(GROUPS, '/publish'), { label: 'Publish', parent: null });+});++test('a detail page links back to the page above it', () => {+ assert.deepEqual(routeTitle(GROUPS, '/tracked-content/category/travel'), {+ label: 'Category',+ parent: { path: '/tracked-content', label: 'Tracked content' },+ });+ assert.equal(routeTitle(GROUPS, '/automations/rules/new')?.label, 'New rule');+ assert.equal(routeTitle(GROUPS, '/automations/rules/42')?.label, 'Edit rule');+});++test('an unknown path has no title', () => {+ assert.equal(routeTitle(GROUPS, '/nowhere'), null);+});++test('the tab title names the page before the app', () => {+ assert.equal(documentTitle('Publish'), 'Publish - Twiligent');+ assert.equal(documentTitle(null), 'Twiligent');+});diff --git a/frontend/tests/lib/utils.test.ts b/frontend/tests/lib/utils.test.tsnew file mode 100644index 0000000..4368a6d--- /dev/null+++ b/frontend/tests/lib/utils.test.ts@@ -0,0 +1,16 @@+import { test } from 'node:test';+import assert from 'node:assert/strict';+import { cn } from '../../src/lib/utils.ts';++test('a token text size survives next to a text colour', () => {+ assert.equal(cn('text-body text-ink-muted'), 'text-body text-ink-muted');+ assert.equal(cn('text-small text-ink-muted', 'text-danger'), 'text-small text-danger');+});++test('a later token text size replaces an earlier size', () => {+ assert.equal(cn('text-sm', 'text-small'), 'text-small');+});++test('a token radius on every corner replaces a radius on the top corners', () => {+ assert.equal(cn('rounded-t-dialog', 'rounded-dialog'), 'rounded-dialog');+});