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
fix: stop TabPills advertising aria-controls for panels that never mount (#7420)
Adam Eivyf53c88a8f333
diff --git a/client/src/components/ui/TabPills.jsx b/client/src/components/ui/TabPills.jsxindex 9176c8e7d1..416f1edc1d 100644--- a/client/src/components/ui/TabPills.jsx+++ b/client/src/components/ui/TabPills.jsx@@ -27,9 +27,15 @@// Other knobs cover the call-site quirks: `runningKind` swaps a per-tab icon// for a spinner; `stretch` makes each tab `flex-1` (StoryboardPanel);// `controlsIdPrefix` wires `aria-controls` (and `id="tab-<id>"`) to matching-// tabpanels — pass `'tabpanel'` to mirror ChiefOfStaff's wiring. `t.trailing`-// is an optional ReactNode rendered after the count (e.g. PipelineIssue's-// per-stage status dot).+// tabpanels — pass `'tabpanel'` to mirror ChiefOfStaff's wiring. `aria-controls`+// is set only on the ACTIVE tab: a caller that mounts one panel at a time (the+// common case) leaves every inactive tab's `aria-controls` pointing at an IDREF+// that is not in the document otherwise (#7420). `id` stays on every tab+// regardless of active state, because a caller that keeps every panel mounted+// and toggles `hidden` (LoomSeriesPlan, PipelineSeries) gives each panel a+// static `aria-labelledby="tab-<id>"` — dropping the id would dangle THAT+// reference instead. `t.trailing` is an optional ReactNode rendered after the+// count (e.g. PipelineIssue's per-stage status dot).import { useRef, useEffect, useState, useCallback } from 'react';import { ChevronLeft, ChevronRight, Loader2 } from 'lucide-react';@@ -231,7 +237,7 @@ export default function TabPills({role={isFilter ? undefined : 'tab'}aria-selected={isFilter ? undefined : active}aria-pressed={isFilter ? active : undefined}- aria-controls={!isFilter && controlsIdPrefix ? `${controlsIdPrefix}-${t.id}` : undefined}+ aria-controls={!isFilter && active && controlsIdPrefix ? `${controlsIdPrefix}-${t.id}` : undefined}id={!isFilter && controlsIdPrefix ? `tab-${t.id}` : undefined}ref={!isFilter ? (node) => { tabRefs.current[index] = node; } : undefined}tabIndex={!isFilter ? (active ? 0 : -1) : undefined}@@ -285,7 +291,7 @@ export default function TabPills({type="button"role="tab"aria-selected={active}- aria-controls={controlsIdPrefix ? `${controlsIdPrefix}-${t.id}` : undefined}+ aria-controls={active && controlsIdPrefix ? `${controlsIdPrefix}-${t.id}` : undefined}id={controlsIdPrefix ? `tab-${t.id}` : undefined}ref={(node) => { tabRefs.current[index] = node; }}tabIndex={active ? 0 : -1}diff --git a/client/src/components/ui/TabPills.test.jsx b/client/src/components/ui/TabPills.test.jsxindex 6540328841..473c653f20 100644--- a/client/src/components/ui/TabPills.test.jsx+++ b/client/src/components/ui/TabPills.test.jsx@@ -130,6 +130,30 @@ describe('TabPills — underline variant (default)', () => {expect(castBtn).toHaveAttribute('id', 'tab-cast');expect(castBtn).toHaveAttribute('aria-controls', 'tabpanel-cast');});++ // #7420: a bar that mounts one panel at a time only ever has ONE panel in the+ // document, so every OTHER tab's `aria-controls` pointed at an id that did+ // not exist. Only the active tab may claim to control something real.+ it('omits aria-controls from every inactive tab (nothing to control in a one-panel-at-a-time bar)', () => {+ render(<TabPills tabs={sampleTabs} activeTab="cast" onChange={() => {}} controlsIdPrefix="tabpanel" />);+ for (const name of [/Places/i, /Objects/i]) {+ expect(screen.getByRole('tab', { name })).not.toHaveAttribute('aria-controls');+ }+ // `id` stays on every tab: a caller that keeps every panel mounted and+ // toggles `hidden` (rather than conditionally rendering) gives each panel+ // a static `aria-labelledby="tab-<id>"`, which would dangle without it.+ expect(screen.getByRole('tab', { name: /Places/i })).toHaveAttribute('id', 'tab-places');+ });++ it('same contract in the pills variant', () => {+ render(<TabPills variant="pills" 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');+ const placesBtn = screen.getByRole('tab', { name: /Places/i });+ expect(placesBtn).not.toHaveAttribute('aria-controls');+ expect(placesBtn).toHaveAttribute('id', 'tab-places');+ });});// The preferred phone treatment: the same tab buttons, icons only. A `<select>`diff --git a/client/src/pages/ApiExplorer.jsx b/client/src/pages/ApiExplorer.jsxindex d9782b1b40..19fac01248 100644--- a/client/src/pages/ApiExplorer.jsx+++ b/client/src/pages/ApiExplorer.jsx@@ -503,6 +503,12 @@ export default function ApiExplorer() {if (!VALID_TABS.has(tab)) return <Navigate to="/api-reference/catalog" replace />;+ // RouteTabsHeader passes no `controlsIdPrefix` (route tabs navigate, they+ // don't reveal a sibling panel already in the DOM — see its own comment), so+ // the panel names itself with its own heading rather than an `aria-labelledby`+ // borrowed from a tab id that doesn't exist (#7420).+ const activeTabLabel = TABS.find((t) => t.id === tab)?.label;+return (<div className="h-full min-h-0 flex flex-col bg-port-bg"><PageHeader@@ -512,7 +518,8 @@ export default function ApiExplorer() {actions={<button type="button" onClick={() => navigate('/settings/api-access')} className="text-xs text-port-accent hover:underline">API access settings</button>}/><RouteTabsHeader tabs={TABS} activeTab={tab} ariaLabel="API Explorer sections" />- <div role="tabpanel" className="min-h-0 flex-1 overflow-auto">+ <div role="tabpanel" aria-labelledby="api-explorer-panel-heading" className="min-h-0 flex-1 overflow-auto">+ <h2 id="api-explorer-panel-heading" className="sr-only">{activeTabLabel}</h2>{tab === 'catalog' && <CatalogView />}{tab === 'rest' && <RestReferenceView />}{tab === 'events' && <EventCatalogView />}diff --git a/client/src/pages/ApiExplorer.test.jsx b/client/src/pages/ApiExplorer.test.jsxindex fa363ab48c..ce9bef30dd 100644--- a/client/src/pages/ApiExplorer.test.jsx+++ b/client/src/pages/ApiExplorer.test.jsx@@ -16,6 +16,7 @@ vi.mock('../services/api', () => api);vi.mock('../lib/clipboard', () => ({ copyToClipboard: vi.fn() }));import ApiExplorer from './ApiExplorer';+import { expectNoDanglingAriaRefs } from '../test/ariaRefAssertions.js';const catalog = {stats: { operations: 2050, sourceFiles: 221, domains: 124, mounts: 145, modeled: 10, generated: 2040 },@@ -173,4 +174,13 @@ describe('ApiExplorer', () => {expect(screen.getByText('cos:mind:event')).toBeTruthy();expect(screen.getByRole('link', { name: /Open AsyncAPI JSON/i })).toHaveAttribute('href', '/api/api-docs/asyncapi.json');});++ // #7420: RouteTabsHeader passes no `controlsIdPrefix`, so the panel names+ // itself rather than borrowing an `aria-labelledby` from a tab id that+ // doesn't exist.+ it.each(['catalog', 'rest', 'events', 'tools'])('%s tab names the panel it points at, with no dangling refs', async (tab) => {+ const { container } = renderPage(`/api-reference/${tab}`);+ await waitFor(() => expect(screen.getByRole('tabpanel')).toBeInTheDocument());+ expectNoDanglingAriaRefs(container);+ });});diff --git a/client/src/pages/Sharing.jsx b/client/src/pages/Sharing.jsxindex 2c6cab9a23..ff48784569 100644--- a/client/src/pages/Sharing.jsx+++ b/client/src/pages/Sharing.jsx@@ -90,10 +90,17 @@ function SharingHeader({ active }) {export default function Sharing() {const { section = 'buckets', bucketId } = useParams();if (section === 'duplicates' || section === 'conflicts') {+ // RouteTabsHeader passes no `controlsIdPrefix`, so the panel names itself+ // with its own heading rather than an `aria-labelledby` borrowed from a+ // tab id that doesn't exist (#7420).+ const activeTabLabel = SECTIONS.find((item) => item.id === section)?.label;return (<div><SharingHeader active={section} />- {section === 'duplicates' ? <DuplicatesTab /> : <ConflictsTab />}+ <div role="tabpanel" aria-labelledby="sharing-panel-heading">+ <h2 id="sharing-panel-heading" className="sr-only">{activeTabLabel}</h2>+ {section === 'duplicates' ? <DuplicatesTab /> : <ConflictsTab />}+ </div></div>);}@@ -287,6 +294,11 @@ function SharingBuckets({ selectedId }) {return (<div><SharingHeader active="buckets" />+ {/* RouteTabsHeader passes no `controlsIdPrefix`, so the panel names+ itself with its own heading rather than an `aria-labelledby`+ borrowed from a tab id that doesn't exist (#7420). */}+ <div role="tabpanel" aria-labelledby="sharing-panel-heading">+ <h2 id="sharing-panel-heading" className="sr-only">Buckets</h2><div className="flex justify-end mb-4"><buttontype="button"@@ -543,6 +555,7 @@ function SharingBuckets({ selectedId }) {)}</section></div>+ </div></div>);}diff --git a/client/src/pages/Sharing.test.jsx b/client/src/pages/Sharing.test.jsxindex 59129705ad..7232595df0 100644--- a/client/src/pages/Sharing.test.jsx+++ b/client/src/pages/Sharing.test.jsx@@ -17,10 +17,14 @@ vi.mock('../services/api', () => ({listShareActivity: vi.fn(),getSettings: vi.fn(),updateSettings: vi.fn(),+ listUniverseDuplicates: vi.fn(),+ listSeriesDuplicates: vi.fn(),+ listConflicts: vi.fn(),}));import Sharing, { SECTIONS, isLiveSubscription } from './Sharing';import { expectPageNavTabs } from '../test/pageNavTabAssertions.js';+import { expectNoDanglingAriaRefs } from '../test/ariaRefAssertions.js';import * as api from '../services/api';const NOW = Date.parse('2026-05-18T12:00:00Z');@@ -134,3 +138,30 @@ describe('Sharing SECTIONS ↔ nav manifest', () => {]);});});++// #7420: RouteTabsHeader passes no `controlsIdPrefix`, so each section names+// its own panel rather than borrowing an `aria-labelledby` from a tab id that+// doesn't exist. Covers all three sections this page's own tab bar can reach.+describe('Sharing — no dangling aria-controls/aria-labelledby', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ api.listShareBuckets.mockResolvedValue({ buckets: [], localSchemaVersion: 1 });+ api.getSettings.mockResolvedValue({});+ api.listShareInbox.mockResolvedValue({ items: [] });+ api.listShareActivity.mockResolvedValue({ manifests: [] });+ api.listUniverseDuplicates.mockResolvedValue({ groups: [] });+ api.listSeriesDuplicates.mockResolvedValue({ groups: [] });+ api.listConflicts.mockResolvedValue({ conflicts: [] });+ });++ const routes = [{ path: '/sharing/:section', element: <Sharing /> }];+ const renderAt = (entry) => render(+ <RouterProvider router={createMemoryRouter(routes, { initialEntries: [entry] })} />,+ );++ it.each(['buckets', 'duplicates', 'conflicts'])('%s section names every panel it points at', async (section) => {+ const { container } = renderAt(`/sharing/${section}`);+ await waitFor(() => expect(screen.getByRole('tabpanel')).toBeInTheDocument());+ expectNoDanglingAriaRefs(container);+ });+});diff --git a/client/src/pages/SystemHealthPage.jsx b/client/src/pages/SystemHealthPage.jsxindex 481bb74bba..6580dfbc11 100644--- a/client/src/pages/SystemHealthPage.jsx+++ b/client/src/pages/SystemHealthPage.jsx@@ -64,6 +64,12 @@ export default function SystemResourcesPage() {const validTab = RESOURCE_TABS.some((item) => item.id === tab);if (!validTab) return <Navigate to="/system-resources/overview" replace />;+ // RouteTabsHeader passes no `controlsIdPrefix` (route tabs navigate, they+ // don't reveal a sibling panel already in the DOM), so the panel names+ // itself with its own heading rather than an `aria-labelledby` borrowed+ // from a tab id that doesn't exist (#7420).+ const activeTabLabel = RESOURCE_TABS.find((item) => item.id === tab)?.label;+return (<div className="mx-auto max-w-7xl space-y-4"><header className="overflow-hidden rounded-2xl border border-port-border bg-gradient-to-r from-port-card via-port-card to-port-accent/10 p-4 sm:p-5">@@ -81,17 +87,20 @@ export default function SystemResourcesPage() {</div></header>- {tab === 'overview' && <SystemHealthOverview />}- {tab === 'storage' && (- <StoragePanel- report={report}- loading={reportLoading}- onRunReport={runReport}- onReport={setReport}- cleanup={cleanup}- />- )}- {tab === 'queues' && <QueuesPanel />}+ <div role="tabpanel" aria-labelledby="system-resources-panel-heading">+ <h2 id="system-resources-panel-heading" className="sr-only">{activeTabLabel}</h2>+ {tab === 'overview' && <SystemHealthOverview />}+ {tab === 'storage' && (+ <StoragePanel+ report={report}+ loading={reportLoading}+ onRunReport={runReport}+ onReport={setReport}+ cleanup={cleanup}+ />+ )}+ {tab === 'queues' && <QueuesPanel />}+ </div></div>);}diff --git a/client/src/pages/SystemHealthPage.test.jsx b/client/src/pages/SystemHealthPage.test.jsxindex a577d514c0..156fef07f4 100644--- a/client/src/pages/SystemHealthPage.test.jsx+++ b/client/src/pages/SystemHealthPage.test.jsx@@ -67,6 +67,7 @@ import * as api from '../services/api';import { dismissHealthWarning } from '../services/apiSystem.js';import SystemHealthPage, { RESOURCE_TABS } from './SystemHealthPage';import { expectPageNavTabs } from '../test/pageNavTabAssertions.js';+import { expectNoDanglingAriaRefs } from '../test/ariaRefAssertions.js';const renderPage = (path = '/system-resources/overview') => render(<MemoryRouter initialEntries={[path]}>@@ -257,3 +258,29 @@ describe('RESOURCE_TABS ↔ nav manifest', () => {expectPageNavTabs(RESOURCE_TABS, ['overview:Overview', 'storage:Storage', 'queues:Queues']);});});++// #7420: RouteTabsHeader passes no `controlsIdPrefix`, so the panel names+// itself rather than borrowing an `aria-labelledby` from a tab id that+// doesn't exist.+describe('SystemHealthPage — no dangling aria-controls/aria-labelledby', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ api.getSystemHealth.mockResolvedValue(HEALTH);+ api.runSystemResourceReport.mockResolvedValue({+ generatedAt: '2026-08-16T00:00:00.000Z',+ filesystem: { totalBytes: 1000, usedBytes: 750, freeBytes: 250, usagePercent: 75 },+ summary: { managedReclaimableBytes: 0 },+ storageAreas: [],+ cleanupCandidates: [],+ sourceErrors: [],+ models: { downloaded: [], loaded: [], totals: { all: 0 } },+ queues: { media: { queued: 0, running: 0 }, agents: null },+ });+ });++ it.each(['overview', 'storage'])('%s tab names the panel it points at, with no dangling refs', async (tab) => {+ const { container } = renderPage(`/system-resources/${tab}`);+ await waitFor(() => expect(screen.getByRole('tabpanel')).toBeInTheDocument());+ expectNoDanglingAriaRefs(container);+ });+});diff --git a/client/src/test/ariaRefAssertions.js b/client/src/test/ariaRefAssertions.jsnew file mode 100644index 0000000000..b91ed56720--- /dev/null+++ b/client/src/test/ariaRefAssertions.js@@ -0,0 +1,32 @@+/**+ * Shared assertion for a rendered tree's `aria-controls` / `aria-labelledby`+ * IDREFs.+ *+ * A dangling IDREF (an id that names no element in the document) is invisible+ * to every existing `screen.getByRole`/`toHaveAttribute` assertion — those+ * check the attribute's VALUE, never that the value resolves to something+ * real. That is how #7420 survived: `TabPills` wired `aria-controls` onto+ * every tab in a bar that only ever mounts one panel, and nothing failed+ * until a screen reader tried to follow the reference. Each `aria-*` value can+ * be space-separated (the IDREF-list attributes), so split before checking.+ *+ * Node-only consumer (test files); kept in `src/test/` for the same reason as+ * `pageNavTabAssertions.js` — a test-only helper has no business in the+ * browser barrel.+ */++import { expect } from 'vitest';++const IDREF_ATTRS = ['aria-controls', 'aria-labelledby'];++export function expectNoDanglingAriaRefs(container) {+ const doc = container.ownerDocument;+ for (const attr of IDREF_ATTRS) {+ for (const el of container.querySelectorAll(`[${attr}]`)) {+ const ids = el.getAttribute(attr).trim().split(/\s+/).filter(Boolean);+ for (const id of ids) {+ expect(doc.getElementById(id), `${attr}="${id}" on <${el.tagName.toLowerCase()}> has no matching element`).not.toBeNull();+ }+ }+ }+}