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: keep command palette results visible in short viewports (#9529)

Adam Eivyed8aa177bfed
diff --git a/client/src/components/CmdKSearch.browser.test.js b/client/src/components/CmdKSearch.browser.test.js
new file mode 100644
index 0000000000..edc8f26020
--- /dev/null
+++ b/client/src/components/CmdKSearch.browser.test.js
@@ -0,0 +1,144 @@
+// @vitest-environment node
+import { afterAll, beforeAll, describe, expect, it } from 'vitest';
+import { existsSync } from 'node:fs';
+import { createRequire } from 'node:module';
+import { fileURLToPath } from 'node:url';
+import { createServer } from 'vite';
+import react from '@vitejs/plugin-react';
+
+const requireServer = createRequire(new URL('../../../server/package.json', import.meta.url));
+const { chromium } = requireServer('playwright-core');
+const chrome = [process.env.CHROME_PATH, chromium.executablePath(),
+ '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome',
+ '/usr/bin/google-chrome', '/usr/bin/chromium', '/usr/bin/chromium-browser',
+].find(path => path && existsSync(path));
+
+describe.skipIf(!chrome)('command palette viewport and keyboard layout', () => {
+ let server;
+ let browser;
+ let origin;
+ beforeAll(async () => {
+ server = await createServer({
+ configFile: false,
+ root: fileURLToPath(new URL('../..', import.meta.url)),
+ plugins: [react(), {
+ name: 'palette-browser-fixture',
+ resolveId(id) { if (id === '/palette-fixture.jsx') return '\0palette-fixture.jsx'; },
+ load(id) {
+ if (id !== '\0palette-fixture.jsx') return;
+ return `
+ import React from 'react';
+ import { createRoot } from 'react-dom/client';
+ import { MemoryRouter, useLocation } from 'react-router';
+ import CmdKSearch from '/src/components/CmdKSearch.jsx';
+ import '/src/index.css';
+ function Probe() { return React.createElement('output', null, useLocation().pathname); }
+ createRoot(document.getElementById('root')).render(
+ React.createElement(MemoryRouter, null, React.createElement('button', { id: 'opener' }, 'Open'), React.createElement(CmdKSearch), React.createElement(Probe))
+ );
+ `;
+ },
+ configureServer(vite) {
+ vite.middlewares.use('/palette-test', async (_req, res) => {
+ res.setHeader('Content-Type', 'text/html');
+ res.end(await vite.transformIndexHtml('/palette-test',
+ '<div id="root"></div><script type="module" src="/palette-fixture.jsx"></script>'));
+ });
+ },
+ }],
+ server: { host: '127.0.0.1', port: 0 },
+ });
+ await server.listen();
+ origin = server.resolvedUrls.local[0];
+ browser = await chromium.launch({ executablePath: chrome, headless: true });
+ }, 60000);
+ afterAll(async () => {
+ await browser?.close();
+ await server?.close();
+ });
+
+ it.each([{ width: 756, height: 412 }, { width: 667, height: 320 }, { width: 1440, height: 1000 }])(
+ 'keeps active results visible at $width x $height and preserves dispatch and capture',
+ async (viewport) => {
+ const page = await browser.newPage({ viewport });
+ try {
+ await page.route('**/api/**', route => {
+ const path = new URL(route.request().url()).pathname;
+ const body = path === '/api/palette/manifest'
+ ? { nav: Array.from({ length: 40 }, (_, i) => ({
+ id: `nav.example.${i}`, path: `/example/${i}`, label: `Example ${String(i).padStart(2, '0')}`,
+ section: 'Example', aliases: [], keywords: [],
+ })), actions: [{ id: 'brain_capture', label: 'Capture to Brain', section: 'Brain' }] }
+ : { features: [], layouts: [], sources: [], items: [] };
+ return route.fulfill({ json: body });
+ });
+ await page.goto(`${origin}palette-test`);
+ await page.locator('#opener').focus();
+ await page.keyboard.press('ControlOrMeta+k');
+ const input = page.getByRole('combobox');
+ const searchResponse = page.waitForResponse(response => response.url().includes('/api/search'));
+ const catalogResponse = page.waitForResponse(response => response.url().includes('/api/catalog/ingredients'));
+ await input.fill('Example');
+ await Promise.all([searchResponse, catalogResponse]);
+ await page.evaluate(() => new Promise(resolve => requestAnimationFrame(() => requestAnimationFrame(resolve))));
+ await page.getByRole('option').first().waitFor();
+ const count = await page.getByRole('option').count();
+ expect(count).toBeGreaterThan(6);
+ for (let i = 0; i < count; i += 1) {
+ if (i) {
+ const previous = await input.getAttribute('aria-activedescendant');
+ await page.keyboard.press('ArrowDown');
+ await page.waitForFunction(id => document.querySelector('[role="combobox"]').getAttribute('aria-activedescendant') !== id, previous);
+ }
+ await page.waitForFunction(() => {
+ const input = document.querySelector('[role="combobox"]');
+ const active = document.getElementById(input.getAttribute('aria-activedescendant')).getBoundingClientRect();
+ const list = document.querySelector('[role="listbox"]').parentElement.getBoundingClientRect();
+ return active.top >= list.top - 1 && active.bottom <= list.bottom + 1;
+ });
+ const geometry = await page.getByRole('dialog').evaluate(dialog => {
+ const rect = el => { const r = el.getBoundingClientRect(); return { top: r.top, bottom: r.bottom, height: r.height }; };
+ const list = dialog.querySelector('[role="listbox"]').parentElement;
+ const active = document.getElementById(dialog.querySelector('[role="combobox"]').getAttribute('aria-activedescendant'));
+ return { panel: rect(dialog), header: rect(dialog.firstElementChild), footer: rect(dialog.lastElementChild),
+ list: rect(list), active: rect(active), overflow: list.scrollHeight > list.clientHeight };
+ });
+ for (const rect of [geometry.panel, geometry.header, geometry.footer, geometry.list]) {
+ expect(rect.top).toBeGreaterThanOrEqual(0);
+ expect(rect.bottom).toBeLessThanOrEqual(viewport.height);
+ }
+ expect(geometry.active.top).toBeGreaterThanOrEqual(geometry.list.top - 1);
+ expect(geometry.active.bottom).toBeLessThanOrEqual(geometry.list.bottom + 1);
+ expect(geometry.overflow).toBe(true);
+ if (viewport.height === 1000) expect(geometry.list.height).toBe(384);
+ }
+ const selected = await input.getAttribute('aria-activedescendant');
+ const destination = await page.locator('[role="option"]').evaluateAll((options, id) =>
+ options.find(option => option.id === id).textContent.match(/\/example\/\d+/)[0], selected);
+ await page.keyboard.press('Enter');
+ await page.waitForFunction(path => document.querySelector('output').textContent === path, destination);
+ await page.locator('#opener').focus();
+ await page.keyboard.press('ControlOrMeta+k');
+ await input.fill('Capture to Brain');
+ await page.getByRole('option').first().click();
+ const captureInput = page.getByLabel('Capture to Brain', { exact: true });
+ await captureInput.fill('Synthetic thought');
+ const capture = await page.getByRole('dialog').boundingBox();
+ expect(capture.y + capture.height).toBeLessThanOrEqual(viewport.height);
+ await page.waitForFunction(() => !document.querySelector('button[aria-label="Capture thought"]').disabled);
+ // Exercise boundary wrapping; forward Tab from the initial input has
+ // a separate shared-hook defect tracked in #9537.
+ await page.keyboard.press('Shift+Tab');
+ expect(await page.getByRole('button', { name: 'Capture thought' }).evaluate(el => el === document.activeElement)).toBe(true);
+ await page.keyboard.press('Tab');
+ expect(await captureInput.evaluate(el => el === document.activeElement)).toBe(true);
+ await page.keyboard.press('Escape');
+ await input.waitFor();
+ await page.keyboard.press('Escape');
+ await page.waitForFunction(() => document.activeElement.id === 'opener');
+ } finally {
+ await page.close();
+ }
+ }, 60000,
+ );
+});
diff --git a/client/src/components/CmdKSearch.jsx b/client/src/components/CmdKSearch.jsx
index df488407a2..5fb9f492a0 100644
--- a/client/src/components/CmdKSearch.jsx
+++ b/client/src/components/CmdKSearch.jsx
@@ -478,9 +478,9 @@ export default function CmdKSearch() {
role="dialog"
aria-modal="true"
aria-label="Command palette"
- className="relative w-full max-w-3xl mx-4 bg-port-card rounded-xl border border-port-border shadow-2xl overflow-hidden"
+ className="relative flex flex-col max-h-dvh-cap [--dvh-inset:calc(10vh+1rem)] w-full max-w-3xl mx-4 bg-port-card rounded-xl border border-port-border shadow-2xl overflow-hidden"
>
- <div className="flex items-center gap-3 px-4 py-4 border-b border-port-border">
+ <div className="flex shrink-0 items-center gap-3 px-4 py-4 border-b border-port-border">
{captureMode ? <Brain size={18} className="text-port-accent shrink-0" /> : <Search size={18} className="text-gray-400 shrink-0" />}
<div className="flex-1 min-w-0">
{captureMode ? (
@@ -534,7 +534,7 @@ export default function CmdKSearch() {
)}
</div>
- {!captureMode && <div className="max-h-96 overflow-y-auto p-2">
+ {!captureMode && <div className="min-h-0 max-h-96 overflow-y-auto p-2">
<div id={listboxId} role="listbox" aria-label="Command palette results">
{renderGroup(
<History size={14} />,
@@ -631,12 +631,12 @@ export default function CmdKSearch() {
</div>}
{captureMode && (
- <div className="px-4 py-5 text-sm text-gray-400">
+ <div className="min-h-0 overflow-y-auto px-4 py-5 text-sm text-gray-400">
Capture one unstructured thought or URL without leaving the command palette.
</div>
)}
- <div className="flex items-center justify-between gap-2 px-4 py-2 border-t border-port-border text-[11px] text-gray-500">
+ <div className="flex shrink-0 items-center justify-between gap-2 px-4 py-2 border-t border-port-border text-[11px] text-gray-500">
<span>{captureMode ? '↵ capture · Esc back' : '↑↓ navigate · ↵ run · Esc close'}</span>
<span>Shared backbone with voice agent</span>
</div>