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
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
refactor([extract-a-shared-tabpills-primitive-in-client-src]): TabPills primitive — consolidate 10 tab-nav sites (#293)
[._.]/ Adam Eivy9527302061ab
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 86f92b88c9..70639df9f8 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -25,6 +25,7 @@## Refactors+- **`TabPills` UI primitive (`client/src/components/ui/TabPills.jsx`).** Consolidates ten duplicated tab-nav patterns — two local `TabNav` components (UniverseBuilder, StoryboardPanel) plus eight inline tab-button blocks (Brain, Calendar, ChiefOfStaff, DigitalTwin, MediaGen, Messages, Settings, Wiki). Two variants (`underline` default, `pills`) with knobs for the call-site quirks (`runningKind` per-tab spinner, `stretch` flex-1 equal-width, `mobileDropdown` `<select>` fallback, `hideLabelOnMobile` icon-only at < sm, `controlsIdPrefix` for `aria-controls` wiring, `listRef`+`onScroll` for ChiefOfStaff's scroll-arrow overlay). Covered by 7 vitest cases. Minor intentional visual unification across the surface area: StoryboardPanel active tab text-port-accent (was text-white), ChiefOfStaff and Settings gained the standard `bg-port-accent/5` active wash + `hover:bg-port-card` inactive.- **CoS — explicit `init()` instead of module-level auto-init.** `server/services/cos.js` previously called `init()` at the bottom of the module, gated by `NODE_ENV !== 'test' && VITEST !== 'true'` so unit tests didn't spin up listeners/timers. The guard was a "test hack in the prod boot path" — `init` is now exported and called explicitly from `server/index.js` alongside `automationScheduler.init()` / `agentActionExecutor.init()` / etc. Test imports of `cos.js` no longer have side effects, and the prod boot path no longer branches on test-env vars.- **`LoraPicker` extracted** (`client/src/components/imageGen/LoraPicker.jsx`). The LoRA multi-select previously inlined in `ImageGen.jsx` is now a shared component used by both the standalone Image Gen page and the Universe Builder batch-render form.- **`ImageGenSettingsForm` extended** with `showLoras` + `showStylePreset` props (mounts `LoraPicker` / `StylePresetPicker`) and the previously-hidden CFG / quantize / model-defaults reset.diff --git a/DONE.md b/DONE.mdindex be53a836c7..170eb2b31d 100644--- a/DONE.md+++ b/DONE.md@@ -8,6 +8,7 @@ For active roadmap see [PLAN.md](./PLAN.md). For project goals see [GOALS.md](./## 2026-05+- **[extract-a-shared-tabpills-primitive-in-client-src] Extract a shared `<TabPills>` primitive in `client/src/components/ui/`.** New `client/src/components/ui/TabPills.jsx` with two variants (`underline` default + `pills` for UniverseBuilder) and knobs for the call-site quirks: `runningKind` (StoryboardPanel's per-tab spinner), `stretch` (flex-1 equal-width tabs), `mobileDropdown` (UniverseBuilder's `<select>` fallback), `hideLabelOnMobile` (Brain/DigitalTwin/ChiefOfStaff icon-only at < sm), `controlsIdPrefix` (ChiefOfStaff's `aria-controls` wiring), `listRef`+`onScroll` (ChiefOfStaff's scroll-arrow overlay). Migrated ten call sites — two local `TabNav` components (UniverseBuilder, StoryboardPanel) plus eight inline tab-button blocks (Brain, Calendar, ChiefOfStaff, DigitalTwin, MediaGen, Messages, Settings, Wiki). Net -250+ LOC consolidated into one primitive + 7 vitest cases. Small intentional visual unification across the surface area: StoryboardPanel active text-white → text-port-accent, ChiefOfStaff/Settings gained the standard `bg-port-accent/5` active wash + `hover:bg-port-card` inactive. PipelineIssue's status-dot tab variant is captured in PLAN.md as a follow-up needing a `trailing` slot extension on the primitive.- **[unify-canoncard-variation-card-into-a-single] Universe Builder — unify CanonCard + variation card into shared `EntryCard` shell.** New `client/src/components/universe/EntryCard.jsx` slot-based primitive (locked accent, title row, body, action column, optional thumbnail, optional footer). `CanonCard` now renders through it and surfaces a top-left thumbnail derived from `primaryImageRef` (falling back to the first `imageRefs[0]`) so each canon entry has a visual at-a-glance. The variation `<li>` in `CategoryEditor` is extracted into a `VariationCard` helper that also renders through `EntryCard` — view mode shows label + prompt + action column (promote / render / lock / edit / remove); edit mode swaps the body for an inline form. Visual consistency between the two card families now flows from the shared shell rather than parallel Tailwind class strings.- **[client-component-tests-for-categoryeditor-promote] Client component tests for `CategoryEditor` + `TrunkView`.** Wired up the first vitest-based client test suite (vitest 3 + jsdom + @testing-library/react + user-event) — new `client/vitest.config.js`, `client/src/test/setup.js`, `test` + `test:watch` scripts in `client/package.json`, CI step in `.github/workflows/ci.yml`. Named-exported `CategoryEditor` and `TrunkView` from `client/src/pages/UniverseBuilder.jsx` and added `client/src/pages/UniverseBuilder.test.jsx` covering: promote button disabled when `!canPromote` (parent's `!selectedId`); promote fires directly with no targetKind for a kinded bucket; clicking promote on a `bucketKind: null` ("other") variation opens the trunk picker; clicking a picker option calls `onPromote(variation, { targetKind })` with the correct kind; `TrunkView` "Bulk-render all" button disabled at zero count and enabled with the right count from variations. Three pre-existing orphaned client tests (`cleanPlatePrompt`, `clipboard`, `normalize`) now run too.- **CoS — explicit `init()` instead of module-level auto-init.** Dropped the `NODE_ENV !== 'test' && VITEST !== 'true'` guard from `server/services/cos.js`; `init` is now exported and called from `server/index.js` alongside the other startup `*.init()` calls. Test imports no longer spin up event listeners / timers as a side effect, and the prod boot path no longer branches on test-env vars.diff --git a/PLAN.md b/PLAN.mdindex 077b54e07c..3793ab066c 100644--- a/PLAN.md+++ b/PLAN.md@@ -13,7 +13,6 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [DONE.md]- **Phase D — Polish & promotion.** ~~"Promote variation to canon" action~~ shipped: `POST /api/universe-builder/:id/promote-variation` LLM-expands a `{label, prompt}` variation into a full canon entry (per-kind `physicalDescription` / `slugline`+`palette` / `description`+`significance`) and atomically writes the canon append + variation removal in one `updateUniverse` patch. CategoryEditor renders a promote button per row; Other-tab buckets open a trunk picker (since `kind: 'other'` can't be auto-resolved). Duplicate-name collisions short-circuit with a 409 before the LLM call. Deferred: client component tests; standalone design doc (not warranted — CLAUDE.md notes + this PR's prose cover the contract).- **Phase C follow-ups (deferred from the Phase C PR):**- [ ] [auto-sort-with-ai-llm-classify-each-kind-other] **Auto-sort with AI** — LLM-classify each `kind: 'other'` bucket into characters/settings/objects + suggest a meaningful name. New server route `POST /api/universe-builder/:id/auto-sort` that sends bucket keys + variation labels to the active LLM and applies the classification. Currently the Other-tab button is a stub that points users at re-running Generate From Idea (Phase B's expand emits kind tags). Land in a follow-up to keep the Phase C PR scoped.- - [ ] [extract-a-shared-tabpills-primitive-in-client-src] **Extract a shared `<TabPills>` primitive in `client/src/components/ui/`.** Phase C's `TabNav` in `UniverseBuilder.jsx` duplicates the pattern in `StoryboardPanel.jsx` `TabNav` + 5 inline tab-button pages (`Calendar.jsx`, `ChiefOfStaff.jsx`, `DigitalTwin.jsx`, `Messages.jsx`, etc.). One primitive that accepts `{ tabs: [{id,label,icon,count}], activeTab, onChange }` would consolidate. Cross-cutting refactor — defer until next time we touch tab UI somewhere.- [ ] [extract-descriptorforcanonentry-kind-entry-into] **Extract `descriptorForCanonEntry(kind, entry)` into `server/lib/canonPrompt.js` (mirror in client).** The new server-side `synthesizeCanonPrompt()` in `server/services/universeBuilder.js` duplicates the per-kind descriptor logic already present in `client/src/components/universe/UniverseCanonSection.jsx`'s `KINDS[].descFor` closures and overlaps with `server/lib/scenePrompt.js` (`settingFrags`). One helper would let canon-render synthesis, the canon UI summary, and scene-prompt framing all share the same field-precedence rules.2. **Step-by-step approval/lock UX across Universe → Series → Arc → Seasons → Episodes.** Iteration 1 shipped a single arc-level lock; extend to per-season + per-field locks, lock the bulk runners, surface stage-progress strip, enforce locks server-side before LLM invocations.3. **Sharing v2 contracts** — per-peer subscription filenames (`sub-<kind>-<recordId>-<senderInstanceId>.json`), tombstone-based item removals, "🔄 live" badge on inbox subscription rows.@@ -87,6 +86,7 @@ For project goals, see [GOALS.md](./GOALS.md). For completed work, see [DONE.md]### Code quality / dedup (from `/simplify` passes)+- [ ] [tabpills-pipelineissue-status-dot-trailing-slot] **Extend `<TabPills>` with a `trailing` slot to migrate `PipelineIssue.jsx`.** That page's tab row renders a per-tab status dot (`<span className="w-1.5 h-1.5 rounded-full ${STATUS_DOT[status]}" />`) after the label (see `client/src/pages/PipelineIssue.jsx:298-319`). Add an optional `t.trailing` ReactNode to the tab shape (rendered after the count), then migrate the call site. Defer until the next time a tab-bar variant lands so the API surface grows in response to a concrete second user, not in anticipation.- [ ] [more-resolveproviderandmodel-migration-candidates] **More `resolveProviderAndModel` migration candidates.** When the helper landed in `server/lib/promptRunner.js` (universe-builder PR), three additional pure two-step provider-resolution chains were left alone to keep scope tight: `server/services/agentContentGenerator.js#runAIGeneration` (line ~80–90), `server/services/agentPersonalityGenerator.js` (line ~68–79), `server/services/loops.js` (line ~64–77). All three are textbook fits (no `enabled` gate, no typed-error throw mid-chain). Migration is one-import + 5-line collapse per file.- [ ] [extract-assertprovider-provider-errormessage-code] **Extract `assertProvider(provider, { errorMessage, code, status })` helper.** After the `resolveProviderAndModel` migration there are now 4 `if (!provider) throw …` sites with varying error shapes (`Error` vs `ServerError`, `status: 400/503`, codes `NO_PROVIDER`/`UNIVERSE_PROMOTE_NO_PROVIDER`/etc.). One helper that takes the error-shape args would consolidate without forcing each caller to share the same error type.- [ ] [extract-mergeexpandintodraft-draft-result-from] **Extract `mergeExpandIntoDraft(draft, result)` from `UniverseBuilder.jsx#handleExpand`.** The function is ~150 lines mixing pure-merge logic (categories, sheets, canon, locks) with I/O shell (API call, setDraft, auto-save, toast). Pull the merge into a top-level pure helper so the I/O surface shrinks and the merge is unit-testable. Deferred from Phase B `/simplify` to keep that PR tightly scoped.diff --git a/client/src/components/ui/TabPills.jsx b/client/src/components/ui/TabPills.jsxnew file mode 100644index 0000000000..f3adca9389--- /dev/null+++ b/client/src/components/ui/TabPills.jsx@@ -0,0 +1,155 @@+// Shared tab-nav primitive. Two visual families: `underline` (default — flat+// bottom border with port-accent marker; used across page-level tabs) and+// `pills` (rounded card with internal pill rows; used by UniverseBuilder).+// Knobs cover the call-site quirks: `runningKind` swaps a per-tab icon for a+// spinner; `stretch` makes each tab `flex-1` (StoryboardPanel); `mobileDropdown`+// collapses to a `<select>` below `sm` (UniverseBuilder); `controlsIdPrefix`+// wires `aria-controls` (and `id="tab-<id>"`) to matching tabpanels — pass+// `'tabpanel'` to mirror ChiefOfStaff's wiring.+import { Loader2 } from 'lucide-react';++const SIZE = {+ xs: { text: 'text-[11px]', icon: 11, padding: 'px-2 py-2', gap: 'gap-1' },+ sm: { text: 'text-sm', icon: 14, padding: 'px-3 py-1.5', gap: 'gap-1.5' },+ md: { text: 'text-sm', icon: 16, padding: 'px-3 sm:px-4 py-3', gap: 'gap-2' },+};++export default function TabPills({+ tabs,+ activeTab,+ onChange,+ variant = 'underline',+ size = 'md',+ stretch = false,+ runningKind = null,+ mobileDropdown = false,+ mobileSelectId,+ ariaLabel,+ controlsIdPrefix,+ hideLabelOnMobile = false,+ className = '',+ listRef,+ onScroll,+}) {+ const sz = SIZE[size] || SIZE.md;+ const visibleTabs = tabs.filter(Boolean);++ if (variant === 'pills') {+ return (+ <>+ {mobileDropdown && (+ <div className="sm:hidden">+ {mobileSelectId && <label htmlFor={mobileSelectId} className="sr-only">{ariaLabel || 'Section'}</label>}+ <select+ id={mobileSelectId}+ value={activeTab}+ onChange={(e) => onChange(e.target.value)}+ aria-label={mobileSelectId ? undefined : (ariaLabel || 'Section')}+ className="w-full bg-port-card border border-port-border rounded px-3 py-2 text-white text-sm focus:outline-none focus:border-port-accent min-h-[40px]"+ >+ {visibleTabs.map((t) => (+ <option key={t.id} value={t.id}>+ {t.label}{t.count != null && t.count > 0 ? ` (${t.count})` : ''}+ </option>+ ))}+ </select>+ </div>+ )}+ <div+ ref={listRef}+ onScroll={onScroll}+ className={`${mobileDropdown ? 'hidden sm:flex' : 'flex'} items-center gap-1 bg-port-card border border-port-border rounded p-1 overflow-x-auto ${className}`}+ role="tablist"+ aria-label={ariaLabel}+ >+ {visibleTabs.map((t) => {+ const Icon = t.icon;+ const active = t.id === activeTab;+ const running = runningKind && t.runningKind === runningKind;+ return (+ <button+ key={t.id}+ type="button"+ role="tab"+ aria-selected={active}+ aria-controls={controlsIdPrefix ? `${controlsIdPrefix}-${t.id}` : undefined}+ id={controlsIdPrefix ? `tab-${t.id}` : undefined}+ disabled={t.disabled}+ onClick={() => onChange(t.id)}+ className={`flex items-center ${sz.gap} ${sz.padding} rounded ${sz.text} transition-colors whitespace-nowrap ${+ active+ ? 'bg-port-accent/20 text-port-accent border border-port-accent/40'+ : 'text-gray-300 hover:bg-port-bg border border-transparent'+ } ${t.disabled ? 'opacity-50 cursor-not-allowed' : ''}`}+ >+ {running+ ? <Loader2 size={sz.icon} className="animate-spin shrink-0" />+ : (Icon && <Icon size={sz.icon} aria-hidden="true" />)}+ {t.label}+ {t.count != null && t.count > 0 && (+ <span className={`text-[10px] ${active ? 'text-port-accent/70' : 'text-gray-500'}`}>+ {t.count}+ </span>+ )}+ </button>+ );+ })}+ </div>+ </>+ );+ }++ // underline variant+ return (+ <div+ ref={listRef}+ onScroll={onScroll}+ className={`flex border-b border-port-border ${stretch ? 'items-stretch bg-port-bg/40 shrink-0' : 'gap-1'} overflow-x-auto scrollbar-hide ${className}`}+ role="tablist"+ aria-label={ariaLabel}+ >+ {visibleTabs.map((t) => {+ const Icon = t.icon;+ const active = t.id === activeTab;+ const running = runningKind && t.runningKind === runningKind;+ return (+ <button+ key={t.id}+ type="button"+ role="tab"+ aria-selected={active}+ aria-controls={controlsIdPrefix ? `${controlsIdPrefix}-${t.id}` : undefined}+ id={controlsIdPrefix ? `tab-${t.id}` : undefined}+ disabled={t.disabled}+ onClick={() => onChange(t.id)}+ title={hideLabelOnMobile ? t.label : undefined}+ className={`flex items-center ${stretch ? 'flex-1 min-w-0 justify-center' : 'shrink-0 justify-center'} ${sz.gap} ${sz.padding} ${sz.text} font-medium transition-colors whitespace-nowrap min-h-[44px] sm:min-h-[40px] border-b-2 -mb-px ${+ active+ ? 'text-port-accent border-port-accent bg-port-accent/5'+ : 'text-gray-400 border-transparent hover:text-white hover:bg-port-card'+ } ${t.disabled ? 'opacity-50 cursor-not-allowed' : ''}`}+ >+ {running+ ? <Loader2 size={sz.icon} className="animate-spin shrink-0" />+ : (Icon && <Icon size={sz.icon} aria-hidden="true" className="shrink-0" />)}+ {t.label && (stretch ? (+ <span className="truncate">{t.label}</span>+ ) : hideLabelOnMobile ? (+ <>+ <span className="hidden sm:inline">{t.label}</span>+ <span className="sr-only sm:hidden">{t.label}</span>+ </>+ ) : (+ <span>{t.label}</span>+ ))}+ {t.count != null && t.count > 0 && (+ <span className={`text-[10px] ${active ? 'text-port-accent/70' : 'text-gray-500'}`}>+ {t.count}+ </span>+ )}+ </button>+ );+ })}+ </div>+ );+}diff --git a/client/src/components/ui/TabPills.test.jsx b/client/src/components/ui/TabPills.test.jsxnew file mode 100644index 0000000000..c6cdef8642--- /dev/null+++ b/client/src/components/ui/TabPills.test.jsx@@ -0,0 +1,109 @@+import { describe, it, expect, vi } from 'vitest';+import { render, screen, within } from '@testing-library/react';+import userEvent from '@testing-library/user-event';+import { Users, MapPin, Package } from 'lucide-react';++import TabPills from './TabPills';++const sampleTabs = [+ { id: 'cast', label: 'Cast', icon: Users, count: 3 },+ { id: 'places', label: 'Places', icon: MapPin, count: 0 },+ { id: 'objects', label: 'Objects', icon: Package },+];++describe('TabPills — underline variant (default)', () => {+ it('renders one button per tab with role="tab" and aria-selected on the active one', () => {+ render(<TabPills tabs={sampleTabs} activeTab="places" onChange={() => {}} />);+ const tabs = screen.getAllByRole('tab');+ expect(tabs).toHaveLength(3);+ expect(tabs.find((t) => t.textContent.includes('Cast'))).toHaveAttribute('aria-selected', 'false');+ expect(tabs.find((t) => t.textContent.includes('Places'))).toHaveAttribute('aria-selected', 'true');+ });++ it('fires onChange with the tab id when a tab is clicked', async () => {+ const onChange = vi.fn();+ const user = userEvent.setup();+ render(<TabPills tabs={sampleTabs} activeTab="cast" onChange={onChange} />);+ await user.click(screen.getByRole('tab', { name: /Places/i }));+ expect(onChange).toHaveBeenCalledTimes(1);+ expect(onChange).toHaveBeenCalledWith('places');+ });++ it('shows the count next to the label when count > 0, hides it at 0 or undefined', () => {+ render(<TabPills tabs={sampleTabs} activeTab="cast" onChange={() => {}} />);+ const castBtn = screen.getByRole('tab', { name: /Cast/i });+ expect(within(castBtn).getByText('3')).toBeInTheDocument();+ const placesBtn = screen.getByRole('tab', { name: /Places/i });+ expect(within(placesBtn).queryByText('0')).not.toBeInTheDocument();+ });++ it('filters out falsy tab entries (so callers can use `cond && {...}`)', () => {+ const tabs = [+ { id: 'a', label: 'A' },+ false,+ null,+ { id: 'b', label: 'B' },+ ];+ render(<TabPills tabs={tabs} activeTab="a" onChange={() => {}} />);+ expect(screen.getAllByRole('tab')).toHaveLength(2);+ });++ it('wires aria-controls + button id when controlsIdPrefix is provided', () => {+ render(<TabPills tabs={sampleTabs} activeTab="cast" onChange={() => {}} controlsIdPrefix="tabpanel" />);+ const castBtn = screen.getByRole('tab', { name: /Cast/i });+ expect(castBtn).toHaveAttribute('id', 'tab-cast');+ expect(castBtn).toHaveAttribute('aria-controls', 'tabpanel-cast');+ });+});++describe('TabPills — pills variant', () => {+ it('renders a hidden mobile <select> with all labels when mobileDropdown is set', () => {+ render(+ <TabPills+ variant="pills"+ mobileDropdown+ mobileSelectId="ub-tab-select"+ tabs={sampleTabs}+ activeTab="cast"+ onChange={() => {}}+ />+ );+ const select = screen.getByRole('combobox');+ expect(select).toHaveAttribute('id', 'ub-tab-select');+ expect(select.value).toBe('cast');+ // Count appears in option text when present+ expect(within(select).getByRole('option', { name: /Cast \(3\)/i })).toBeInTheDocument();+ expect(within(select).getByRole('option', { name: 'Objects' })).toBeInTheDocument();+ });++ it('mobile <select> falls back to aria-label when mobileSelectId is omitted', () => {+ render(+ <TabPills+ variant="pills"+ mobileDropdown+ ariaLabel="Universe sections"+ tabs={sampleTabs}+ activeTab="cast"+ onChange={() => {}}+ />+ );+ // No <label> renders without an id, so the accessible name must come from aria-label+ const select = screen.getByRole('combobox', { name: 'Universe sections' });+ expect(select).toHaveAttribute('aria-label', 'Universe sections');+ expect(select).not.toHaveAttribute('id');+ });+});++describe('TabPills — runningKind', () => {+ it('swaps the icon for a spinner when a tab.runningKind matches the active runningKind', () => {+ const tabs = [+ { id: 'a', label: 'A', icon: Users, runningKind: 'fetch' },+ { id: 'b', label: 'B', icon: MapPin, runningKind: 'render' },+ ];+ const { container } = render(+ <TabPills tabs={tabs} activeTab="a" onChange={() => {}} runningKind="fetch" />+ );+ // Lucide renders an SVG with `lucide-loader-2` class on the spinner.+ expect(container.querySelector('.lucide-loader-2, .lucide-loader-circle')).toBeTruthy();+ });+});diff --git a/client/src/components/writers-room/StoryboardPanel.jsx b/client/src/components/writers-room/StoryboardPanel.jsxindex 67720ff317..49572647a9 100644--- a/client/src/components/writers-room/StoryboardPanel.jsx+++ b/client/src/components/writers-room/StoryboardPanel.jsx@@ -18,6 +18,7 @@ import { deriveAvailableBackends, IMAGE_GEN_MODE } from '../../lib/imageGenBackeimport { timeAgo } from '../../utils/formatters';import useMounted from '../../hooks/useMounted';import Drawer from '../Drawer';+import TabPills from '../ui/TabPills';import { ImageGenTab } from '../settings/ImageGenTab';import SceneCard from './SceneCard';import StagePromptModelPicker from './StagePromptModelPicker';@@ -270,15 +271,20 @@ export default function StoryboardPanel({return (<div className="flex flex-col h-full">- <TabNav- tab={tab}- setTab={setTab}+ <TabPills+ size="xs"+ stretch+ activeTab={tab}+ onChange={setTab}runningKind={runningKind}- charactersCount={characters.length}- settingsCount={settings.length}- objectsCount={objects.length}- scenesCount={scenesCount}- boardsCount={scenes.length}+ tabs={[+ { id: TAB.CHARACTERS, label: 'Characters', icon: Users, count: characters.length, runningKind: 'characters' },+ { id: TAB.WORLD, label: 'World', icon: MapPinIcon, count: settings.length, runningKind: 'settings' },+ { id: TAB.OBJECTS, label: 'Objects', icon: Package, count: objects.length, runningKind: 'objects' },+ { id: TAB.SCENES, label: 'Scenes', icon: ListTree, count: scenesCount },+ { id: TAB.BOARDS, label: 'Boards', icon: Clapperboard, count: scenes.length, runningKind: 'script' },+ { id: TAB.CONFIG, label: 'Config', icon: SlidersHorizontal },+ ]}/>{runningKind && (@@ -385,60 +391,6 @@ export default function StoryboardPanel({);}-function TabNav({- tab,- setTab,- runningKind,- charactersCount,- settingsCount,- objectsCount,- scenesCount,- boardsCount,-}) {- const tabs = [- { id: TAB.CHARACTERS, label: 'Characters', icon: Users, count: charactersCount, runningWhen: 'characters' },- { id: TAB.WORLD, label: 'World', icon: MapPinIcon, count: settingsCount, runningWhen: 'settings' },- { id: TAB.OBJECTS, label: 'Objects', icon: Package, count: objectsCount, runningWhen: 'objects' },- { id: TAB.SCENES, label: 'Scenes', icon: ListTree, count: scenesCount, runningWhen: null },- { id: TAB.BOARDS, label: 'Boards', icon: Clapperboard, count: boardsCount, runningWhen: 'script' },- { id: TAB.CONFIG, label: 'Config', icon: SlidersHorizontal, count: null, runningWhen: null },- ];- return (- <div className="flex items-stretch border-b border-port-border bg-port-bg/40 shrink-0 overflow-x-auto">- {tabs.map((t) => {- const active = t.id === tab;- const running = runningKind && t.runningWhen === runningKind;- const Icon = t.icon;- return (- <button- key={t.id}- type="button"- onClick={() => setTab(t.id)}- className={`flex-1 min-w-0 flex items-center justify-center gap-1 px-2 py-2 text-[11px] border-b-2 transition-colors ${- active- ? 'border-port-accent text-white bg-port-card/40'- : 'border-transparent text-gray-500 hover:text-gray-200 hover:bg-port-card/20'- }`}- title={t.label}- aria-pressed={active}- >- {running- ? <Loader2 size={11} className="animate-spin text-port-accent shrink-0" />- : <Icon size={11} className="shrink-0" />- }- <span className="truncate">{t.label}</span>- {t.count != null && t.count > 0 && (- <span className={`text-[9px] px-1 rounded ${active ? 'text-gray-400' : 'text-gray-600'}`}>- {t.count}- </span>- )}- </button>- );- })}- </div>- );-}-const BIBLE_KINDS = {characters: {label: 'Character bible',diff --git a/client/src/pages/Brain.jsx b/client/src/pages/Brain.jsxindex d325fb5b97..11ddc409ea 100644--- a/client/src/pages/Brain.jsx+++ b/client/src/pages/Brain.jsx@@ -3,6 +3,7 @@ import { useParams, useNavigate } from 'react-router-dom';import * as api from '../services/api';import {Brain as BrainIcon} from 'lucide-react';import BrailleSpinner from '../components/BrailleSpinner';+import TabPills from '../components/ui/TabPills';import { TABS } from '../components/brain/constants';import { timeAgo } from '../utils/formatters';@@ -123,31 +124,13 @@ export default function Brain() {)}</div>- {/* Tab navigation — horizontal scroll on mobile, icon-only below sm */}- <div className="flex border-b border-port-border overflow-x-auto">- {TABS.map((tabItem) => {- const Icon = tabItem.icon;- const isActive = activeTab === tabItem.id;- return (- <button- key={tabItem.id}- onClick={() => handleTabChange(tabItem.id)}- className={`shrink-0 flex items-center gap-2 px-3 sm:px-4 py-2 sm:py-3 text-sm font-medium min-h-[40px] transition-colors ${- isActive- ? 'text-port-accent border-b-2 border-port-accent bg-port-accent/5'- : 'text-gray-400 hover:text-white hover:bg-port-card'- }`}- role="tab"- aria-selected={isActive}- aria-label={tabItem.label}- title={tabItem.label}- >- <Icon size={16} aria-hidden="true" />- <span className="hidden sm:inline">{tabItem.label}</span>- </button>- );- })}- </div>+ <TabPills+ tabs={TABS}+ activeTab={activeTab}+ onChange={handleTabChange}+ hideLabelOnMobile+ ariaLabel="Brain sections"+ />{/* Tab content */}<div className="flex-1 overflow-auto p-4">diff --git a/client/src/pages/Calendar.jsx b/client/src/pages/Calendar.jsxindex 4eef69dcd4..6786fc1e33 100644--- a/client/src/pages/Calendar.jsx+++ b/client/src/pages/Calendar.jsx@@ -3,6 +3,7 @@ import { CalendarDays, Calendar as CalendarIcon, ClipboardList, Clock, Columns,import { useState, useEffect, useCallback } from 'react';import * as api from '../services/api';import BrailleSpinner from '../components/BrailleSpinner';+import TabPills from '../components/ui/TabPills';import AgendaTab from '../components/calendar/AgendaTab';import DayView from '../components/calendar/DayView';@@ -92,28 +93,7 @@ export default function Calendar() {</div></div>- <div className="flex border-b border-port-border">- {TABS.map((tabItem) => {- const Icon = tabItem.icon;- const isActive = activeTab === tabItem.id;- return (- <button- key={tabItem.id}- onClick={() => handleTabChange(tabItem.id)}- className={`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors ${- isActive- ? 'text-port-accent border-b-2 border-port-accent bg-port-accent/5'- : 'text-gray-400 hover:text-white hover:bg-port-card'- }`}- role="tab"- aria-selected={isActive}- >- <Icon size={16} aria-hidden="true" />- {tabItem.label}- </button>- );- })}- </div>+ <TabPills tabs={TABS} activeTab={activeTab} onChange={handleTabChange} ariaLabel="Calendar sections" /><div className="flex-1 overflow-auto p-4">{renderTabContent()}diff --git a/client/src/pages/ChiefOfStaff.jsx b/client/src/pages/ChiefOfStaff.jsxindex 69c029cbba..dbc11f532f 100644--- a/client/src/pages/ChiefOfStaff.jsx+++ b/client/src/pages/ChiefOfStaff.jsx@@ -6,6 +6,7 @@ import * as api from '../services/api';import { Play, Square, Clock, CheckCircle, AlertCircle, Cpu, ChevronDown, ChevronUp, ChevronLeft, ChevronRight, Brain, PanelLeftClose, PanelLeftOpen } from 'lucide-react';import toast from '../components/ui/Toast';import BrailleSpinner from '../components/BrailleSpinner';+import TabPills from '../components/ui/TabPills';// Import from modular componentsimport {@@ -824,37 +825,17 @@ export default function ChiefOfStaff() {<ChevronRight size={18} className="text-gray-400" /></button>)}- <div- ref={tabsRef}- role="tablist"- aria-label="Chief of Staff sections"- className="flex gap-1 border-b border-port-border overflow-x-auto scrollbar-hide pb-px"+ <TabPills+ tabs={TABS}+ activeTab={activeTab}+ onChange={(id) => navigate(`/cos/${id}`)}+ hideLabelOnMobile+ ariaLabel="Chief of Staff sections"+ controlsIdPrefix="tabpanel"+ listRef={tabsRef}onScroll={checkTabsScroll}- >- {TABS.map(tabItem => {- const Icon = tabItem.icon;- const isSelected = activeTab === tabItem.id;- return (- <button- key={tabItem.id}- role="tab"- aria-selected={isSelected}- aria-controls={`tabpanel-${tabItem.id}`}- id={`tab-${tabItem.id}`}- onClick={() => navigate(`/cos/${tabItem.id}`)}- className={`flex items-center justify-center gap-1.5 sm:gap-2 px-3 sm:px-4 min-w-[44px] min-h-[44px] sm:min-w-0 sm:min-h-[40px] text-sm font-medium transition-colors border-b-2 -mb-px whitespace-nowrap shrink-0 ${- isSelected- ? 'text-port-accent border-port-accent'- : 'text-gray-500 border-transparent hover:text-white'- }`}- >- <Icon size={16} aria-hidden="true" />- <span className="hidden sm:inline">{tabItem.label}</span>- <span className="sr-only sm:hidden">{tabItem.label}</span>- </button>- );- })}- </div>+ className="pb-px"+ /></div>{/* Tab Content */}diff --git a/client/src/pages/DigitalTwin.jsx b/client/src/pages/DigitalTwin.jsxindex 55e39f645b..a21a713452 100644--- a/client/src/pages/DigitalTwin.jsx+++ b/client/src/pages/DigitalTwin.jsx@@ -3,6 +3,7 @@ import { useParams, useNavigate } from 'react-router-dom';import * as api from '../services/api';import { Heart } from 'lucide-react';import BrailleSpinner from '../components/BrailleSpinner';+import TabPills from '../components/ui/TabPills';import { TABS, getHealthColor, getHealthLabel } from '../components/digital-twin/constants';@@ -123,30 +124,13 @@ export default function DigitalTwin() {)}</div>- {/* Tab navigation */}- <div className="flex gap-1 overflow-x-auto border-b border-port-border scrollbar-hide">- {TABS.map((tabItem) => {- const Icon = tabItem.icon;- const isActive = activeTab === tabItem.id;- return (- <button- key={tabItem.id}- onClick={() => handleTabChange(tabItem.id)}- className={`flex items-center gap-2 px-3 sm:px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap min-h-[44px] border-b-2 -mb-px ${- isActive- ? 'text-port-accent border-port-accent bg-port-accent/5'- : 'text-gray-400 border-transparent hover:text-white hover:bg-port-card'- }`}- role="tab"- aria-selected={isActive}- >- <Icon size={16} aria-hidden="true" />- <span className="hidden sm:inline">{tabItem.label}</span>- <span className="sr-only sm:hidden">{tabItem.label}</span>- </button>- );- })}- </div>+ <TabPills+ tabs={TABS}+ activeTab={activeTab}+ onChange={handleTabChange}+ hideLabelOnMobile+ ariaLabel="Digital Twin sections"+ />{/* Tab content */}<div className="flex-1 overflow-auto p-4">diff --git a/client/src/pages/MediaGen.jsx b/client/src/pages/MediaGen.jsxindex 0bb23403be..3e9e3f8d81 100644--- a/client/src/pages/MediaGen.jsx+++ b/client/src/pages/MediaGen.jsx@@ -1,5 +1,6 @@import { useNavigate, useLocation, Outlet } from 'react-router-dom';import { Layers, Image as ImageIcon, Film, History, HardDrive, Scissors, FolderOpen, Clapperboard, Sparkles } from 'lucide-react';+import TabPills from '../components/ui/TabPills';const TABS = [{ id: 'image', label: 'Image', icon: ImageIcon },@@ -24,27 +25,7 @@ export default function MediaGen() {<h1 className="text-2xl font-bold text-white">Media Gen</h1></div>- <div className="flex border-b border-port-border overflow-x-auto" role="tablist">- {TABS.map(({ id, label, icon: Icon }) => {- const isActive = activeTab === id;- return (- <button- key={id}- onClick={() => navigate(`/media/${id}`)}- className={`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap ${- isActive- ? 'text-port-accent border-b-2 border-port-accent bg-port-accent/5'- : 'text-gray-400 hover:text-white hover:bg-port-card'- }`}- role="tab"- aria-selected={isActive}- >- <Icon size={16} aria-hidden="true" />- {label}- </button>- );- })}- </div>+ <TabPills tabs={TABS} activeTab={activeTab} onChange={(id) => navigate(`/media/${id}`)} ariaLabel="Media Gen sections" /><div className="flex-1 overflow-auto p-4"><Outlet />diff --git a/client/src/pages/Messages.jsx b/client/src/pages/Messages.jsxindex 84d3351ee9..c312a6289d 100644--- a/client/src/pages/Messages.jsx+++ b/client/src/pages/Messages.jsx@@ -3,6 +3,7 @@ import { Mail, RefreshCw, Settings } from 'lucide-react';import { useState, useEffect, useCallback } from 'react';import * as api from '../services/api';import BrailleSpinner from '../components/BrailleSpinner';+import TabPills from '../components/ui/TabPills';import InboxTab from '../components/messages/InboxTab';import ConfigTab from '../components/messages/ConfigTab';@@ -76,28 +77,7 @@ export default function Messages() {</div></div>- <div className="flex border-b border-port-border">- {TABS.map((tabItem) => {- const Icon = tabItem.icon;- const isActive = activeTab === tabItem.id;- return (- <button- key={tabItem.id}- onClick={() => handleTabChange(tabItem.id)}- className={`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors ${- isActive- ? 'text-port-accent border-b-2 border-port-accent bg-port-accent/5'- : 'text-gray-400 hover:text-white hover:bg-port-card'- }`}- role="tab"- aria-selected={isActive}- >- <Icon size={16} aria-hidden="true" />- {tabItem.label}- </button>- );- })}- </div>+ <TabPills tabs={TABS} activeTab={activeTab} onChange={handleTabChange} ariaLabel="Messages sections" /><div className="flex-1 overflow-auto p-4">{renderTabContent()}diff --git a/client/src/pages/Settings.jsx b/client/src/pages/Settings.jsxindex 35367378e6..6160dc7dc3 100644--- a/client/src/pages/Settings.jsx+++ b/client/src/pages/Settings.jsx@@ -6,6 +6,7 @@ import { GeneralTab } from '../components/settings/GeneralTab';import { MortalLoomTab } from '../components/settings/MortalLoomTab';import { SharingTab } from '../components/settings/SharingTab';import { VoiceTab } from '../components/settings/VoiceTab';+import TabPills from '../components/ui/TabPills';const TABS = [{ id: 'general', label: 'General' },@@ -56,23 +57,7 @@ export default function Settings() {<h1 className="text-2xl font-bold text-white">Settings</h1></div>- <div className="flex border-b border-port-border overflow-x-auto" role="tablist">- {TABS.map(({ id, label }) => (- <button- key={id}- onClick={() => handleTabChange(id)}- role="tab"- aria-selected={activeTab === id}- className={`px-4 py-3 text-sm font-medium transition-colors whitespace-nowrap border-b-2 -mb-px ${- activeTab === id- ? 'text-port-accent border-port-accent bg-port-accent/5'- : 'text-gray-400 border-transparent hover:text-white hover:border-port-border'- }`}- >- {label}- </button>- ))}- </div>+ <TabPills tabs={TABS} activeTab={activeTab} onChange={handleTabChange} ariaLabel="Settings sections" /><div className="flex-1 overflow-auto p-4">{renderTabContent()}diff --git a/client/src/pages/UniverseBuilder.jsx b/client/src/pages/UniverseBuilder.jsxindex e646032caa..cf021c10db 100644--- a/client/src/pages/UniverseBuilder.jsx+++ b/client/src/pages/UniverseBuilder.jsx@@ -34,6 +34,7 @@ import ShareToButton from '../components/sharing/ShareToButton';import OriginBadge from '../components/sharing/OriginBadge';import UniverseCanonSection from '../components/universe/UniverseCanonSection';import EntryCard from '../components/universe/EntryCard';+import TabPills from '../components/ui/TabPills';import { deriveAvailableBackends, IMAGE_GEN_MODE } from '../lib/imageGenBackends';import { PIPELINE_IMAGE_DEFAULTS, readPipelineImageSettings } from '../lib/pipelineImageDefaults';import { normalizeSlugline } from '../lib/scenePrompt';@@ -1646,17 +1647,22 @@ export default function UniverseBuilder() {)}</header>- <TabNav+ <TabPills+ variant="pills"+ size="sm"+ mobileDropdown+ mobileSelectId="ub-tab-select"activeTab={activeTab}- setTab={setTab}- hasOtherBuckets={hasOtherBuckets}- counts={{- cast: (draft.characters?.length || 0) + bucketsByKind.characters.reduce((n, k) => n + (draft.categories?.[k]?.variations?.length || 0), 0),- places: (draft.settings?.length || 0) + bucketsByKind.settings.reduce((n, k) => n + (draft.categories?.[k]?.variations?.length || 0), 0),- objects: (draft.objects?.length || 0) + bucketsByKind.objects.reduce((n, k) => n + (draft.categories?.[k]?.variations?.length || 0), 0),- other: bucketsByKind.other.reduce((n, k) => n + (draft.categories?.[k]?.variations?.length || 0), 0),- composites: totalSheets,- }}+ onChange={setTab}+ tabs={[+ { id: TAB_BIBLE, label: 'Bible', icon: BookOpen },+ { id: TAB_CAST, label: 'Cast', icon: Users, count: (draft.characters?.length || 0) + bucketsByKind.characters.reduce((n, k) => n + (draft.categories?.[k]?.variations?.length || 0), 0) },+ { id: TAB_PLACES, label: 'Places', icon: MapPin, count: (draft.settings?.length || 0) + bucketsByKind.settings.reduce((n, k) => n + (draft.categories?.[k]?.variations?.length || 0), 0) },+ { id: TAB_OBJECTS, label: 'Objects', icon: Package, count: (draft.objects?.length || 0) + bucketsByKind.objects.reduce((n, k) => n + (draft.categories?.[k]?.variations?.length || 0), 0) },+ hasOtherBuckets && { id: TAB_OTHER, label: 'Other', icon: FolderTree, count: bucketsByKind.other.reduce((n, k) => n + (draft.categories?.[k]?.variations?.length || 0), 0) },+ { id: TAB_COMPOSITES, label: 'Composites', icon: Layers, count: totalSheets },+ { id: TAB_RENDER, label: 'Render', icon: ImagePlus },+ ]}/>{activeTab === TAB_BIBLE && (@@ -2574,70 +2580,6 @@ function VariationCard({return <EntryCard locked={locked} title={title} body={body} actions={actions} />;}-// Tab nav — desktop shows a horizontal pill row; mobile collapses to a-// <select> dropdown (CLAUDE.md "Mobile responsive"). The Other tab only-// renders when at least one un-kinded bucket exists, per Phase C spec.-function TabNav({ activeTab, setTab, hasOtherBuckets, counts }) {- const tabs = [- { id: TAB_BIBLE, label: 'Bible', icon: BookOpen, count: null },- { id: TAB_CAST, label: 'Cast', icon: Users, count: counts.cast },- { id: TAB_PLACES, label: 'Places', icon: MapPin, count: counts.places },- { id: TAB_OBJECTS, label: 'Objects', icon: Package, count: counts.objects },- ...(hasOtherBuckets ? [{ id: TAB_OTHER, label: 'Other', icon: FolderTree, count: counts.other }] : []),- { id: TAB_COMPOSITES, label: 'Composites', icon: Layers, count: counts.composites },- { id: TAB_RENDER, label: 'Render', icon: ImagePlus, count: null },- ];- return (- <>- {/* Mobile dropdown */}- <div className="sm:hidden">- <label htmlFor="ub-tab-select" className="sr-only">Section</label>- <select- id="ub-tab-select"- value={activeTab}- onChange={(e) => setTab(e.target.value)}- className="w-full bg-port-card border border-port-border rounded px-3 py-2 text-white text-sm focus:outline-none focus:border-port-accent min-h-[40px]"- >- {tabs.map((t) => (- <option key={t.id} value={t.id}>- {t.label}{t.count != null ? ` (${t.count})` : ''}- </option>- ))}- </select>- </div>- {/* Desktop pill row */}- <div className="hidden sm:flex items-center gap-1 bg-port-card border border-port-border rounded p-1 overflow-x-auto" role="tablist">- {tabs.map((t) => {- const Icon = t.icon;- const active = t.id === activeTab;- return (- <button- key={t.id}- type="button"- role="tab"- aria-selected={active}- onClick={() => setTab(t.id)}- className={`flex items-center gap-1.5 px-3 py-1.5 rounded text-sm transition-colors whitespace-nowrap ${- active- ? 'bg-port-accent/20 text-port-accent border border-port-accent/40'- : 'text-gray-300 hover:bg-port-bg border border-transparent'- }`}- >- <Icon size={14} />- {t.label}- {t.count != null && (- <span className={`text-[10px] ${active ? 'text-port-accent/70' : 'text-gray-500'}`}>- {t.count}- </span>- )}- </button>- );- })}- </div>- </>- );-}-function BibleTab({draft, updateDraft, toggleLock,llm,diff --git a/client/src/pages/Wiki.jsx b/client/src/pages/Wiki.jsxindex 66676264aa..a62b543072 100644--- a/client/src/pages/Wiki.jsx+++ b/client/src/pages/Wiki.jsx@@ -3,6 +3,7 @@ import { useParams, useNavigate } from 'react-router-dom';import * as api from '../services/api';import { BookOpen, Search, Network, FileText, BarChart3, Activity } from 'lucide-react';import BrailleSpinner from '../components/BrailleSpinner';+import TabPills from '../components/ui/TabPills';import WikiOverviewTab from '../components/wiki/tabs/OverviewTab';import WikiBrowseTab from '../components/wiki/tabs/BrowseTab';@@ -143,29 +144,7 @@ export default function Wiki() {</div></div>- {/* Tab navigation */}- <div className="flex border-b border-port-border">- {TABS.map((tabItem) => {- const Icon = tabItem.icon;- const isActive = activeTab === tabItem.id;- return (- <button- key={tabItem.id}- onClick={() => navigate(`/wiki/${tabItem.id}`)}- className={`flex items-center gap-2 px-4 py-3 text-sm font-medium transition-colors ${- isActive- ? 'text-port-accent border-b-2 border-port-accent bg-port-accent/5'- : 'text-gray-400 hover:text-white hover:bg-port-card'- }`}- role="tab"- aria-selected={isActive}- >- <Icon size={16} aria-hidden="true" />- {tabItem.label}- </button>- );- })}- </div>+ <TabPills tabs={TABS} activeTab={activeTab} onChange={(id) => navigate(`/wiki/${id}`)} ariaLabel="Wiki sections" />{/* Tab content */}<div className="flex-1 overflow-auto p-4">