-
-
Notifications
You must be signed in to change notification settings - Fork 167
feat(settings): context-aware Cmd+K settings search (from #349) #399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -82,13 +82,30 @@ | |||||||||||||||||
| return resolveTab(requested as DeepLinkId); | ||||||||||||||||||
| } | ||||||||||||||||||
| return 'general'; | ||||||||||||||||||
| }, []); // Intentional — only consume the URL param on first mount. | ||||||||||||||||||
| const [tab, setTab] = React.useState<SettingsTabId>(initialTab); | ||||||||||||||||||
| // Keep the visible tab in sync when the `?tab=` param changes AFTER mount — | ||||||||||||||||||
| // e.g. the ⌘K settings search navigates to /settings?tab=<id> while Settings | ||||||||||||||||||
| // is already open. initialTab (above) only consumes the param on first mount, | ||||||||||||||||||
| // so without this the hash would update but the tab wouldn't switch. | ||||||||||||||||||
| React.useEffect(() => { | ||||||||||||||||||
| const requested = getRouteParam(route, 'tab'); | ||||||||||||||||||
| if (requested && (DEEP_LINK_IDS as readonly string[]).includes(requested)) { | ||||||||||||||||||
| setTab(resolveTab(requested as DeepLinkId)); | ||||||||||||||||||
|
cubic-dev-ai[bot] marked this conversation as resolved.
|
||||||||||||||||||
| } | ||||||||||||||||||
|
Comment on lines
+93
to
+95
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Changing the hash from a valid deep link such as Prompt for AI agents
Suggested change
|
||||||||||||||||||
| }, [route]); | ||||||||||||||||||
| const version = useAppVersion(); | ||||||||||||||||||
| // Templates' own editor is a full-page takeover with its own header/back | ||||||||||||||||||
| // button — while it's open, the outer "Templates" title/description/divider | ||||||||||||||||||
| // would just be a leftover from the list view carried over on top of it. | ||||||||||||||||||
| const [templateEditorOpen, setTemplateEditorOpen] = React.useState(false); | ||||||||||||||||||
| // Leaving the Templates tab (via the nav rail OR the ⌘K settings search) | ||||||||||||||||||
| // unmounts TemplatesTab, but its editor-open flag lived on here — a stale | ||||||||||||||||||
| // `true` would suppress the page header when Templates is reopened. Reset it | ||||||||||||||||||
| // whenever the active tab isn't Templates. | ||||||||||||||||||
| React.useEffect(() => { | ||||||||||||||||||
| if (tab !== 'templates' && templateEditorOpen) setTemplateEditorOpen(false); | ||||||||||||||||||
| }, [tab, templateEditorOpen]); | ||||||||||||||||||
| const showPageHeader = !(tab === 'templates' && templateEditorOpen); | ||||||||||||||||||
|
|
||||||||||||||||||
| // Supplies AppShell's recordingStatus/onToggleRecording props directly — | ||||||||||||||||||
|
|
||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,71 @@ | ||
| import { test, expect } from '../fixtures/electron'; | ||
| import type { Page } from '@playwright/test'; | ||
|
|
||
| /** | ||
| * T1 — renderer-only, mock IPC. Drives the context-aware ⌘K palette while the | ||
| * Settings page is open: it must switch to "Search settings…" mode, filter the | ||
| * settings index, and navigate to the tab the chosen setting lives on — and, | ||
| * critically, switch the VISIBLE tab even when Settings is already open (the | ||
| * route-reactive fix in Settings.tsx). Ported/adapted from @Vassista's PR #349. | ||
| */ | ||
|
|
||
| const palette = '[data-testid="command-palette"]'; | ||
| const input = '[data-testid="command-palette-input"]'; | ||
| const result = '[data-testid="command-palette-result"]'; | ||
| const settingsPage = '[data-testid="settings-page"]'; | ||
|
|
||
| const launchOpts = { mockIpc: true } as const; | ||
|
|
||
| async function openSettings(page: Page, tab?: string) { | ||
| await page.evaluate((t) => { | ||
| window.location.hash = t ? `#/settings?tab=${t}` : '#/settings'; | ||
| }, tab); | ||
| await expect(page.locator(settingsPage)).toBeVisible(); | ||
| } | ||
|
|
||
| test('⌘K in Settings searches settings, not notes', async ({ launchApp }) => { | ||
| const { page } = await launchApp(launchOpts); | ||
| await openSettings(page); | ||
|
|
||
| await page.keyboard.press('ControlOrMeta+k'); | ||
| await expect(page.locator(palette)).toBeVisible(); | ||
|
|
||
| // Context-aware: the palette is in settings mode. | ||
| await expect(page.locator(input)).toHaveAttribute('placeholder', 'Search settings…'); | ||
| await expect(page.locator(palette)).toContainText('Microphone'); | ||
| await expect(page.locator(palette)).toContainText('AI provider'); | ||
|
|
||
| // Filtering narrows the settings index. | ||
| await page.locator(input).fill('provider'); | ||
| await expect(page.locator(result)).toHaveCount(1); | ||
| await expect(page.locator(result).nth(0)).toContainText('AI provider'); | ||
|
|
||
| // Query is trimmed, and the index title matches the real settings label | ||
| // ("Post meeting notifications", no hyphen) so searching the visible label | ||
| // works even with surrounding whitespace. | ||
| await page.locator(input).fill(' post meeting '); | ||
| await expect(page.locator(result).filter({ hasText: 'Post meeting notifications' })).toHaveCount(1); | ||
| }); | ||
|
|
||
| test('selecting a setting navigates to its tab and switches the visible tab', async ({ | ||
| launchApp, | ||
| }) => { | ||
| const { page } = await launchApp(launchOpts); | ||
| // Start on the AI tab so the jump to a General-tab setting has to actually | ||
| // switch tabs — this exercises the route-reactive sync, not just first mount. | ||
| await openSettings(page, 'ai'); | ||
| await expect(page.locator(settingsPage)).toContainText('AI provider'); | ||
|
|
||
| await page.keyboard.press('ControlOrMeta+k'); | ||
| await page.locator(input).fill('launch on login'); | ||
| await expect(page.locator(result)).toHaveCount(1); | ||
| await expect(page.locator(result).nth(0)).toContainText('Launch on login'); | ||
| await page.keyboard.press('Enter'); | ||
|
|
||
| // Palette closes, the route carries the target tab, and the General tab is | ||
| // now the one rendered (its content is visible; the AI-only row is gone). | ||
| await expect(page.locator(palette)).toBeHidden(); | ||
| await expect.poll(() => page.evaluate(() => window.location.hash)).toContain('tab=general'); | ||
| await expect(page.locator(settingsPage)).toContainText('Launch on login'); | ||
| await expect(page.locator(settingsPage)).not.toContainText('AI provider'); | ||
| }); |
Uh oh!
There was an error while loading. Please reload this page.