Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

test(e2e): trace the palette destinations from source, and assert focus leaves the sidebar\n\nTwo more review findings on #5887, both correct, plus two errors of my own that\ntracing the routes properly exposed.\n\nCodeRabbit: `/^#\/settings/` also matches `#/settings/notifications`, another\nmapped action's destination — so the palette test could pass while Enter ran the\nwrong item, which is the regression it exists to catch. End-anchored every\npattern.\n\nFollowing that through the redirect chains found two mistakes in the map I added\nin the previous commit:\n\n * nav.intelligence targets `/settings/intelligence`, which is itself\n `<Navigate to="/brain">` (settingsRouteElements.tsx:184). It lands on\n `#/brain`, not `#/settings/intelligence`.\n * nav.settings targets `/settings`, whose index is `SettingsIndexRedirect`;\n at the >=768px viewport Playwright runs that is\n `<Navigate to="/settings/account">` (SettingsIndexRedirect.tsx:15-18).\n So `#/settings/account`.\n\nAnd the fixture started at `/#/brain`, which is nav.intelligence's landing — so\nhad that action been selected, "the hash matches" would have been true before\nEnter and told us nothing. Moved to `/#/notifications`, which no mapped action\ntargets.\n\nCodeRabbit, focus trap: `stillInNav` only tested that focus left the nav ROWS.\nFocus landing on the collapse toggle satisfies that while remaining inside the\nsidebar column, so a real trap would still pass. Now asks the DOM after each Tab\nwhether `document.activeElement` is still contained by\n`[data-testid="root-shell-sidebar"]`, and requires at least one step to leave.\n\nNOT EXECUTED — no local builds or test runs in this phase. Destinations were\ntraced by reading globalActions.ts:119-170, AppRoutes.tsx,\nsettingsRouteElements.tsx:184 and SettingsIndexRedirect.tsx:15-18. Prettier\nclean, tsc reports no errors in the touched files. CI is the check.\n

M3gA-Mind231b8814903b
diff --git a/app/test/playwright/specs/app-shell-keyboard-navigation.spec.ts b/app/test/playwright/specs/app-shell-keyboard-navigation.spec.ts
index 7243e606d7..f70f5efefc 100644
--- a/app/test/playwright/specs/app-shell-keyboard-navigation.spec.ts
+++ b/app/test/playwright/specs/app-shell-keyboard-navigation.spec.ts
@@ -105,15 +105,27 @@ test.describe('App shell — keyboard traversal', () => {
await navRow(page, 'connections').focus();
const seen = new Set<string>();
+ let everLeftSidebar = false;
for (let i = 0; i < 12; i += 1) {
await page.keyboard.press('Tab');
seen.add(await focused(page));
+ // "Left the nav rows" is not "left the sidebar": focus landing on the
+ // collapse toggle satisfies the first and not the second, so a trap
+ // inside the sidebar column would still pass (#5887, CodeRabbit).
+ // Ask the DOM directly whether the active element is still contained by
+ // the sidebar.
+ const inside = await page.evaluate(() => {
+ const bar = document.querySelector('[data-testid="root-shell-sidebar"]');
+ const active = document.activeElement;
+ return Boolean(bar && active && bar.contains(active));
+ });
+ if (!inside) everLeftSidebar = true;
}
- const stillInNav = [...seen].every(s => s.startsWith('nav:tab-'));
- expect(stillInNav, `focus never left the nav rail; visited: ${[...seen].join(', ')}`).toBe(
- false
- );
+ expect(
+ everLeftSidebar,
+ `focus never left the sidebar column in 12 tabs; visited: ${[...seen].join(', ')}`
+ ).toBe(true);
});
test('a focused nav row shows a visible focus ring', async ({ page }) => {
diff --git a/app/test/playwright/specs/command-palette-keyboard.spec.ts b/app/test/playwright/specs/command-palette-keyboard.spec.ts
index b879b58003..044fa2d58a 100644
--- a/app/test/playwright/specs/command-palette-keyboard.spec.ts
+++ b/app/test/playwright/specs/command-palette-keyboard.spec.ts
@@ -32,23 +32,31 @@ const PALETTE_INPUT = 'input[cmdk-input]';
const ITEM = '[cmdk-item]';
/**
- * Where each seed navigation action lands, from `lib/commands/globalActions.ts`
- * (`nav('/…')` handlers) followed through `AppRoutes.tsx`'s redirects.
+ * Where each seed navigation action ACTUALLY lands — the handler's target in
+ * `lib/commands/globalActions.ts:119-170` followed through every redirect.
*
- * Needed because asserting "the hash is non-empty" cannot tell one action from
- * another — raised in review (#5887) by both CodeRabbit and Codex, and Codex
- * pinned down why it was worse than merely weak: the fixture boots on `#/chat`,
- * and the first two actions are `nav.home` (-> `/home` -> `/chat`) and
- * `nav.chat` (-> `/chat`), so the old assertion was already true BEFORE Enter
- * and stayed true whichever action ran, or if none did.
+ * Traced from source rather than assumed, which caught two errors in my first
+ * version of this map (#5887, CodeRabbit):
+ *
+ * nav.intelligence -> `/settings/intelligence`, which is itself
+ * `<Navigate to="/brain">` (settingsRouteElements.tsx:184), so it lands on
+ * `#/brain` — NOT `#/settings/intelligence` as I first wrote.
+ * nav.settings -> `/settings`, whose index is `SettingsIndexRedirect`; at the
+ * >=768px viewport Playwright runs, that is `<Navigate to="/settings/account">`
+ * (SettingsIndexRedirect.tsx:15-18). So `#/settings/account`.
+ *
+ * Every pattern is end-anchored. A loose `/^#\/settings/` also matches
+ * `#/settings/notifications`, which is another mapped action's destination — so
+ * the test could pass while Enter ran the wrong item, which is the exact
+ * regression it exists to catch (#5887, CodeRabbit).
*/
const DESTINATIONS: Record<string, RegExp> = {
- 'nav.home': /^#\/chat/, // /home redirects to /chat
- 'nav.chat': /^#\/chat/,
- 'nav.intelligence': /^#\/settings\/intelligence/,
- 'nav.skills': /^#\/connections/,
- 'nav.activity': /^#\/settings\/notifications/, // /activity redirects
- 'nav.settings': /^#\/settings/,
+ 'nav.home': /^#\/chat(?:[/?]|$)/, // /home -> /chat
+ 'nav.chat': /^#\/chat(?:[/?]|$)/,
+ 'nav.intelligence': /^#\/brain(?:[?]|$)/, // /settings/intelligence -> /brain
+ 'nav.skills': /^#\/connections(?:[?]|$)/,
+ 'nav.activity': /^#\/settings\/notifications(?:[?]|$)/, // /activity -> here
+ 'nav.settings': /^#\/settings\/account(?:[?]|$)/, // /settings index -> account
};
const shortcut = () => (process.platform === 'darwin' ? 'Meta+K' : 'Control+K');
@@ -109,9 +117,9 @@ test.describe('Command palette — keyboard-only selection', () => {
// decorative one: if ArrowDown moved the highlight visually but Enter still
// fired item 0, the test must fail.
//
- // Start somewhere neither candidate lands, so "the route changed" carries
- // information at all.
- await page.goto('/#/brain');
+ // Start somewhere NO mapped action lands, so "the route changed" carries
+ // information. `/brain` would not do — it is nav.intelligence's landing.
+ await page.goto('/#/notifications');
await openPalette(page);
const ids = await visibleIds(page);