Skip to content

Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS

ux: convert remaining hand-rolled sub-navs to TabPills (#7359)

[._.]/ Adam Eivye462b4ee70dd
diff --git a/client/src/AGENTS.md b/client/src/AGENTS.md
index 5637da4746..629a3cf22b 100644
--- a/client/src/AGENTS.md
+++ b/client/src/AGENTS.md
@@ -13,7 +13,7 @@ These apply to React/Vite client code. Universal constraints (functional program
- **A sub-nav that doesn't fit a phone collapses to ICON LINKS, not a `<select>`** - this is a stated product preference, not a judgement call to re-make per page: a dropdown reads as a form control and hides where you are behind a tap, while an icon row still looks and behaves like navigation and keeps every destination one tap away. Pass `mobileCompact` to `TabPills` and it renders the same tab buttons icon-only below `sm` (label kept as `max-sm:sr-only`, so the accessible name never changes) with a chevron at whichever edge is still scrollable. `RouteTabsHeader` decides *whether* to collapse (past `MOBILE_COMPACT_THRESHOLD` tabs); `TabPills` decides *how*. #7283 made the `<select>` universal and was reverted — don't reintroduce it as "consistency". Corollaries:
- **Every tab in a fixed set of sections needs an icon, and no two in one bar may share one.** One iconless tab drops the whole bar back to the `<select>`, and on a phone the icon is all the user sees, so a repeated glyph is a repeated destination. Section tabs get theirs from the sidebar registry via `buildSectionNavTabs(getSectionNavTabs(s), NAV_PRESENTATION, s)`, which **throws** on a missing one; `client/src/lib/navPresentation.test.js` pins coverage and uniqueness for every section.
- **The `<select>` fallback is for lists icons can't serve** — an unbounded, data-driven one where every entry would draw the same glyph (FableLoomStory's episode list). Not for a fixed set of sections someone hasn't given icons yet. Unbounded *record pickers* that happen to be `<select>`s (the account switchers in `pages/X.jsx`, `pages/StackerNews.jsx`) are not sub-navs and are out of scope.
- - **Not yet enforced tree-wide.** Several hand-rolled tab strips still bypass `TabPills` (`components/apps/AppDetailView.jsx`'s 15-tab scroller, `pages/SystemHealthPage.jsx`, `pages/Sharing.jsx`, `components/writers-room/WorkEditor.jsx`'s `MobileTab`, …) — converting them and adding a `subNavConventions.test.js` is tracked in #7359. Until then, **reuse `TabPills`; never roll a new tab bar.**
+ - Enforced tree-wide by `client/src/subNavConventions.test.js`, which flags a `border-b-2` tab strip outside `TabPills` and allowlists the few underlines that are not section sub-navs (comment-anchored manuscript prose). **Reuse `TabPills`; never roll a new tab bar.**
- **Above the fold** - keep actionable content and info above the fold and design pages for maximum information and access without scrolling
- **No hardcoded localhost** - use `window.location.hostname` for URLs; app accessed via Tailscale remotely
- **Chrome floating over media uses `.port-media-overlay`** - a label, status bar, badge, or control panel sitting on top of an image, a video, or a 3D canvas takes its surface and ink from the theme (`.port-media-overlay`, or `.port-media-overlay-strong` for a small label directly on photography; `.port-media-overlay-item` for its buttons, `.port-media-overlay-divider` for its separators — all defined in `index.css`, which carries the mechanism and the rule for picking between this, `.always-dark`, and the OpenWorld HUD remap). **Don't write `bg-black/NN` + `text-white`/`text-gray-N00` for this** — day mode remaps the text to the theme's dark ink while the black scrim stays black, so the label renders dark-on-black. Older overlays outside the 3D/Three.js pages still carry that idiom (migration tracked in #3796), so match the new convention rather than the nearest neighbor.
diff --git a/client/src/components/apps/AppDetailView.jsx b/client/src/components/apps/AppDetailView.jsx
index 7b0066a6e0..71122a5531 100644
--- a/client/src/components/apps/AppDetailView.jsx
+++ b/client/src/components/apps/AppDetailView.jsx
@@ -1,6 +1,11 @@
import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
import { Link, useParams, useNavigate, useSearchParams } from 'react-router';
-import { ArrowLeft, Play, Square, RotateCcw, ExternalLink, Gamepad2, Hammer, RefreshCw, Pencil, AlertTriangle, Sparkles } from 'lucide-react';
+import {
+ ArrowLeft, Play, Square, RotateCcw, ExternalLink, Gamepad2, Hammer, RefreshCw,
+ Pencil, AlertTriangle, Sparkles, LayoutDashboard, Zap, Dog, FileText, GitBranch,
+ Compass, CircleDot, GitPullRequest, Ticket, Cpu, ShieldCheck, BookOpen, Boxes,
+ ListChecks,
+} from 'lucide-react';
import DeployPanel from './DeployPanel';
import EditAppDrawer from './EditAppDrawer';
import toast from '../ui/Toast';
@@ -28,6 +33,27 @@ import ReferencesTab from './tabs/ReferencesTab';
import SubmodulesTab from './tabs/SubmodulesTab';
import DatadogTab from './tabs/DatadogTab';
import UpdateTab from './tabs/UpdateTab';
+import TabPills from '../ui/TabPills';
+
+// Icons live here rather than on `APP_DETAIL_TABS` so `constants.js` stays
+// importable from node-env server tests (no lucide-react from `server/`).
+export const APP_DETAIL_TAB_ICONS = {
+ overview: LayoutDashboard,
+ automation: Zap,
+ datadog: Dog,
+ documents: FileText,
+ git: GitBranch,
+ gsd: Compass,
+ issues: CircleDot,
+ 'pull-requests': GitPullRequest,
+ jira: Ticket,
+ processes: Cpu,
+ quality: ShieldCheck,
+ references: BookOpen,
+ submodules: Boxes,
+ tasks: ListChecks,
+ update: RefreshCw,
+};
export default function AppDetailView() {
const { appId } = useParams();
@@ -522,22 +548,14 @@ function AppDetail() {
</div>
)}
- {/* Tab Bar */}
- <div className="flex gap-1 mt-4 -mb-4 overflow-x-auto">
- {visibleTabs.map(t => (
- <button
- key={t.id}
- onClick={() => navigate(`/apps/${appId}/${t.id}`)}
- className={`px-4 py-2 text-sm font-medium whitespace-nowrap border-b-2 transition-colors ${
- effectiveTab === t.id
- ? 'border-port-accent text-port-accent'
- : 'border-transparent text-gray-400 hover:text-white hover:border-gray-600'
- }`}
- >
- {t.label}
- </button>
- ))}
- </div>
+ <TabPills
+ tabs={visibleTabs.map((t) => ({ ...t, icon: APP_DETAIL_TAB_ICONS[t.id] }))}
+ activeTab={effectiveTab}
+ onChange={(id) => navigate(`/apps/${appId}/${id}`)}
+ mobileCompact
+ ariaLabel="App sections"
+ className="mt-4 -mb-4"
+ />
</div>
{/* Tab Content */}
diff --git a/client/src/components/apps/AppDetailView.test.jsx b/client/src/components/apps/AppDetailView.test.jsx
index 87e0b450b9..26635ec5b3 100644
--- a/client/src/components/apps/AppDetailView.test.jsx
+++ b/client/src/components/apps/AppDetailView.test.jsx
@@ -57,7 +57,8 @@ vi.mock('./tabs/DatadogTab', () => ({ default: () => <div data-testid="datadog-t
vi.mock('./tabs/UpdateTab', () => ({ default: () => null }));
import * as api from '../../services/api';
-import AppDetailView from './AppDetailView';
+import AppDetailView, { APP_DETAIL_TAB_ICONS } from './AppDetailView';
+import { APP_DETAIL_TABS } from './constants';
const APP = {
id: 'app-1',
@@ -163,9 +164,9 @@ describe('AppDetailView managed-app feature tabs', () => {
renderDetail();
await screen.findByRole('heading', { name: 'Example App' });
- expect(screen.queryByRole('button', { name: 'DataDog' })).toBeNull();
- expect(screen.queryByRole('button', { name: 'JIRA' })).toBeNull();
- expect(screen.queryByRole('button', { name: 'GSD' })).toBeNull();
+ expect(screen.queryByRole('tab', { name: 'DataDog' })).toBeNull();
+ expect(screen.queryByRole('tab', { name: 'JIRA' })).toBeNull();
+ expect(screen.queryByRole('tab', { name: 'GSD' })).toBeNull();
});
it('lets app overrides show or hide tabs independently of global settings', async () => {
@@ -182,9 +183,9 @@ describe('AppDetailView managed-app feature tabs', () => {
renderDetail();
await screen.findByRole('heading', { name: 'Example App' });
- expect(screen.getByRole('button', { name: 'DataDog' })).toBeInTheDocument();
- expect(screen.getByRole('button', { name: 'JIRA' })).toBeInTheDocument();
- expect(screen.queryByRole('button', { name: 'GSD' })).toBeNull();
+ expect(screen.getByRole('tab', { name: 'DataDog' })).toBeInTheDocument();
+ expect(screen.getByRole('tab', { name: 'JIRA' })).toBeInTheDocument();
+ expect(screen.queryByRole('tab', { name: 'GSD' })).toBeNull();
});
it('keeps a disabled feature tab reachable from a direct URL', async () => {
@@ -197,9 +198,15 @@ describe('AppDetailView managed-app feature tabs', () => {
renderDetail('/apps/app-1/datadog');
await screen.findByRole('heading', { name: 'Example App' });
- expect(screen.queryByRole('button', { name: 'DataDog' })).toBeNull();
+ expect(screen.queryByRole('tab', { name: 'DataDog' })).toBeNull();
expect(screen.getByTestId('datadog-tab')).toBeInTheDocument();
});
+
+ it('assigns a unique icon to every app-detail tab', () => {
+ const icons = APP_DETAIL_TABS.map((tab) => APP_DETAIL_TAB_ICONS[tab.id]);
+ expect(icons.every(Boolean)).toBe(true);
+ expect(new Set(icons).size).toBe(APP_DETAIL_TABS.length);
+ });
});
describe('AppDetailView fetch lifecycle', () => {
diff --git a/client/src/components/apps/constants.js b/client/src/components/apps/constants.js
index 1c13e46d68..404cd92908 100644
--- a/client/src/components/apps/constants.js
+++ b/client/src/components/apps/constants.js
@@ -168,7 +168,9 @@ export const isAppFeatureEnabled = (app, featureId, globalEnabled) => {
// Overview first, then alphabetical. Every id is a real route segment
// (`/apps/:appId/:tab`) so each tab is linkable, bookmarkable, and reachable
-// from ⌘K — see the routing rules in client/src/AGENTS.md.
+// from ⌘K — see the routing rules in client/src/AGENTS.md. Icons live in
+// `APP_DETAIL_TAB_ICONS` (`AppDetailView.jsx`) so this module stays importable
+// from node-env server tests.
//
// `feature` gates a tab against the install-wide feature setting, with an
// app-level `featureOverrides` choice taking precedence. `visibleWhen(app)` is
diff --git a/client/src/components/cos/tabs/schedule/PromptEditor.jsx b/client/src/components/cos/tabs/schedule/PromptEditor.jsx
index 9a077c5526..4eb210629f 100644
--- a/client/src/components/cos/tabs/schedule/PromptEditor.jsx
+++ b/client/src/components/cos/tabs/schedule/PromptEditor.jsx
@@ -1,5 +1,15 @@
import { useState, useEffect } from 'react';
+import {
+ Shield, BadgeCheck, Hammer, Layers, GitBranch, FileText, Sparkles, Bot,
+ Cpu, Workflow, Boxes, ScanSearch, ListChecks, PenLine, Clapperboard, Rocket,
+} from 'lucide-react';
import { pipelineStages } from './scheduleConstants';
+import TabPills from '../../../ui/TabPills';
+
+const STAGE_ICONS = [
+ Shield, BadgeCheck, Hammer, Layers, GitBranch, FileText, Sparkles, Bot,
+ Cpu, Workflow, Boxes, ScanSearch, ListChecks, PenLine, Clapperboard, Rocket,
+];
export default function PromptEditor({ config, promptValue, setPromptValue, editingPrompt, setEditingPrompt, handleSavePrompt, updating, activeApps }) {
const stages = pipelineStages(config);
@@ -94,23 +104,23 @@ export default function PromptEditor({ config, promptValue, setPromptValue, edit
<div>
<span className="text-sm text-gray-400 block mb-2">Stage Prompts</span>
<div className="border border-port-border rounded-lg overflow-hidden">
- <div className="flex border-b border-port-border bg-port-card">
- {stages.map((stage, i) => (
- <button
- key={i}
- onClick={() => setActiveTab(i)}
- className={`flex-1 px-3 py-2 text-xs font-medium transition-colors ${
- activeTab === i
- ? 'text-port-accent-2 bg-port-accent-2/10 border-b-2 border-port-accent-2'
- : 'text-gray-400 hover:text-gray-300 hover:bg-port-border/30'
- }`}
- >
- <span className="text-[10px] text-gray-500 mr-1">Stage {i + 1}</span>
- {stage.name}
- {stage.readOnly && <span className="ml-1 text-[10px] text-gray-500">(read-only)</span>}
- </button>
- ))}
- </div>
+ <TabPills
+ tabs={stages.map((stage, i) => ({
+ id: String(i),
+ label: stage.name,
+ icon: STAGE_ICONS[i],
+ trailing: stage.readOnly
+ ? <span className="text-[10px] text-gray-500">(read-only)</span>
+ : undefined,
+ }))}
+ activeTab={String(activeTab)}
+ onChange={(id) => setActiveTab(Number(id))}
+ variant="underline"
+ stretch
+ size="sm"
+ mobileCompact
+ ariaLabel="Stage prompts"
+ />
<div className="bg-port-bg px-3 py-2 text-xs text-gray-400 font-mono max-h-64 overflow-y-auto">
<pre className="whitespace-pre-wrap break-words">{stagePrompts[activeTab] || 'No prompt configured'}</pre>
</div>
diff --git a/client/src/components/meatspace/post/PostProgress.jsx b/client/src/components/meatspace/post/PostProgress.jsx
index e909cd2b75..08d97a8c9d 100644
--- a/client/src/components/meatspace/post/PostProgress.jsx
+++ b/client/src/components/meatspace/post/PostProgress.jsx
@@ -1,5 +1,5 @@
import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
-import { ArrowLeft, Flame, Trophy, Clock, Gauge } from 'lucide-react';
+import { ArrowLeft, Flame, Trophy, Clock, Gauge, TrendingUp, History } from 'lucide-react';
import {
LineChart, Line, XAxis, YAxis, Tooltip, ResponsiveContainer, CartesianGrid
} from 'recharts';
@@ -10,6 +10,7 @@ import { formatDurationMin } from '../../../utils/formatters';
import { DRILL_LABELS, DRILL_TO_DOMAIN, domainLabel } from './constants';
import { streakGlyph } from '../../../lib/streakGlyph.js';
import PostHistory from './PostHistory';
+import TabPills from '../../ui/TabPills';
const RANGES = [
{ label: '7d', days: 7 },
@@ -69,8 +70,14 @@ export const PROGRESS_SUBROUTES = [
{ id: 'sessions', label: 'Sessions' },
];
+const PROGRESS_TABS = [
+ { id: 'trends', label: 'Trends', icon: TrendingUp },
+ { id: 'sessions', label: 'Sessions', icon: History },
+];
+
export default function PostProgress({ subtab, onBack }) {
const navigate = useNavigate();
+ const goToProgress = (id) => navigate(id === 'sessions' ? '/post/progress/sessions' : '/post/progress');
const chartColors = useChartColors();
const [progress, setProgress] = useState(null);
const [range, setRange] = useState(90);
@@ -143,7 +150,7 @@ export default function PostProgress({ subtab, onBack }) {
if (subtab === 'sessions') {
return (
<div className="space-y-4">
- <ProgressTabs subtab="sessions" navigate={navigate} />
+ <ProgressTabs subtab="sessions" onChange={goToProgress} />
<PostHistory onBack={onBack} />
</div>
);
@@ -182,7 +189,7 @@ export default function PostProgress({ subtab, onBack }) {
</div>
</div>
- <ProgressTabs subtab={undefined} navigate={navigate} />
+ <ProgressTabs subtab={undefined} onChange={goToProgress} />
{loaded && !hasAny && (
<div className="bg-port-card border border-port-border rounded-lg text-center text-gray-500 py-12 text-sm">
@@ -470,28 +477,15 @@ const RETENTION_STATE_LABEL = {
permanent: 'mastered permanently',
};
-function ProgressTabs({ subtab, navigate }) {
- const tabs = [
- // Trends is the bare `/post/progress`, so it has no sub-route id.
- { id: undefined, label: 'Trends', to: '/post/progress' },
- ...PROGRESS_SUBROUTES.map(t => ({ ...t, to: `/post/progress/${t.id}` })),
- ];
+function ProgressTabs({ subtab, onChange }) {
return (
- <div className="flex gap-1 border-b border-port-border">
- {tabs.map(t => (
- <button
- key={t.label}
- onClick={() => navigate(t.to)}
- className={`px-4 py-2 text-sm transition-colors border-b-2 -mb-px ${
- subtab === t.id
- ? 'border-port-accent text-white'
- : 'border-transparent text-gray-500 hover:text-white'
- }`}
- >
- {t.label}
- </button>
- ))}
- </div>
+ <TabPills
+ tabs={PROGRESS_TABS}
+ activeTab={subtab === 'sessions' ? 'sessions' : 'trends'}
+ onChange={onChange}
+ mobileCompact
+ ariaLabel="Progress sections"
+ />
);
}
diff --git a/client/src/components/writers-room/WorkEditor.jsx b/client/src/components/writers-room/WorkEditor.jsx
index 52ef27d07e..afc9a86f24 100644
--- a/client/src/components/writers-room/WorkEditor.jsx
+++ b/client/src/components/writers-room/WorkEditor.jsx
@@ -26,6 +26,7 @@ import {
Quote,
} from 'lucide-react';
import toast from '../ui/Toast';
+import TabPills from '../ui/TabPills';
import ProseEditor from '../ui/ProseEditor';
import Drawer from '../Drawer';
import UnsavedChangesConfirm from '../ui/UnsavedChangesConfirm';
@@ -69,6 +70,10 @@ import { modKey } from '../../utils/platform';
const ANALYSIS_KIND = { SCRIPT: 'script', CHARACTERS: 'characters', PLACES: 'places', OBJECTS: 'objects', EVALUATE: 'evaluate', FORMAT: 'format' };
const DRAWER = { VERSIONS: 'versions', HISTORY: 'history', POLISH: 'polish', VOICE: 'voice' };
const MOBILE_TAB = { WRITING: 'writing', STORYBOARD: 'storyboard' };
+const MOBILE_TABS = [
+ { id: MOBILE_TAB.WRITING, label: 'Writing', icon: PenLine },
+ { id: MOBILE_TAB.STORYBOARD, label: 'Storyboard', icon: Clapperboard },
+];
// The three prose surfaces the header toggles between. Declared once so the
// toggle group stays a map instead of three hand-copied buttons.
@@ -892,10 +897,17 @@ export default function WorkEditor({ work, onChange, onToggleExercise, exerciseO
Review mode is a full-width surface with no storyboard sidebar, so the
toggle is irrelevant there. */}
{viewMode !== 'review' && (
- <div className="lg:hidden flex border-b border-port-border bg-port-bg/40 shrink-0">
- <MobileTab active={mobileTab === MOBILE_TAB.WRITING} onClick={() => setMobileTab(MOBILE_TAB.WRITING)} icon={PenLine} label="Writing" />
- <MobileTab active={mobileTab === MOBILE_TAB.STORYBOARD} onClick={() => setMobileTab(MOBILE_TAB.STORYBOARD)} icon={Clapperboard} label="Storyboard" />
- </div>
+ <TabPills
+ tabs={MOBILE_TABS}
+ activeTab={mobileTab}
+ onChange={setMobileTab}
+ variant="underline"
+ stretch
+ size="sm"
+ mobileCompact
+ ariaLabel="Writing or storyboard"
+ className="lg:hidden shrink-0"
+ />
)}
{/*
@@ -1163,15 +1175,3 @@ function AnalysisRunBanner({ kind, label, startedAt }) {
);
}
-function MobileTab({ active, onClick, icon: Icon, label }) {
- return (
- <button
- onClick={onClick}
- className={`flex-1 flex items-center justify-center gap-1.5 py-2 min-h-[44px] text-[12px] border-b-2 ${
- active ? 'border-port-accent text-white' : 'border-transparent text-gray-500 hover:text-gray-300'
- }`}
- >
- <Icon size={13} /> {label}
- </button>
- );
-}
diff --git a/client/src/pages/Sharing.jsx b/client/src/pages/Sharing.jsx
index cf296017b1..2c6cab9a23 100644
--- a/client/src/pages/Sharing.jsx
+++ b/client/src/pages/Sharing.jsx
@@ -8,7 +8,7 @@
*/
import { useEffect, useState } from 'react';
-import { useParams, useNavigate, Link } from 'react-router';
+import { useParams, useNavigate } from 'react-router';
import {
Share2, Plus, Trash2, Folder, Inbox, History, Save, Loader2, Check, X, Users, AlertCircle, RefreshCw, Copy, GitMerge,
} from 'lucide-react';
@@ -30,6 +30,8 @@ import {
} from '../services/api';
import { getPageNavTabs } from '../../../server/lib/navManifest.js';
import { buildPageNavTabs } from '../lib/pageNavTabs.js';
+import RouteTabsHeader from '../components/ui/RouteTabsHeader';
+import TabPills from '../components/ui/TabPills';
const emptyForm = () => ({ name: '', path: '', mode: 'inbox', displayNameOverride: '', bioOverride: '' });
@@ -65,6 +67,12 @@ export const SECTIONS = buildPageNavTabs(getPageNavTabs('sharing'), SECTION_PRES
// browser back/forward — a stale/hand-edited value degrades to Inbox.
export const BUCKET_TAB_IDS = ['inbox', 'activity', 'settings'];
+const BUCKET_TABS = [
+ { id: 'inbox', label: 'Inbox', icon: Inbox },
+ { id: 'activity', label: 'Activity', icon: History },
+ { id: 'settings', label: 'Settings', icon: Save },
+];
+
function SharingHeader({ active }) {
return (
<>
@@ -72,21 +80,9 @@ function SharingHeader({ active }) {
<Share2 className="w-6 h-6 text-port-accent" />
<h1 className="text-2xl font-bold text-white">Sharing</h1>
</div>
- <nav className="flex items-center gap-1 mb-6 border-b border-port-border">
- {SECTIONS.map(({ id, label, icon: Icon, to }) => (
- <Link
- key={id}
- to={to}
- className={`inline-flex items-center gap-2 px-3 py-2 text-sm border-b-2 -mb-px ${
- active === id
- ? 'border-port-accent text-white'
- : 'border-transparent text-gray-400 hover:text-white'
- }`}
- >
- <Icon size={14} /> {label}
- </Link>
- ))}
- </nav>
+ <div className="mb-6">
+ <RouteTabsHeader tabs={SECTIONS} activeTab={active} ariaLabel="Sharing sections" />
+ </div>
</>
);
}
@@ -508,12 +504,19 @@ function SharingBuckets({ selectedId }) {
</div>
) : (
<div>
- {/* Tabs */}
- <div className="flex gap-1 mb-3 border-b border-port-border">
- <TabButton active={activeTab === 'inbox'} onClick={() => setActiveTab('inbox')} icon={Inbox} label="Inbox" count={(inboxByBucket[selected.id] || []).length} />
- <TabButton active={activeTab === 'activity'} onClick={() => setActiveTab('activity')} icon={History} label="Activity" />
- <TabButton active={activeTab === 'settings'} onClick={() => setActiveTab('settings')} icon={Save} label="Settings" />
- </div>
+ <TabPills
+ tabs={BUCKET_TABS.map((tab) => (
+ tab.id === 'inbox'
+ ? { ...tab, count: (inboxByBucket[selected.id] || []).length }
+ : tab
+ ))}
+ activeTab={activeTab}
+ onChange={setActiveTab}
+ size="sm"
+ mobileCompact
+ ariaLabel="Bucket views"
+ className="mb-3"
+ />
{activeTab === 'inbox' && (
<Inboxlist
@@ -544,22 +547,6 @@ function SharingBuckets({ selectedId }) {
);
}
-function TabButton({ active, onClick, icon: Icon, label, count }) {
- return (
- <button
- type="button"
- onClick={onClick}
- className={`inline-flex items-center gap-1.5 px-3 py-1.5 text-xs ${active ? 'border-b-2 border-port-accent text-white' : 'border-b-2 border-transparent text-gray-400 hover:text-white'}`}
- >
- <Icon size={12} />
- {label}
- {typeof count === 'number' && count > 0 ? (
- <span className="inline-flex items-center justify-center min-w-[16px] px-1 py-0 rounded-full bg-port-accent text-[10px] text-white">{count}</span>
- ) : null}
- </button>
- );
-}
-
function Inboxlist({ bucket, items, onPromote, onDismiss }) {
if (bucket.mode === 'auto-merge') {
return (
diff --git a/client/src/pages/StoryBuilder.jsx b/client/src/pages/StoryBuilder.jsx
index 06836ab032..98248bbbb9 100644
--- a/client/src/pages/StoryBuilder.jsx
+++ b/client/src/pages/StoryBuilder.jsx
@@ -15,7 +15,7 @@ import StyleProbeImage from '../components/universe/StyleProbeImage';
import ProviderModelSelector from '../components/ProviderModelSelector';
import {
Sparkles, Lock, Unlock, Check, ChevronRight, ChevronLeft, AlertTriangle,
- Plus, RefreshCw, Loader2, ExternalLink, Wand2, Cloud, CloudOff,
+ Plus, RefreshCw, Loader2, ExternalLink, Wand2, Cloud, CloudOff, Lightbulb, FileInput,
} from 'lucide-react';
import toast from '../components/ui/Toast';
import Banner from '../components/ui/Banner';
@@ -37,6 +37,7 @@ import { getCatalogType, payloadSnippet } from '../lib/catalogTypes';
import { useCatalogTypes } from '../hooks/useCatalogTypes.jsx';
import useDrawerTab from '../hooks/useDrawerTab';
import useStoryImportIntake from '../hooks/useStoryImportIntake';
+import TabPills from '../components/ui/TabPills';
// Bible fields the embedded arc step flushes before an ArcCanvas generate/verify.
// The Story Builder edits these on their own steps (not inside the arc step), so
@@ -47,6 +48,10 @@ const ARC_FLUSH_FIELDS = ['name', 'logline', 'premise', 'styleNotes', 'issueCoun
// Intake tabs on the index view. The active one lives in `?intake=` (via
// useDrawerTab) rather than local state so it's shareable and reload-safe.
const INTAKE_TABS = ['seed', 'import'];
+const INTAKE_TAB_ITEMS = [
+ { id: 'seed', label: 'Start from an idea', icon: Lightbulb },
+ { id: 'import', label: 'Import a finished work', icon: FileInput },
+];
const CONTENT_TYPE_LABELS = {
'short-story': 'Short story', novel: 'Novel', screenplay: 'Screenplay', 'comic-script': 'Comic script',
@@ -240,10 +245,6 @@ function StoryBuilderIndex() {
// away the pasted manuscript and the minute-long analysis preview (#3904).
const intake = useStoryImportIntake(onCreated);
- const tabClass = (id) => `px-4 py-2 text-sm rounded-t border-b-2 ${
- mode === id ? 'border-port-accent text-white' : 'border-transparent text-gray-400 hover:text-gray-200'
- }`;
-
return (
// Wide two-column shell above lg: create form left, "Continue a story" list
// right (mirrors the POST launcher redesign, #1986). Below lg the grid
@@ -263,10 +264,14 @@ function StoryBuilderIndex() {
<div className="grid grid-cols-1 lg:grid-cols-[minmax(0,1fr)_22rem] gap-6 items-start">
<section className="bg-port-card border border-port-border rounded-lg">
- <div className="flex gap-1 border-b border-port-border px-2 pt-2">
- <button onClick={() => setMode('seed')} className={tabClass('seed')}>Start from an idea</button>
- <button onClick={() => setMode('import')} className={tabClass('import')}>Import a finished work</button>
- </div>
+ <TabPills
+ tabs={INTAKE_TAB_ITEMS}
+ activeTab={mode}
+ onChange={setMode}
+ mobileCompact
+ ariaLabel="How to start"
+ className="px-2 pt-2"
+ />
{mode === 'seed' ? (
<div className="p-4 space-y-3">
diff --git a/client/src/pages/SystemHealthPage.jsx b/client/src/pages/SystemHealthPage.jsx
index 0c85f5d992..481bb74bba 100644
--- a/client/src/pages/SystemHealthPage.jsx
+++ b/client/src/pages/SystemHealthPage.jsx
@@ -1,5 +1,5 @@
import { useEffect, useState, useRef } from 'react';
-import { Link, Navigate, NavLink, useParams } from 'react-router';
+import { Link, Navigate, useParams } from 'react-router';
import { Activity, AlertTriangle, HardDrive, Cpu, Database, ListOrdered, RefreshCw, ServerCog, X, Zap } from 'lucide-react';
import * as api from '../services/api';
import toast from '../components/ui/Toast';
@@ -14,6 +14,7 @@ import MediaCapacityPanel from '../components/system-resources/MediaCapacityPane
import BuildStampPanel from '../components/system-resources/BuildStampPanel.jsx';
import { getPageNavTabs } from '../../../server/lib/navManifest.js';
import { buildPageNavTabs } from '../lib/pageNavTabs.js';
+import RouteTabsHeader from '../components/ui/RouteTabsHeader';
import { HEALTH_STYLE, pctTone, barTone, resolveHealthThresholds } from '../lib/healthStyle.js';
// Every alert names its own next step. The server tags each warning with a
@@ -75,19 +76,9 @@ export default function SystemResourcesPage() {
</p>
</div>
</div>
- <nav aria-label="System resources sections" className="mt-5 grid grid-cols-3 border-b border-port-border sm:flex sm:gap-1">
- {RESOURCE_TABS.map(({ id, label, icon: Icon }) => (
- <NavLink
- key={id}
- to={`/system-resources/${id}`}
- className={({ isActive }) => `flex min-h-[40px] items-center justify-center gap-1 border-b-2 px-1 py-2 text-xs transition-colors sm:shrink-0 sm:gap-1.5 sm:px-3 sm:text-sm ${
- isActive ? 'border-port-accent text-white' : 'border-transparent text-gray-500 hover:text-gray-200'
- }`}
- >
- <Icon size={14} /> {label}
- </NavLink>
- ))}
- </nav>
+ <div className="mt-5">
+ <RouteTabsHeader tabs={RESOURCE_TABS} activeTab={tab} ariaLabel="System resources sections" />
+ </div>
</header>
{tab === 'overview' && <SystemHealthOverview />}
diff --git a/client/src/pages/SystemHealthPage.test.jsx b/client/src/pages/SystemHealthPage.test.jsx
index bf309cd2a7..a577d514c0 100644
--- a/client/src/pages/SystemHealthPage.test.jsx
+++ b/client/src/pages/SystemHealthPage.test.jsx
@@ -188,7 +188,7 @@ describe('SystemHealthPage remediation links', () => {
});
renderPage('/system-resources/storage');
- expect(screen.getByRole('link', { name: /Storage/ })).toHaveAttribute('href', '/system-resources/storage');
+ expect(screen.getByRole('tab', { name: /Storage/ })).toHaveAttribute('aria-selected', 'true');
expect(api.runSystemResourceReport).not.toHaveBeenCalled();
fireEvent.click(screen.getByRole('button', { name: 'Run system report' }));
await waitFor(() => expect(api.runSystemResourceReport).toHaveBeenCalledWith({ silent: true }));
diff --git a/client/src/subNavConventions.test.js b/client/src/subNavConventions.test.js
new file mode 100644
index 0000000000..d4bf47860e
--- /dev/null
+++ b/client/src/subNavConventions.test.js
@@ -0,0 +1,89 @@
+/**
+ * Repo-wide sub-nav convention.
+ *
+ * `client/src/AGENTS.md` requires a section sub-nav that doesn't fit a phone
+ * to collapse to icon links via `TabPills.mobileCompact`, not a `<select>` and
+ * not a hand-rolled underline bar. Every bar that already routes through
+ * `TabPills` gets that treatment; the failure mode this guard catches is a new
+ * `<nav>`/`<div>` that maps a tab array onto `border-b-2`-styled buttons or
+ * `Link`s and so ships a third answer to "what does a sub-nav do on a phone".
+ *
+ * The rule is deliberately blunt: **no `border-b-2` in a class string** under
+ * `src/` except in the primitive itself and an allowlisted file carrying a
+ * one-line reason. TabPills owns that underline token; a caller that needs it
+ * is a caller that should be a TabPills. Unbounded record switchers (shell
+ * sessions, manuscript issues, Beeper accounts) do not use this token and so
+ * do not match — they are not section sub-navs.
+ *
+ * Scoped to git-tracked non-test sources under `client/src`. Comments are
+ * masked first: a doc comment quoting `border-b-2` is documentation, not markup.
+ */
+
+import { describe, it, expect } from 'vitest';
+import { readFileSync } from 'fs';
+import { join, dirname } from 'path';
+import { fileURLToPath } from 'url';
+import { trackedSourceFiles } from './test/trackedFiles.js';
+import { lineOf, maskComments, stringLiterals } from './test/classNameScan.js';
+
+const CLIENT_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
+
+/**
+ * Files allowed to carry `border-b-2`, each with the reason it is not a
+ * section sub-nav. Adding a row is the point at which to ask whether TabPills
+ * fits instead.
+ */
+const ALLOWED = new Map([
+ [
+ 'src/components/ui/TabPills.jsx',
+ 'the primitive this guard exists to funnel callers into',
+ ],
+ [
+ 'src/components/pipeline/manuscript/ManuscriptHighlightedProse.jsx',
+ 'underline on comment-anchored prose, not a section sub-nav',
+ ],
+ [
+ 'src/components/pipeline/manuscript/ManuscriptLiveSection.jsx',
+ 'same comment-anchor underline in the live editor',
+ ],
+]);
+
+const BORDER_TOKEN = /(?:^|[\s'"`{])border-b-2(?=[\s'"`}]|$)/;
+
+function violationsIn(rawSource, file) {
+ const source = maskComments(rawSource);
+ return stringLiterals(source)
+ .filter(({ value }) => BORDER_TOKEN.test(value))
+ .map(({ value, index }) => `${file}:${lineOf(source, index)} — "${value.trim()}"`);
+}
+
+const findViolations = (file) =>
+ violationsIn(readFileSync(join(CLIENT_ROOT, file), 'utf8'), file);
+
+describe('sub-nav conventions', () => {
+ const files = trackedSourceFiles(CLIENT_ROOT);
+
+ it('scans a populated client tree', () => {
+ expect(files.length).toBeGreaterThan(100);
+ });
+
+ it('flags a hand-rolled border-b-2 tab strip and clears the primitive', () => {
+ const flagged = (markup) => violationsIn(markup, 'probe.jsx').length;
+ expect(flagged('<button className="px-4 py-2 border-b-2 border-port-accent">Overview</button>')).toBe(1);
+ expect(flagged('<Link className={`inline-flex border-b-2 ${active ? "border-port-accent" : "border-transparent"}`} />')).toBe(1);
+ expect(flagged('<button className="px-4 py-2 border-b border-port-border">Overview</button>')).toBe(0);
+ expect(violationsIn('// e.g. "border-b-2 border-port-accent"', 'probe.jsx')).toEqual([]);
+ });
+
+ it('never hand-rolls a border-b-2 tab strip outside TabPills', () => {
+ const violations = files
+ .filter((file) => !ALLOWED.has(file))
+ .flatMap((file) => findViolations(file));
+ expect(violations).toEqual([]);
+ });
+
+ it('keeps the allowlist honest — every exempt file still has the underline it was exempted for', () => {
+ const stale = [...ALLOWED.keys()].filter((file) => findViolations(file).length === 0);
+ expect(stale).toEqual([]);
+ });
+});
diff --git a/client/src/test/classNameScan.js b/client/src/test/classNameScan.js
index c8827e8410..7d2cad1135 100644
--- a/client/src/test/classNameScan.js
+++ b/client/src/test/classNameScan.js
@@ -1,12 +1,13 @@
/**
* Shared string-literal scanner for the class-string convention guards.
*
- * `src/responsiveGridConventions.test.js` and `src/popoverClampConventions.test.js`
- * both enforce a narrow-viewport rule by reading every quoted string in the client
- * tree and inspecting the Tailwind tokens inside it. They need the same two
- * primitives — blank out comments so a doc block quoting an example class isn't
- * scanned as markup, then walk the remaining string literals — so those live here
- * once rather than being copied into each guard.
+ * `src/responsiveGridConventions.test.js`, `src/popoverClampConventions.test.js`,
+ * and `src/subNavConventions.test.js` all enforce a class-string convention by
+ * reading every quoted string in the client tree and inspecting the Tailwind
+ * tokens inside it. They need the same two primitives — blank out comments so a
+ * doc block quoting an example class isn't scanned as markup, then walk the
+ * remaining string literals — so those live here once rather than being copied
+ * into each guard.
*
* Node-only consumers (test files) exclusively; kept in `src/test/` for the same
* reason as `trackedFiles.js` — `lib/` carries the enforced barrel + README rule
diff --git a/scripts/ci-test-plan.js b/scripts/ci-test-plan.js
index 74c41fbc81..b743d22646 100644
--- a/scripts/ci-test-plan.js
+++ b/scripts/ci-test-plan.js
@@ -392,7 +392,7 @@ const structuralTestsFor = (changedFiles, trackedSet) => {
// reached its widest blast radius through a plain-`.js` hook (`useAsyncAction`),
// so a `.jsx`-only trigger would miss the case that matters most, and the
// responsive-grid, popover-clamp, pre-wrap/break, safe-storage,
- // heading-truncation, and global-shadow guards read class strings, storage
+ // heading-truncation, sub-nav, and global-shadow guards read class strings, storage
// accesses, declarations, and JSX markup out of both extensions.
// None of these files has a source sibling or imports an app module, so nothing
// else selects them — without this entry they only ever run on a full suite.
@@ -406,6 +406,7 @@ const structuralTestsFor = (changedFiles, trackedSet) => {
add('client/src/preWrapClasses.test.js');
add('client/src/responsiveGridConventions.test.js');
add('client/src/storageConventions.test.js');
+ add('client/src/subNavConventions.test.js');
}
return selected;
diff --git a/scripts/repo-scan-guards.test.js b/scripts/repo-scan-guards.test.js
index d2d190477a..c7ba24a4bc 100644
--- a/scripts/repo-scan-guards.test.js
+++ b/scripts/repo-scan-guards.test.js
@@ -63,6 +63,7 @@ const STRUCTURALLY_SELECTED = new Map([
['client/src/preWrapClasses.test.js', 'structuralTestsFor: client/src/**.js(x)'],
['client/src/responsiveGridConventions.test.js', 'structuralTestsFor: client/src/**.js(x)'],
['client/src/storageConventions.test.js', 'structuralTestsFor: client/src/**.js(x)'],
+ ['client/src/subNavConventions.test.js', 'structuralTestsFor: client/src/**.js(x)'],
// `.ps1` is not in EXECUTABLE_RE, so touching one is an "unclassified changed
// file" and forces the complete suite. The guard also rides the Windows
// contract list.