Skip to content
Merged
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
Original file line numberDiff line numberDiff line change
Expand Up@@ -1248,6 +1248,7 @@ export function MasterSearchHeader({
recentQueries={recentQueries}
commandScopes={commandScopes}
placement={commandSurfacePlacement}
requiresTypedQueryToOpen={usesPhoneFooterDock}
dropdownOpen={commandDropdownOpen}
onDropdownOpenChange={setCommandDropdownOpen}
onQueryChange={onQueryChange}
Expand Down
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
"use client";

import { AlertTriangle, Clock, CornerDownLeft, Search, X } from "lucide-react";
import { useEffect, useId, useMemo, useState, type KeyboardEvent as ReactKeyboardEvent, type ReactNode } from "react";
import {
useEffect,
useId,
useMemo,
useRef,
useState,
type KeyboardEvent as ReactKeyboardEvent,
type ReactNode,
} from "react";

import {
modeActionItemsFor,
Expand DownExpand Up@@ -261,6 +269,7 @@ export function UniversalSearchCommandSurface({
onFocusSearchInput,
onListboxIdReady,
placement = "inline",
requiresTypedQueryToOpen = false,
children,
}: {
modeId: AppModeId;
Expand All@@ -279,14 +288,20 @@ export function UniversalSearchCommandSurface({
onFocusSearchInput?: () => void;
onListboxIdReady?: (listboxId: string) => void;
placement?: CommandSurfacePlacement;
requiresTypedQueryToOpen?: boolean;
children: ReactNode;
}) {
const config = searchCommandSurfaceConfig(modeId);
const listboxId = useId();
const [activeIndex, setActiveIndex] = useState(-1);
const trimmedQuery = query.trim();
const composerFocusedRef = useRef(false);
const mode = appModeDefinition(modeId);

function canOpenDropdownNow() {
return !requiresTypedQueryToOpen || trimmedQuery.length > 0;
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deferral applies beyond phone

Low Severity

Typed-query deferral is keyed on placement === "bottom-dock", but master-search-header assigns bottom-dock to every answer-mode footer composer, not only phone footer layouts. Desktop answer search loses focus-only recents and keyboard-open behavior that inline placement still provides, which goes beyond the PR’s phone-only intent.

Fix in CursorFix in Web

Reviewed by Cursor Bugbot for commit 1f95987. Configure here.


const showSafetyBanner =
modeId === "differentials" && differentialRedFlagTerms.some((term) => trimmedQuery.toLowerCase().includes(term));
const showFormCodeHint = modeId === "forms" && isFormCodeQuery(trimmedQuery);
Expand DownExpand Up@@ -514,12 +529,14 @@ export function UniversalSearchCommandSurface({
function handleComposerKeyDown(event: ReactKeyboardEvent<HTMLInputElement>) {
if (event.key === "ArrowDown") {
event.preventDefault();
if (!canOpenDropdownNow()) return;
onDropdownOpenChange(true);
setActiveIndex((current) => (current + 1) % Math.max(flatItems.length, 1));
return;
}
if (event.key === "ArrowUp") {
event.preventDefault();
if (!canOpenDropdownNow()) return;
onDropdownOpenChange(true);
setActiveIndex((current) => (current <= 0 ? flatItems.length - 1 : current - 1));
return;
Expand DownExpand Up@@ -551,6 +568,16 @@ export function UniversalSearchCommandSurface({
onListboxIdReady?.(listboxId);
}, [listboxId, onListboxIdReady]);

useEffect(() => {
if (requiresTypedQueryToOpen && composerFocusedRef.current && trimmedQuery.length > 0) {
onDropdownOpenChange(true);
}
if (requiresTypedQueryToOpen && trimmedQuery.length === 0) {
onDropdownOpenChange(false);
setActiveIndex(-1);
}
}, [requiresTypedQueryToOpen, trimmedQuery, onDropdownOpenChange]);

useEffect(() => {
function handleSlashFocus(event: KeyboardEvent) {
if (event.key !== "/" || event.metaKey || event.ctrlKey || event.altKey) return;
Expand DownExpand Up@@ -599,8 +626,14 @@ export function UniversalSearchCommandSurface({
handleComposerKeyDown(event as unknown as ReactKeyboardEvent<HTMLInputElement>);
}
}}
onFocusCapture={() => onDropdownOpenChange(true)}
onFocusCapture={() => {
composerFocusedRef.current = true;
if (canOpenDropdownNow()) {
onDropdownOpenChange(true);
}
}}
onBlurCapture={(event) => {
composerFocusedRef.current = false;
if (!event.currentTarget.contains(event.relatedTarget as Node | null)) {
onDropdownOpenChange(false);
setActiveIndex(-1);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/rag.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -5940,7 +5940,7 @@ export async function searchChunksWithTelemetry(args: SearchChunksArgs) {
owner_filter: ownerScopeForDocumentFilteredRetrieval(
args.ownerId,
documentFilter ? [documentFilter] : undefined,
documentFilter ? undefined : args.allowGlobalSearch,
args.allowGlobalSearch,
),
});

Expand Down
8 changes: 6 additions & 2 deletions tests/ui-tools.spec.ts
Original file line numberDiff line numberDiff line change
Expand Up@@ -97,9 +97,13 @@ async function commandSurfaceOpensAbovePill(page: Page) {
{ timeout: 10_000 },
);
await input.click();
await input.fill("");
await expect(page.getByRole("listbox")).toHaveCount(0);
await input.press("ArrowDown");
await expect(page.getByRole("listbox")).toHaveCount(0);

await input.fill("li");
await expect(async () => {
await input.press("ArrowDown");
await expect(page.getByText("Examples", { exact: true }).first()).toBeVisible();
await expect(page.getByRole("listbox").first()).toBeVisible();
}).toPass({ timeout: 15_000 });

Expand Down