Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions .ai/contexts/ipc-bridge.md
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,20 @@ pages are `general`, `sessions`, `keyboard`, `automation`, `remote`, `integratio

The panel reparents existing rows into named regions before wiring their handlers.
Hidden pages remain in the DOM, preserving every field id and the one Save path.
The settings filter (`#sv-filter`) reads each `.settings-field-info.textContent`
on input, using a trimmed, case-insensitive substring. It hides unmatched rows,
empty groups and disclosure prose, then stacks matching pages in one scrolling
area. It does not build an index, read ids or control values, re-render controls,
or enter the dirty snapshot. No-match navigation items are dimmed but remain
operable; selection changes the remembered page without leaving filter mode.
Tab from navigation enters a visible matching control, or Save when there are no
results. Escape in the filter clears it, consumes the key and keeps focus; clearing
restores the selected page and all its groups. Reopening starts with an empty filter.
Archived is excluded because it manages objects with its own filter and selection;
the settings filter never modifies that manager's DOM. Project identity and Danger
zone have no settings rows and are excluded too. The existing ResizeObserver remains
the only narrow-layout trigger; the filter stays above the horizontal nav strip.
DOM regressions and CSS contracts live in `test/dom-settings-nav.test.js`.
The Archived projects manager is documented above. This project shows the identity
from the same path-and-folder-key project lookup used by deletion, performed after
shell-profile loading finishes: name, full path, host label, folder key and cached
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ What changes for you in each release of Switchboard. How to write an entry: [doc
## Unreleased

### New
- Filter Global or Project Settings by label or description across pages, edit matching settings, and press Escape to return to your page. (#1173)
- Settings → Sessions → CLI Agents offers **Show Codex usage**, off by default. Turn it on to show your Codex limits in the status bar and Stats; usage hides quietly when unavailable. (#1139)

### Changed
Expand Down
14 changes: 14 additions & 0 deletions docs/settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ All pages share one Save: switching pages keeps edits, and the footer counts
unsaved changes. Save keeps Settings open and flashes Saved; Cancel discards edits
without asking. Live switches and Unarchive still take effect immediately.

**Filter settings…**, above the navigation, finds text in setting labels and
descriptions across all pages, in both Global and Project Settings. Matching rows
appear under their page titles; pages without matches are dimmed in the navigation.
Matching ignores case and outer spaces, and does not search control values or ids.
There is no fuzzy matching. You can edit and save the matching rows normally.
Press Escape in the field, or clear it, to return to the current page. Selecting a
navigation item while filtering keeps the results visible and chooses the page
to return to. The filter is keyboard reachable and does not count as an edit.

Archived keeps its own **Filter by name, path or host…** field: archives are excluded
from the settings filter. Clear the settings filter to use Archived; its filter
and selected rows are preserved. Project identity and Danger zone actions are
also outside the settings search.

### General

Startup, Shell, Terminal and IDE settings:
Expand Down
52 changes: 47 additions & 5 deletions public/settings-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -537,7 +537,7 @@
: [['general', 'General'], ['sessions', 'Sessions'], ['keyboard', 'Keyboard'], ['automation', 'Automation'], ['remote', 'Remote hosts'], ['integrations', 'Integrations'], ['archived', 'Archived'], ['advanced', 'Advanced']];
const layout = document.createElement('div');
layout.className = 'settings-layout';
layout.innerHTML = `<nav class="settings-nav" aria-label="Settings sections"><ul>${pageDefs.map(([id, label]) => `<li><button type="button" data-section="${id}" aria-controls="settings-page-${id}" tabindex="-1">${label}</button></li>`).join('')}</ul></nav><div class="settings-pages"></div>`;
layout.innerHTML = `<div class="settings-navigation"><input type="search" id="sv-filter" class="settings-input settings-filter" aria-label="Filter settings" placeholder="Filter settings…"><nav class="settings-nav" aria-label="Settings sections"><ul>${pageDefs.map(([id, label]) => `<li><button type="button" data-section="${id}" aria-controls="settings-page-${id}" tabindex="-1">${label}</button></li>`).join('')}</ul></nav></div><div class="settings-pages"></div>`;
form.prepend(layout);
const pages = new Map(pageDefs.map(([id, label]) => {
const page = document.createElement('section');
Expand Down Expand Up @@ -631,14 +631,54 @@
});
const navButtons = [...layout.querySelectorAll('.settings-nav button')];
const storageKey = 'settingsSection:' + (isProject ? 'project' : 'global');
const filter = layout.querySelector('#sv-filter');
const emptyResults = document.createElement('p');
emptyResults.className = 'settings-description settings-filter-empty';
emptyResults.setAttribute('role', 'status');
emptyResults.textContent = 'No settings match. Clear the filter to see all settings.';
emptyResults.hidden = true;
layout.querySelector('.settings-pages').append(emptyResults);
let selectedPage;
function applySettingsFilter() {
const query = filter.value.trim().toLowerCase();
layout.classList.toggle('settings-filtering', Boolean(query));
let anyMatch = false;
for (const [id, page] of pages) {
let matches = false;
if (id !== 'archived') {
for (const row of page.querySelectorAll('.settings-field')) {
const text = row.querySelector('.settings-field-info')?.textContent.toLowerCase() || '';
row.hidden = Boolean(query) && !text.includes(query);
if (!row.hidden) matches = true;
}
for (const group of page.querySelectorAll('.settings-section')) {
group.hidden = Boolean(query) && ![...group.querySelectorAll('.settings-field')].some(row => !row.hidden);
}
page.querySelectorAll('.settings-details').forEach(details => { details.hidden = Boolean(query); });
}
page.hidden = query ? !matches : id !== selectedPage;
navButtons.find(button => button.dataset.section === id).classList.toggle('settings-no-match', Boolean(query) && !matches);
anyMatch ||= matches;
}
emptyResults.hidden = !query || anyMatch;
}
filter.addEventListener('input', applySettingsFilter);
filter.addEventListener('keydown', event => {
if (event.key !== 'Escape' || !filter.value) return;
event.preventDefault();
event.stopPropagation();
filter.value = '';
applySettingsFilter();
});
function revealActiveNav() {
if (settingsViewer.classList.contains('settings-narrow')) {
navButtons.find(button => button.classList.contains('active'))?.scrollIntoView?.({ block: 'nearest', inline: 'nearest' });
}
}
function selectPage(id) {
if (!pages.has(id)) id = pageDefs[0][0];
for (const [pageId, page] of pages) page.hidden = pageId !== id;
selectedPage = id;
applySettingsFilter();
for (const button of navButtons) {
const selected = button.dataset.section === id;
button.classList.toggle('active', selected);
Expand All @@ -663,8 +703,10 @@
navButtons[next].focus();
} else if (event.key === 'Tab' && !event.shiftKey) {
event.preventDefault();
const page = pages.get(button.dataset.section);
(page.querySelector('input:not(:disabled), select:not(:disabled), button:not(:disabled), summary') || page.querySelector('h2')).focus();
const selected = pages.get(button.dataset.section);
const page = selected.hidden ? [...pages.values()].find(page => !page.hidden) : selected;
const control = page && [...page.querySelectorAll('input:not(:disabled), select:not(:disabled), button:not(:disabled), summary')].find(control => !control.closest('[hidden]'));
(control || page?.querySelector('h2') || form.querySelector('#sv-save-btn')).focus();
}
});
}
Expand All @@ -689,7 +731,7 @@
unsaved.className = 'settings-unsaved';
unsaved.setAttribute('role', 'status');
footer.prepend(unsaved);
const trackedControls = [...form.querySelectorAll('input, select')].filter(control => !['sv-activity-trace', 'sv-activity-reporting'].includes(control.id));
const trackedControls = [...form.querySelectorAll('input, select')].filter(control => !['sv-filter', 'sv-activity-trace', 'sv-activity-reporting'].includes(control.id));
const controlValue = control => String(control.type === 'checkbox' ? control.checked : control.value);
let initialHosts;
let initialShortcuts;
Expand Down
39 changes: 37 additions & 2 deletions public/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -4101,8 +4101,22 @@ body { display: flex; flex-direction: column; }
gap: 24px;
}

.settings-nav {
.settings-navigation {
flex: 0 0 160px;
min-width: 0;
min-height: 0;
display: flex;
flex-direction: column;
gap: 12px;
}

.settings-navigation .settings-filter {
width: 100%;
min-width: 0;
box-sizing: border-box;
}

.settings-nav {
overflow-y: auto;
}

Expand Down Expand Up @@ -4134,6 +4148,10 @@ body { display: flex; flex-direction: column; }
background: var(--accent-wash);
}

.settings-nav button.settings-no-match {
opacity: 0.45;
}

.settings-nav button:focus-visible,
.settings-details summary:focus-visible {
outline: 2px solid var(--accent);
Expand All @@ -4156,6 +4174,20 @@ body { display: flex; flex-direction: column; }
display: none;
}

.settings-layout [hidden] {
display: none;
}

.settings-filtering .settings-pages {
overflow-y: auto;
}

.settings-filtering .settings-page {
height: auto;
overflow-y: visible;
margin-bottom: 24px;
}

.settings-page h2 {
font-size: 20px;
margin: 0 0 16px;
Expand Down Expand Up @@ -4268,8 +4300,11 @@ body { display: flex; flex-direction: column; }
gap: 12px;
}

.settings-narrow .settings-nav {
.settings-narrow .settings-navigation {
flex: 0 0 auto;
}

.settings-narrow .settings-nav {
overflow-x: auto;
}

Expand Down
166 changes: 166 additions & 0 deletions test/dom-settings-nav.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,172 @@ const root = path.join(__dirname, '..');
const settle = () => new Promise(resolve => setImmediate(resolve));
const globalPages = ['general', 'sessions', 'keyboard', 'automation', 'remote', 'integrations', 'archived', 'advanced'];

test('settings filter is labelled and keyboard reachable above navigation in both scopes', async t => {
const h = setup(t);
for (const scope of ['global', 'project']) {
await h.open(scope);
const filter = h.q('#sv-filter');
assert.ok(filter, 'Settings exposes a filter field');
assert.equal(filter.getAttribute('aria-label'), 'Filter settings');
assert.equal(filter.placeholder, 'Filter settings…');
assert.equal(filter.tabIndex, 0);
assert.ok(filter.compareDocumentPosition(h.q('.settings-nav')) & h.w.Node.DOCUMENT_POSITION_FOLLOWING);
filter.focus();
assert.equal(h.w.document.activeElement, filter);
}
});

function filterSettings(h, value) {
const filter = h.q('#sv-filter');
assert.ok(filter, 'Settings exposes a filter field');
filter.value = value;
filter.dispatchEvent(new h.w.Event('input', { bubbles: true }));
return filter;
}

function visibleSettingsRows(h) {
return [...h.w.document.querySelectorAll('.settings-page .settings-field')]
.filter(row => !row.closest('[hidden]'));
}

test('filter beta leaves only its row under General and dims every other navigation item', async t => {
const h = setup(t);
await h.open();
h.click('sessions');
filterSettings(h, ' BeTa ');
assert.deepEqual(h.active(), ['general']);
assert.deepEqual(visibleSettingsRows(h).map(row => row.querySelector('.settings-label').textContent), ['Receive beta versions']);
assert.equal(h.q('#settings-page-general h2').textContent, 'General');
for (const button of h.nav()) assert.equal(button.classList.contains('settings-no-match'), button.dataset.section !== 'general');
assert.deepEqual([...h.q('#settings-page-general').querySelectorAll('.settings-section')].filter(group => !group.hidden).map(group => group.querySelector('h3').textContent), ['Updates']);
});

test('filter reads current descriptions across pages, not ids, values or fuzzy words', async t => {
const h = setup(t);
await h.open();
filterSettings(h, 'downgrades');
assert.deepEqual(visibleSettingsRows(h).map(row => row.querySelector('input')?.id), ['sv-receive-beta-versions']);
h.q('#sv-pre-launch').value = 'uniquefiltervalue';
for (const term of ['uniquefiltervalue', 'sv-receive-beta-versions', 'recbeta']) {
filterSettings(h, term);
assert.deepEqual(visibleSettingsRows(h), [], term + ' must not match');
assert.deepEqual(h.active(), []);
assert.equal(h.q('.settings-filter-empty')?.hidden, false);
assert.match(h.q('.settings-filter-empty').textContent, /No settings match/);
}
for (const id of ['sv-receive-beta-versions', 'sv-pre-launch']) {
h.q('#' + id).closest('.settings-field').querySelector('.settings-description').append(' currentfiltertext');
}
filterSettings(h, 'currentfiltertext');
assert.deepEqual(h.active(), ['general', 'sessions']);
assert.equal(visibleSettingsRows(h).length, 2, 'matching reads live DOM descriptions');
});

test('Escape or clearing restores the current page, rows and navigation without persisting a filter', async t => {
const h = setup(t);
await h.open();
h.click('keyboard');
const filter = filterSettings(h, 'beta');
assert.deepEqual(h.active(), ['general']);
assert.equal(h.w.localStorage.getItem('settingsSection:global'), 'keyboard');
filter.focus();
const escape = new h.w.KeyboardEvent('keydown', { key: 'Escape', bubbles: true, cancelable: true });
filter.dispatchEvent(escape);
assert.equal(filter.value, '');
assert.equal(escape.defaultPrevented, true);
assert.equal(h.w.document.activeElement, filter);
assert.deepEqual(h.active(), ['keyboard']);
assert.equal(visibleSettingsRows(h).length, 8);
assert.ok(h.nav().every(button => !button.classList.contains('settings-no-match')));
filterSettings(h, 'beta');
filterSettings(h, '');
assert.deepEqual(h.active(), ['keyboard']);
filterSettings(h, 'beta');
await h.open();
assert.equal(h.q('#sv-filter').value, '');
assert.deepEqual(h.active(), ['keyboard']);
});

test('filtered navigation keeps results stacked and Tab focuses a visible matching control', async t => {
const h = setup(t);
await h.open();
filterSettings(h, 'beta');
const nav = h.click('sessions');
assert.deepEqual(h.active(), ['general'], 'navigation cannot expose unrelated rows while filtering');
nav.dispatchEvent(new h.w.KeyboardEvent('keydown', { key: 'Tab', bubbles: true, cancelable: true }));
assert.equal(h.w.document.activeElement, h.q('#sv-receive-beta-versions'));
filterSettings(h, '');
assert.deepEqual(h.active(), ['sessions']);
});

test('a filtered global row saves through the same form and filtering is never a dirty edit', async t => {
const h = setup(t);
await h.open();
const toggle = h.q('#sv-receive-beta-versions');
filterSettings(h, 'beta');
assert.equal(h.q('#sv-unsaved').textContent, '', 'filter is not a setting');
assert.deepEqual(visibleSettingsRows(h), [toggle.closest('.settings-field')]);
assert.equal(h.q('#sv-receive-beta-versions'), toggle);
toggle.click();
h.q('#sv-save-btn').click();
await settle();
assert.equal(h.saved.global.receiveBetaVersions, true);
assert.equal(Object.hasOwn(h.saved.global, 'filter'), false);
assert.equal(h.q('#sv-unsaved').textContent, '');
filterSettings(h, 'other text');
assert.equal(h.q('#sv-unsaved').textContent, '');
});

test('project filtering reveals Launch settings, preserves inheritance and saves overrides', async t => {
const h = setup(t);
await h.open('project');
h.click('project');
filterSettings(h, 'pre-launch');
assert.deepEqual(h.active(), ['launch']);
assert.deepEqual(visibleSettingsRows(h).map(row => row.querySelector('.settings-label').textContent), ['Pre-launch Command']);
const field = h.q('#sv-pre-launch');
assert.equal(field.disabled, true);
h.q('[data-field="preLaunchCmd"]').click();
field.value = 'echo filter';
field.dispatchEvent(new h.w.Event('input', { bubbles: true }));
h.q('#sv-save-btn').click();
await settle();
assert.equal(h.saved['project:/project'].preLaunchCmd, 'echo filter');
filterSettings(h, '');
assert.deepEqual(h.active(), ['project']);
assert.equal(h.q('#sv-archive-btn').closest('[hidden]'), null);
});

test('Archived retains its independent filter and selection when settings filtering is cleared', async t => {
const h = setup(t);
h.saved.global = { hiddenProjects: ['/alpha', '/beta'] };
await h.open('global', { section: 'archived' });
const archivedFilter = h.q('.archived-filter');
archivedFilter.value = 'beta';
archivedFilter.dispatchEvent(new h.w.Event('input', { bubbles: true }));
const selection = h.q('.archived-row input[type="checkbox"]');
assert.ok(selection);
selection.click();
filterSettings(h, 'beta');
assert.deepEqual(h.active(), ['general'], 'Archived is excluded from settings matches');
assert.equal(h.q('#sv-unsaved').textContent, '');
filterSettings(h, '');
assert.deepEqual(h.active(), ['archived']);
assert.equal(h.q('.archived-filter'), archivedFilter);
assert.equal(archivedFilter.value, 'beta');
assert.equal(selection.checked, true);
assert.equal(h.w.document.querySelectorAll('.archived-row').length, 1);
assert.match(h.q('.archived-row').textContent, /beta/);
});

test('filter layout hides unmatched flex rows and stacks results in a shared scrolling area', () => {
const css = fs.readFileSync(path.join(root, 'public/style.css'), 'utf8');
assert.match(css, /\.settings-layout \[hidden\]\s*\{\s*display:\s*none/);
assert.match(css, /\.settings-filtering \.settings-pages\s*\{[^}]*overflow-y:\s*auto/);
assert.match(css, /\.settings-filtering \.settings-page\s*\{[^}]*height:\s*auto/);
assert.match(css, /\.settings-nav button\.settings-no-match\s*\{[^}]*opacity:/);
});

test('Codex usage is opt-in under CLI Agents and saving applies it without restart', async t => {
const h = setup(t);
const applied = [];
Expand Down
Loading