Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

feat(search): rebuild search-view filters as an always-visible facet row (#3921)

gbirmanfc4fc7c6d665
diff --git a/js/app/packages/app/component/command/category-search-filters.ts b/js/app/packages/app/component/command/category-search-filters.ts
index afa2b202bd..ad028a90d6 100644
--- a/js/app/packages/app/component/command/category-search-filters.ts
+++ b/js/app/packages/app/component/command/category-search-filters.ts
@@ -1,6 +1,9 @@
import type { SetPredicatesInput } from '@app/component/next-soup/filters/filter-store/predicates-store';
import type { Query } from '@app/component/next-soup/filters/filter-store/types';
-import { INDEX_OPTIONS } from '@app/component/next-soup/soup-view/filters-bar/search-filter-controls';
+import {
+ SEARCH_INDEX_SEEDS,
+ type SearchIndexId,
+} from '@app/component/next-soup/soup-view/filters-bar/search/search-filters-state';
import type { CategoryFilter } from './types';
type CategorySearchFilters = {
@@ -8,12 +11,12 @@ type CategorySearchFilters = {
clientFilters: SetPredicatesInput<string>;
};
-// Each Cmd+K category maps to a search-view INDEX_OPTIONS value so the
-// resulting Type: chip behaves the same as one picked from the filter
-// dropdown. Cmd+K DMs maps to the same channels index as Channels for now;
-// channelType-based narrowing (DMs vs non-DMs) is left for a follow-up once
-// the search backend honors it.
-const CATEGORY_TO_INDEX: Partial<Record<CategoryFilter, string>> = {
+// Each Cmd+K category maps to a search-view index type so the resulting
+// Type: chip behaves the same as one picked from the filter row. Cmd+K DMs
+// maps to the same channels index as Channels for now; channelType-based
+// narrowing (DMs vs non-DMs) is left for a follow-up once the search
+// backend honors it.
+const CATEGORY_TO_INDEX: Partial<Record<CategoryFilter, SearchIndexId>> = {
channels: 'channels',
dms: 'channels',
documents: 'document-or-file',
@@ -27,11 +30,9 @@ export function getCategorySearchFilters(
): CategorySearchFilters | undefined {
const indexValue = CATEGORY_TO_INDEX[category];
if (!indexValue) return undefined;
- const option = INDEX_OPTIONS.find((o) => o.value === indexValue);
- if (!option) return undefined;
return {
- filters: option.queryFilters,
+ filters: SEARCH_INDEX_SEEDS[indexValue],
clientFilters: { or: [indexValue] },
};
}
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsx
index 081a2b25ea..ad72304e1c 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/consolidated-filter-chip.tsx
@@ -11,8 +11,10 @@ import {
Show,
Switch,
} from 'solid-js';
-import type { SearchableOption } from './search-filter-controls';
-import { SearchableMultiSelect } from './searchable-multi-select';
+import {
+ SearchableMultiSelect,
+ type SearchableOption,
+} from './searchable-multi-select';
export type FilterValue = {
id: string;
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsx
index e6485344ed..655c8385e4 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/inbox-selector.tsx
@@ -7,8 +7,10 @@ import TrayIcon from '@phosphor/tray.svg';
import { useEmailLinksQuery } from '@queries/email/link';
import { Button } from '@ui';
import { createMemo, Show } from 'solid-js';
-import type { SearchableOption } from './search-filter-controls';
-import { SearchableMultiSelect } from './searchable-multi-select';
+import {
+ SearchableMultiSelect,
+ type SearchableOption,
+} from './searchable-multi-select';
/**
* Scopes the list to a subset of the user's linked inboxes. Multi-select,
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx
deleted file mode 100644
index a0a2c36f30..0000000000
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search-filter-controls.tsx
+++ /dev/null
@@ -1,541 +0,0 @@
-import type { FilterID } from '@app/component/next-soup/filters/configs';
-import {
- defineQueryFilters,
- NIL_UUID,
- type Query,
-} from '@app/component/next-soup/filters/filter-store';
-import {
- type CallStatus,
- callStatusFromAttended,
-} from '@app/component/next-soup/filters/filter-store/types';
-import {
- activeSoupViewCounts,
- soupViewCacheKey,
-} from '@app/component/next-soup/soup-view/soup-view-cache-key';
-import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
-import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
-import { EntityIcon } from '@core/component/EntityIcon';
-import { UserIcon } from '@core/component/UserIcon';
-import { useQuickAccess } from '@core/context/quickAccess';
-import { useUserId } from '@core/context/user';
-import { EntityIcon as EntityIconWithAvatar } from '@entity/extractors/entity-icon';
-import type {
- ChannelFilters,
- EmailFilters,
-} from '@service-storage/generated/schemas';
-import {
- type Accessor,
- batch,
- createEffect,
- createMemo,
- type JSX,
-} from 'solid-js';
-
-export type SearchableOption = {
- id: string;
- label: string;
- icon?: () => JSX.Element;
-};
-
-const CALL_STATUS_LABELS: Record<CallStatus, string> = {
- ATTENDED: 'Attended',
- MISSED: 'Missed',
- UNATTENDED: 'Unattended',
-};
-
-export const CALL_STATUS_OPTIONS: {
- label: string;
- value: CallStatus | undefined;
-}[] = [
- { label: CALL_STATUS_LABELS.ATTENDED, value: 'ATTENDED' },
- { label: CALL_STATUS_LABELS.MISSED, value: 'MISSED' },
- { label: CALL_STATUS_LABELS.UNATTENDED, value: 'UNATTENDED' },
- { label: 'All', value: undefined },
-];
-
-export const CALL_STATUS_FILTER_OPTIONS: {
- id: CallStatus;
- label: string;
-}[] = [
- { id: 'ATTENDED', label: CALL_STATUS_LABELS.ATTENDED },
- { id: 'MISSED', label: CALL_STATUS_LABELS.MISSED },
- { id: 'UNATTENDED', label: CALL_STATUS_LABELS.UNATTENDED },
-];
-
-export function getCallStatusLabel(status: CallStatus): string {
- return CALL_STATUS_LABELS[status];
-}
-
-/**
- * Picker for the "In" chip (channels + DMs). Used by channel-message and
- * call-record search.
- */
-function useChannelPicker() {
- const { useList } = useQuickAccess();
- const channels = useList('channel', 'dm');
-
- const options = createMemo((): SearchableOption[] =>
- channels()
- .filter((ch) => ch.data.name)
- .map((ch) => ({
- id: ch.id,
- label: ch.data.name,
- icon: () => (
- <div class="size-4">
- <EntityIconWithAvatar
- entity={ch.data}
- suppressClick
- showTooltip={false}
- />
- </div>
- ),
- }))
- );
-
- const labelMap = createMemo(() => {
- const map = new Map<string, string>();
- for (const opt of options()) map.set(opt.id, opt.label);
- return map;
- });
-
- return { options, labelMap };
-}
-
-/**
- * Picker for the "From" chip (people). Used by channel-message sender
- * filter and call-record speaker filter.
- */
-function usePersonPicker() {
- const { useList } = useQuickAccess();
- const currentUserId = useUserId();
- const people = useList('person');
-
- const options = createMemo((): SearchableOption[] => {
- const uid = currentUserId();
- let me: SearchableOption | undefined;
- const others: SearchableOption[] = [];
- for (const s of people()) {
- const opt: SearchableOption = {
- id: s.id,
- label:
- s.id === uid ? `${s.data.name || 'Me'} (me)` : s.data.name || s.id,
- icon: () => (
- <UserIcon id={s.id} size="sm" suppressClick showTooltip={false} />
- ),
- };
- if (s.id === uid) me = opt;
- else others.push(opt);
- }
- return [...(me ? [me] : []), ...others];
- });
-
- const labelMap = createMemo(() => {
- const map = new Map<string, string>();
- for (const opt of options()) map.set(opt.id, opt.label);
- return map;
- });
-
- return { options, labelMap };
-}
-
-/**
- * Shared options + label maps for the In (channel) and From (person)
- * search-filter chips. Both are reused across channel-message and
- * call-record search.
- */
-export function useSearchFilterOptions() {
- const channel = useChannelPicker();
- const person = usePersonPicker();
-
- return {
- channelOptions: channel.options,
- channelLabelMap: channel.labelMap,
- senderOptions: person.options,
- senderLabelMap: person.labelMap,
- };
-}
-
-type ChannelSubFilters = Pick<ChannelFilters, 'channel_ids' | 'sender_ids'>;
-type EmailSubFilters = Pick<EmailFilters, 'importance'>;
-type CallSubFilters = {
- channel_ids?: string[];
- speaker_ids?: string[];
- status?: CallStatus | null;
- attended?: boolean | null;
-};
-
-function getCachedChannelSubFilters(contentId: string): ChannelSubFilters {
- if ((activeSoupViewCounts.get(contentId) ?? 0) > 1) return {};
- try {
- const raw = localStorage.getItem(
- soupViewCacheKey(contentId, 'channel-sub-filters')
- );
- return raw ? JSON.parse(raw) : {};
- } catch {
- return {};
- }
-}
-
-export function cacheChannelSubFilters(
- contentId: string,
- filters: ChannelSubFilters
-) {
- if ((activeSoupViewCounts.get(contentId) ?? 0) > 1) return;
- try {
- localStorage.setItem(
- soupViewCacheKey(contentId, 'channel-sub-filters'),
- JSON.stringify(filters)
- );
- } catch {
- // best-effort: quota or security errors should not break filter flow
- }
-}
-
-function getCachedEmailSubFilters(contentId: string): EmailSubFilters {
- if ((activeSoupViewCounts.get(contentId) ?? 0) > 1) return {};
- try {
- const raw = localStorage.getItem(
- soupViewCacheKey(contentId, 'email-sub-filters')
- );
- return raw ? JSON.parse(raw) : {};
- } catch {
- return {};
- }
-}
-
-export function cacheEmailSubFilters(
- contentId: string,
- filters: EmailSubFilters
-) {
- if ((activeSoupViewCounts.get(contentId) ?? 0) > 1) return;
- try {
- localStorage.setItem(
- soupViewCacheKey(contentId, 'email-sub-filters'),
- JSON.stringify(filters)
- );
- } catch {
- // best-effort
- }
-}
-
-function getCachedCallSubFilters(contentId: string): CallSubFilters {
- if ((activeSoupViewCounts.get(contentId) ?? 0) > 1) return {};
- try {
- const raw = localStorage.getItem(
- soupViewCacheKey(contentId, 'call-sub-filters')
- );
- return raw ? JSON.parse(raw) : {};
- } catch {
- return {};
- }
-}
-
-export function cacheCallSubFilters(
- contentId: string,
- filters: CallSubFilters
-) {
- if ((activeSoupViewCounts.get(contentId) ?? 0) > 1) return;
- try {
- localStorage.setItem(
- soupViewCacheKey(contentId, 'call-sub-filters'),
- JSON.stringify(filters)
- );
- } catch {
- // best-effort
- }
-}
-
-function getInitialCallStatus(
- cached: CallSubFilters,
- query: Query
-): CallStatus | undefined {
- if ('status' in cached) return cached.status ?? undefined;
- if ('attended' in cached) return callStatusFromAttended(cached.attended);
-
- return (
- query.include?.callStatus ??
- callStatusFromAttended(query.include?.callAttended)
- );
-}
-
-type SearchFilterHookOpts = {
- contentId: string;
- isSearchView: Accessor<boolean>;
-};
-
-/** Channel-message search filters (in:, from:). */
-export function useChannelSearchFilter(opts: SearchFilterHookOpts) {
- const { soup, queryFilters } = useSoupView();
- const { changeIndex } = useSearchIndexController();
-
- const isActive = () => soup.predicates.isActive('channels');
-
- const channelIds = createMemo(
- () => queryFilters.state.include.channelId ?? []
- );
- const senderIds = createMemo(
- () => queryFilters.state.include?.channelSenderId ?? []
- );
-
- createEffect(() => {
- if (!opts.isSearchView() || !isActive()) return;
- const sub: ChannelSubFilters = {};
- if (channelIds().length) sub.channel_ids = channelIds();
- if (senderIds().length) sub.sender_ids = senderIds();
- cacheChannelSubFilters(opts.contentId, sub);
- });
-
- return {
- isActive,
- channelIds,
- setChannelIds: (ids: string[]) => {
- if (!isActive()) changeIndex('channels');
- queryFilters.set({
- include: {
- channelId: ids,
- },
- });
- },
- senderIds,
- setSenderIds: (ids: string[]) => {
- if (!isActive()) changeIndex('channels');
-
- queryFilters.set({
- include: {
- channelSenderId: ids,
- },
- });
- },
- };
-}
-
-/** Email search filters (importance). */
-export function useEmailSearchFilter(opts: SearchFilterHookOpts) {
- const { soup, queryFilters } = useSoupView();
- const { changeIndex } = useSearchIndexController();
-
- const isActive = () => soup.predicates.isActive('email');
- const importance = createMemo(
- () => queryFilters.state.include.emailImportance
- );
-
- const setImportance = (val: boolean | undefined) =>
- batch(() => {
- if (!isActive()) changeIndex('email');
- queryFilters.set({
- include: {
- emailImportance: val,
- },
- exclude: {
- emailImportance: undefined,
- },
- });
- });
-
- createEffect(() => {
- if (!opts.isSearchView() || !isActive()) return;
- cacheEmailSubFilters(opts.contentId, { importance: importance() ?? null });
- });
-
- return { isActive, importance, setImportance };
-}
-
-type CallFieldMap = {
- callChannelId: string[] | undefined;
- callSpeakerId: string[] | undefined;
-};
-
-/** Call-record search filters (in:, from:, status). */
-export function useCallSearchFilter(opts: SearchFilterHookOpts) {
- const { soup, queryFilters } = useSoupView();
- const { changeIndex } = useSearchIndexController();
-
- const isActive = () => soup.predicates.isActive('calls');
- const mutate = <K extends keyof CallFieldMap>(
- field: K,
- value: CallFieldMap[K]
- ) =>
- batch(() => {
- if (!isActive()) changeIndex('calls');
- queryFilters.set({
- include: {
- [field]: value,
- },
- });
- });
-
- const channelIds = createMemo(
- () => queryFilters.state.include.callChannelId ?? []
- );
- const speakerIds = createMemo(
- () => queryFilters.state.include.callSpeakerId ?? []
- );
- const status = createMemo(
- () =>
- queryFilters.state.include.callStatus ??
- callStatusFromAttended(queryFilters.state.include.callAttended)
- );
-
- const setStatus = (value: CallStatus | undefined) =>
- batch(() => {
- if (!isActive()) changeIndex('calls');
- queryFilters.set({
- include: {
- callStatus: value,
- callAttended: undefined,
- },
- });
- });
-
- createEffect(() => {
- if (!opts.isSearchView() || !isActive()) return;
- const sub: CallSubFilters = {};
- const currentStatus = status();
- if (channelIds().length) sub.channel_ids = channelIds();
- if (speakerIds().length) sub.speaker_ids = speakerIds();
- if (currentStatus !== undefined) sub.status = currentStatus;
- cacheCallSubFilters(opts.contentId, sub);
- });
-
- return {
- isActive,
- channelIds,
- setChannelIds: (ids: string[]) =>
- mutate('callChannelId', ids.length ? ids : undefined),
- speakerIds,
- setSpeakerIds: (ids: string[]) =>
- mutate('callSpeakerId', ids.length ? ids : undefined),
- status,
- setStatus,
- };
-}
-
-export function useSearchIndexController() {
- const { soup, queryFilters } = useSoupView();
- const panel = useSplitPanelOrThrow();
- const contentId = panel.handle.content().id;
-
- const changeIndex = (newValue: string) => {
- batch(() => {
- for (const opt of INDEX_OPTIONS) {
- if (soup.predicates.isActive(opt.value)) {
- soup.predicates.toggle({ or: [opt.value as FilterID] });
- }
- }
-
- if (newValue === 'all') {
- cacheChannelSubFilters(contentId, {});
- queryFilters.replace({ include: { emailImportance: true } });
- return;
- }
-
- const opt = INDEX_OPTIONS.find((o) => o.value === newValue);
- if (!opt) return;
- soup.predicates.toggle({ or: [opt.value as FilterID] });
-
- if (opt.value === 'channels') {
- const cached = getCachedChannelSubFilters(contentId);
-
- queryFilters.replace({
- include: {
- ...opt.queryFilters.include,
- channelId: cached.channel_ids,
- channelSenderId: cached.sender_ids,
- },
- exclude: opt.queryFilters.exclude,
- });
- } else if (opt.value === 'email') {
- const cached = getCachedEmailSubFilters(contentId);
- const importance =
- 'importance' in cached
- ? (cached.importance ?? undefined)
- : opt.queryFilters.include?.emailImportance;
-
- queryFilters.replace({
- include: {
- ...opt.queryFilters.include,
- emailImportance: importance,
- },
- exclude: opt.queryFilters.exclude,
- });
- } else if (opt.value === 'calls') {
- const cached = getCachedCallSubFilters(contentId);
- const status = getInitialCallStatus(cached, opt.queryFilters);
-
- queryFilters.replace({
- include: {
- ...opt.queryFilters.include,
- callChannelId: cached.channel_ids,
- callSpeakerId: cached.speaker_ids,
- callStatus: status,
- callAttended: undefined,
- },
- exclude: opt.queryFilters.exclude,
- });
- } else {
- queryFilters.replace({
- include: opt.queryFilters.include,
- exclude: opt.queryFilters.exclude,
- });
- }
- });
- };
-
- return { changeIndex };
-}
-
-export const INDEX_OPTIONS: {
- label: string;
- value: string;
- icon: () => JSX.Element;
- queryFilters: Query;
-}[] = [
- {
- value: 'channels',
- label: 'Channels',
- icon: () => (
- <EntityIcon targetType="channel" size="xs" theme="monochrome" />
- ),
- queryFilters: defineQueryFilters({ exclude: { channelId: [NIL_UUID] } }),
- },
- {
- value: 'document-or-file',
- label: 'Documents',
- icon: () => <EntityIcon targetType="md" size="xs" theme="monochrome" />,
- queryFilters: defineQueryFilters({ exclude: { subType: ['task'] } }),
- },
- {
- value: 'task',
- label: 'Tasks',
- icon: () => <EntityIcon targetType="task" size="xs" theme="monochrome" />,
- queryFilters: defineQueryFilters({ include: { subType: ['task'] } }),
- },
- {
- value: 'email',
- label: 'Email',
- icon: () => <EntityIcon targetType="email" size="xs" theme="monochrome" />,
- queryFilters: defineQueryFilters({
- include: { emailImportance: true },
- }),
- },
- {
- value: 'calls',
- label: 'Calls',
- icon: () => <EntityIcon targetType="call" size="xs" theme="monochrome" />,
- queryFilters: defineQueryFilters({}, { skipTargets: ['callf'] }),
- },
- {
- value: 'folders',
- label: 'Folders',
- icon: () => (
- <EntityIcon targetType="project" size="xs" theme="monochrome" />
- ),
- queryFilters: defineQueryFilters({ exclude: { folderId: [NIL_UUID] } }),
- },
- {
- value: 'agent',
- label: 'Agents',
- icon: () => <EntityIcon targetType="chat" size="xs" theme="monochrome" />,
- queryFilters: defineQueryFilters({ exclude: { chatId: [NIL_UUID] } }),
- },
-];
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-facet-chip.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-facet-chip.tsx
new file mode 100644
index 0000000000..08a6f9ee0a
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-facet-chip.tsx
@@ -0,0 +1,171 @@
+import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
+import { Combobox } from '@kobalte/core/combobox';
+import XIcon from '@phosphor/x.svg';
+import { Button, Dropdown, Layer, SingleSelectCheck } from '@ui';
+import {
+ type Accessor,
+ createSignal,
+ For,
+ Match,
+ Show,
+ Switch,
+} from 'solid-js';
+import { SearchableMultiSelect } from '../searchable-multi-select';
+import type { FacetOption, SearchFacetVM } from './search-facets';
+
+interface SearchFacetChipProps {
+ facet: SearchFacetVM;
+ open?: Accessor<boolean>;
+ setOpen?: (v: boolean) => void;
+}
+
+const ChipDivider = () => (
+ <div class="w-px self-stretch bg-edge-muted shrink-0" />
+);
+
+const ValueDisplay = (props: { values: FacetOption[] }) => {
+ const first = () => props.values[0];
+ const overflowCount = () => props.values.length - 1;
+
+ return (
+ <span
+ class="inline-flex h-full items-center gap-1.5"
+ title={props.values.map((v) => v.label).join(', ')}
+ >
+ <Show when={first()?.icon}>
+ {(icon) => (
+ <span class="size-4 flex items-center justify-center shrink-0">
+ {icon()()}
+ </span>
+ )}
+ </Show>
+ <span class="truncate max-w-32">{first()?.label}</span>
+ <Show when={overflowCount() > 0}>
+ <span class="inline-flex items-center justify-center px-1 min-w-4 h-4 rounded-full bg-ink/10 text-xxs">
+ +{overflowCount()}
+ </span>
+ </Show>
+ </span>
+ );
+};
+
+const SingleValueSegment = (props: {
+ facet: Extract<SearchFacetVM, { kind: 'single' }>;
+ open?: Accessor<boolean>;
+ setOpen?: (v: boolean) => void;
+}) => {
+ const [internalOpen, setInternalOpen] = createSignal(false);
+ const isOpen = () => (props.open ? props.open() : internalOpen());
+ const setOpen = (v: boolean) => (props.setOpen ?? setInternalOpen)(v);
+
+ return (
+ <Dropdown open={isOpen()} onOpenChange={setOpen}>
+ <Dropdown.Trigger
+ variant="ghost"
+ class="inline-flex items-center gap-1.5 px-2 h-auto! hover:bg-ink/5 active:bg-ink/8 rounded-none"
+ >
+ <ValueDisplay values={props.facet.values()} />
+ </Dropdown.Trigger>
+ <Dropdown.Content>
+ <Dropdown.Group>
+ <For each={props.facet.options}>
+ {(option) => (
+ <Dropdown.Item
+ onSelect={() => props.facet.onSelect(option.id)}
+ closeOnSelect
+ >
+ <Show when={option.icon}>
+ {(icon) => (
+ <span class="size-4 flex items-center justify-center shrink-0">
+ {icon()()}
+ </span>
+ )}
+ </Show>
+ <span class="flex-1 truncate">{option.label}</span>
+ <SingleSelectCheck
+ active={props.facet.selectedId() === option.id}
+ />
+ </Dropdown.Item>
+ )}
+ </For>
+ </Dropdown.Group>
+ </Dropdown.Content>
+ </Dropdown>
+ );
+};
+
+const MultiValueSegment = (props: {
+ facet: Extract<SearchFacetVM, { kind: 'multi' }>;
+}) => {
+ const panel = useSplitPanelOrThrow();
+ const [open, setOpen] = createSignal(false);
+
+ return (
+ <SearchableMultiSelect
+ options={props.facet.options}
+ activeIds={props.facet.activeIds}
+ onChange={props.facet.onChange}
+ placeholder={props.facet.placeholder}
+ placement="bottom-start"
+ open={open}
+ onOpenChange={(v) => {
+ setOpen(v);
+ if (!v) {
+ queueMicrotask(() =>
+ panel.panelRef()?.focus({ preventScroll: true })
+ );
+ }
+ }}
+ >
+ <Combobox.Trigger class="inline-flex h-full items-center gap-1.5 px-2 hover:bg-hover active:bg-active">
+ <ValueDisplay values={props.facet.values()} />
+ </Combobox.Trigger>
+ </SearchableMultiSelect>
+ );
+};
+
+/**
+ * Always-visible chip for one search facet: `label | value | ✕`. The ✕
+ * resets the facet to its default and only renders while the facet is off
+ * its default.
+ */
+export const SearchFacetChip = (props: SearchFacetChipProps) => (
+ <Layer depth={2}>
+ <div class="h-7 flex items-stretch text-xs whitespace-nowrap rounded-md bg-surface text-ink border border-edge-muted overflow-clip">
+ <span class="inline-flex items-center px-2 text-ink-muted">
+ {props.facet.label}
+ </span>
+
+ <ChipDivider />
+
+ <Switch>
+ <Match when={props.facet.kind === 'single' && props.facet}>
+ {(facet) => (
+ <SingleValueSegment
+ facet={facet()}
+ open={props.open}
+ setOpen={props.setOpen}
+ />
+ )}
+ </Match>
+ <Match when={props.facet.kind === 'multi' && props.facet}>
+ {(facet) => <MultiValueSegment facet={facet()} />}
+ </Match>
+ </Switch>
+
+ <Show when={!props.facet.isDefault()}>
+ <ChipDivider />
+ <Button
+ class="rounded-none h-full not-disabled:hover:text-failure"
+ size="icon-sm"
+ onClick={(e) => {
+ e.stopPropagation();
+ props.facet.reset();
+ }}
+ >
+ <XIcon class="size-3.5!" />
+ </Button>
+ </Show>
+ </div>
+ </Layer>
+);
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-facets.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-facets.tsx
new file mode 100644
index 0000000000..bc045dfc34
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-facets.tsx
@@ -0,0 +1,324 @@
+import type { CallStatus } from '@app/component/next-soup/filters/filter-store/types';
+import { EntityIcon } from '@core/component/EntityIcon';
+import { UserIcon } from '@core/component/UserIcon';
+import { useQuickAccess } from '@core/context/quickAccess';
+import { useUserId } from '@core/context/user';
+import { EntityIcon as EntityIconWithAvatar } from '@entity/extractors/entity-icon';
+import { type Accessor, createMemo, type JSX } from 'solid-js';
+import type { SearchableOption } from '../searchable-multi-select';
+import type {
+ SearchFiltersController,
+ SearchIndexId,
+ SearchTypeValue,
+} from './search-filters-state';
+
+export const SEARCH_INDEX_OPTIONS: {
+ value: SearchIndexId;
+ label: string;
+ icon: () => JSX.Element;
+}[] = [
+ {
+ value: 'channels',
+ label: 'Channels',
+ icon: () => (
+ <EntityIcon targetType="channel" size="xs" theme="monochrome" />
+ ),
+ },
+ {
+ value: 'document-or-file',
+ label: 'Documents',
+ icon: () => <EntityIcon targetType="md" size="xs" theme="monochrome" />,
+ },
+ {
+ value: 'task',
+ label: 'Tasks',
+ icon: () => <EntityIcon targetType="task" size="xs" theme="monochrome" />,
+ },
+ {
+ value: 'email',
+ label: 'Email',
+ icon: () => <EntityIcon targetType="email" size="xs" theme="monochrome" />,
+ },
+ {
+ value: 'calls',
+ label: 'Calls',
+ icon: () => <EntityIcon targetType="call" size="xs" theme="monochrome" />,
+ },
+ {
+ value: 'folders',
+ label: 'Folders',
+ icon: () => (
+ <EntityIcon targetType="project" size="xs" theme="monochrome" />
+ ),
+ },
+ {
+ value: 'agent',
+ label: 'Agents',
+ icon: () => <EntityIcon targetType="chat" size="xs" theme="monochrome" />,
+ },
+];
+
+const CALL_STATUS_LABELS: Record<CallStatus, string> = {
+ ATTENDED: 'Attended',
+ MISSED: 'Missed',
+ UNATTENDED: 'Unattended',
+};
+
+export type FacetOption = {
+ id: string;
+ label: string;
+ icon?: () => JSX.Element;
+};
+
+type FacetBase = {
+ id: string;
+ label: string;
+ /** Display values — at least one entry; neutral state is synthesized. */
+ values: Accessor<FacetOption[]>;
+ isDefault: Accessor<boolean>;
+ reset: () => void;
+};
+
+export type SearchFacetVM = FacetBase &
+ (
+ | {
+ kind: 'single';
+ options: FacetOption[];
+ selectedId: Accessor<string>;
+ onSelect: (id: string) => void;
+ }
+ | {
+ kind: 'multi';
+ options: Accessor<SearchableOption[]>;
+ activeIds: Accessor<string[]>;
+ onChange: (ids: string[]) => void;
+ placeholder: string;
+ }
+ );
+
+/**
+ * Picker for the "In" chip (channels + DMs). Used by channel-message and
+ * call-record search.
+ */
+function useChannelPicker(): Accessor<SearchableOption[]> {
+ const { useList } = useQuickAccess();
+ const channels = useList('channel', 'dm');
+
+ return createMemo(() =>
+ channels()
+ .filter((ch) => ch.data.name)
+ .map((ch) => ({
+ id: ch.id,
+ label: ch.data.name,
+ icon: () => (
+ <div class="size-4">
+ <EntityIconWithAvatar
+ entity={ch.data}
+ suppressClick
+ showTooltip={false}
+ />
+ </div>
+ ),
+ }))
+ );
+}
+
+/**
+ * Picker for the "From" chip (people). Used by channel-message sender
+ * filter and call-record speaker filter.
+ */
+function usePersonPicker(): Accessor<SearchableOption[]> {
+ const { useList } = useQuickAccess();
+ const currentUserId = useUserId();
+ const people = useList('person');
+
+ return createMemo(() => {
+ const uid = currentUserId();
+ let me: SearchableOption | undefined;
+ const others: SearchableOption[] = [];
+ for (const s of people()) {
+ const opt: SearchableOption = {
+ id: s.id,
+ label:
+ s.id === uid ? `${s.data.name || 'Me'} (me)` : s.data.name || s.id,
+ icon: () => (
+ <UserIcon id={s.id} size="sm" suppressClick showTooltip={false} />
+ ),
+ };
+ if (s.id === uid) me = opt;
+ else others.push(opt);
+ }
+ return [...(me ? [me] : []), ...others];
+ });
+}
+
+function singleFacet(args: {
+ id: string;
+ label: string;
+ options: FacetOption[];
+ defaultId: string;
+ selectedId: Accessor<string>;
+ onSelect: (id: string) => void;
+}): SearchFacetVM {
+ return {
+ kind: 'single',
+ id: args.id,
+ label: args.label,
+ options: args.options,
+ selectedId: args.selectedId,
+ onSelect: args.onSelect,
+ isDefault: () => args.selectedId() === args.defaultId,
+ reset: () => args.onSelect(args.defaultId),
+ values: () => {
+ const selected = args.selectedId();
+ const option = args.options.find((o) => o.id === selected);
+ return [option ?? args.options[0]];
+ },
+ };
+}
+
+function multiFacet(args: {
+ id: string;
+ label: string;
+ neutralLabel: string;
+ placeholder: string;
+ options: Accessor<SearchableOption[]>;
+ activeIds: Accessor<string[]>;
+ onChange: (ids: string[]) => void;
+}): SearchFacetVM {
+ return {
+ kind: 'multi',
+ id: args.id,
+ label: args.label,
+ options: args.options,
+ activeIds: args.activeIds,
+ onChange: args.onChange,
+ placeholder: args.placeholder,
+ isDefault: () => args.activeIds().length === 0,
+ reset: () => args.onChange([]),
+ values: () => {
+ const ids = args.activeIds();
+ if (ids.length === 0) return [{ id: 'all', label: args.neutralLabel }];
+ const options = args.options();
+ return ids.map((id) => {
+ const option = options.find((o) => o.id === id);
+ return { id, label: option?.label ?? id, icon: option?.icon };
+ });
+ },
+ };
+}
+
+/**
+ * Materializes the facet registry against the controller. Each facet is
+ * defined once; which ones render follows the active type. Adding a facet =
+ * one definition here + its compile line in `compileSearchQuery`.
+ */
+export function useSearchFacets(
+ controller: SearchFiltersController
+): Accessor<SearchFacetVM[]> {
+ const channelOptions = useChannelPicker();
+ const personOptions = usePersonPicker();
+
+ const type = singleFacet({
+ id: 'type',
+ label: 'Type',
+ options: [
+ { id: 'all', label: 'All' },
+ ...SEARCH_INDEX_OPTIONS.map((o) => ({
+ id: o.value,
+ label: o.label,
+ icon: o.icon,
+ })),
+ ],
+ defaultId: 'all',
+ selectedId: controller.type,
+ onSelect: (id) => controller.setType(id as SearchTypeValue),
+ });
+
+ const importance = singleFacet({
+ id: 'importance',
+ label: 'Importance',
+ options: [
+ { id: 'all', label: 'All' },
+ { id: 'signal', label: 'Signal' },
+ { id: 'noise', label: 'Noise' },
+ ],
+ defaultId: 'all',
+ selectedId: () => {
+ const value = controller.emailImportance();
+ if (value === undefined) return 'all';
+ return value ? 'signal' : 'noise';
+ },
+ onSelect: (id) =>
+ controller.setEmailImportance(id === 'all' ? undefined : id === 'signal'),
+ });
+
+ const channelIn = multiFacet({
+ id: 'channel-in',
+ label: 'In',
+ neutralLabel: 'All channels',
+ placeholder: 'Search channels...',
+ options: channelOptions,
+ activeIds: controller.channelIn,
+ onChange: controller.setChannelIn,
+ });
+
+ const channelFrom = multiFacet({
+ id: 'channel-from',
+ label: 'From',
+ neutralLabel: 'Anyone',
+ placeholder: 'Search senders...',
+ options: personOptions,
+ activeIds: controller.channelFrom,
+ onChange: controller.setChannelFrom,
+ });
+
+ const callIn = multiFacet({
+ id: 'call-in',
+ label: 'In',
+ neutralLabel: 'All channels',
+ placeholder: 'Search channels...',
+ options: channelOptions,
+ activeIds: controller.callIn,
+ onChange: controller.setCallIn,
+ });
+
+ const callFrom = multiFacet({
+ id: 'call-from',
+ label: 'From',
+ neutralLabel: 'Anyone',
+ placeholder: 'Search speakers...',
+ options: personOptions,
+ activeIds: controller.callFrom,
+ onChange: controller.setCallFrom,
+ });
+
+ const callStatus = singleFacet({
+ id: 'call-status',
+ label: 'Status',
+ options: [
+ { id: 'all', label: 'All' },
+ ...(Object.keys(CALL_STATUS_LABELS) as CallStatus[]).map((status) => ({
+ id: status,
+ label: CALL_STATUS_LABELS[status],
+ })),
+ ],
+ defaultId: 'all',
+ selectedId: () => controller.callStatus() ?? 'all',
+ onSelect: (id) =>
+ controller.setCallStatus(id === 'all' ? undefined : (id as CallStatus)),
+ });
+
+ return createMemo(() => {
+ switch (controller.type()) {
+ case 'email':
+ return [type, importance];
+ case 'channels':
+ return [type, channelIn, channelFrom];
+ case 'calls':
+ return [type, callIn, callFrom, callStatus];
+ default:
+ return [type];
+ }
+ });
+}
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-filters-row.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-filters-row.tsx
new file mode 100644
index 0000000000..14dafdcf06
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-filters-row.tsx
@@ -0,0 +1,43 @@
+import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
+import { registerHotkey } from '@core/hotkey/hotkeys';
+import { TOKENS } from '@core/hotkey/tokens';
+import { createSignal, For } from 'solid-js';
+import { SearchFacetChip } from './search-facet-chip';
+import { useSearchFacets } from './search-facets';
+import { createSearchFiltersController } from './search-filters-state';
+
+/**
+ * Always-visible filter row for the search view. Renders one chip per facet
+ * applicable to the active type.
+ */
+export function SearchFiltersRow() {
+ const controller = createSearchFiltersController();
+ const facets = useSearchFacets(controller);
+ const panel = useSplitPanelOrThrow();
+ const [typeMenuOpen, setTypeMenuOpen] = createSignal(false);
+
+ registerHotkey({
+ hotkey: 'f',
+ scopeId: panel.splitHotkeyScope,
+ description: 'Filter by type',
+ hotkeyToken: TOKENS.soup.filter,
+ keyDownHandler: () => {
+ setTypeMenuOpen(true);
+ return true;
+ },
+ });
+
+ return (
+ <div class="flex items-center gap-1.5 flex-wrap min-w-0">
+ <For each={facets()}>
+ {(facet) => (
+ <SearchFacetChip
+ facet={facet}
+ open={facet.id === 'type' ? typeMenuOpen : undefined}
+ setOpen={facet.id === 'type' ? setTypeMenuOpen : undefined}
+ />
+ )}
+ </For>
+ </div>
+ );
+}
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-filters-state.ts b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-filters-state.ts
new file mode 100644
index 0000000000..816c777b0c
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/search/search-filters-state.ts
@@ -0,0 +1,197 @@
+import { getViewPreset } from '@app/component/app-sidebar/soup-filter-presets';
+import {
+ defineQueryFilters,
+ NIL_UUID,
+ type Query,
+} from '@app/component/next-soup/filters/filter-store';
+import {
+ type CallStatus,
+ callStatusFromAttended,
+ type FieldFilters,
+} from '@app/component/next-soup/filters/filter-store/types';
+import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
+import { batch, createMemo } from 'solid-js';
+
+export type SearchIndexId =
+ | 'channels'
+ | 'document-or-file'
+ | 'task'
+ | 'email'
+ | 'calls'
+ | 'folders'
+ | 'agent';
+
+export type SearchTypeValue = SearchIndexId | 'all';
+
+/**
+ * Server-side narrowing for each index type. `defineQueryFilters` NIL-fills
+ * the id field of every target the input doesn't reference, so each seed
+ * matches only its own entity type. Sub-facet values (importance, channel
+ * ids, ...) are layered on top by `compileSearchQuery`.
+ */
+export const SEARCH_INDEX_SEEDS: Record<SearchIndexId, Query> = {
+ channels: defineQueryFilters({ exclude: { channelId: [NIL_UUID] } }),
+ 'document-or-file': defineQueryFilters({ exclude: { subType: ['task'] } }),
+ task: defineQueryFilters({ include: { subType: ['task'] } }),
+ email: defineQueryFilters({}, { skipTargets: ['ef'] }),
+ calls: defineQueryFilters({}, { skipTargets: ['callf'] }),
+ folders: defineQueryFilters({ exclude: { folderId: [NIL_UUID] } }),
+ agent: defineQueryFilters({ exclude: { chatId: [NIL_UUID] } }),
+};
+
+export type SearchFiltersSections = {
+ email: { importance: boolean | undefined };
+ channels: { in: string[]; from: string[] };
+ calls: { in: string[]; from: string[]; status: CallStatus | undefined };
+};
+
+export type SearchFiltersState = SearchFiltersSections & {
+ type: SearchTypeValue;
+};
+
+export const DEFAULT_SECTIONS: SearchFiltersSections = {
+ email: { importance: undefined },
+ channels: { in: [], from: [] },
+ calls: { in: [], from: [], status: undefined },
+};
+
+/**
+ * Single compile path: facet state → query filters. Both data paths (soup
+ * AST feed and search-service request) derive from the resulting store
+ * state, so this is the only place facet semantics turn into filters.
+ *
+ * `'all'` compiles to just the search preset baseline — no index narrowing
+ * and no email-importance bias. Only the active type's section is compiled;
+ * inactive sections never constrain results.
+ */
+export function compileSearchQuery(state: SearchFiltersState): Query {
+ const baseline = getViewPreset('search')?.filters ?? {};
+ const include: FieldFilters = { ...baseline.include };
+ const exclude: FieldFilters = { ...baseline.exclude };
+
+ if (state.type === 'all') return { include, exclude };
+
+ const seed = SEARCH_INDEX_SEEDS[state.type];
+ Object.assign(include, seed.include);
+ Object.assign(exclude, seed.exclude);
+
+ if (state.type === 'email') {
+ if (state.email.importance !== undefined) {
+ include.emailImportance = state.email.importance;
+ }
+ } else if (state.type === 'channels') {
+ if (state.channels.in.length) include.channelId = state.channels.in;
+ if (state.channels.from.length) {
+ include.channelSenderId = state.channels.from;
+ }
+ } else if (state.type === 'calls') {
+ if (state.calls.in.length) include.callChannelId = state.calls.in;
+ if (state.calls.from.length) include.callSpeakerId = state.calls.from;
+ if (state.calls.status !== undefined) {
+ include.callStatus = state.calls.status;
+ }
+ }
+
+ return { include, exclude };
+}
+
+/**
+ * Facet state is derived from the soup view's `queryFilters` +
+ * `soup.predicates` (the single source of truth — external writers like
+ * Cmd+K search overrides and per-entry restore keep working untouched).
+ * Setters recompile the full state through `compileSearchQuery` and replace
+ * the store wholesale.
+ */
+export function createSearchFiltersController() {
+ const { soup, queryFilters } = useSoupView();
+
+ const type = createMemo<SearchTypeValue>(
+ () =>
+ soup.predicates
+ .orIds()
+ .find((id): id is SearchIndexId => id in SEARCH_INDEX_SEEDS) ?? 'all'
+ );
+
+ const include = () => queryFilters.state.include;
+ const withoutNil = (ids: string[] | undefined) =>
+ (ids ?? []).filter((id) => id !== NIL_UUID);
+
+ const emailImportance = () => include().emailImportance;
+ const channelIn = createMemo(() => withoutNil(include().channelId));
+ const channelFrom = createMemo(() => withoutNil(include().channelSenderId));
+ const callIn = createMemo(() => withoutNil(include().callChannelId));
+ const callFrom = createMemo(() => withoutNil(include().callSpeakerId));
+ const callStatus = () =>
+ include().callStatus ?? callStatusFromAttended(include().callAttended);
+
+ const currentSections = (): SearchFiltersSections => ({
+ email: { importance: emailImportance() },
+ channels: { in: channelIn(), from: channelFrom() },
+ calls: { in: callIn(), from: callFrom(), status: callStatus() },
+ });
+
+ // Per-index values are remembered for the lifetime of the view: switching
+ // the type away stashes the active section, switching back rehydrates it.
+ let stash: SearchFiltersSections = structuredClone(DEFAULT_SECTIONS);
+
+ const apply = (state: SearchFiltersState) =>
+ batch(() => {
+ queryFilters.replace(compileSearchQuery(state));
+ soup.predicates.set(({ andIds }) => ({
+ and: andIds,
+ or: state.type === 'all' ? [] : [state.type],
+ }));
+ });
+
+ const applySections = (sections: Partial<SearchFiltersSections>) =>
+ apply({ type: type(), ...currentSections(), ...sections });
+
+ const setType = (next: SearchTypeValue) => {
+ const current = type();
+ if (next === current) return;
+
+ if (current === 'email') {
+ stash = { ...stash, email: { importance: emailImportance() } };
+ } else if (current === 'channels') {
+ stash = { ...stash, channels: { in: channelIn(), from: channelFrom() } };
+ } else if (current === 'calls') {
+ stash = {
+ ...stash,
+ calls: { in: callIn(), from: callFrom(), status: callStatus() },
+ };
+ }
+
+ apply({ type: next, ...stash });
+ };
+
+ return {
+ type,
+ setType,
+ emailImportance,
+ setEmailImportance: (importance: boolean | undefined) =>
+ applySections({ email: { importance } }),
+ channelIn,
+ setChannelIn: (ids: string[]) =>
+ applySections({ channels: { in: ids, from: channelFrom() } }),
+ channelFrom,
+ setChannelFrom: (ids: string[]) =>
+ applySections({ channels: { in: channelIn(), from: ids } }),
+ callIn,
+ setCallIn: (ids: string[]) =>
+ applySections({
+ calls: { in: ids, from: callFrom(), status: callStatus() },
+ }),
+ callFrom,
+ setCallFrom: (ids: string[]) =>
+ applySections({
+ calls: { in: callIn(), from: ids, status: callStatus() },
+ }),
+ callStatus,
+ setCallStatus: (status: CallStatus | undefined) =>
+ applySections({ calls: { in: callIn(), from: callFrom(), status } }),
+ };
+}
+
+export type SearchFiltersController = ReturnType<
+ typeof createSearchFiltersController
+>;
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/searchable-multi-select.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/searchable-multi-select.tsx
index 7a1061503e..2b8ca04abb 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/searchable-multi-select.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/searchable-multi-select.tsx
@@ -12,7 +12,12 @@ import {
Show,
} from 'solid-js';
import { Virtualizer, type VirtualizerHandle } from 'virtua/solid';
-import type { SearchableOption } from './search-filter-controls';
+
+export type SearchableOption = {
+ id: string;
+ label: string;
+ icon?: () => JSX.Element;
+};
const ITEM_HEIGHT = 36;
const LISTBOX_CLASS = 'max-h-[240px] overflow-y-auto scrollbar-hidden';
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx
index 2f0fd9047b..4fe6ceb4c3 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx
@@ -1,4 +1,5 @@
import { useAnalytics } from '@app/component/analytics-context';
+import { SearchFiltersRow } from '@app/component/next-soup/soup-view/filters-bar/search/search-filters-row';
import { SoupActiveFiltersBar } from '@app/component/next-soup/soup-view/filters-bar/soup-active-filters-bar';
import { SoupViewContextGroup } from '@app/component/next-soup/soup-view/filters-bar/soup-view-context-group';
import { SoupViewContextSort } from '@app/component/next-soup/soup-view/filters-bar/soup-view-context-sort';
@@ -61,14 +62,14 @@ export function SoupFiltersBar() {
<Show when={!isMobile()}>
<SplitToolbarLeft>
<div class="flex items-start gap-1 min-w-0 flex-1">
- <Show when={!isSearchView()}>
+ <Show when={!isSearchView()} fallback={<SearchFiltersRow />}>
<SoupViewContextSort />
<SoupViewContextGroup />
+ <UnifiedFilterDropdown
+ open={filterDropdownOpen}
+ onOpenChange={setFilterDropdownOpen}
+ />
</Show>
- <UnifiedFilterDropdown
- open={filterDropdownOpen}
- onOpenChange={setFilterDropdownOpen}
- />
</div>
</SplitToolbarLeft>
<SplitToolbarRight>
@@ -86,10 +87,12 @@ export function SoupFiltersBar() {
</Tooltip>
</SplitToolbarRight>
{/* Active filters bar - shown below the toolbar when there are filters */}
- <SoupActiveFiltersBar
- filters={consolidatedFiltersList()}
- onClearAll={resetToTabDefaults}
- />
+ <Show when={!isSearchView()}>
+ <SoupActiveFiltersBar
+ filters={consolidatedFiltersList()}
+ onClearAll={resetToTabDefaults}
+ />
+ </Show>
</Show>
);
}
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
index 26a7ea6ee3..b645c22c45 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
@@ -26,7 +26,7 @@ import FilterIcon from '@phosphor/funnel-simple.svg';
import { PropertyValueIcon } from '@property/component/propertyValue/PropertyValueIcon';
import { PROPERTY_OPTION_IDS, SYSTEM_PROPERTY_IDS } from '@property/constants';
import { useContacts } from '@queries/contacts/contacts';
-import { cn, Dropdown, SingleSelectCheck, Tooltip } from '@ui';
+import { cn, Dropdown, Tooltip } from '@ui';
import {
type Accessor,
batch,
@@ -41,16 +41,9 @@ import {
Switch,
} from 'solid-js';
import {
- CALL_STATUS_OPTIONS,
- INDEX_OPTIONS,
+ SearchableMultiSelectInline,
type SearchableOption,
- useCallSearchFilter,
- useChannelSearchFilter,
- useEmailSearchFilter,
- useSearchFilterOptions,
- useSearchIndexController,
-} from './search-filter-controls';
-import { SearchableMultiSelectInline } from './searchable-multi-select';
+} from './searchable-multi-select';
export const TypeIndicator = (props: { active: boolean }) => (
<span
@@ -457,196 +450,6 @@ const SearchableFilterSubmenu = (props: {
);
};
-/** Single-value sub-menu (e.g. Importance, Status). */
-function SingleValueSubmenu<T>(props: {
- label: string;
- options: { label: string; value: T }[];
- current: Accessor<T>;
- onSelect: (value: T) => void;
-}) {
- return (
- <Dropdown.Sub>
- <Dropdown.SubTrigger>
- <span class="text-ink">{props.label}</span>
- <CaretRightIcon class="size-3 text-ink-muted" />
- </Dropdown.SubTrigger>
- <Dropdown.SubContent>
- <Dropdown.Group>
- <For each={props.options}>
- {(option) => {
- const active = () => props.current() === option.value;
- return (
- <Dropdown.Item
- onSelect={() => props.onSelect(option.value)}
- closeOnSelect
- >
- <span class="flex-1 truncate">{option.label}</span>
- <SingleSelectCheck active={active()} />
- </Dropdown.Item>
- );
- }}
- </For>
- </Dropdown.Group>
- </Dropdown.SubContent>
- </Dropdown.Sub>
- );
-}
-
-type InFromOpen = 'in' | 'from' | null;
-
-/** In + From (channel messages). */
-const ChannelSearchSubContent = (props: {
- channel: ReturnType<typeof useChannelSearchFilter>;
- channelOptions: Accessor<SearchableOption[]>;
- senderOptions: Accessor<SearchableOption[]>;
-}) => {
- const [openSub, setOpenSub] = createSignal<InFromOpen>(null);
- return (
- <>
- <SearchableFilterSubmenu
- label="In"
- options={props.channelOptions}
- activeIds={props.channel.channelIds}
- onChange={props.channel.setChannelIds}
- placeholder="Search channels..."
- open={() => openSub() === 'in'}
- onOpenChange={(v) => setOpenSub(v ? 'in' : null)}
- />
- <SearchableFilterSubmenu
- label="From"
- options={props.senderOptions}
- activeIds={props.channel.senderIds}
- onChange={props.channel.setSenderIds}
- placeholder="Search senders..."
- open={() => openSub() === 'from'}
- onOpenChange={(v) => setOpenSub(v ? 'from' : null)}
- />
- </>
- );
-};
-
-const IMPORTANCE_OPTIONS: {
- label: string;
- value: boolean | undefined;
-}[] = [
- { label: 'Signal', value: true },
- { label: 'Noise', value: false },
- { label: 'All', value: undefined },
-];
-
-/** Importance (emails). */
-const EmailSearchSubContent = (props: {
- email: ReturnType<typeof useEmailSearchFilter>;
-}) => (
- <SingleValueSubmenu
- label="Importance"
- options={IMPORTANCE_OPTIONS}
- current={props.email.importance}
- onSelect={props.email.setImportance}
- />
-);
-
-/** In + From + Status (calls). */
-const CallSearchSubContent = (props: {
- call: ReturnType<typeof useCallSearchFilter>;
- channelOptions: Accessor<SearchableOption[]>;
- senderOptions: Accessor<SearchableOption[]>;
-}) => {
- const [openSub, setOpenSub] = createSignal<InFromOpen>(null);
- return (
- <>
- <SearchableFilterSubmenu
- label="In"
- options={props.channelOptions}
- activeIds={props.call.channelIds}
- onChange={props.call.setChannelIds}
- placeholder="Search channels..."
- open={() => openSub() === 'in'}
- onOpenChange={(v) => setOpenSub(v ? 'in' : null)}
- />
- <SearchableFilterSubmenu
- label="From"
- options={props.senderOptions}
- activeIds={props.call.speakerIds}
- onChange={props.call.setSpeakerIds}
- placeholder="Search speakers..."
- open={() => openSub() === 'from'}
- onOpenChange={(v) => setOpenSub(v ? 'from' : null)}
- />
- <SingleValueSubmenu
- label="Status"
- options={CALL_STATUS_OPTIONS}
- current={() => props.call.status() ?? undefined}
- onSelect={props.call.setStatus}
- />
- </>
- );
-};
-
-const SearchIndexRowLabel = (props: {
- option: (typeof INDEX_OPTIONS)[number];
- active: Accessor<boolean>;
-}) => (
- <>
- <Show when={props.option.icon}>
- {(icon) => (
- <span class="size-4 flex items-center justify-center shrink-0">
- {icon()()}
- </span>
- )}
- </Show>
- <span class="flex-1 truncate">{props.option.label}</span>
- <SingleSelectCheck active={props.active()} />
- </>
-);
-
-/** Flat row — selecting it just switches the active index. */
-const SearchIndexItem = (props: {
- option: (typeof INDEX_OPTIONS)[number];
- active: Accessor<boolean>;
- onSelect: () => void;
-}) => (
- <Dropdown.Item onSelect={props.onSelect} closeOnSelect>
- <SearchIndexRowLabel option={props.option} active={props.active} />
- </Dropdown.Item>
-);
-
-/** Row with a nested submenu.
- *
- * `children` must be lazy (via `<Match>`) so the nested submenus
- * instantiate *inside* this row's `Dropdown.SubContent`. Eager JSX
- * would evaluate in the outer content's context, which makes Kobalte
- * register nested `Dropdown.Sub`s against the wrong parent —
- * positioning falls back to the viewport and keyboard nav treats them as
- * siblings of the row. */
-const SearchIndexSubRow = (props: {
- option: (typeof INDEX_OPTIONS)[number];
- active: Accessor<boolean>;
- onSelect: () => void;
- closeRoot: () => void;
- children: JSX.Element;
-}) => (
- <Dropdown.Sub>
- <Dropdown.SubTrigger
- onPointerDown={props.onSelect}
- onKeyDown={(e) => {
- if (e.key === 'Enter' || e.key === ' ') {
- e.preventDefault();
- e.stopPropagation();
- props.onSelect();
- props.closeRoot();
- }
- }}
- >
- <SearchIndexRowLabel option={props.option} active={props.active} />
- <CaretRightIcon class="size-3 text-ink-muted" />
- </Dropdown.SubTrigger>
- <Dropdown.SubContent>
- <Dropdown.Group>{props.children}</Dropdown.Group>
- </Dropdown.SubContent>
- </Dropdown.Sub>
-);
-
interface UnifiedFilterDropdownProps {
/** Optional controlled open state */
open?: Accessor<boolean>;
@@ -671,7 +474,6 @@ export const UnifiedFilterDropdown = (
useSoupView();
const contacts = useContacts();
const userId = useUserId();
- const contentId = panel.handle.content().id;
const currentView = createMemo((): ListView | undefined => {
const content = panel.handle.content();
@@ -802,18 +604,6 @@ export const UnifiedFilterDropdown = (
};
const isTasksView = () => currentView() === 'tasks';
- const isSearchView = () => currentView() === 'search';
- const hasActiveIndex = () =>
- INDEX_OPTIONS.some((opt) => soup.predicates.isActive(opt.value));
-
- const { changeIndex: handleIndexChange } = useSearchIndexController();
-
- const channel = useChannelSearchFilter({ contentId, isSearchView });
- const email = useEmailSearchFilter({ contentId, isSearchView });
- const call = useCallSearchFilter({ contentId, isSearchView });
-
- const { channelOptions: inChannelOptions, senderOptions: fromSenderOptions } =
- useSearchFilterOptions();
registerHotkey({
hotkey: 'f',
@@ -852,7 +642,7 @@ export const UnifiedFilterDropdown = (
};
return (
- <Show when={categories().length > 0 || isTasksView() || isSearchView()}>
+ <Show when={categories().length > 0 || isTasksView()}>
<Dropdown
open={open()}
onOpenChange={handleOpenChange}
@@ -875,9 +665,7 @@ export const UnifiedFilterDropdown = (
<Dropdown.Content>
<Dropdown.Group>
<Show
- when={
- categories().length === 1 && !isTasksView() && !isSearchView()
- }
+ when={categories().length === 1 && !isTasksView()}
fallback={
<>
<For each={categories()}>
@@ -936,56 +724,6 @@ export const UnifiedFilterDropdown = (
placeholder="Search assignees..."
/>
</Show>
-
- {/* Search view: 7 type rows (Channels/Email have nested submenus) */}
- <Show when={isSearchView()}>
- <For each={INDEX_OPTIONS}>
- {(option) => {
- const rowProps = {
- option,
- active: () => soup.predicates.isActive(option.value),
- onSelect: () => handleIndexChange(option.value),
- closeRoot: () => setOpen(false),
- };
- return (
- <Switch fallback={<SearchIndexItem {...rowProps} />}>
- <Match when={option.value === 'channels'}>
- <SearchIndexSubRow {...rowProps}>
- <ChannelSearchSubContent
- channel={channel}
- channelOptions={inChannelOptions}
- senderOptions={fromSenderOptions}
- />
- </SearchIndexSubRow>
- </Match>
- <Match when={option.value === 'email'}>
- <SearchIndexSubRow {...rowProps}>
- <EmailSearchSubContent email={email} />
- </SearchIndexSubRow>
- </Match>
- <Match when={option.value === 'calls'}>
- <SearchIndexSubRow {...rowProps}>
- <CallSearchSubContent
- call={call}
- channelOptions={inChannelOptions}
- senderOptions={fromSenderOptions}
- />
- </SearchIndexSubRow>
- </Match>
- </Switch>
- );
- }}
- </For>
-
- {/* All row */}
- <Dropdown.Item
- onSelect={() => handleIndexChange('all')}
- closeOnSelect
- >
- <span class="flex-1 truncate">All</span>
- <SingleSelectCheck active={!hasActiveIndex()} />
- </Dropdown.Item>
- </Show>
</>
}
>
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.tsx
index fa4e074f9a..8ffbc923b3 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.tsx
@@ -10,15 +10,10 @@ import {
} from '@app/component/next-soup/filters';
import {
defineQueryFilters,
- NIL_UUID,
type Query,
queryStateFrom,
} from '@app/component/next-soup/filters/filter-store';
import { mergeQuery } from '@app/component/next-soup/filters/filter-store/query-store';
-import {
- type CallStatus,
- callStatusFromAttended,
-} from '@app/component/next-soup/filters/filter-store/types';
import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
import type { ListView } from '@app/constants/list-views';
@@ -29,28 +24,12 @@ import { deepEqual } from '@core/util/compareUtils';
import CircleDashedIcon from '@phosphor/circle-dashed.svg';
import { SYSTEM_PROPERTY_IDS } from '@property/constants';
import { useContacts } from '@queries/contacts/contacts';
-import {
- type Accessor,
- batch,
- createMemo,
- createSignal,
- type JSX,
-} from 'solid-js';
+import { batch, createMemo, createSignal, type JSX } from 'solid-js';
import type {
ConsolidatedFilter,
FilterValue,
} from './consolidated-filter-chip';
-import {
- CALL_STATUS_FILTER_OPTIONS,
- cacheCallSubFilters,
- cacheChannelSubFilters,
- cacheEmailSubFilters,
- getCallStatusLabel,
- INDEX_OPTIONS,
- type SearchableOption,
- useSearchFilterOptions,
- useSearchIndexController,
-} from './search-filter-controls';
+import type { SearchableOption } from './searchable-multi-select';
import {
buildContactLabel,
VIEW_FILTER_CATEGORIES,
@@ -89,9 +68,6 @@ export function useFilterRefinements() {
const user = useUserContext();
const contacts = useContacts();
const currentUserId = useUserId();
- const { channelOptions, channelLabelMap, senderOptions, senderLabelMap } =
- useSearchFilterOptions();
- const { changeIndex } = useSearchIndexController();
const getPresetContext = (): PresetContext => ({
userId: user.userId(),
@@ -261,17 +237,6 @@ export function useFilterRefinements() {
return VIEW_FILTER_CATEGORIES[view as ListView] ?? [];
});
- const setFilterIds =
- (
- field: 'callChannelId' | 'callSpeakerId' | 'channelId' | 'channelSenderId'
- ) =>
- (ids: string[]) =>
- queryFilters.set({
- include: {
- [field]: ids,
- },
- });
-
/**
* Cache for consolidated filter chips, similar to chipCache but for the new format.
* We track the view and tab to invalidate when they change, since cached chips
@@ -441,68 +406,6 @@ export function useFilterRefinements() {
);
}
- // Search index type filters (single-select, replaces)
- const coveredByView = new Set<string>(
- viewCategories().flatMap((c) => c.options.map((o) => o.id))
- );
- const activeIndexOptions: FilterValue[] = [];
- for (const option of INDEX_OPTIONS) {
- const optionId = option.value as FilterID;
- if (
- soup.predicates.isActive(optionId) &&
- !coveredByView.has(optionId) &&
- !presetFilterIds.has(optionId)
- ) {
- activeIndexOptions.push({
- id: option.value,
- label: option.label,
- icon: option.icon,
- });
- }
- }
-
- if (activeIndexOptions.length > 0) {
- const key = 'type:index';
- seenKeys.add(key);
-
- const getActiveIndexValues = (): FilterValue[] => {
- const result: FilterValue[] = [];
- for (const option of INDEX_OPTIONS) {
- const optionId = option.value as FilterID;
- if (
- soup.predicates.isActive(optionId) &&
- !coveredByView.has(optionId) &&
- !presetFilterIds.has(optionId)
- ) {
- result.push({
- id: option.value,
- label: option.label,
- icon: option.icon,
- });
- }
- }
- return result;
- };
-
- filters.push(
- getOrCreateConsolidatedChip(key, () => ({
- key,
- categoryLabel: 'Type',
- categoryLabelPlural: 'Types',
- values: getActiveIndexValues,
- availableOptions: INDEX_OPTIONS.map((o) => ({
- id: o.value,
- label: o.label,
- icon: o.icon,
- })),
- multiple: false,
- isValueActive: (id) => soup.predicates.isActive(id),
- onToggleValue: (id) => changeIndex(id),
- onRemoveAll: () => changeIndex('all'),
- }))
- );
- }
-
// Assignee filter (consolidated) - using searchable approach
const pushAssigneeConsolidatedChip = () => {
const key = 'assignee';
@@ -553,202 +456,6 @@ export function useFilterRefinements() {
pushAssigneeConsolidatedChip();
- // Searchable filters helper for consolidated chips
- const pushSearchableConsolidatedChip = (args: {
- key: string;
- categoryLabel: string;
- getIds: () => string[];
- searchableOptions: Accessor<SearchableOption[]>;
- labelMap: Accessor<Map<string, string>>;
- onChange: (ids: string[]) => void;
- searchPlaceholder: string;
- }) => {
- const popupOpen =
- consolidatedChipCache.get(args.key)?.isPopupOpen?.() ?? false;
- const ids = args.getIds();
- if (ids.length === 0 && !popupOpen) return;
-
- seenKeys.add(args.key);
-
- // Compute values as accessor for reactivity
- const getValues = (): FilterValue[] => {
- const options = args.searchableOptions();
- return args.getIds().map((id) => {
- const opt = options.find((o) => o.id === id);
- return {
- id,
- label: args.labelMap().get(id) ?? id,
- icon: opt?.icon,
- };
- });
- };
-
- filters.push(
- getOrCreateConsolidatedChip(args.key, () => {
- const [isPopupOpen, _setPopupOpen] = createSignal(false);
- const setPopupOpen = (v: boolean) => {
- if (!v) {
- queueMicrotask(() =>
- panel.panelRef()?.focus({ preventScroll: true })
- );
- }
- _setPopupOpen(v);
- };
- return {
- key: args.key,
- categoryLabel: args.categoryLabel,
- values: getValues,
- searchableOptions: args.searchableOptions,
- activeSearchableIds: args.getIds,
- onSearchableChange: args.onChange,
- searchPlaceholder: args.searchPlaceholder,
- isPopupOpen,
- setPopupOpen,
- onRemoveAll: () => args.onChange([]),
- };
- })
- );
- };
-
- // Channel In/From filters
- pushSearchableConsolidatedChip({
- key: 'channel-in',
- categoryLabel: 'In',
- getIds: () =>
- (queryFilters.state.include.channelId ?? []).filter(
- (id) => id !== NIL_UUID
- ),
- searchableOptions: channelOptions,
- labelMap: channelLabelMap,
- onChange: setFilterIds('channelId'),
- searchPlaceholder: 'Search channels...',
- });
-
- pushSearchableConsolidatedChip({
- key: 'channel-from',
- categoryLabel: 'From',
- getIds: () => queryFilters.state.include.channelSenderId ?? [],
- searchableOptions: senderOptions,
- labelMap: senderLabelMap,
- onChange: setFilterIds('channelSenderId'),
- searchPlaceholder: 'Search senders...',
- });
-
- // Search view specific filters
- if (currentView() === 'search') {
- if (soup.predicates.isActive('calls')) {
- pushSearchableConsolidatedChip({
- key: 'call-in',
- categoryLabel: 'In',
- getIds: () =>
- (queryFilters.state.include.callChannelId ?? []).filter(
- (id) => id !== NIL_UUID
- ),
- searchableOptions: channelOptions,
- labelMap: channelLabelMap,
- onChange: setFilterIds('callChannelId'),
- searchPlaceholder: 'Search channels...',
- });
-
- pushSearchableConsolidatedChip({
- key: 'call-from',
- categoryLabel: 'From',
- getIds: () => queryFilters.state.include.callSpeakerId ?? [],
- searchableOptions: senderOptions,
- labelMap: senderLabelMap,
- onChange: setFilterIds('callSpeakerId'),
- searchPlaceholder: 'Search speakers...',
- });
-
- // Call status filter
- const getCurrentCallStatus = (): CallStatus | undefined =>
- queryFilters.state.include.callStatus ??
- callStatusFromAttended(queryFilters.state.include.callAttended);
-
- if (getCurrentCallStatus() !== undefined) {
- const key = 'call-status';
- seenKeys.add(key);
-
- const getCallStatusValues = (): FilterValue[] => {
- const status = getCurrentCallStatus();
- if (status === undefined) return [];
- return [{ id: status, label: getCallStatusLabel(status) }];
- };
-
- filters.push(
- getOrCreateConsolidatedChip(key, () => ({
- key,
- categoryLabel: 'Status',
- values: getCallStatusValues,
- availableOptions: CALL_STATUS_FILTER_OPTIONS,
- multiple: false,
- isValueActive: (id) => id === getCurrentCallStatus(),
- onToggleValue: (id) =>
- queryFilters.set({
- include: {
- callStatus: id as CallStatus,
- callAttended: undefined,
- },
- }),
- onRemoveAll: () =>
- queryFilters.set({
- include: {
- callStatus: undefined,
- callAttended: undefined,
- },
- }),
- }))
- );
- }
- }
-
- // Email importance filter
- if (
- soup.predicates.isActive('email') &&
- queryFilters.state.include.emailImportance !== undefined
- ) {
- const key = 'email-importance';
- seenKeys.add(key);
-
- const getImportanceValues = (): FilterValue[] => {
- const importance = filterData().include.emailImportance;
- if (importance === undefined) return [];
- return [
- {
- id: importance ? 'signal' : 'noise',
- label: importance ? 'Signal' : 'Noise',
- },
- ];
- };
-
- filters.push(
- getOrCreateConsolidatedChip(key, () => ({
- key,
- categoryLabel: 'Importance',
- values: getImportanceValues,
- availableOptions: [
- { id: 'signal', label: 'Signal' },
- { id: 'noise', label: 'Noise' },
- ],
- multiple: false,
- isValueActive: (id) =>
- id ===
- (filterData().include.emailImportance ? 'signal' : 'noise'),
- onToggleValue: (id) =>
- queryFilters.add({
- include: { emailImportance: id === 'signal' },
- }),
- onRemoveAll: () =>
- queryFilters.remove({
- include: {
- emailImportance: queryFilters.state.include.emailImportance,
- },
- }),
- }))
- );
- }
- }
-
// Evict stale chips
for (const key of consolidatedChipCache.keys()) {
if (!seenKeys.has(key)) consolidatedChipCache.delete(key);
@@ -858,15 +565,10 @@ export function useFilterRefinements() {
const preset = currentPreset();
if (!preset) return;
- const contentId = panel.handle.content().id;
-
batch(() => {
soup.predicates.set(preset.clientFilters);
queryFilters.replace(preset.filters ?? null);
setAssigneeFilter([]);
- cacheChannelSubFilters(contentId, {});
- cacheCallSubFilters(contentId, {});
- cacheEmailSubFilters(contentId, {});
});
};
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-cache-key.ts b/js/app/packages/app/component/next-soup/soup-view/soup-view-cache-key.ts
deleted file mode 100644
index 10380bd15f..0000000000
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-cache-key.ts
+++ /dev/null
@@ -1,8 +0,0 @@
-export function soupViewCacheKey(contentId: string, suffix?: string): string {
- const base = `macro:soup-view:${contentId}`;
- return suffix ? `${base}:${suffix}` : base;
-}
-
-// Tracks how many SoupViewList instances are mounted per contentId.
-// Used to detect duplicate splits showing the same view.
-export const activeSoupViewCounts = new Map<string, number>();
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
index 38b6527d19..1b4276971a 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view.tsx
@@ -28,7 +28,6 @@ import {
persistSoupNavigationTouchHighlight,
soupNavigationTouchHighlight,
} from '@app/component/next-soup/soup-view/soup-navigation-touch-highlight';
-import { activeSoupViewCounts } from '@app/component/next-soup/soup-view/soup-view-cache-key';
import {
SoupViewContextProvider,
useSoupView,
@@ -888,17 +887,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
const isProjectList = panel.handle.content().type === 'project';
const contentId = panel.handle.content().id;
- // Maintained for the channel/email/call sub-filters in
- // search-filter-controls.tsx, which check duplicate-instance status via
- // this counter.
- const prevCount = activeSoupViewCounts.get(contentId) ?? 0;
- activeSoupViewCounts.set(contentId, prevCount + 1);
- onCleanup(() => {
- const count = activeSoupViewCounts.get(contentId) ?? 1;
- if (count <= 1) activeSoupViewCounts.delete(contentId);
- else activeSoupViewCounts.set(contentId, count - 1);
- });
-
const cacheKey = `soup-view-${panel.handle.id}-${contentId}${previewPanel ? '-preview' : ''}`;
// Cross-session, view-kind-scoped user preferences. Each has its own