Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

feat(desktop): add task queries to the command palette (#84685)

Shy Alter48599b3e6d8b
diff --git a/products/desktop/packages/shared/src/analytics-events.ts b/products/desktop/packages/shared/src/analytics-events.ts
index 8156a26e8f98..6a257b475b07 100644
--- a/products/desktop/packages/shared/src/analytics-events.ts
+++ b/products/desktop/packages/shared/src/analytics-events.ts
@@ -57,6 +57,11 @@ export type CommandMenuAction =
| "open-artifact"
| "open-channel"
| "open-command-center"
+ | "save-feed"
+ | "complete-filter"
+ | "show-all-matches"
+ | "repair-query"
+ | "open-feed"
| "open-inbox"
| "open-archived"
| "open-loops"
diff --git a/products/desktop/packages/ui/src/features/command/CommandKeyHints.tsx b/products/desktop/packages/ui/src/features/command/CommandKeyHints.tsx
index c06f67b35544..07a90645234a 100644
--- a/products/desktop/packages/ui/src/features/command/CommandKeyHints.tsx
+++ b/products/desktop/packages/ui/src/features/command/CommandKeyHints.tsx
@@ -1,6 +1,7 @@
import { Kbd, KbdGroup } from "@posthog/quill";
+import type { ReactNode } from "react";
-export function CommandKeyHints() {
+export function CommandKeyHints({ children }: { children?: ReactNode }) {
return (
<div className="flex items-center justify-center gap-4 border-border border-t py-1">
<div className="flex items-center gap-2">
@@ -22,6 +23,7 @@ export function CommandKeyHints() {
</KbdGroup>
<span className="text-xs">close</span>
</div>
+ {children}
</div>
);
}
diff --git a/products/desktop/packages/ui/src/features/command/CommandMenu.feedQuery.test.tsx b/products/desktop/packages/ui/src/features/command/CommandMenu.feedQuery.test.tsx
new file mode 100644
index 000000000000..d880933fd0b9
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/command/CommandMenu.feedQuery.test.tsx
@@ -0,0 +1,260 @@
+import { Theme } from "@radix-ui/themes";
+import { render, screen } from "@testing-library/react";
+import userEvent from "@testing-library/user-event";
+import { afterEach, describe, expect, it, vi } from "vitest";
+
+let taskResultsComplete = true;
+
+// The palette pulls half the app in; everything irrelevant to the feed-query
+// mode is stubbed to its empty state.
+vi.mock("@posthog/ui/shell/analytics", () => ({ track: vi.fn() }));
+vi.mock("@posthog/ui/features/auth/authClient", () => ({
+ useOptionalAuthenticatedClient: () => null,
+}));
+vi.mock("@posthog/ui/features/auth/useCurrentUser", () => ({
+ useCurrentUser: () => ({ data: { uuid: "user-1" } }),
+}));
+vi.mock("@posthog/di/container", () => ({ resolveService: () => ({}) }));
+vi.mock("@posthog/ui/features/feature-flags/useFeatureFlag", () => ({
+ useFeatureFlag: () => false,
+}));
+vi.mock("@posthog/ui/features/tasks/useTasks", () => ({
+ useTasks: () => ({ data: [] }),
+}));
+vi.mock("@posthog/ui/features/archive/useArchivedTaskIds", () => ({
+ useArchivedTaskIds: () => new Set(),
+}));
+vi.mock("@posthog/ui/features/workspace/useWorkspace", () => ({
+ useWorkspaces: () => ({ data: [], isFetched: true }),
+}));
+vi.mock("@posthog/ui/features/canvas/hooks/useChannels", () => ({
+ useChannels: () => ({ channels: [], isLoading: false }),
+}));
+vi.mock("@posthog/ui/features/canvas/hooks/useOrgMembers", () => ({
+ useOrgMembers: () => ({
+ members: [
+ {
+ id: 1,
+ uuid: "uuid-shy",
+ email: "[email protected]",
+ first_name: "Shy",
+ last_name: "Alter",
+ },
+ ],
+ isLoading: false,
+ isError: false,
+ isComplete: true,
+ }),
+}));
+vi.mock("@posthog/ui/features/canvas/hooks/useChannelsLayout", () => ({
+ useChannelsLayout: () => true,
+}));
+vi.mock("@posthog/ui/features/canvas/hooks/useTaskChannelMap", () => ({
+ useTaskChannelMap: () => new Map(),
+}));
+vi.mock("@posthog/ui/features/command/useFileSearchContext", () => ({
+ useFileSearchContext: () => ({ repoPath: null }),
+}));
+vi.mock("@posthog/ui/features/command/useTaskSearch", () => ({
+ useTaskSearch: () => ({ data: [] }),
+}));
+vi.mock("@posthog/ui/features/folders/useFolders", () => ({
+ useFolders: () => ({ folders: [] }),
+}));
+vi.mock("@posthog/ui/router/useAppView", () => ({
+ useAppView: () => ({ type: "home" }),
+}));
+vi.mock("@posthog/ui/features/sidebar/useTaskPrStatus", () => ({
+ useTaskPrStatus: () => ({ prState: null, hasDiff: false, prUrl: null }),
+}));
+vi.mock("@posthog/ui/features/canvas/hooks/useTaskFeedResults", () => ({
+ useTaskFeedResults: (query: string | undefined) => ({
+ tasks: query
+ ? [
+ {
+ id: "task-1",
+ title: "Fix billing address validation",
+ repository: "example-org/webapp",
+ channel: null,
+ },
+ ]
+ : [],
+ isComplete: taskResultsComplete,
+ isLoading: false,
+ issues: [],
+ }),
+ useFeedQueryPlan: () => ({ plan: undefined, isLoading: false }),
+}));
+
+const mocks = vi.hoisted(() => ({ navigateToFeed: vi.fn() }));
+vi.mock("@posthog/ui/router/navigationBridge", async (importOriginal) => ({
+ ...(await importOriginal<Record<string, unknown>>()),
+ navigateToFeed: mocks.navigateToFeed,
+}));
+
+import {
+ ANONYMOUS_AUTH_STATE,
+ useAuthStore,
+} from "@posthog/ui/features/auth/store";
+import { useTaskFeedsStore } from "@posthog/ui/features/canvas/stores/taskFeedsStore";
+import { CommandMenu } from "./CommandMenu";
+
+describe("CommandMenu feed queries", () => {
+ afterEach(() => {
+ taskResultsComplete = true;
+ });
+
+ it("offers Save as feed and the matching tasks for a token query", async () => {
+ const user = userEvent.setup();
+ render(
+ <Theme>
+ <CommandMenu open onOpenChange={() => {}} />
+ </Theme>,
+ );
+
+ await user.type(
+ screen.getByPlaceholderText(/Search commands and tasks/),
+ "created-by:@me ",
+ );
+ // The footer advertises the save shortcut; the results are debounced.
+ expect(await screen.findByText(/save search/)).toBeTruthy();
+ expect(
+ await screen.findByText(
+ "Fix billing address validation",
+ {},
+ { timeout: 2000 },
+ ),
+ ).toBeTruthy();
+
+ // ⌘S hands the query to the save modal.
+ await user.keyboard("{Meta>}s{/Meta}");
+ expect(
+ await screen.findByText("Save search", { selector: "h2" }),
+ ).toBeTruthy();
+ });
+
+ it("labels incomplete task search results", async () => {
+ taskResultsComplete = false;
+ const user = userEvent.setup();
+ render(
+ <Theme>
+ <CommandMenu open onOpenChange={() => {}} />
+ </Theme>,
+ );
+
+ await user.type(
+ screen.getByPlaceholderText(/Search commands and tasks/),
+ "created-by:@me ",
+ );
+
+ expect(
+ await screen.findByText("Some matching tasks may not be shown."),
+ ).toBeTruthy();
+ });
+
+ it("opens a saved search from the saved: filter", async () => {
+ useAuthStore.setState({
+ authState: { ...ANONYMOUS_AUTH_STATE, currentProjectId: 1 },
+ });
+ useTaskFeedsStore.setState({
+ feeds: [
+ {
+ id: "feed-1",
+ projectId: 1,
+ ownerId: "user-1",
+ name: "My failing tasks",
+ query: "created-by:@me status:failed",
+ createdAt: "2026-08-01T00:00:00Z",
+ },
+ {
+ id: "feed-2",
+ projectId: 2,
+ ownerId: "user-1",
+ name: "My failing tasks elsewhere",
+ query: "created-by:@me status:failed",
+ createdAt: "2026-08-01T00:00:00Z",
+ },
+ ],
+ });
+ const user = userEvent.setup();
+ render(
+ <Theme>
+ <CommandMenu open onOpenChange={() => {}} />
+ </Theme>,
+ );
+
+ await user.type(
+ screen.getByPlaceholderText(/Search commands and tasks/),
+ "saved:fail",
+ );
+ expect(screen.queryByText("My failing tasks elsewhere")).toBeNull();
+ // A pure `saved:` query is saved-search completion, so it must not run a
+ // task query or show unrelated task results or a match summary.
+ expect(screen.queryByText("Fix billing address validation")).toBeNull();
+ expect(screen.queryByText(/save search/)).toBeNull();
+ await user.click(await screen.findByText("My failing tasks"));
+ expect(mocks.navigateToFeed).toHaveBeenCalledWith("feed-1");
+ });
+
+ it("completes a key then a value from the always-on suggestions", async () => {
+ const user = userEvent.setup();
+ render(
+ <Theme>
+ <CommandMenu open onOpenChange={() => {}} />
+ </Theme>,
+ );
+ const input = screen.getByPlaceholderText<HTMLInputElement>(
+ /Search commands and tasks/,
+ );
+
+ await user.type(input, "cre");
+ await user.click(await screen.findByText("created-by:"));
+ expect(input.value).toBe("created-by:");
+
+ await user.click(await screen.findByText("@me"));
+ expect(input.value).toBe("created-by:@me ");
+ });
+
+ it("keeps the command catalog out of a value completion", async () => {
+ const user = userEvent.setup();
+ render(
+ <Theme>
+ <CommandMenu open onOpenChange={() => {}} />
+ </Theme>,
+ );
+ const input = screen.getByPlaceholderText<HTMLInputElement>(
+ /Search commands and tasks/,
+ );
+
+ expect(await screen.findByText("Actions")).toBeTruthy();
+ await user.type(input, "created-by:");
+ expect(await screen.findByText("Teammates")).toBeTruthy();
+ expect(screen.queryByText("Actions")).toBeNull();
+ expect(screen.queryByText("Navigation")).toBeNull();
+ });
+
+ it("scopes sections with type:", async () => {
+ const user = userEvent.setup();
+ render(
+ <Theme>
+ <CommandMenu open onOpenChange={() => {}} />
+ </Theme>,
+ );
+ const input = screen.getByPlaceholderText<HTMLInputElement>(
+ /Search commands and tasks/,
+ );
+
+ // Commands render by default…
+ expect(await screen.findByText("Actions")).toBeTruthy();
+ // …and a task scope drops them while keeping the task query running.
+ await user.type(input, "type:task billing ");
+ expect(screen.queryByText("Actions")).toBeNull();
+ expect(
+ await screen.findByText(
+ "Fix billing address validation",
+ {},
+ { timeout: 2000 },
+ ),
+ ).toBeTruthy();
+ });
+});
diff --git a/products/desktop/packages/ui/src/features/command/CommandMenu.stories.tsx b/products/desktop/packages/ui/src/features/command/CommandMenu.stories.tsx
new file mode 100644
index 000000000000..4fddb47bef46
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/command/CommandMenu.stories.tsx
@@ -0,0 +1,18 @@
+import type { Meta, StoryObj } from "@storybook/react-vite";
+import { CommandMenu } from "./CommandMenu";
+
+// The palette renders open over an empty backdrop. Its data hooks resolve to
+// empty in Storybook (no authenticated client), so the story is for the
+// query-language chrome: the highlighted input, the filter catalog, and the
+// suggestion sections as a query is typed.
+const meta: Meta<typeof CommandMenu> = {
+ title: "Command/CommandMenu",
+ component: CommandMenu,
+ parameters: { layout: "fullscreen" },
+ args: { open: true, onOpenChange: () => {} },
+};
+
+export default meta;
+type Story = StoryObj<typeof CommandMenu>;
+
+export const Open: Story = {};
diff --git a/products/desktop/packages/ui/src/features/command/CommandMenu.tsx b/products/desktop/packages/ui/src/features/command/CommandMenu.tsx
index db269216149d..1088cbe2c897 100644
--- a/products/desktop/packages/ui/src/features/command/CommandMenu.tsx
+++ b/products/desktop/packages/ui/src/features/command/CommandMenu.tsx
@@ -22,18 +22,24 @@ import {
AutocompleteLabel,
AutocompleteList,
AutocompleteStatus,
+ cn,
Dialog,
DialogContent,
Kbd,
+ KbdGroup,
} from "@posthog/quill";
import { LOOPS_FLAG, PROJECT_BLUEBIRD_FLAG } from "@posthog/shared";
import {
ANALYTICS_EVENTS,
type CommandMenuAction,
} from "@posthog/shared/analytics-events";
-import type { Task } from "@posthog/shared/domain-types";
import { useArchivedTaskIds } from "@posthog/ui/features/archive/useArchivedTaskIds";
import { channelGlyph } from "@posthog/ui/features/canvas/components/channelGlyph";
+import {
+ EDITOR_TEXT_CLASS,
+ FeedQueryHighlight,
+} from "@posthog/ui/features/canvas/components/FeedQueryInput";
+import { TaskFeedModal } from "@posthog/ui/features/canvas/components/TaskFeedModal";
import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels";
import { useChannelsLayout } from "@posthog/ui/features/canvas/hooks/useChannelsLayout";
import { getDefaultReviewMode } from "@posthog/ui/features/code-review/getDefaultReviewMode";
@@ -48,7 +54,13 @@ import {
formatHotkeyParts,
SHORTCUTS,
} from "@posthog/ui/features/command/keyboard-shortcuts";
+import { PaletteFilterChips } from "@posthog/ui/features/command/PaletteFilterChips";
+import { TaskCommandIcon } from "@posthog/ui/features/command/TaskCommandIcon";
import { taskSearchDelay } from "@posthog/ui/features/command/taskSearchQuery";
+import {
+ matchSummary,
+ useFeedQueryCommands,
+} from "@posthog/ui/features/command/useFeedQueryCommands";
import { useFileSearchContext } from "@posthog/ui/features/command/useFileSearchContext";
import {
type Command,
@@ -63,9 +75,7 @@ import {
closeSettings,
openSettings,
} from "@posthog/ui/features/settings/hooks/useOpenSettings";
-import { TaskIcon } from "@posthog/ui/features/sidebar/components/items/TaskIcon";
import { useSidebarStore } from "@posthog/ui/features/sidebar/sidebarStore";
-import { useTaskPrStatus } from "@posthog/ui/features/sidebar/useTaskPrStatus";
import { useTasks } from "@posthog/ui/features/tasks/useTasks";
import { useWorkspaces } from "@posthog/ui/features/workspace/useWorkspace";
import { LoopIcon } from "@posthog/ui/primitives/LoopIcon";
@@ -75,6 +85,7 @@ import {
navigateToArchived,
navigateToChannel,
navigateToCommandCenter,
+ navigateToFeed,
navigateToInbox,
navigateToLoops,
} from "@posthog/ui/router/navigationBridge";
@@ -96,38 +107,102 @@ import {
ZoomInIcon,
ZoomOutIcon,
} from "@radix-ui/react-icons";
-import { useCallback, useEffect, useMemo, useState } from "react";
+import {
+ type KeyboardEvent as ReactKeyboardEvent,
+ useCallback,
+ useEffect,
+ useLayoutEffect,
+ useMemo,
+ useRef,
+ useState,
+} from "react";
interface CommandMenuProps {
open: boolean;
onOpenChange: (open: boolean) => void;
}
-/**
- * Task icon for the command palette. Renders the same shared `TaskIcon` as
- * the sidebar — cloud run status, PR/branch status, etc. — deriving its
- * inputs from the raw task and a per-task PR-status query.
- */
-function TaskCommandIcon({ task }: { task: Task }) {
- const { prState, hasDiff } = useTaskPrStatus({
- id: task.id,
- cloudPrUrl: null,
- taskRunEnvironment: task.latest_run?.environment,
+const DEFAULT_RESULT_LIMIT = 8;
+const COLLAPSED_CHIP_COUNT = 5;
+
+function PaletteQueryMirror({
+ query,
+ wrapRef,
+ visible,
+}: {
+ query: string;
+ wrapRef: React.RefObject<HTMLDivElement | null>;
+ visible: boolean;
+}) {
+ const mirrorRef = useRef<HTMLDivElement>(null);
+ const [box, setBox] = useState<{
+ left: number;
+ top: number;
+ width: number;
+ height: number;
+ padLeft: number;
+ padRight: number;
+ } | null>(null);
+
+ // A child layout effect runs before the parent ref attaches.
+ useEffect(() => {
+ if (!visible) return;
+ const wrap = wrapRef.current;
+ const input = wrap?.querySelector("input");
+ if (!wrap || !input) return;
+ const measure = () => {
+ const w = wrap.getBoundingClientRect();
+ const r = input.getBoundingClientRect();
+ const style = getComputedStyle(input);
+ setBox({
+ left: r.left - w.left,
+ top: r.top - w.top,
+ width: r.width,
+ height: r.height,
+ padLeft: Number.parseFloat(style.paddingLeft),
+ padRight: Number.parseFloat(style.paddingRight),
+ });
+ };
+ measure();
+ const observer = new ResizeObserver(measure);
+ observer.observe(input);
+ const sync = () => {
+ if (mirrorRef.current) mirrorRef.current.scrollLeft = input.scrollLeft;
+ };
+ input.addEventListener("scroll", sync);
+ return () => {
+ observer.disconnect();
+ input.removeEventListener("scroll", sync);
+ };
+ }, [visible, wrapRef]);
+
+ // A completion can change the input scroll position without a scroll event.
+ useLayoutEffect(() => {
+ const input = wrapRef.current?.querySelector("input");
+ if (input && mirrorRef.current)
+ mirrorRef.current.scrollLeft = input.scrollLeft;
});
- const stateSlackThreadUrl = (
- task.latest_run?.state as { slack_thread_url?: unknown } | undefined
- )?.slack_thread_url;
- const slackThreadUrl =
- typeof stateSlackThreadUrl === "string" ? stateSlackThreadUrl : undefined;
+
+ if (!visible || !box) return null;
return (
- <TaskIcon
- workspaceMode={task.latest_run?.environment}
- taskRunStatus={task.latest_run?.status}
- originProduct={task.origin_product}
- slackThreadUrl={slackThreadUrl}
- prState={prState}
- hasDiff={hasDiff}
- />
+ <div
+ ref={mirrorRef}
+ aria-hidden
+ className={cn(
+ "pointer-events-none absolute z-10 flex items-center overflow-x-hidden",
+ EDITOR_TEXT_CLASS,
+ )}
+ style={{
+ left: box.left,
+ top: box.top,
+ width: box.width,
+ height: box.height,
+ paddingLeft: box.padLeft,
+ paddingRight: box.padRight,
+ }}
+ >
+ <FeedQueryHighlight query={query} />
+ </div>
);
}
@@ -159,6 +234,12 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
);
const [query, setQuery] = useState("");
const [remoteQuery, setRemoteQuery] = useState("");
+ // The legacy title search only ever surfaces while the palette is browsing
+ // (see `showRemoteSearch` below). The feed-query `mode` that decides that is
+ // derived further down, after this debounce, so the effect reads the latest
+ // value through a ref instead because a filter query must not start a search whose
+ // results the palette then throws away.
+ const remoteSearchAllowedRef = useRef(true);
const { repoPath } = useFileSearchContext();
const canSearchFiles = !!repoPath;
const openFilePicker = useFileSearchStore((state) => state.openPicker);
@@ -173,7 +254,10 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
setRemoteQuery("");
return;
}
- const timer = window.setTimeout(() => setRemoteQuery(trimmed), delay);
+ const timer = window.setTimeout(
+ () => setRemoteQuery(remoteSearchAllowedRef.current ? trimmed : ""),
+ delay,
+ );
return () => window.clearTimeout(timer);
}, [open, query]);
@@ -344,7 +428,18 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
];
const actions: Command[] = [
- ...themeOptions,
+ {
+ id: "new-task",
+ label: "New task",
+ keywords: "create",
+ icon: <FileTextIcon className="h-3 w-3 text-gray-11" />,
+ action: "new-task",
+ shortcut: SHORTCUTS.NEW_TASK,
+ onRun: () => {
+ closeSettingsDialog();
+ openTaskInput();
+ },
+ },
{
id: "toggle-left-sidebar",
label: "Toggle left sidebar",
@@ -365,18 +460,8 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
},
]
: []),
- {
- id: "new-task",
- label: "New task",
- keywords: "create",
- icon: <FileTextIcon className="h-3 w-3 text-gray-11" />,
- action: "new-task",
- shortcut: SHORTCUTS.NEW_TASK,
- onRun: () => {
- closeSettingsDialog();
- openTaskInput();
- },
- },
+ // Last, because the first row is what a stray Enter runs.
+ ...themeOptions,
];
if (canSearchFiles) {
@@ -578,19 +663,100 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
spacesLayout,
});
- // Commands, channels, and tasks share a single filterable list.
- const sections = useMemo(
- () =>
- prioritizeExactCommandMatches(
- [
- ...searchSections,
- ...commandSections,
- ...channelSections,
- ...taskSections,
- ],
- query,
- ),
- [searchSections, commandSections, channelSections, taskSections, query],
+ const [feedModalQuery, setFeedModalQuery] = useState<string | null>(null);
+ const onSaveAsFeed = useCallback(
+ (feedQuery: string) => {
+ onOpenChange(false);
+ setFeedModalQuery(feedQuery);
+ },
+ [onOpenChange],
+ );
+
+ const [caret, setCaret] = useState(0);
+ const inputWrapRef = useRef<HTMLDivElement>(null);
+ const trackCaret = useCallback(() => {
+ const position =
+ inputWrapRef.current?.querySelector("input")?.selectionStart;
+ if (position != null) setCaret(position);
+ }, []);
+ // Restore the caret after React applies a completed suggestion.
+ const pendingCaret = useRef<number | null>(null);
+ useLayoutEffect(() => {
+ if (pendingCaret.current == null) return;
+ const input = inputWrapRef.current?.querySelector("input");
+ input?.setSelectionRange(pendingCaret.current, pendingCaret.current);
+ input?.focus();
+ pendingCaret.current = null;
+ });
+ const onApplyFilter = useCallback((next: string, nextCaret: number) => {
+ setQuery(next);
+ setCaret(nextCaret);
+ pendingCaret.current = nextCaret;
+ }, []);
+
+ const [showAllFor, setShowAllFor] = useState<string | null>(null);
+ const resultLimit =
+ showAllFor === query ? Number.MAX_SAFE_INTEGER : DEFAULT_RESULT_LIMIT;
+ const showAllMatches = useCallback(() => setShowAllFor(query), [query]);
+
+ const feedQuery = useFeedQueryCommands({
+ query,
+ caret,
+ enabled: open && spacesLayout,
+ limit: resultLimit,
+ onApply: onApplyFilter,
+ onShowAll: showAllMatches,
+ });
+ const {
+ mode,
+ scope,
+ hasFilterTokens,
+ searchText,
+ keyChips,
+ matchCount,
+ partialResults,
+ shownCount,
+ hasRepairs,
+ } = feedQuery;
+
+ // Keep the debounce's gate in step with the condition that decides whether
+ // the remote search is even rendered, so the two can't drift.
+ useEffect(() => {
+ const browsing = mode === "browsing" || mode === "completingKey";
+ remoteSearchAllowedRef.current = browsing && !scope;
+ }, [mode, scope]);
+
+ const sections = useMemo(() => {
+ const browsing = mode === "browsing" || mode === "completingKey";
+ const showCommands = browsing && (!scope || scope === "command");
+ const showChannels = browsing && (!scope || scope === "space");
+ const showPlainTasks = browsing && !scope;
+ const showRemoteSearch = browsing && !scope;
+ return prioritizeExactCommandMatches(
+ [
+ ...feedQuery.sections,
+ ...(showRemoteSearch ? searchSections : []),
+ ...(showCommands ? commandSections : []),
+ ...(showChannels ? channelSections : []),
+ ...(showPlainTasks ? taskSections : []),
+ ],
+ searchText,
+ );
+ }, [
+ feedQuery.sections,
+ searchSections,
+ commandSections,
+ channelSections,
+ taskSections,
+ mode,
+ scope,
+ searchText,
+ ]);
+
+ const paletteFilter = useCallback(
+ (command: { label: string; keywords?: string }) =>
+ matchesCommandSearch(command, searchText),
+ [searchText],
);
const allCommands = useMemo(
@@ -598,6 +764,9 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
[sections],
);
+ const highlightedId = useRef<string | null>(null);
+ const showMatchSummary = mode === "querying" || matchCount != null;
+
const handleSelect = (id: string | null): void => {
if (id === null) return;
const cmd = allCommands.find((c) => c.id === id);
@@ -607,91 +776,185 @@ export function CommandMenu({ open, onOpenChange }: CommandMenuProps) {
channel_id: cmd.channelId,
});
cmd.onRun();
+ if (cmd.keepOpen) return;
onOpenChange(false);
setQuery("");
};
+ const onInputKeyDown = (event: ReactKeyboardEvent<HTMLInputElement>) => {
+ if (
+ event.key.toLowerCase() === "s" &&
+ (event.metaKey || event.ctrlKey) &&
+ hasFilterTokens
+ ) {
+ event.preventDefault();
+ track(ANALYTICS_EVENTS.COMMAND_MENU_ACTION, { action_type: "save-feed" });
+ onSaveAsFeed(query.trim());
+ return;
+ }
+ if (event.key !== "Tab") return;
+ if (mode === "completingKey" && keyChips.length > 0) {
+ event.preventDefault();
+ keyChips[0].apply();
+ return;
+ }
+ const highlighted = allCommands.find(
+ (c) => c.id === highlightedId.current && c.keepOpen,
+ );
+ const target = highlighted ?? allCommands.find((c) => c.keepOpen);
+ if (!target) return;
+ event.preventDefault();
+ target.onRun();
+ };
+
return (
- <Dialog open={open} onOpenChange={onOpenChange}>
- <DialogContent
- className="w-[720px] max-w-[90vw] gap-0 p-0"
- showCloseButton={false}
- >
- <Autocomplete<Command>
- inline
- defaultOpen
- items={sections}
- value={query}
- autoHighlight="always"
- keepHighlight
- onValueChange={(val, eventDetails) => {
- if (eventDetails.reason !== "input-change") return;
- if (typeof val === "string") {
- setQuery(val);
- }
- }}
- filter={matchesCommandSearch}
+ <>
+ <Dialog open={open} onOpenChange={onOpenChange}>
+ <DialogContent
+ className="w-[720px] max-w-[90vw] gap-0 p-0"
+ showCloseButton={false}
>
- <AutocompleteInput
- placeholder={
- bluebirdEnabled
- ? `Search commands, ${spacesLayout ? "spaces" : "channels"}, and tasks…`
- : "Search commands and tasks…"
- }
- autoFocus
- showClear
- />
- <AutocompleteStatus
- emptyContent={
- <span>
- No results for <strong>"{query}"</strong>
- </span>
- }
- />
- <AutocompleteList className="max-h-[60vh]">
- {(section: CommandSection) => (
- <AutocompleteGroup key={section.label} items={section.items}>
- <AutocompleteLabel>{section.label}</AutocompleteLabel>
- <AutocompleteCollection>
- {(cmd: Command) => (
- <AutocompleteItem
- key={cmd.id}
- value={cmd.id}
- onClick={() => handleSelect(cmd.id)}
- // Long task names wrap instead of truncating, so the
- // item must grow: min-height, not a fixed height. Quill
- // wraps our children in an inner content span; force it to
- // fill the row (so a trailing shortcut can `ml-auto` to the
- // end) and let it overflow visibly so the shortcut Kbd
- // boxes aren't clipped by the wrapper's `truncate`.
- className="group flex h-auto! min-h-7 w-full items-center gap-2 py-1.5 pr-2 text-left [&>span]:w-full [&>span]:overflow-visible"
- >
- {cmd.icon}
- <span className="wrap-break-word min-w-0 whitespace-normal">
- {cmd.label}
- </span>
- {cmd.detail && (
- <span className="shrink-0 text-gray-9">
- · {cmd.detailPrefix ?? "#"}
- {cmd.detail}
- </span>
- )}
- {cmd.shortcut && (
- <span className="ml-auto flex shrink-0 items-center gap-2 pl-2">
- {formatHotkeyParts(cmd.shortcut).map((part) => (
- <Kbd key={part}>{part}</Kbd>
- ))}
+ <Autocomplete<Command>
+ inline
+ defaultOpen
+ items={sections}
+ value={query}
+ autoHighlight
+ keepHighlight
+ onItemHighlighted={(value) => {
+ highlightedId.current = typeof value === "string" ? value : null;
+ }}
+ onValueChange={(val, eventDetails) => {
+ if (typeof val !== "string") return;
+ if (eventDetails.reason === "input-change") {
+ setQuery(val);
+ trackCaret();
+ return;
+ }
+ if (val === "") setQuery("");
+ }}
+ filter={paletteFilter}
+ >
+ <div ref={inputWrapRef} className="relative">
+ <PaletteQueryMirror
+ query={query}
+ wrapRef={inputWrapRef}
+ visible={spacesLayout}
+ />
+ <AutocompleteInput
+ placeholder={
+ spacesLayout
+ ? "Search commands and tasks, or filter with created-by:"
+ : bluebirdEnabled
+ ? "Search commands, channels, and tasks…"
+ : "Search commands and tasks…"
+ }
+ autoFocus
+ showClear
+ className={
+ spacesLayout
+ ? cn(
+ "[&_input]:whitespace-pre [&_input]:font-mono [&_input]:text-[13px] [&_input]:tracking-normal",
+ "[&_input]:text-transparent [&_input]:caret-(--gray-12) [&_input]:placeholder:text-(--gray-9)",
+ "[&_input]:selection:bg-(--blue-a4) [&_input]:selection:text-transparent",
+ )
+ : undefined
+ }
+ onKeyDown={onInputKeyDown}
+ onKeyUp={trackCaret}
+ onClick={trackCaret}
+ onSelect={trackCaret}
+ />
+ </div>
+ {keyChips.length > 0 && (
+ <PaletteFilterChips
+ key={mode}
+ chips={keyChips}
+ collapsedCount={COLLAPSED_CHIP_COUNT}
+ />
+ )}
+ {showMatchSummary ? (
+ <div className="border-(--gray-a4) border-b px-3 py-1.5 text-(--gray-9) text-xs tabular-nums">
+ {partialResults
+ ? "Some matching tasks may not be shown."
+ : matchSummary(matchCount, shownCount, hasRepairs)}
+ </div>
+ ) : (
+ query !== "" && (
+ <AutocompleteStatus
+ emptyContent={
+ <span>
+ No results for <strong>"{query}"</strong>
+ </span>
+ }
+ />
+ )
+ )}
+ <AutocompleteList className="max-h-[60vh]">
+ {(section: CommandSection) => (
+ <AutocompleteGroup key={section.label} items={section.items}>
+ <AutocompleteLabel>{section.label}</AutocompleteLabel>
+ <AutocompleteCollection>
+ {(cmd: Command) => (
+ <AutocompleteItem
+ key={cmd.id}
+ value={cmd.id}
+ onClick={() => handleSelect(cmd.id)}
+ className="group flex h-auto! min-h-7 w-full items-center gap-2 py-1.5 pr-2 text-left [&>span]:w-full [&>span]:overflow-visible"
+ >
+ {cmd.icon}
+ <span className="wrap-break-word min-w-0 whitespace-normal">
+ {cmd.label}
+ {cmd.subtitle && (
+ <span className="block truncate text-gray-9 text-xs">
+ {cmd.subtitle}
+ </span>
+ )}
</span>
- )}
- </AutocompleteItem>
- )}
- </AutocompleteCollection>
- </AutocompleteGroup>
+ {cmd.detail && (
+ <span className="shrink-0 text-gray-9">
+ · {cmd.detailPrefix ?? "#"}
+ {cmd.detail}
+ </span>
+ )}
+ {cmd.shortcut && (
+ <span className="ml-auto flex shrink-0 items-center gap-2 pl-2">
+ {formatHotkeyParts(cmd.shortcut).map((part) => (
+ <Kbd key={part}>{part}</Kbd>
+ ))}
+ </span>
+ )}
+ </AutocompleteItem>
+ )}
+ </AutocompleteCollection>
+ </AutocompleteGroup>
+ )}
+ </AutocompleteList>
+ </Autocomplete>
+ <CommandKeyHints>
+ {hasFilterTokens && (
+ <div className="flex items-center gap-2">
+ <KbdGroup>
+ <Kbd>{formatHotkeyParts("mod+s").join("")}</Kbd>
+ </KbdGroup>
+ <span className="text-xs">
+ save search
+ {matchCount === 0 && " · no matches yet"}
+ </span>
+ </div>
)}
- </AutocompleteList>
- </Autocomplete>
- <CommandKeyHints />
- </DialogContent>
- </Dialog>
+ </CommandKeyHints>
+ </DialogContent>
+ </Dialog>
+ <TaskFeedModal
+ open={feedModalQuery !== null}
+ onOpenChange={(modalOpen) => {
+ if (!modalOpen) setFeedModalQuery(null);
+ }}
+ initialQuery={feedModalQuery ?? undefined}
+ surface="command_menu"
+ onCreated={(feed) => navigateToFeed(feed.id)}
+ />
+ </>
);
}
diff --git a/products/desktop/packages/ui/src/features/command/PaletteFilterChips.tsx b/products/desktop/packages/ui/src/features/command/PaletteFilterChips.tsx
new file mode 100644
index 000000000000..2d6993853c0f
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/command/PaletteFilterChips.tsx
@@ -0,0 +1,67 @@
+import { cn } from "@posthog/quill";
+import type { FeedQueryKeyChip } from "@posthog/ui/features/command/useFeedQueryCommands";
+import { useState } from "react";
+
+export function PaletteFilterChips({
+ chips,
+ collapsedCount,
+}: {
+ chips: FeedQueryKeyChip[];
+ collapsedCount: number;
+}) {
+ const [expanded, setExpanded] = useState(false);
+
+ const overflow = Math.max(0, chips.length - collapsedCount);
+ const open = expanded || overflow === 0;
+ const visible = open ? chips : chips.slice(0, collapsedCount);
+
+ return (
+ <div
+ className={cn(
+ "flex gap-1.5 border-(--gray-a4) border-b px-3 py-1.5",
+ open ? "flex-wrap items-start" : "items-center",
+ )}
+ >
+ <span className="shrink-0 select-none py-1 text-(--gray-9) text-[11px]">
+ Filter by
+ </span>
+ {visible.map((chip) => (
+ <button
+ key={chip.label}
+ type="button"
+ className={cn(
+ "flex h-[22px] shrink-0 items-center rounded-md border border-(--gray-a6) bg-(--gray-a2) px-2",
+ "text-[11.5px]",
+ "hover:border-(--gray-a8) hover:bg-(--gray-a4)",
+ "focus-visible:-outline-offset-1 focus-visible:outline focus-visible:outline-(--focus-8) focus-visible:outline-2",
+ )}
+ onMouseDown={(e) => e.preventDefault()}
+ onClick={chip.apply}
+ >
+ <span className="flex items-baseline gap-1.5 leading-none">
+ <span className="font-mono text-(--blue-11) text-[11px]">
+ {chip.label}
+ </span>
+ {open && chip.hint && (
+ <span className="text-(--gray-9)">{chip.hint}</span>
+ )}
+ </span>
+ </button>
+ ))}
+ {overflow > 0 && (
+ <button
+ type="button"
+ className={cn(
+ "h-[22px] shrink-0 rounded-md px-2 text-(--gray-11) text-[11.5px] leading-none",
+ "hover:bg-(--gray-a3) hover:text-(--gray-12)",
+ "focus-visible:-outline-offset-1 focus-visible:outline focus-visible:outline-(--focus-8) focus-visible:outline-2",
+ )}
+ onMouseDown={(e) => e.preventDefault()}
+ onClick={() => setExpanded((value) => !value)}
+ >
+ {expanded ? "Show fewer" : `${overflow} more`}
+ </button>
+ )}
+ </div>
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/command/TaskCommandIcon.tsx b/products/desktop/packages/ui/src/features/command/TaskCommandIcon.tsx
new file mode 100644
index 000000000000..1c1a51bf8bb8
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/command/TaskCommandIcon.tsx
@@ -0,0 +1,31 @@
+import type { Task } from "@posthog/shared/domain-types";
+import { TaskIcon } from "@posthog/ui/features/sidebar/components/items/TaskIcon";
+import { useTaskPrStatus } from "@posthog/ui/features/sidebar/useTaskPrStatus";
+
+/**
+ * Task icon for the command palette. Renders the same shared `TaskIcon` as
+ * the sidebar, including cloud run and PR/branch status, while deriving its
+ * inputs from the raw task and a per-task PR-status query.
+ */
+export function TaskCommandIcon({ task }: { task: Task }) {
+ const { prState, hasDiff } = useTaskPrStatus({
+ id: task.id,
+ cloudPrUrl: null,
+ taskRunEnvironment: task.latest_run?.environment,
+ });
+ const stateSlackThreadUrl = (
+ task.latest_run?.state as { slack_thread_url?: unknown } | undefined
+ )?.slack_thread_url;
+ const slackThreadUrl =
+ typeof stateSlackThreadUrl === "string" ? stateSlackThreadUrl : undefined;
+ return (
+ <TaskIcon
+ workspaceMode={task.latest_run?.environment}
+ taskRunStatus={task.latest_run?.status}
+ originProduct={task.origin_product}
+ slackThreadUrl={slackThreadUrl}
+ prState={prState}
+ hasDiff={hasDiff}
+ />
+ );
+}
diff --git a/products/desktop/packages/ui/src/features/command/useFeedQueryCommands.tsx b/products/desktop/packages/ui/src/features/command/useFeedQueryCommands.tsx
new file mode 100644
index 000000000000..906df19235f8
--- /dev/null
+++ b/products/desktop/packages/ui/src/features/command/useFeedQueryCommands.tsx
@@ -0,0 +1,351 @@
+import { ArrowRightIcon, MagnifyingGlassIcon } from "@phosphor-icons/react";
+import {
+ feedQueryTypeScope,
+ parseFeedQuery,
+ type TypeValue,
+} from "@posthog/core/tasks/feedQuery";
+import { formatRelativeTimeShort } from "@posthog/shared";
+import { useFeedQuerySuggestions } from "@posthog/ui/features/canvas/components/feedQuerySuggestions";
+import { applyFeedQuerySuggestion } from "@posthog/ui/features/canvas/components/feedQuerySuggestionUtils";
+import { useChannels } from "@posthog/ui/features/canvas/hooks/useChannels";
+import { useProjectTaskFeeds } from "@posthog/ui/features/canvas/hooks/useProjectTaskFeeds";
+import { useTaskFeedResults } from "@posthog/ui/features/canvas/hooks/useTaskFeedResults";
+import { TaskCommandIcon } from "@posthog/ui/features/command/TaskCommandIcon";
+import type {
+ Command,
+ CommandSection,
+} from "@posthog/ui/features/command/useSearchSections";
+import { closeSettings } from "@posthog/ui/features/settings/hooks/useOpenSettings";
+import { useDebouncedValue } from "@posthog/ui/primitives/hooks/useDebouncedValue";
+import { navigateToFeed } from "@posthog/ui/router/navigationBridge";
+import { openTask } from "@posthog/ui/router/useOpenTask";
+import { useMemo } from "react";
+
+const FEED_QUERY_DEBOUNCE_MS = 300;
+
+export type PaletteMode =
+ | "browsing"
+ | "completingKey"
+ | "completingValue"
+ | "querying";
+
+export function matchSummary(
+ matchCount: number | null,
+ shownCount: number,
+ hasRepairs = false,
+): string {
+ if (matchCount == null) return "Searching…";
+ if (matchCount === 0) {
+ return hasRepairs
+ ? "No tasks match this query."
+ : "No tasks match this query. Remove a filter to see more tasks.";
+ }
+ if (matchCount > shownCount) {
+ return `Showing ${shownCount} of ${matchCount} matching tasks.`;
+ }
+ return `${matchCount} ${matchCount === 1 ? "matching task" : "matching tasks"}`;
+}
+
+export interface FeedQueryKeyChip {
+ label: string;
+ hint?: string;
+ apply: () => void;
+}
+
+export interface FeedQueryPalette {
+ sections: CommandSection[];
+ keyChips: FeedQueryKeyChip[];
+ mode: PaletteMode;
+ scope: TypeValue | null;
+ hasFilterTokens: boolean;
+ matchCount: number | null;
+ partialResults: boolean;
+ shownCount: number;
+ hasRepairs: boolean;
+ searchText: string;
+}
+
+export function useFeedQueryCommands({
+ query,
+ caret,
+ enabled,
+ limit,
+ onApply,
+ onShowAll,
+}: {
+ query: string;
+ caret: number;
+ enabled: boolean;
+ limit: number;
+ onApply: (next: string, caret: number) => void;
+ onShowAll: () => void;
+}): FeedQueryPalette {
+ const trimmed = query.trim();
+ const parsed = useMemo(() => parseFeedQuery(trimmed), [trimmed]);
+ const scope = enabled ? feedQueryTypeScope(parsed) : null;
+ // The planner ignores `type:` and `saved:`, so neither can activate task-query mode.
+ const hasFilterTokens =
+ enabled && parsed.tokens.some((t) => t.key !== "type" && t.key !== "saved");
+ const searchText = enabled ? parsed.text : query;
+
+ const { group, context } = useFeedQuerySuggestions(query, caret, {
+ includeType: true,
+ });
+
+ const runsQuery = hasFilterTokens || scope === "task";
+ const { debounced: previewQuery, isPending } = useDebouncedValue(
+ enabled && runsQuery ? trimmed : "",
+ FEED_QUERY_DEBOUNCE_MS,
+ );
+ const results = useTaskFeedResults(previewQuery);
+ const counting = isPending || results.isLoading;
+ const feeds = useProjectTaskFeeds();
+ const { channels } = useChannels();
+
+ const previewParsed = useMemo(
+ () => parseFeedQuery(previewQuery),
+ [previewQuery],
+ );
+ const partialResults = runsQuery && !counting && !results.isComplete;
+ const noMatches =
+ runsQuery && !counting && results.isComplete && results.tasks.length === 0;
+ const splittable =
+ noMatches && previewParsed.text !== "" && previewParsed.tokens.length > 0;
+ const filtersOnlyQuery = splittable
+ ? previewParsed.tokens.map((token) => token.raw).join(" ")
+ : "";
+ const textOnlyQuery = splittable ? previewParsed.text : "";
+ const filtersOnly = useTaskFeedResults(filtersOnlyQuery);
+ const textOnly = useTaskFeedResults(textOnlyQuery);
+
+ const savedMode = context.activeKey === "saved";
+ const savedHits = useMemo(() => {
+ if (!enabled) return [];
+ if (!savedMode && scope !== "saved") return [];
+ const needle = (savedMode ? context.typed : searchText).toLowerCase();
+ return feeds.filter(
+ (feed) =>
+ feed.name.toLowerCase().includes(needle) ||
+ feed.query.toLowerCase().includes(needle),
+ );
+ }, [enabled, savedMode, scope, context.typed, searchText, feeds]);
+
+ const keyMode = context.activeKey === null;
+ const mode: PaletteMode = useMemo(() => {
+ if (!enabled) return "browsing";
+ if (!keyMode && (group.items.length > 0 || savedHits.length > 0)) {
+ return "completingValue";
+ }
+ if (runsQuery) return "querying";
+ if (context.typed !== "" && group.items.length > 0) return "completingKey";
+ return "browsing";
+ }, [
+ enabled,
+ keyMode,
+ group.items.length,
+ savedHits.length,
+ runsQuery,
+ context.typed,
+ ]);
+
+ const channelNames = useMemo(
+ () => new Map(channels.map((channel) => [channel.id, channel.name])),
+ [channels],
+ );
+
+ return useMemo(() => {
+ if (!enabled) {
+ return {
+ sections: [],
+ keyChips: [],
+ mode,
+ scope: null,
+ hasFilterTokens: false,
+ matchCount: null,
+ partialResults: false,
+ shownCount: 0,
+ hasRepairs: false,
+ searchText,
+ };
+ }
+ const sections: CommandSection[] = [];
+
+ const keyChips: FeedQueryKeyChip[] = keyMode
+ ? group.items.map((suggestion) => ({
+ label: suggestion.label,
+ hint: suggestion.hint,
+ apply: () => {
+ const edit = applyFeedQuerySuggestion(query, context, suggestion);
+ onApply(edit.next, edit.caret);
+ },
+ }))
+ : [];
+
+ if (!keyMode && group.items.length > 0) {
+ sections.push({
+ label: group.heading,
+ items: group.items.map(
+ (suggestion): Command => ({
+ id: `feed-filter-${context.activeKey ?? "key"}-${suggestion.label}`,
+ label: suggestion.label,
+ detail: suggestion.hint,
+ detailPrefix: "",
+ keywords: `${query} ${searchText}`,
+ icon: suggestion.icon,
+ action: "complete-filter",
+ keepOpen: true,
+ shortcut: undefined,
+ onRun: () => {
+ const edit = applyFeedQuerySuggestion(query, context, suggestion);
+ onApply(edit.next, edit.caret);
+ },
+ }),
+ ),
+ });
+ }
+
+ if (savedHits.length > 0) {
+ sections.push({
+ label: "Saved searches",
+ items: savedHits.map(
+ (feed): Command => ({
+ id: `saved-search-${feed.id}`,
+ label: feed.name,
+ detail: feed.query,
+ detailPrefix: "",
+ keywords: `${query} ${searchText} ${feed.name}`,
+ icon: <ArrowRightIcon size={12} className="text-gray-11" />,
+ action: "open-feed",
+ onRun: () => {
+ closeSettings();
+ navigateToFeed(feed.id);
+ },
+ }),
+ ),
+ });
+ }
+
+ const matchCount =
+ runsQuery && !counting && results.isComplete
+ ? results.tasks.length
+ : null;
+ const shown = runsQuery ? results.tasks.slice(0, limit) : [];
+ if (shown.length > 0) {
+ const items = shown.map((task): Command => {
+ const space = task.channel ? channelNames.get(task.channel) : undefined;
+ const subtitle = [
+ task.repository ?? undefined,
+ space ? `#${space}` : undefined,
+ formatRelativeTimeShort(task.created_at),
+ ]
+ .filter(Boolean)
+ .join(" · ");
+ return {
+ id: `feed-query-task-${task.id}`,
+ label: task.title,
+ subtitle,
+ keywords: `${query} ${searchText}`,
+ icon: <TaskCommandIcon task={task} />,
+ action: "open-task",
+ channelId: task.channel ?? undefined,
+ onRun: () => {
+ closeSettings();
+ void openTask(
+ task,
+ task.channel ? { channelId: task.channel } : undefined,
+ );
+ },
+ };
+ });
+ if (matchCount != null && matchCount > shown.length) {
+ items.push({
+ id: "feed-query-show-all",
+ label: `Show all ${matchCount} matches`,
+ icon: <MagnifyingGlassIcon size={12} className="text-gray-11" />,
+ action: "show-all-matches",
+ keepOpen: true,
+ onRun: onShowAll,
+ });
+ }
+ sections.push({ label: "Matching tasks", items });
+ }
+
+ let hasRepairs = false;
+ if (splittable) {
+ const repairs: Command[] = [];
+ const addRepair = (
+ id: string,
+ label: string,
+ count: number,
+ next: string,
+ ) => {
+ if (count === 0) return;
+ repairs.push({
+ id,
+ label,
+ detail: `${count} ${count === 1 ? "task" : "tasks"}`,
+ detailPrefix: "",
+ icon: <MagnifyingGlassIcon size={12} className="text-gray-11" />,
+ action: "repair-query",
+ keepOpen: true,
+ onRun: () => onApply(`${next} `, next.length + 1),
+ });
+ };
+ addRepair(
+ "feed-query-drop-text",
+ `Search without "${previewParsed.text}"`,
+ filtersOnly.tasks.length,
+ filtersOnlyQuery,
+ );
+ addRepair(
+ "feed-query-drop-filters",
+ "Search without the filters",
+ textOnly.tasks.length,
+ textOnlyQuery,
+ );
+ if (repairs.length > 0) {
+ hasRepairs = true;
+ sections.push({ label: "Try instead", items: repairs });
+ }
+ }
+
+ return {
+ sections,
+ keyChips,
+ mode,
+ scope,
+ hasFilterTokens,
+ matchCount,
+ partialResults,
+ shownCount: shown.length,
+ hasRepairs,
+ searchText,
+ };
+ }, [
+ enabled,
+ mode,
+ group,
+ context,
+ keyMode,
+ query,
+ searchText,
+ scope,
+ hasFilterTokens,
+ runsQuery,
+ counting,
+ results.isComplete,
+ results.tasks,
+ partialResults,
+ savedHits,
+ limit,
+ channelNames,
+ splittable,
+ previewParsed.text,
+ filtersOnly.tasks.length,
+ filtersOnlyQuery,
+ textOnly.tasks.length,
+ textOnlyQuery,
+ onApply,
+ onShowAll,
+ ]);
+}
diff --git a/products/desktop/packages/ui/src/features/command/useSearchSections.tsx b/products/desktop/packages/ui/src/features/command/useSearchSections.tsx
index ea8080fd6f1d..090d4239d605 100644
--- a/products/desktop/packages/ui/src/features/command/useSearchSections.tsx
+++ b/products/desktop/packages/ui/src/features/command/useSearchSections.tsx
@@ -19,6 +19,9 @@ export type Command = {
/** Muted trailing detail shown after a middot, e.g. a task's channel. */
detail?: string;
detailPrefix?: string;
+ /** Muted second line under the label, where a trailing `detail` would be the
+ * part a long label truncates away. */
+ subtitle?: string;
keywords?: string;
icon: ReactNode;
action: CommandMenuAction;
@@ -26,6 +29,8 @@ export type Command = {
channelId?: string;
/** Hotkey string (e.g. "mod+b") shown right-aligned when present. */
shortcut?: string;
+ /** Running this keeps the palette open (e.g. completing a filter token). */
+ keepOpen?: boolean;
onRun: () => void;
};