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

fix(a11y): give the four hand-rolled tablists TabPills' roving tabindex

Louis Deconinckb683c6891f62
diff --git a/client/src/a11yConventions.test.js b/client/src/a11yConventions.test.js
index 5c8f769194..644f7b4413 100644
--- a/client/src/a11yConventions.test.js
+++ b/client/src/a11yConventions.test.js
@@ -3733,4 +3733,70 @@ function B() { const sensors = useSensors(useSensor(PointerSensor)); return <Dnd
});
expect(stale, `routed-heading exemption entries that no longer match a heading-less routed element — delete them:\n${stale.join('\n')}`).toEqual([]);
});
+
+ // --- shared tab bar primitive (#7244) --------------------------------------
+ //
+ // `role="tablist"` promises the WAI-ARIA tabs contract — one tab stop per
+ // bar, Arrow/Home/End moving between tabs — and only
+ // `components/ui/TabPills.jsx` implements it (roving tabindex
+ // `tabIndex={active ? 0 : -1}` plus `handleTabKeyDown`, which also skips
+ // `disabled` tabs). A hand-rolled bar puts every tab in the tab order and
+ // answers the promised keys with nothing (WCAG 4.1.2); the four audited
+ // surfaces in #7244 are exactly the drift #6910's primitive never reached.
+ // client/src/AGENTS.md already says "reuse it, never roll a new tab bar" —
+ // this scan is the backstop that keeps the next hand-rolled tab bar from
+ // shipping the same gap again.
+
+ // Every element whose `role` attribute literally reads "tablist", wherever
+ // one is written. Reading the answer off the parsed tag covers
+ // `role="tablist"`, `role='tablist'` and `role={'tablist'}` as one question;
+ // a commented-out example is masked before the walk, a `title` attribute's
+ // text is never a tag's `role`, and a dynamic `role={expr}` resolves to no
+ // verdict — left to review rather than guessed at.
+ const handRolledTablists = function* (src) {
+ // 'tablist' absent → lexing the file cannot yield a tablist tag.
+ if (!src.includes('tablist')) return;
+ for (const node of forEachOpeningTag(src)) {
+ if (normalizedAttributeValue(attributeValue(node.tag, 'role')) === 'tablist') yield node;
+ }
+ };
+
+ it('routes every tablist through the shared <TabPills> primitive (#7244)', () => {
+ // Probe first — the tree is green by construction (the four audited sites
+ // moved onto TabPills in the same change), so nothing in it pins what the
+ // walk rejects, and a silent change of shape would turn the rule vacuous.
+ const probe = (src) => [...handRolledTablists(src)].map(({ index }) => lineOf(src, index));
+ expect(probe('<div role="tablist" aria-label="X"><button role="tab">A</button></div>')).toEqual([1]);
+ // …whichever way the literal is spelled, and wherever the tag starts.
+ expect(probe("<p>x</p>\n<div\n role='tablist'\n/>")).toEqual([2]);
+ expect(probe('<div role={"tablist"} />')).toEqual([1]);
+ expect(probe('<div role="tablist" /><nav role="tablist" />')).toEqual([1, 1]);
+ // The shared primitive's call site carries no `role` — it is the answer,
+ // not the question.
+ expect(probe('<TabPills tabs={tabs} activeTab={a} onChange={c} />')).toEqual([]);
+ // A bare role="tab" outside a list is a different defect, and a dynamic
+ // role is unverifiable — both are out of this rule's remit.
+ expect(probe('<div role="tab" /><div role={roleFor(kind)} />')).toEqual([]);
+ // A JSX example written in a comment is masked before the walk, and a
+ // mention inside another attribute's quoted value is never read as a role.
+ expect(probe(maskComments('{/* <div role="tablist" /> */}'))).toEqual([]);
+ expect(probe('<div data-note="x" title="see tablist docs" />')).toEqual([]);
+
+ // Prove the walk sees the real spelling on the shared component itself —
+ // a matcher that silently missed it would pass the tree vacuously.
+ expect(
+ [...handRolledTablists(maskedSourceOf('src/components/ui/TabPills.jsx'))].length,
+ 'components/ui/TabPills.jsx no longer writes role="tablist" — has the primitive changed shape?',
+ ).toBeGreaterThanOrEqual(1);
+
+ const offenders = [];
+ for (const file of trackedSourceFiles()) {
+ if (file === 'src/components/ui/TabPills.jsx') continue;
+ const src = maskedSourceOf(file);
+ for (const { index } of handRolledTablists(src)) {
+ offenders.push(`${file}:${lineOf(src, index)}`);
+ }
+ }
+ expect(offenders, `Hand-rolled role="tablist" — render the shared components/ui/TabPills.jsx instead; it owns the roving tabindex + Arrow/Home/End contract a hand-rolled bar cannot honor (WCAG 4.1.2):\n${offenders.join('\n')}`).toEqual([]);
+ });
});
diff --git a/client/src/components/messages/InboxTab.jsx b/client/src/components/messages/InboxTab.jsx
index 7106f10454..c30b9ff102 100644
--- a/client/src/components/messages/InboxTab.jsx
+++ b/client/src/components/messages/InboxTab.jsx
@@ -2,6 +2,7 @@ import { useState, useEffect, useCallback, useRef, useMemo } from 'react';
import { Mail, Search, RefreshCw, ChevronRight, Sparkles, Archive, Trash2, Reply, Eye, Flag, Pin, Loader2, Settings, FilterX, AlertTriangle } from 'lucide-react';
import { useNavigate, useSearchParams } from 'react-router';
import toast from '../ui/Toast';
+import TabPills from '../ui/TabPills';
import * as api from '../../services/api';
import socket from '../../services/socket';
import { timeAgo, formatDateNumeric } from '../../utils/formatters';
@@ -414,6 +415,18 @@ export default function InboxTab({ accounts }) {
[messages, currentTab]
);
+ // TabPills descriptors carry the per-filter count badge; the filter
+ // predicates themselves stay on TRIAGE_TABS for the list derivation above.
+ const triagePills = useMemo(
+ () => TRIAGE_TABS.map((tab) => ({
+ id: tab.key,
+ label: tab.label,
+ icon: tab.icon,
+ count: messages.filter(tab.filter).length,
+ })),
+ [messages]
+ );
+
// Scope the "have we ever synced?" answer to the accounts the current view can
// show — with an account filter on, another account's sync says nothing about
// this one. A sync that landed in this session wins over the (not-yet-refetched)
@@ -545,35 +558,17 @@ export default function InboxTab({ accounts }) {
</div>
</div>
- {/* Triage filter tabs — scroll on a phone rather than clipping "All" / "Untriaged". */}
- <div
- className="-mx-1 px-1 flex items-center gap-1 border-b border-port-border pb-1 overflow-x-auto scrollbar-hide touch-pan-x"
- role="tablist"
- aria-label="Triage filters"
- >
- {TRIAGE_TABS.map(tab => {
- const count = messages.filter(tab.filter).length;
- const TabIcon = tab.icon;
- const isActive = activeTab === tab.key;
- return (
- <button
- key={tab.key}
- role="tab"
- aria-selected={isActive}
- onClick={() => setActiveTab(tab.key)}
- className={`flex items-center gap-1.5 px-2.5 sm:px-3 py-1.5 rounded-t text-xs whitespace-nowrap shrink-0 transition-colors ${
- isActive
- ? 'bg-port-card text-white border border-port-border border-b-transparent -mb-[1px]'
- : 'text-gray-500 hover:text-gray-300'
- }`}
- >
- <TabIcon size={12} />
- {tab.label}
- {count > 0 && <span className={`ml-0.5 px-1.5 py-0.5 rounded-full text-[10px] ${isActive ? 'bg-port-accent/20 text-port-accent' : 'bg-port-border text-gray-400'}`}>{count}</span>}
- </button>
- );
- })}
- </div>
+ {/* Triage filter tabs — the shared TabPills owns the roving tabindex and
+ arrow-key contract; its strip keeps the phone horizontal scroll so
+ "All" / "Untriaged" never clip. */}
+ <TabPills
+ tabs={triagePills}
+ activeTab={activeTab}
+ onChange={setActiveTab}
+ size="sm"
+ ariaLabel="Triage filters"
+ className="-mx-1 px-1"
+ />
{visibleMessages.length === 0 && !loading && (
<InboxEmptyState
diff --git a/client/src/components/messages/InboxTab.test.jsx b/client/src/components/messages/InboxTab.test.jsx
index df0b5e2a0c..1137fef774 100644
--- a/client/src/components/messages/InboxTab.test.jsx
+++ b/client/src/components/messages/InboxTab.test.jsx
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { fireEvent, render, screen, waitFor } from '@testing-library/react';
+import { fireEvent, render, screen, waitFor, within } from '@testing-library/react';
import { MemoryRouter, Route, Routes, useLocation } from 'react-router';
const api = vi.hoisted(() => ({
@@ -243,3 +243,49 @@ describe('InboxTab message selection URL', () => {
expect(toolbar.className).toMatch(/sm:flex-row/);
});
});
+
+describe('InboxTab triage tab bar (#7244)', () => {
+ const message = {
+ id: 'message-1',
+ accountId: neverSyncedAccount.id,
+ subject: 'A message to inspect',
+ bodyText: 'Message body',
+ from: { name: 'Example Sender' },
+ date: '2026-08-16T00:00:00.000Z',
+ source: 'gmail',
+ evaluation: { action: 'reply', priority: 'medium' },
+ };
+
+ it('keeps one tab stop on the bar and moves it with arrow keys, updating the URL', async () => {
+ api.getMessageInbox.mockResolvedValue({ messages: [message], total: 1 });
+ renderInboxWithLocation([syncedAccount]);
+
+ const tablist = await screen.findByRole('tablist', { name: 'Triage filters' });
+ const tabs = within(tablist).getAllByRole('tab');
+ expect(tabs).toHaveLength(6);
+ // One tab stop for the whole bar — the active "All" filter — and the
+ // per-filter count still rides the tab label.
+ expect(tabs.filter((t) => t.getAttribute('tabindex') === '0')).toHaveLength(1);
+ const allTab = screen.getByRole('tab', { name: /^All/ });
+ expect(allTab).toHaveAttribute('tabindex', '0');
+ expect(within(allTab).getByText('1')).toBeInTheDocument();
+
+ // ArrowRight moves the tab stop and the active filter together; the filter
+ // change lands in the URL like a click does.
+ const replyTab = screen.getByRole('tab', { name: /^Reply/ });
+ allTab.focus();
+ fireEvent.keyDown(allTab, { key: 'ArrowRight' });
+ expect(replyTab).toHaveAttribute('aria-selected', 'true');
+ expect(document.activeElement).toBe(replyTab);
+ expect(screen.getByTestId('location')).toHaveTextContent('triage=reply');
+
+ // Home/End jump to the ends of the bar.
+ const untriagedTab = screen.getByRole('tab', { name: /^Untriaged/ });
+ fireEvent.keyDown(replyTab, { key: 'End' });
+ expect(document.activeElement).toBe(untriagedTab);
+ expect(untriagedTab).toHaveAttribute('aria-selected', 'true');
+ fireEvent.keyDown(untriagedTab, { key: 'Home' });
+ expect(document.activeElement).toBe(allTab);
+ expect(allTab).toHaveAttribute('aria-selected', 'true');
+ });
+});
diff --git a/client/src/pages/MoodBoardDetail.jsx b/client/src/pages/MoodBoardDetail.jsx
index 8cd876b407..2dd315dfef 100644
--- a/client/src/pages/MoodBoardDetail.jsx
+++ b/client/src/pages/MoodBoardDetail.jsx
@@ -14,6 +14,7 @@ import { useParams, useNavigate, Link } from 'react-router';
import { ArrowLeft, ImageIcon, FileText, Trash2, Plus, Save, Link2, Unlink, RefreshCw, Images, Film, Play, ScanEye, Copy } from 'lucide-react';
import PageSkeleton from '../components/ui/PageSkeleton';
import toast from '../components/ui/Toast';
+import TabPills from '../components/ui/TabPills';
import InlineConfirmRow from '../components/ui/InlineConfirmRow';
import GalleryImagePicker from '../components/imageGen/GalleryImagePicker';
import GalleryVideoPicker from '../components/videoGen/GalleryVideoPicker';
@@ -449,26 +450,19 @@ function MoodBoardEditor({ id }) {
{/* Add item */}
<div className="bg-port-card border border-port-border rounded-md p-4 mb-6">
<div className="flex flex-wrap items-center gap-2 mb-3">
- <div className="flex items-center gap-2" role="tablist" aria-label="Item type">
- <button
- type="button"
- role="tab"
- aria-selected={itemType === 'image'}
- onClick={() => setItemType('image')}
- className={`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded transition-colors ${itemType === 'image' ? 'bg-port-accent text-white' : 'bg-port-bg text-gray-400 hover:text-white'}`}
- >
- <ImageIcon className="w-4 h-4" aria-hidden="true" /> Image
- </button>
- <button
- type="button"
- role="tab"
- aria-selected={itemType === 'text'}
- onClick={() => setItemType('text')}
- className={`flex items-center gap-1.5 px-3 py-1.5 text-sm rounded transition-colors ${itemType === 'text' ? 'bg-port-accent text-white' : 'bg-port-bg text-gray-400 hover:text-white'}`}
- >
- <FileText className="w-4 h-4" aria-hidden="true" /> Note
- </button>
- </div>
+ {/* The shared TabPills owns the roving tabindex + arrow-key
+ contract — never roll a tab bar (client/src/AGENTS.md). */}
+ <TabPills
+ variant="pills"
+ size="sm"
+ tabs={[
+ { id: 'image', label: 'Image', icon: ImageIcon },
+ { id: 'text', label: 'Note', icon: FileText },
+ ]}
+ activeTab={itemType}
+ onChange={setItemType}
+ ariaLabel="Item type"
+ />
{/* Gallery pins (#4188) — pick or upload, added to the board immediately. */}
<div className="flex items-center gap-2 sm:ml-auto">
<button
diff --git a/client/src/pages/MoodBoardDetail.test.jsx b/client/src/pages/MoodBoardDetail.test.jsx
index 007025fc6e..7b7fbb8b6e 100644
--- a/client/src/pages/MoodBoardDetail.test.jsx
+++ b/client/src/pages/MoodBoardDetail.test.jsx
@@ -229,6 +229,28 @@ describe('MoodBoardDetail stale-response guards', () => {
});
});
+describe('MoodBoardDetail item-type tabs (#7244)', () => {
+ it('keeps one tab stop on the bar and switches the add form with arrow keys', async () => {
+ mockGetMoodBoard.mockResolvedValueOnce({ id: 'a', name: 'Board A', items: [] });
+ renderPage();
+ await waitFor(() => expect(boardNameValue()).toBe('Board A'));
+
+ const image = screen.getByRole('tab', { name: 'Image' });
+ const note = screen.getByRole('tab', { name: 'Note' });
+ expect(image).toHaveAttribute('tabindex', '0');
+ expect(note).toHaveAttribute('tabindex', '-1');
+
+ // ArrowRight moves the tab stop and swaps the add-item form together.
+ image.focus();
+ fireEvent.keyDown(image, { key: 'ArrowRight' });
+ expect(note).toHaveAttribute('aria-selected', 'true');
+ expect(note).toHaveAttribute('tabindex', '0');
+ expect(document.activeElement).toBe(note);
+ expect(screen.getByLabelText('Note')).toBeInTheDocument();
+ expect(screen.queryByLabelText('Image URL')).not.toBeInTheDocument();
+ });
+});
+
describe('MoodBoardDetail video items (#4188)', () => {
it('renders a video item as a poster with a play affordance, then plays inline', async () => {
mockGetMoodBoard.mockResolvedValueOnce({
diff --git a/client/src/pages/VideoTimelineEditor.jsx b/client/src/pages/VideoTimelineEditor.jsx
index a6452dba8b..b75d77ffe0 100644
--- a/client/src/pages/VideoTimelineEditor.jsx
+++ b/client/src/pages/VideoTimelineEditor.jsx
@@ -28,6 +28,7 @@ import {
} from '../components/media/VideoTimelineLanes';
import { NumberField, FadeFields, RemoveButton } from '../components/media/VideoTimelineInspector';
import PageSkeleton from '../components/ui/PageSkeleton';
+import TabPills from '../components/ui/TabPills';
import {
assetUrl,
segmentDuration,
@@ -78,9 +79,9 @@ const LANE_CAPS = {
};
const LIBRARY_TABS = [
- { id: 'clips', label: 'Clips', Icon: Film },
- { id: 'stills', label: 'Stills', Icon: ImageIcon },
- { id: 'audio', label: 'Audio', Icon: Music },
+ { id: 'clips', label: 'Clips', icon: Film },
+ { id: 'stills', label: 'Stills', icon: ImageIcon },
+ { id: 'audio', label: 'Audio', icon: Music },
];
const desktopTimelineLayout = () => (
@@ -759,24 +760,17 @@ export default function VideoTimelineEditor() {
id="timeline-library"
className="order-2 lg:order-1 bg-port-card/50 border border-port-border rounded-lg p-2 max-h-[600px] overflow-y-auto"
>
- <div className="flex gap-1 mb-2" role="tablist" aria-label="Clip library">
- {LIBRARY_TABS.map(({ id, label, Icon }) => (
- <button
- key={id}
- type="button"
- role="tab"
- aria-selected={libraryTab === id}
- onClick={() => setLibraryTab(id)}
- className={`flex-1 flex items-center justify-center gap-1 px-1.5 py-1 text-[10px] rounded ${
- libraryTab === id
- ? 'bg-port-accent/20 text-port-accent'
- : 'text-gray-400 hover:text-white border border-port-border'
- }`}
- >
- <Icon className="w-3 h-3" aria-hidden="true" /> {label}
- </button>
- ))}
- </div>
+ {/* The shared TabPills owns the roving tabindex + arrow-key contract —
+ never roll a tab bar (client/src/AGENTS.md). */}
+ <TabPills
+ variant="pills"
+ size="xs"
+ tabs={LIBRARY_TABS}
+ activeTab={libraryTab}
+ onChange={setLibraryTab}
+ ariaLabel="Clip library"
+ className="mb-2"
+ />
{libraryTab === 'clips' && (libraryClips.length === 0 ? (
<div className="text-xs text-gray-500 px-1 py-4">No clips. Generate some on the Video page.</div>
diff --git a/client/src/pages/VideoTimelineEditor.test.jsx b/client/src/pages/VideoTimelineEditor.test.jsx
index 1272356b6b..2c6886e177 100644
--- a/client/src/pages/VideoTimelineEditor.test.jsx
+++ b/client/src/pages/VideoTimelineEditor.test.jsx
@@ -1,5 +1,5 @@
import { beforeEach, describe, expect, it, vi } from 'vitest';
-import { render, screen, waitFor, fireEvent } from '@testing-library/react';
+import { render, screen, waitFor, fireEvent, within, act } from '@testing-library/react';
// The editor's pure rules live in lib/videoTimelineModel.js and its blocks in
// components/media/VideoTimelineLanes.jsx, both tested there. What only exists
@@ -212,6 +212,27 @@ describe('workspace layout — mobile library regression (#5424)', () => {
fireEvent.click(screen.getByRole('button', { name: 'Hide library' }));
expect(workspace?.parentElement).toHaveClass('lg:grid-cols-[1fr_240px]');
});
+
+ it('keeps one tab stop on the Clip library bar and switches it with arrow keys (#7244)', async () => {
+ await renderEditor();
+
+ const tablist = screen.getByRole('tablist', { name: 'Clip library' });
+ const [clips, stills, audio] = within(tablist).getAllByRole('tab');
+ expect(clips).toHaveAttribute('tabindex', '0');
+ expect(stills).toHaveAttribute('tabindex', '-1');
+ expect(audio).toHaveAttribute('tabindex', '-1');
+
+ clips.focus();
+ fireEvent.keyDown(clips, { key: 'ArrowRight' });
+ // The arrow key moves the tab stop and switches the library pane together.
+ expect(stills).toHaveAttribute('aria-selected', 'true');
+ expect(stills).toHaveAttribute('tabindex', '0');
+ expect(document.activeElement).toBe(stills);
+ expect(screen.getByPlaceholderText('Search images…')).toBeInTheDocument();
+ // The stills pane fires its gallery fetch on selection — settle it so the
+ // update doesn't land outside act.
+ await act(async () => {});
+ });
});
describe('lane caps', () => {
diff --git a/client/src/pages/VoiceCallHost.jsx b/client/src/pages/VoiceCallHost.jsx
index 3fd67802a7..6d93bf77ee 100644
--- a/client/src/pages/VoiceCallHost.jsx
+++ b/client/src/pages/VoiceCallHost.jsx
@@ -21,6 +21,7 @@
import { useCallback, useEffect, useRef, useState } from 'react';
import { Mic, MicOff, PhoneCall, Radio, Volume2 } from 'lucide-react';
import socket from '../services/socket';
+import TabPills from '../components/ui/TabPills';
import { useDrawerTab } from '../hooks';
import {
CALL_FRAME_SAMPLES,
@@ -320,28 +321,18 @@ export default function VoiceCallHost() {
</p>
</header>
- <div role="tablist" aria-label="Call host mode" className="flex gap-2">
- <button
- type="button"
- role="tab"
- aria-selected={isCall}
- disabled={attached}
- onClick={() => setMode('call')}
- className={`flex min-h-[44px] items-center gap-2 rounded px-3 text-sm disabled:opacity-50 ${isCall ? 'bg-port-accent/20 text-port-accent' : 'border border-port-border text-gray-300 hover:bg-port-border/50'}`}
- >
- <PhoneCall size={16} />Call
- </button>
- <button
- type="button"
- role="tab"
- aria-selected={!isCall}
- disabled={attached}
- onClick={() => setMode('capture')}
- className={`flex min-h-[44px] items-center gap-2 rounded px-3 text-sm disabled:opacity-50 ${!isCall ? 'bg-port-accent/20 text-port-accent' : 'border border-port-border text-gray-300 hover:bg-port-border/50'}`}
- >
- <Radio size={16} />Capture system audio
- </button>
- </div>
+ {/* The shared TabPills owns the roving tabindex + arrow-key contract;
+ `disabled` keeps a locked mode out of the arrow-key order too. */}
+ <TabPills
+ variant="pills"
+ tabs={[
+ { id: 'call', label: 'Call', icon: PhoneCall, disabled: attached },
+ { id: 'capture', label: 'Capture system audio', icon: Radio, disabled: attached },
+ ]}
+ activeTab={mode}
+ onChange={setMode}
+ ariaLabel="Call host mode"
+ />
{blocked && <p role="alert" className="rounded border border-port-error bg-port-error/10 p-3 text-sm text-port-error">{blocked}</p>}
{notice && <p role="status" className="rounded border border-port-warning bg-port-warning/10 p-3 text-sm text-port-warning">{notice}</p>}
diff --git a/client/src/pages/VoiceCallHost.test.jsx b/client/src/pages/VoiceCallHost.test.jsx
index 37693434f3..13815af90a 100644
--- a/client/src/pages/VoiceCallHost.test.jsx
+++ b/client/src/pages/VoiceCallHost.test.jsx
@@ -159,6 +159,29 @@ describe('VoiceCallHost', () => {
unmount();
expect(socket.emit).toHaveBeenCalledWith('voice:call:detach');
});
+
+ it('keeps one tab stop on the mode tabs and locks both once a host is attached (#7244)', async () => {
+ render(<VoiceCallHost />, { wrapper: MemoryRouter });
+
+ const call = screen.getByRole('tab', { name: 'Call' });
+ const capture = screen.getByRole('tab', { name: 'Capture system audio' });
+ expect(call).toHaveAttribute('tabindex', '0');
+ expect(capture).toHaveAttribute('tabindex', '-1');
+
+ // ArrowRight moves the tab stop and the mode together.
+ call.focus();
+ fireEvent.keyDown(call, { key: 'ArrowRight' });
+ expect(capture).toHaveAttribute('aria-selected', 'true');
+ expect(capture).toHaveAttribute('tabindex', '0');
+ expect(document.activeElement).toBe(capture);
+ expect(await screen.findByText('Start capture')).toBeTruthy();
+
+ // Once a host is attached the mode is locked: both tabs leave the tab
+ // order AND the arrow-key order rather than being focused.
+ act(() => socket.__fire('voice:capture:state', { hostAttached: true, active: true, turns: 1 }));
+ expect(call).toBeDisabled();
+ expect(capture).toBeDisabled();
+ });
});
describe('VoiceCallHost — meeting capture mode', () => {