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.

fix(filters): use old filter menu interiors for new filter menus (#6500)

Seamus35fc809ce507
diff --git a/apps/web/src/components/view-shell/ListDropdowns.test.tsx b/apps/web/src/components/view-shell/ListDropdowns.test.tsx
new file mode 100644
index 0000000000..e13b0ebacf
--- /dev/null
+++ b/apps/web/src/components/view-shell/ListDropdowns.test.tsx
@@ -0,0 +1,150 @@
+import {
+ cleanup,
+ fireEvent,
+ render,
+ screen,
+ waitFor,
+} from '@solidjs/testing-library';
+import { createSignal, type ParentProps } from 'solid-js';
+import { afterEach, beforeEach, expect, it, vi } from 'vitest';
+import { ListFilterDropdown } from './ListDropdowns';
+
+// Exercise the actual menus/comboboxes without initializing the app UI barrel.
+vi.mock('@ui', async () => ({
+ ...(await import('../ui/utils/classname')),
+ ...(await import('../ui/components/Dropdown')),
+ ...(await import('../ui/components/Layer')),
+}));
+vi.mock('../ui/components/Tooltip', () => ({
+ Tooltip: (props: ParentProps) => props.children,
+}));
+vi.mock('@core/mobile/isTouchDevice', () => ({ isTouchDevice: () => false }));
+vi.mock('@core/mobile/inputModality', () => ({ isModality: () => false }));
+
+let motionStyles: HTMLStyleElement;
+beforeEach(() => {
+ motionStyles = document.createElement('style');
+ motionStyles.textContent =
+ '* { transition-duration: 0s; animation-name: none; }';
+ document.head.append(motionStyles);
+ vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ }
+ );
+ vi.stubGlobal('scrollTo', vi.fn());
+ Element.prototype.scrollIntoView = vi.fn();
+});
+afterEach(() => {
+ cleanup();
+ motionStyles.remove();
+ vi.unstubAllGlobals();
+});
+
+function setup(single = false, searchable = false) {
+ const [selected, setSelected] = createSignal<string[]>([]);
+ const [open, setOpen] = createSignal(true);
+ render(() => (
+ <ListFilterDropdown
+ label="Filter tasks"
+ open={open()}
+ onOpenChange={setOpen}
+ groups={[
+ {
+ id: 'people',
+ label: 'Assignee',
+ selectionMode: single ? 'single' : 'multiple',
+ searchPlaceholder: searchable ? 'Search assignees...' : undefined,
+ options: [
+ { id: 'alice', label: 'Alice' },
+ { id: 'bob', label: 'Bob' },
+ ],
+ },
+ ]}
+ isSelected={(_, id) => selected().includes(id)}
+ onSelectionChange={(_, id, checked) =>
+ setSelected((ids) =>
+ checked
+ ? single
+ ? [id]
+ : [...ids, id]
+ : ids.filter((value) => value !== id)
+ )
+ }
+ onClear={() => setSelected([])}
+ />
+ ));
+ return { selected, open, setOpen };
+}
+
+function selectOption(element: HTMLElement) {
+ fireEvent(element, new MouseEvent('pointerup', { button: 0, bubbles: true }));
+}
+
+async function openSubmenu() {
+ const trigger = await screen.findByRole('menuitem', { name: 'Assignee' });
+ await waitFor(() => expect(document.activeElement).toBe(trigger));
+ fireEvent.keyDown(trigger, { key: 'ArrowRight' });
+}
+
+it('keeps multi-select menus open while adding and removing filters', async () => {
+ const { selected, open } = setup();
+ await openSubmenu();
+ selectOption(await screen.findByRole('menuitemcheckbox', { name: 'Alice' }));
+ expect(selected()).toEqual(['alice']);
+ expect(open()).toBe(true);
+ expect(
+ screen
+ .getByRole('menuitemcheckbox', { name: 'Alice' })
+ .getAttribute('aria-checked')
+ ).toBe('true');
+ selectOption(screen.getByRole('menuitemcheckbox', { name: 'Bob' }));
+ expect(selected()).toEqual(['alice', 'bob']);
+ selectOption(screen.getByRole('menuitemcheckbox', { name: 'Alice' }));
+ expect(selected()).toEqual(['bob']);
+ expect(open()).toBe(true);
+});
+
+it('closes a single-select menu after choosing an option and retains it on reopen', async () => {
+ const { selected, open, setOpen } = setup(true);
+ await openSubmenu();
+ selectOption(await screen.findByRole('menuitemcheckbox', { name: 'Alice' }));
+ expect(selected()).toEqual(['alice']);
+ await waitFor(() => expect(open()).toBe(false));
+ setOpen(true);
+ await openSubmenu();
+ expect(
+ (
+ await screen.findByRole('menuitemcheckbox', { name: 'Alice' })
+ ).getAttribute('aria-checked')
+ ).toBe('true');
+ selectOption(screen.getByRole('menuitemcheckbox', { name: 'Bob' }));
+ expect(selected()).toEqual(['bob']);
+ await waitFor(() => expect(open()).toBe(false));
+});
+
+it('focuses searchable submenus on opening and reopening and supports keyboard selection', async () => {
+ const { selected, open, setOpen } = setup(false, true);
+ for (let attempt = 0; attempt < 2; attempt++) {
+ if (attempt) setOpen(true);
+ await openSubmenu();
+ const input = await screen.findByPlaceholderText('Search assignees...');
+ await waitFor(() => expect(document.activeElement).toBe(input));
+ fireEvent.input(input, { target: { value: attempt ? 'Bob' : 'Alice' } });
+ fireEvent.keyDown(input, { key: 'ArrowDown' });
+ fireEvent.keyDown(input, { key: 'Enter' });
+ await waitFor(() =>
+ expect(selected()).toEqual(attempt ? ['alice', 'bob'] : ['alice'])
+ );
+ expect(open()).toBe(true);
+ fireEvent.keyDown(input, { key: 'Escape' });
+ await waitFor(() =>
+ expect(screen.queryByPlaceholderText('Search assignees...')).toBeNull()
+ );
+ fireEvent.keyDown(document, { key: 'Escape' });
+ await waitFor(() => expect(open()).toBe(false));
+ }
+});
diff --git a/apps/web/src/components/view-shell/ListDropdowns.tsx b/apps/web/src/components/view-shell/ListDropdowns.tsx
index 448f86cb0f..7a0063fc96 100644
--- a/apps/web/src/components/view-shell/ListDropdowns.tsx
+++ b/apps/web/src/components/view-shell/ListDropdowns.tsx
@@ -1,10 +1,13 @@
-import CaretRightIcon from '@phosphor/caret-right.svg';
+import {
+ FilterSubmenu,
+ SearchableFilterSubmenu,
+} from '@app/features/next-soup/soup-view/filters-bar/filter-menu';
import CheckIcon from '@phosphor/check.svg';
import FilterIcon from '@phosphor/funnel-simple.svg';
import SortIcon from '@phosphor/sort-ascending.svg';
import GroupIcon from '@phosphor/stack.svg';
-import { buttonClasses, cn, Dropdown } from '@ui';
-import { For, type JSX, Show } from 'solid-js';
+import { cn, Dropdown } from '@ui';
+import { batch, For, type JSX, Show } from 'solid-js';
export type ListControlOption<TId extends string> = {
id: TId;
@@ -131,6 +134,7 @@ export type ListFilterGroup<
options: ListControlOption<TOptionId>[];
selectionMode?: 'single' | 'multiple';
defaultOptionId?: TOptionId;
+ searchPlaceholder?: string;
contentClass?: string;
};
@@ -140,12 +144,14 @@ export type ListFilterDropdownProps<
> = {
groups: ListFilterGroup<TGroupId, TOptionId>[];
isSelected: (groupId: TGroupId, optionId: TOptionId) => boolean;
+ isGroupActive?: (groupId: TGroupId) => boolean;
onSelectionChange: (
groupId: TGroupId,
optionId: TOptionId,
selected: boolean
) => void;
onClear?: () => void;
+ customTrigger?: JSX.Element;
triggerRef?: (element: HTMLButtonElement) => void;
label?: string;
clearLabel?: string;
@@ -157,151 +163,98 @@ export function ListFilterDropdown<
TGroupId extends string,
TOptionId extends string,
>(props: ListFilterDropdownProps<TGroupId, TOptionId>) {
+ const isGroupActive = (group: ListFilterGroup<TGroupId, TOptionId>) =>
+ props.isGroupActive?.(group.id) ??
+ group.options.some(
+ (option) =>
+ option.id !== group.defaultOptionId &&
+ props.isSelected(group.id, option.id)
+ );
+
return (
<Dropdown
open={props.open}
onOpenChange={props.onOpenChange}
placement="bottom-end"
>
- <Dropdown.Trigger
- ref={props.triggerRef}
- variant="outline"
- size="md"
- square
- depth={2}
- class={cn('rounded-lg bg-surface', props.class)}
- label={props.label ?? 'Filter list'}
+ <Show
+ when={props.customTrigger}
+ fallback={
+ <Dropdown.Trigger
+ ref={props.triggerRef}
+ variant="outline"
+ size="md"
+ square
+ depth={2}
+ class={cn('rounded-lg bg-surface', props.class)}
+ label={props.label ?? 'Filter list'}
+ >
+ <FilterIcon />
+ </Dropdown.Trigger>
+ }
>
- <FilterIcon />
- </Dropdown.Trigger>
- <Dropdown.Content class={cn('min-w-40', props.contentClass)}>
+ {(trigger) => trigger()}
+ </Show>
+ <Dropdown.Content class={cn('min-w-32', props.contentClass)}>
<Dropdown.Group>
<For each={props.groups}>
- {(group) => {
- const hasSelection = () =>
- group.options.some(
- (option) =>
- option.id !== group.defaultOptionId &&
- props.isSelected(group.id, option.id)
- );
- const selectedOptionId = () =>
- group.options.find((option) =>
- props.isSelected(group.id, option.id)
- )?.id;
-
- return (
- <Dropdown.Sub>
- <Dropdown.SubTrigger>
- <span class="flex-1 text-ink">{group.label}</span>
- <Show when={hasSelection()}>
- <span
- aria-hidden="true"
- class="size-1.5 shrink-0 rounded-full bg-accent"
- />
- </Show>
- <CaretRightIcon class="size-3 shrink-0 text-ink-muted" />
- </Dropdown.SubTrigger>
- <Dropdown.SubContent
- class={cn(
- 'max-h-72 min-w-24 max-w-[min(16rem,calc(100vw-1rem))] overflow-y-auto',
- group.contentClass
- )}
- >
- <Dropdown.Group>
- <Show
- when={group.selectionMode === 'single'}
- fallback={
- <For each={group.options}>
- {(option) => (
- <Dropdown.CheckboxItem
- checked={props.isSelected(group.id, option.id)}
- closeOnSelect={false}
- disabled={option.disabled}
- onChange={(selected) =>
- props.onSelectionChange(
- group.id,
- option.id,
- selected
- )
- }
- >
- <span class="ml-1 flex min-w-0 flex-1 items-center gap-1.5">
- <Show when={option.icon}>
- <span
- aria-hidden="true"
- class="flex size-3.5 shrink-0 items-center justify-center [&_svg]:size-3.5"
- >
- {option.icon?.()}
- </span>
- </Show>
- <span class="flex-1 truncate">
- {option.label}
- </span>
- </span>
- </Dropdown.CheckboxItem>
- )}
- </For>
+ {(group) => (
+ <Show
+ when={group.searchPlaceholder}
+ fallback={
+ <FilterSubmenu
+ label={group.label}
+ active={isGroupActive(group)}
+ options={group.options}
+ isSelected={(id) => props.isSelected(group.id, id)}
+ onSelect={(id) =>
+ props.onSelectionChange(
+ group.id,
+ id,
+ group.selectionMode === 'single' ||
+ !props.isSelected(group.id, id)
+ )
+ }
+ closeOnSelect={group.selectionMode === 'single'}
+ contentClass={group.contentClass}
+ />
+ }
+ >
+ <SearchableFilterSubmenu
+ label={group.label}
+ active={isGroupActive(group)}
+ options={() => group.options}
+ activeIds={() =>
+ group.options
+ .filter((option) => props.isSelected(group.id, option.id))
+ .map((option) => option.id)
+ }
+ onChange={(ids) =>
+ batch(() => {
+ for (const option of group.options) {
+ const selected = ids.includes(option.id);
+ if (
+ selected !== props.isSelected(group.id, option.id)
+ ) {
+ props.onSelectionChange(
+ group.id,
+ option.id,
+ selected
+ );
}
- >
- <Dropdown.RadioGroup
- value={selectedOptionId()}
- onChange={(value) => {
- const option = group.options.find(
- (candidate) => candidate.id === value
- );
- if (!option) return;
-
- props.onSelectionChange(group.id, option.id, true);
- }}
- >
- <For each={group.options}>
- {(option) => (
- <Dropdown.RadioItem
- value={option.id}
- closeOnSelect={false}
- disabled={option.disabled}
- >
- <span class="ml-1 flex min-w-0 flex-1 items-center gap-1.5">
- <Show when={option.icon}>
- <span
- aria-hidden="true"
- class="flex size-3.5 shrink-0 items-center justify-center [&_svg]:size-3.5"
- >
- {option.icon?.()}
- </span>
- </Show>
- <span class="flex-1 truncate">
- {option.label}
- </span>
- </span>
- <Dropdown.ItemIndicator>
- <CheckIcon class="size-3.5 text-accent" />
- </Dropdown.ItemIndicator>
- </Dropdown.RadioItem>
- )}
- </For>
- </Dropdown.RadioGroup>
- </Show>
- </Dropdown.Group>
- </Dropdown.SubContent>
- </Dropdown.Sub>
- );
- }}
+ }
+ })
+ }
+ placeholder={group.searchPlaceholder}
+ />
+ </Show>
+ )}
</For>
</Dropdown.Group>
<Show when={props.onClear}>
{(onClear) => (
<Dropdown.Group>
- <Dropdown.Item
- class={buttonClasses({
- variant: 'strong',
- size: 'sm',
- fullWidth: true,
- class:
- 'rounded-lg text-xs data-highlighted:bg-ink data-highlighted:text-surface-4 data-highlighted:overlay-[color-mix(in_oklch,var(--color-surface-4)_12%,transparent)]',
- })}
- onSelect={onClear()}
- >
+ <Dropdown.Item class="text-failure-ink" onSelect={onClear()}>
{props.clearLabel ?? 'Clear filters'}
</Dropdown.Item>
</Dropdown.Group>
diff --git a/apps/web/src/components/view-shell/MobileFilterDrawer.tsx b/apps/web/src/components/view-shell/MobileFilterDrawer.tsx
index 973ef802a1..2963de8165 100644
--- a/apps/web/src/components/view-shell/MobileFilterDrawer.tsx
+++ b/apps/web/src/components/view-shell/MobileFilterDrawer.tsx
@@ -100,10 +100,9 @@ function Root(props: MobileFilterDrawerProps) {
<Button
variant="ghost"
size="sm"
- class="min-h-10 rounded-full bg-ink/6 px-4"
+ class="min-h-10 px-4 text-failure-ink not-touch:not-disabled:hover:text-failure-ink"
onClick={() => props.onClear()}
>
- <XIcon class="size-3!" />
Clear all
</Button>
</div>
diff --git a/apps/web/src/features/drive-view/drive-view.tsx b/apps/web/src/features/drive-view/drive-view.tsx
index 1a5b9514ef..2536c52426 100644
--- a/apps/web/src/features/drive-view/drive-view.tsx
+++ b/apps/web/src/features/drive-view/drive-view.tsx
@@ -1,4 +1,5 @@
import {
+ ListFilterDropdown,
useViewControlHotkeys,
useViewTabHotkeys,
ViewSidebar,
@@ -14,6 +15,8 @@ import { queryStateFrom } from '@app/features/next-soup/filters/filter-store';
import type { SetPredicatesInput } from '@app/features/next-soup/filters/filter-store/predicates-store';
import { mergeQuery } from '@app/features/next-soup/filters/filter-store/query-store';
import { soupItemMatchesProjectMembership } from '@app/features/next-soup/filters/query-filters';
+import { FilterSubmenu } from '@app/features/next-soup/soup-view/filters-bar/filter-menu';
+import { UnifiedFilterDropdown } from '@app/features/next-soup/soup-view/filters-bar/unified-filter-dropdown';
import { SoupViewList } from '@app/features/next-soup/soup-view/soup-view';
import { useSoupView } from '@app/features/next-soup/soup-view/soup-view-context';
import {
@@ -34,6 +37,7 @@ import EmptyStateFolderGraphic from '@design/empty-state-folder.svg';
import ArrowLeftIcon from '@phosphor/arrow-left.svg';
import CaretDownIcon from '@phosphor/caret-down.svg';
import FolderIcon from '@phosphor/folder.svg';
+import FilterIcon from '@phosphor/funnel-simple.svg';
import PlusIcon from '@phosphor/plus.svg';
import SpinnerIcon from '@phosphor/spinner.svg';
import UploadIcon from '@phosphor/upload-simple.svg';
@@ -43,9 +47,14 @@ import type { Favorite } from '@service-storage/generated/schemas/favorite';
import { Dropdown, EmptyStatePanel } from '@ui';
import { createMemo, For, Show, Suspense } from 'solid-js';
import { Dynamic } from 'solid-js/web';
-import { DRIVE_TABS, type DriveState, type DriveTab } from './core/types';
+import {
+ DRIVE_TABS,
+ type DriveScope,
+ type DriveState,
+ type DriveTab,
+} from './core/types';
import { createDriveNavigation } from './primitives/drive-navigation';
-import { driveQuery } from './queries/drive-query';
+import { driveFilterTab, driveQuery } from './queries/drive-query';
import { createDriveResults } from './queries/drive-results';
import { DriveLayout } from './views/drive-layout';
@@ -150,6 +159,7 @@ export function DriveView(props: DriveViewProps) {
return !id || soupItemMatchesProjectMembership(item, id);
},
});
+ view.setActiveTab(driveFilterTab(state()));
view.soup.grouping.setActiveGroupId(undefined);
view.soup.sort.setAll([state().sort]);
panel.handle.setDisplayName('Drive');
@@ -177,6 +187,61 @@ export function DriveView(props: DriveViewProps) {
setActiveId: selectTab,
});
+ const scopeOptions: { id: DriveScope; label: string }[] = [
+ { id: 'default', label: 'Default' },
+ { id: 'all', label: 'All files' },
+ { id: 'attachments', label: 'Email attachments' },
+ ];
+ const FilterMenu = () => (
+ <Show when={state().location.kind === 'tab'}>
+ <Show
+ when={!isRecent()}
+ fallback={
+ <ListFilterDropdown
+ label="Filter files"
+ groups={[
+ {
+ id: 'scope',
+ label: 'Files',
+ selectionMode: 'single',
+ defaultOptionId: 'default',
+ options: scopeOptions,
+ },
+ ]}
+ isSelected={(_, id) => state().scope === id}
+ onSelectionChange={(_, id) => setScope(id)}
+ />
+ }
+ >
+ <Suspense>
+ <UnifiedFilterDropdown
+ customTrigger={
+ <Dropdown.Trigger
+ variant="outline"
+ size="md"
+ square
+ depth={2}
+ class="rounded-lg bg-surface"
+ label="Filter files"
+ >
+ <FilterIcon />
+ </Dropdown.Trigger>
+ }
+ >
+ <FilterSubmenu
+ label="Files"
+ active={state().scope !== 'default'}
+ options={scopeOptions}
+ isSelected={(id) => state().scope === id}
+ onSelect={setScope}
+ closeOnSelect
+ />
+ </UnifiedFilterDropdown>
+ </Suspense>
+ </Show>
+ </Show>
+ );
+
const CreateMenu = () => (
<Dropdown placement="bottom-start">
<Dropdown.Trigger
@@ -278,7 +343,7 @@ export function DriveView(props: DriveViewProps) {
}}
onTab={selectTab}
onFolder={selectFolder}
- onScope={setScope}
+ filterMenu={FilterMenu}
onSort={(sort) => {
setState((current) => ({ ...current, sort }));
view.soup.sort.setAll([sort]);
diff --git a/apps/web/src/features/drive-view/queries/drive-query.test.ts b/apps/web/src/features/drive-view/queries/drive-query.test.ts
index a55cf40345..4eb594b1b5 100644
--- a/apps/web/src/features/drive-view/queries/drive-query.test.ts
+++ b/apps/web/src/features/drive-view/queries/drive-query.test.ts
@@ -14,7 +14,7 @@ import {
queryStateFrom,
} from '@app/features/next-soup/filters/filter-store';
import type { DriveSelection } from '../context/drive-source';
-import { driveQuery } from './drive-query';
+import { driveFilterTab, driveQuery } from './drive-query';
const selection: DriveSelection = {
location: { kind: 'tab', tab: 'owned' },
@@ -25,6 +25,7 @@ const selection: DriveSelection = {
describe('Drive query scopes', () => {
it('keeps owned/shared scopes and excludes tasks and disabled snippets', () => {
const owned = driveQuery(selection, 'me');
+ expect(driveFilterTab(selection)).toBe('owned');
expect(owned.filters.include?.documentOwnerId).toEqual(['me']);
expect(owned.filters.exclude?.subType).toEqual(['task', 'snippet']);
const shared = driveQuery(
@@ -35,6 +36,10 @@ describe('Drive query scopes', () => {
expect(shared.clientFilters.and).toContain('shared-entity');
});
it('allows all files and attachments without retaining the owned restriction', () => {
+ expect(driveFilterTab({ ...selection, scope: 'all' })).toBe('all');
+ expect(driveFilterTab({ ...selection, scope: 'attachments' })).toBe(
+ 'attachments'
+ );
const all = driveQuery({ ...selection, scope: 'all' }, 'me');
expect(all.filters.include?.documentOwnerId).toBeUndefined();
const attachments = driveQuery(
diff --git a/apps/web/src/features/drive-view/queries/drive-query.ts b/apps/web/src/features/drive-view/queries/drive-query.ts
index d138e4e754..6ba85e0f1b 100644
--- a/apps/web/src/features/drive-view/queries/drive-query.ts
+++ b/apps/web/src/features/drive-view/queries/drive-query.ts
@@ -5,6 +5,14 @@ import {
import { getViewPreset } from '@app/features/next-soup/sidebar/soup-filter-presets';
import type { DriveSelection } from '../context/drive-source';
+/** Match the legacy filter controller's base tab to the current Drive scope. */
+export function driveFilterTab(state: DriveSelection) {
+ const location = state.location;
+ if (location.kind === 'folder') return location.id ? 'all' : 'folders';
+ if (location.tab === 'owned' && state.scope !== 'default') return state.scope;
+ return location.tab;
+}
+
export function driveQuery(state: DriveSelection, userId: string | undefined) {
const context = { userId, isTeamAdmin: false };
const location = state.location;
@@ -42,10 +50,7 @@ export function driveQuery(state: DriveSelection, userId: string | undefined) {
clientFilters: { and: ['document-or-file'] },
};
}
- const tab =
- location.tab === 'owned' && state.scope !== 'default'
- ? state.scope
- : location.tab;
+ const tab = driveFilterTab(state);
const preset =
getViewPreset('documents', tab, context) ??
getViewPreset('documents', 'all', context)!;
diff --git a/apps/web/src/features/drive-view/queries/drive-results.ts b/apps/web/src/features/drive-view/queries/drive-results.ts
index 287a3318ef..8e491c0ab5 100644
--- a/apps/web/src/features/drive-view/queries/drive-results.ts
+++ b/apps/web/src/features/drive-view/queries/drive-results.ts
@@ -1,7 +1,7 @@
import type { useSoupView } from '@app/features/next-soup/soup-view/soup-view-context';
import type { Accessor } from 'solid-js';
import type { DriveResults } from '../context/drive-source';
-import { driveQuery } from './drive-query';
+import { driveFilterTab, driveQuery } from './drive-query';
export function createDriveResults(
view: ReturnType<typeof useSoupView>,
@@ -10,11 +10,7 @@ export function createDriveResults(
return {
apply(selection, clearSearch) {
const preset = driveQuery(selection, userId());
- view.setActiveTab(
- selection.location.kind === 'tab' && selection.location.tab !== 'recent'
- ? selection.location.tab
- : 'all'
- );
+ view.setActiveTab(driveFilterTab(selection));
view.queryFilters.replace(preset.filters);
view.soup.predicates.set(preset.clientFilters);
view.soup.grouping.setActiveGroupId(undefined);
diff --git a/apps/web/src/features/drive-view/views/drive-layout.tsx b/apps/web/src/features/drive-view/views/drive-layout.tsx
index 379af66c9f..f2d63ea74f 100644
--- a/apps/web/src/features/drive-view/views/drive-layout.tsx
+++ b/apps/web/src/features/drive-view/views/drive-layout.tsx
@@ -1,6 +1,5 @@
import {
CollapsibleSection,
- ListFilterDropdown,
ListSortDropdown,
SearchBar,
ViewShell,
@@ -22,7 +21,6 @@ import {
import {
DRIVE_TABS,
type DriveFolder,
- type DriveScope,
type DriveSort,
type DriveState,
type DriveTab,
@@ -39,7 +37,7 @@ export function DriveLayout(props: {
searchRef: (element: HTMLInputElement) => void;
onTab: (tab: DriveTab) => void;
onFolder: (id: string | null) => void;
- onScope: (scope: DriveScope) => void;
+ filterMenu: () => JSX.Element;
onSort: (sort: DriveSort) => void;
onToggleFolder: (id: string) => void;
onFavoritesOpen: (open: boolean) => void;
@@ -327,27 +325,7 @@ export function DriveLayout(props: {
]}
/>
</Show>
- <Show when={props.state.location.kind === 'tab'}>
- <ListFilterDropdown
- label="Filter files"
- groups={[
- {
- id: 'scope',
- label: 'Files',
- selectionMode: 'single',
- defaultOptionId: 'default',
- options: [
- { id: 'default', label: 'Default' },
- { id: 'all', label: 'All files' },
- { id: 'attachments', label: 'Email attachments' },
- ],
- },
- ]}
- isSelected={(_, id) => props.state.scope === id}
- onSelectionChange={(_, id) => props.onScope(id)}
- onClear={() => props.onScope('default')}
- />
- </Show>
+ <props.filterMenu />
</div>
</div>
</div>
diff --git a/apps/web/src/features/email-view/filters/use-email-filters.tsx b/apps/web/src/features/email-view/filters/use-email-filters.tsx
index 4dddf92b67..25cfcf1d8e 100644
--- a/apps/web/src/features/email-view/filters/use-email-filters.tsx
+++ b/apps/web/src/features/email-view/filters/use-email-filters.tsx
@@ -28,7 +28,7 @@ export function useEmailFilters() {
// Tags come last: the static groups are short, the tag list grows with use.
const groups = createMemo((): EmailFilterGroup[] => [
...STATIC_FILTER_GROUPS,
- tagGroup(),
+ ...(tagGroup().options.length > 0 ? [tagGroup()] : []),
]);
const groupFor = (groupId: EmailFilterGroupId) =>
groups().find((group) => group.id === groupId);
diff --git a/apps/web/src/features/inbox-view/components/InboxFilters.tsx b/apps/web/src/features/inbox-view/components/InboxFilters.tsx
index bc616a35ad..38be59a11a 100644
--- a/apps/web/src/features/inbox-view/components/InboxFilters.tsx
+++ b/apps/web/src/features/inbox-view/components/InboxFilters.tsx
@@ -1,11 +1,16 @@
-import { MobileFilterDrawer } from '@app/components/view-shell';
-import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
+import {
+ ListFilterDropdown,
+ type ListFilterGroup,
+ MobileFilterDrawer,
+ useViewControlHotkeys,
+} from '@app/components/view-shell';
+import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { EntityIcon } from '@core/component/EntityIcon';
import { Accordion } from '@kobalte/core/accordion';
import BellSimpleIcon from '@phosphor/bell-simple.svg';
import FilterIcon from '@phosphor/funnel-simple.svg';
-import { Dropdown, ToggleSwitch } from '@ui';
-import { createMemo, For, type JSX, Show } from 'solid-js';
+import { Dropdown } from '@ui';
+import { createMemo, createSignal, For, type JSX, Show } from 'solid-js';
import { selectedHomeTypes, setHomeTypeSelected } from '../core/type-selection';
import { INBOX_FILTER_GROUPS } from '../inbox-facets';
import { useInboxView } from '../inbox-view-context';
@@ -129,6 +134,8 @@ function useInboxFilters() {
const isSelected = (groupId: string, optionId: string) => {
const selectedIds = state.facets[groupId] ?? [];
+ if (groupId === 'read' && optionId === 'all')
+ return selectedIds.length === 0;
return groupId === 'type'
? selectedHomeTypes(selectedIds, TYPE_IDS).includes(optionId)
: selectedIds.includes(optionId);
@@ -139,6 +146,13 @@ function useInboxFilters() {
optionId: string,
selected: boolean
) => {
+ if (groupId === 'read') {
+ setFacets({
+ ...state.facets,
+ read: optionId === 'all' ? [] : [optionId],
+ });
+ return;
+ }
setFacets({
...state.facets,
[groupId]: setHomeTypeSelected(
@@ -150,20 +164,19 @@ function useInboxFilters() {
});
};
- const unreadOnly = () => state.facets.read?.includes('unread') ?? false;
- const setUnreadOnly = (checked: boolean) =>
- setFacets({ ...state.facets, read: checked ? ['unread'] : [] });
-
const activeCount = () =>
TYPE_IDS.length -
selectedHomeTypes(state.facets.type, TYPE_IDS).length +
- (unreadOnly() ? 1 : 0);
+ (state.facets.read?.length ? 1 : 0);
return {
- unreadOnly,
- setUnreadOnly,
activeCount,
clear: () => setFacets({}),
+ isGroupActive: (groupId: string) =>
+ groupId === 'type'
+ ? selectedHomeTypes(state.facets.type, TYPE_IDS).length <
+ TYPE_IDS.length
+ : (state.facets[groupId]?.length ?? 0) > 0,
isSelected,
setSelected,
};
@@ -179,58 +192,59 @@ function FilterCountBadge(props: { count: number }) {
);
}
+const HOME_FILTER_GROUPS: ListFilterGroup<string, string>[] = [
+ {
+ id: 'read',
+ label: 'Status',
+ selectionMode: 'single',
+ defaultOptionId: 'all',
+ options: [
+ { id: 'unread', label: 'Unread' },
+ { id: 'read', label: 'Read' },
+ { id: 'all', label: 'All' },
+ ],
+ },
+ ...FILTER_GROUPS.map((group) => ({ ...group, label: 'Type' })),
+];
+
export function InboxFilterDropdown() {
const filters = useInboxFilters();
+ const panel = useSplitPanelOrThrow();
+ const [open, setOpen] = createSignal(false);
+ useViewControlHotkeys({
+ scopeId: panel.splitHotkeyScope,
+ enabled: panel.isPanelActive,
+ filter: {
+ description: 'Filter Home',
+ run: () => {
+ setOpen(true);
+ },
+ },
+ });
return (
<div class="relative ml-auto shrink-0">
- <Dropdown placement="bottom-end">
- <Dropdown.Trigger variant="ghost" size="sm" square label="Filter Home">
- <FilterIcon />
- </Dropdown.Trigger>
- <Dropdown.Content class="max-h-[min(36rem,calc(100dvh-5rem))] w-56 overflow-y-auto">
- <Dropdown.Group>
- <Dropdown.Item
- role="menuitemcheckbox"
- aria-checked={filters.unreadOnly()}
- closeOnSelect={false}
- onSelect={() => filters.setUnreadOnly(!filters.unreadOnly())}
- >
- <span class="flex-1">Unread only</span>
- <span aria-hidden="true" inert class="pointer-events-none flex">
- <ToggleSwitch checked={filters.unreadOnly()} size="xs" />
- </span>
- </Dropdown.Item>
- </Dropdown.Group>
- <For each={FILTER_GROUPS}>
- {(group) => (
- <Dropdown.Group>
- <Dropdown.GroupLabel>{group.label}</Dropdown.GroupLabel>
- <For each={group.options}>
- {(option) => (
- <Dropdown.CheckboxItem
- checked={filters.isSelected(group.id, option.id)}
- closeOnSelect={false}
- onChange={(selected) =>
- filters.setSelected(group.id, option.id, selected)
- }
- >
- {option.icon?.()}
- <span>{option.label}</span>
- </Dropdown.CheckboxItem>
- )}
- </For>
- </Dropdown.Group>
- )}
- </For>
- <Dropdown.Group>
- <Dropdown.Item onSelect={filters.clear}>
- Reset filters
- </Dropdown.Item>
- </Dropdown.Group>
- </Dropdown.Content>
- </Dropdown>
-
+ <ListFilterDropdown
+ label="Filter Home"
+ customTrigger={
+ <Dropdown.Trigger
+ variant="ghost"
+ size="sm"
+ square
+ label="Filter Home"
+ >
+ <FilterIcon />
+ </Dropdown.Trigger>
+ }
+ groups={HOME_FILTER_GROUPS}
+ open={open()}
+ onOpenChange={setOpen}
+ isSelected={filters.isSelected}
+ isGroupActive={filters.isGroupActive}
+ onSelectionChange={filters.setSelected}
+ onClear={filters.clear}
+ clearLabel="Reset filters"
+ />
<FilterCountBadge count={filters.activeCount()} />
</div>
);
@@ -246,29 +260,17 @@ export function InboxFilterDrawer() {
activeCount={filters.activeCount()}
onClear={filters.clear}
>
- <MobileDrawer.Item
- role="switch"
- aria-checked={filters.unreadOnly()}
- onClick={() => filters.setUnreadOnly(!filters.unreadOnly())}
- >
- <span class="flex-1">Unread only</span>
- <span aria-hidden="true" inert class="pointer-events-none flex">
- <ToggleSwitch checked={filters.unreadOnly()} />
- </span>
- </MobileDrawer.Item>
-
- <Accordion
- multiple
- collapsible
- defaultValue={[FILTER_GROUPS[0]?.id ?? 'type']}
- >
+ <Accordion multiple collapsible defaultValue={['read', 'type']}>
<div class="flex flex-col">
- <For each={FILTER_GROUPS}>
+ <For each={HOME_FILTER_GROUPS}>
{(group) => {
const activeCount = createMemo(
() =>
- group.options.filter(
- (option) => !filters.isSelected(group.id, option.id)
+ group.options.filter((option) =>
+ group.id === 'type'
+ ? !filters.isSelected(group.id, option.id)
+ : option.id !== 'all' &&
+ filters.isSelected(group.id, option.id)
).length
);
@@ -279,10 +281,16 @@ export function InboxFilterDrawer() {
activeCount={activeCount()}
class="mb-3"
>
- <div role="group" aria-label={group.label}>
+ <div
+ role={
+ group.selectionMode === 'single' ? 'radiogroup' : 'group'
+ }
+ aria-label={group.label}
+ >
<For each={group.options}>
{(option) => (
<MobileFilterDrawer.Option
+ selectionMode={group.selectionMode}
checked={filters.isSelected(group.id, option.id)}
onChange={(checked) =>
filters.setSelected(group.id, option.id, checked)
diff --git a/apps/web/src/features/inbox-view/inbox-view-context.test.tsx b/apps/web/src/features/inbox-view/inbox-view-context.test.tsx
index 3609815d83..5e045c0f2f 100644
--- a/apps/web/src/features/inbox-view/inbox-view-context.test.tsx
+++ b/apps/web/src/features/inbox-view/inbox-view-context.test.tsx
@@ -170,7 +170,7 @@ describe('InboxViewProvider initialization', () => {
expect(mountProvider().context.state.facets).toEqual({});
});
- it('migrates saved read-only filters to All while preserving entity types', () => {
+ it('restores read-only filters with their entity types', () => {
localStorage.setItem(
'macro:home:filters:v1:alice',
JSON.stringify({
@@ -186,9 +186,20 @@ describe('InboxViewProvider initialization', () => {
};
expect(mountProvider().context.state.facets).toEqual({
type: ['channels'],
+ read: ['read'],
});
});
+ it('keeps Read and Unread mutually exclusive and normalizes both to All', () => {
+ const { context } = mountProvider();
+ context.setFacets({ read: ['read'] });
+ expect(context.state.facets).toEqual({ read: ['read'] });
+ context.setFacets({ read: ['unread'] });
+ expect(context.state.facets).toEqual({ read: ['unread'] });
+ context.setFacets({ read: ['unread', 'read'] });
+ expect(context.state.facets).toEqual({});
+ });
+
it('persists resetting all filters and tolerates corrupt stored preferences', () => {
const view = mountProvider();
view.context.setFacets({ type: ['none'], read: ['unread'] });
diff --git a/apps/web/src/features/inbox-view/persistence.ts b/apps/web/src/features/inbox-view/persistence.ts
index 99f54cc917..77f46a65d7 100644
--- a/apps/web/src/features/inbox-view/persistence.ts
+++ b/apps/web/src/features/inbox-view/persistence.ts
@@ -16,10 +16,13 @@ export const INBOX_ENTRY_STATE_KEY = 'inbox.view';
export const INBOX_LIST_ENTRY_STATE_KEY = 'inbox.listState';
const homeFilterStorage = createUserScopedStorage('macro:home:filters:v1');
-/** Home now offers All or Unread; retire saved read-only selections. */
+/** Status is a single choice; an empty selection means All. */
export function normalizeInboxFacets(raw: unknown) {
const facets = normalizeFacetSelection(raw);
- if (facets.read?.length !== 1 || facets.read[0] !== 'unread') {
+ if (
+ facets.read?.length !== 1 ||
+ !['unread', 'read'].includes(facets.read[0])
+ ) {
delete facets.read;
}
return facets;
diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/filter-menu.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/filter-menu.tsx
new file mode 100644
index 0000000000..eab99a15c2
--- /dev/null
+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/filter-menu.tsx
@@ -0,0 +1,221 @@
+import CaretRightIcon from '@phosphor/caret-right.svg';
+import CheckIcon from '@phosphor/check.svg';
+import { cn, Dropdown } from '@ui';
+import {
+ type Accessor,
+ createEffect,
+ createSignal,
+ For,
+ type JSX,
+ onCleanup,
+ Show,
+} from 'solid-js';
+import {
+ SearchableMultiSelectInline,
+ type SearchableOption,
+} from './searchable-multi-select';
+
+export const TypeIndicator = (props: { active: boolean }) => (
+ <span
+ class={cn(
+ 'size-3.5 flex items-center justify-center shrink-0 rounded-sm border text-surface',
+ props.active
+ ? 'bg-accent border-accent'
+ : 'border-transparent group-hover:not-hover:border-edge-muted group-data-highlighted:not-hover:border-edge-muted hover:border-accent'
+ )}
+ >
+ <Show when={props.active}>
+ <CheckIcon class="size-2.5" />
+ </Show>
+ </span>
+);
+
+/** The option row shared by legacy and composable app-view filters. */
+export function FilterOptionItem(props: {
+ label: string;
+ icon?: () => JSX.Element;
+ active: boolean;
+ disabled?: boolean;
+ closeOnSelect?: boolean;
+ onSelect: () => void;
+}) {
+ return (
+ <Dropdown.Item
+ role="menuitemcheckbox"
+ aria-checked={props.active}
+ disabled={props.disabled}
+ onSelect={props.onSelect}
+ closeOnSelect={props.closeOnSelect}
+ >
+ <TypeIndicator active={props.active} />
+ <Show when={props.icon}>
+ {(icon) => (
+ <span class="size-4 flex items-center justify-center shrink-0">
+ {icon()()}
+ </span>
+ )}
+ </Show>
+ <span
+ class={cn(
+ 'flex-1 truncate',
+ props.active ? 'text-ink' : 'text-ink-muted'
+ )}
+ >
+ {props.label}
+ </span>
+ </Dropdown.Item>
+ );
+}
+
+function FilterCategoryLabel(props: { label: string; active: boolean }) {
+ return (
+ <>
+ <span class="flex-1 text-ink">{props.label}</span>
+ <Show when={props.active}>
+ <span
+ aria-hidden="true"
+ class="size-1.5 shrink-0 rounded-full bg-accent"
+ />
+ </Show>
+ <CaretRightIcon class="size-3 shrink-0 text-ink-muted" />
+ </>
+ );
+}
+
+export function FilterSubmenu<TId extends string>(props: {
+ label: string;
+ active?: boolean;
+ options: {
+ id: TId;
+ label: string;
+ icon?: () => JSX.Element;
+ disabled?: boolean;
+ }[];
+ isSelected: (id: TId) => boolean;
+ onSelect: (id: TId) => void;
+ closeOnSelect?: boolean;
+ contentClass?: string;
+}) {
+ return (
+ <Dropdown.Sub>
+ <Dropdown.SubTrigger>
+ <FilterCategoryLabel
+ label={props.label}
+ active={
+ props.active ??
+ props.options.some((option) => props.isSelected(option.id))
+ }
+ />
+ </Dropdown.SubTrigger>
+ <Dropdown.SubContent class={props.contentClass}>
+ <Dropdown.Group>
+ <For each={props.options}>
+ {(option) => (
+ <FilterOptionItem
+ label={option.label}
+ icon={option.icon}
+ disabled={option.disabled}
+ active={props.isSelected(option.id)}
+ onSelect={() => props.onSelect(option.id)}
+ closeOnSelect={props.closeOnSelect}
+ />
+ )}
+ </For>
+ </Dropdown.Group>
+ </Dropdown.SubContent>
+ </Dropdown.Sub>
+ );
+}
+
+/** Searchable submenu for filters with many options like assignees */
+export const SearchableFilterSubmenu = (props: {
+ label: string;
+ active?: boolean;
+ options: Accessor<SearchableOption[]>;
+ activeIds: Accessor<string[]>;
+ onChange: (ids: string[]) => void;
+ placeholder?: string;
+ open?: Accessor<boolean>;
+ onOpenChange?: (v: boolean) => void;
+ /** Keep `options` in their given order instead of pinning selected first. */
+ preserveOrder?: boolean;
+}) => {
+ const [internalOpen, setInternalOpen] = createSignal(false);
+ const isOpen = () => props.open?.() ?? internalOpen();
+ const setIsOpen = (v: boolean) => {
+ if (props.onOpenChange) props.onOpenChange(v);
+ else setInternalOpen(v);
+ };
+ const [inputRef, setInputRef] = createSignal<HTMLInputElement>();
+
+ // Focus the search input while the sub is open.
+ //
+ // Two issues conspire:
+ // 1. Initial focus has to wait for Kobalte's DismissableLayer to register
+ // itself as a nested layer of the parent menu (done in its onMount).
+ // The sub is portaled, so focusing the input before that registration
+ // looks like "focus outside" to the parent and closes the whole menu
+ // tree. One rAF is enough to get past those onMount callbacks.
+ // 2. After that, Kobalte's `onPointerMove` on the SubTrigger keeps
+ // calling `focusWithoutScrolling(e.currentTarget)` on every mouse
+ // move, stealing focus back to the trigger. Reclaim on blur — user
+ // dismissal routes (Escape / click-outside) close the sub first,
+ // which unregisters this listener before focus moves elsewhere.
+ createEffect(() => {
+ const el = inputRef();
+ if (!isOpen() || !el) return;
+
+ const raf = requestAnimationFrame(() => {
+ if (isOpen()) el.focus();
+ });
+
+ const onBlur = () => {
+ queueMicrotask(() => {
+ if (isOpen() && document.activeElement !== el) el.focus();
+ });
+ };
+ el.addEventListener('blur', onBlur);
+
+ onCleanup(() => {
+ cancelAnimationFrame(raf);
+ el.removeEventListener('blur', onBlur);
+ });
+ });
+
+ return (
+ <Dropdown.Sub open={isOpen()} onOpenChange={setIsOpen}>
+ <Dropdown.SubTrigger
+ onPointerEnter={(e: PointerEvent & { currentTarget: HTMLElement }) => {
+ // Kobalte's "grace polygon" keeps an open sub alive when the
+ // pointer crosses toward its content. For sibling In/From triggers,
+ // that means moving between them leaves the prior sub stuck open
+ // and the prior trigger stuck with data-highlighted. Force focus
+ // + open so Kobalte's parent selection manager updates to this
+ // trigger and the shared signal closes the sibling.
+ if (e.pointerType !== 'mouse') return;
+ e.currentTarget.focus({ preventScroll: true });
+ if (!isOpen()) setIsOpen(true);
+ }}
+ >
+ <FilterCategoryLabel
+ label={props.label}
+ active={props.active ?? props.activeIds().length > 0}
+ />
+ </Dropdown.SubTrigger>
+
+ <Dropdown.SubContent class="w-65 max-w-[90vw]">
+ <Dropdown.Group class="p-0 gap-0">
+ <SearchableMultiSelectInline
+ onRequestClose={() => setIsOpen(false)}
+ placeholder={props.placeholder}
+ activeIds={props.activeIds}
+ onChange={props.onChange}
+ options={props.options}
+ inputRef={setInputRef}
+ preserveOrder={props.preserveOrder}
+ />
+ </Dropdown.Group>
+ </Dropdown.SubContent>
+ </Dropdown.Sub>
+ );
+};
diff --git a/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx b/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
index 32bae6eff4..94ce815983 100644
--- a/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
+++ b/apps/web/src/features/next-soup/soup-view/filters-bar/unified-filter-dropdown.tsx
@@ -30,8 +30,6 @@ import { useUserId } from '@core/context/user';
import { registerHotkey } from '@core/hotkey/hotkeys';
import { TOKENS } from '@core/hotkey/tokens';
import { idToDisplayName } from '@core/user/util';
-import CaretRightIcon from '@phosphor/caret-right.svg';
-import CheckIcon from '@phosphor/check.svg';
import CircleDashedIcon from '@phosphor/circle-dashed.svg';
import FilterIcon from '@phosphor/funnel-simple.svg';
import { PropertyValueIcon } from '@property/component/propertyValue/PropertyValueIcon';
@@ -43,13 +41,11 @@ import { cn, Dropdown, Tooltip } from '@ui';
import {
type Accessor,
batch,
- createEffect,
createMemo,
createSignal,
For,
type JSX,
Match,
- onCleanup,
Show,
Switch,
} from 'solid-js';
@@ -58,32 +54,16 @@ import {
filterInboxGithubPrOption,
} from './filter-categories';
import {
- SearchableMultiSelectInline,
- type SearchableOption,
-} from './searchable-multi-select';
+ FilterOptionItem,
+ FilterSubmenu,
+ SearchableFilterSubmenu,
+} from './filter-menu';
+import type { SearchableOption } from './searchable-multi-select';
+
import { useTagFilter } from './tag-filter';
export type { FilterCategory, FilterOption } from './filter-categories';
-export const TypeIndicator = (props: { active: boolean }) => (
- <span
- class={cn(
- 'size-3.5 flex items-center justify-center shrink-0 rounded-sm border text-surface',
- props.active
- ? 'bg-accent border-accent'
- : 'border-transparent group-hover:not-hover:border-edge-muted group-data-highlighted:not-hover:border-edge-muted hover:border-accent'
- )}
- >
- <Show when={props.active}>
- <CheckIcon class="size-2.5" />
- </Show>
- </span>
-);
-
-// Sub-trigger rows differ from default Dropdown.Item only by
-// distributing label + caret to the row ends.
-// const FILTER_MENU_SUBTRIGGER_CLASS = 'justify-between gap-2';
-
// Filter categories by view
const INBOX_FILTER_CATEGORIES: FilterCategory[] = [
{
@@ -394,97 +374,9 @@ export const VIEW_FILTER_CATEGORIES: Record<ListView, FilterCategory[]> = {
search: [],
};
-/** Searchable submenu for filters with many options like assignees */
-const SearchableFilterSubmenu = (props: {
- label: string;
- options: Accessor<SearchableOption[]>;
- activeIds: Accessor<string[]>;
- onChange: (ids: string[]) => void;
- placeholder?: string;
- open?: Accessor<boolean>;
- onOpenChange?: (v: boolean) => void;
- /** Keep `options` in their given order instead of pinning selected first. */
- preserveOrder?: boolean;
-}) => {
- const [internalOpen, setInternalOpen] = createSignal(false);
- const isOpen = () => props.open?.() ?? internalOpen();
- const setIsOpen = (v: boolean) => {
- if (props.onOpenChange) props.onOpenChange(v);
- else setInternalOpen(v);
- };
- const [inputRef, setInputRef] = createSignal<HTMLInputElement>();
-
- // Focus the search input while the sub is open.
- //
- // Two issues conspire:
- // 1. Initial focus has to wait for Kobalte's DismissableLayer to register
- // itself as a nested layer of the parent menu (done in its onMount).
- // The sub is portaled, so focusing the input before that registration
- // looks like "focus outside" to the parent and closes the whole menu
- // tree. One rAF is enough to get past those onMount callbacks.
- // 2. After that, Kobalte's `onPointerMove` on the SubTrigger keeps
- // calling `focusWithoutScrolling(e.currentTarget)` on every mouse
- // move, stealing focus back to the trigger. Reclaim on blur — user
- // dismissal routes (Escape / click-outside) close the sub first,
- // which unregisters this listener before focus moves elsewhere.
- createEffect(() => {
- const el = inputRef();
- if (!isOpen() || !el) return;
-
- const raf = requestAnimationFrame(() => {
- if (isOpen()) el.focus();
- });
-
- const onBlur = () => {
- queueMicrotask(() => {
- if (isOpen() && document.activeElement !== el) el.focus();
- });
- };
- el.addEventListener('blur', onBlur);
-
- onCleanup(() => {
- cancelAnimationFrame(raf);
- el.removeEventListener('blur', onBlur);
- });
- });
-
- return (
- <Dropdown.Sub open={isOpen()} onOpenChange={setIsOpen}>
- <Dropdown.SubTrigger
- onPointerEnter={(e: PointerEvent & { currentTarget: HTMLElement }) => {
- // Kobalte's "grace polygon" keeps an open sub alive when the
- // pointer crosses toward its content. For sibling In/From triggers,
- // that means moving between them leaves the prior sub stuck open
- // and the prior trigger stuck with data-highlighted. Force focus
- // + open so Kobalte's parent selection manager updates to this
- // trigger and the shared signal closes the sibling.
- if (e.pointerType !== 'mouse') return;
- e.currentTarget.focus({ preventScroll: true });
- if (!isOpen()) setIsOpen(true);
- }}
- >
- <span class="text-ink">{props.label}</span>
- <CaretRightIcon class="size-3 text-ink-muted" />
- </Dropdown.SubTrigger>
-
- <Dropdown.SubContent class="w-65 max-w-[90vw]">
- <Dropdown.Group class="p-0 gap-0">
- <SearchableMultiSelectInline
- onRequestClose={() => setIsOpen(false)}
- placeholder={props.placeholder}
- activeIds={props.activeIds}
- onChange={props.onChange}
- options={props.options}
- inputRef={setInputRef}
- preserveOrder={props.preserveOrder}
- />
- </Dropdown.Group>
- </Dropdown.SubContent>
- </Dropdown.Sub>
- );
-};
-
interface UnifiedFilterDropdownProps {
+ /** View-specific refinements alongside the shared filters. */
+ children?: JSX.Element;
/** Optional controlled open state */
open?: Accessor<boolean>;
onOpenChange?: (open: boolean) => void;
@@ -508,38 +400,14 @@ const ReadStatusSubmenu = (props: {
onChange: (value: ReadFilter) => void;
}) => {
return (
- <Dropdown.Sub>
- <Dropdown.SubTrigger>
- <span class="text-ink">Status</span>
- <CaretRightIcon class="size-3 text-ink-muted" />
- </Dropdown.SubTrigger>
-
- <Dropdown.SubContent>
- <Dropdown.Group>
- <For each={READ_FILTER_OPTIONS}>
- {(option) => {
- const active = () => props.value === option.id;
- return (
- <Dropdown.Item
- onSelect={() => props.onChange(option.id)}
- closeOnSelect
- >
- <TypeIndicator active={active()} />
- <span
- class={cn(
- 'flex-1 truncate',
- active() ? 'text-ink' : 'text-ink-muted'
- )}
- >
- {option.label}
- </span>
- </Dropdown.Item>
- );
- }}
- </For>
- </Dropdown.Group>
- </Dropdown.SubContent>
- </Dropdown.Sub>
+ <FilterSubmenu
+ label="Status"
+ active={props.value !== 'all'}
+ options={READ_FILTER_OPTIONS}
+ isSelected={(id) => props.value === id}
+ onSelect={props.onChange}
+ closeOnSelect
+ />
);
};
@@ -992,47 +860,13 @@ export const UnifiedFilterDropdown = (
<For each={categories()}>
{(category) => (
- <Dropdown.Sub>
- <Dropdown.SubTrigger>
- <span class="text-ink">{category.label}</span>
- <CaretRightIcon class="size-3 text-ink-muted" />
- </Dropdown.SubTrigger>
-
- <Dropdown.SubContent>
- <Dropdown.Group>
- <For each={category.options}>
- {(option) => {
- const active = () => isOptionActive(option.id);
- return (
- <Dropdown.Item
- onSelect={() => toggleFilter(option.id)}
- closeOnSelect={!category.multiple}
- >
- <TypeIndicator active={active()} />
-
- <Show when={option.icon}>
- {(icon) => (
- <span class="size-4 flex items-center justify-center shrink-0">
- {icon()()}
- </span>
- )}
- </Show>
-
- <span
- class={cn(
- 'flex-1 truncate',
- active() ? 'text-ink' : 'text-ink-muted'
- )}
- >
- {option.label}
- </span>
- </Dropdown.Item>
- );
- }}
- </For>
- </Dropdown.Group>
- </Dropdown.SubContent>
- </Dropdown.Sub>
+ <FilterSubmenu
+ label={category.label}
+ options={category.options}
+ isSelected={isOptionActive}
+ onSelect={toggleFilter}
+ closeOnSelect={!category.multiple}
+ />
)}
</For>
@@ -1061,6 +895,7 @@ export const UnifiedFilterDropdown = (
<Show when={isCompaniesView()}>
<SearchableFilterSubmenu
label="Stage"
+ active={stageFilter().length > 0}
options={stageOptions}
activeIds={effectiveStageFilter}
onChange={handleStageChange}
@@ -1083,29 +918,13 @@ export const UnifiedFilterDropdown = (
{(option) => {
const active = () => isOptionActive(option.id);
return (
- <Dropdown.Item
+ <FilterOptionItem
+ label={option.label}
+ icon={option.icon}
+ active={active()}
onSelect={() => toggleFilter(option.id)}
closeOnSelect={!categories()[0]!.multiple}
- >
- <TypeIndicator active={active()} />
-
- <Show when={option.icon}>
- {(icon) => (
- <span class="size-4 flex items-center justify-center shrink-0">
- {icon()()}
- </span>
- )}
- </Show>
-
- <span
- class={cn(
- 'flex-1 truncate',
- active() ? 'text-ink' : 'text-ink-muted'
- )}
- >
- {option.label}
- </span>
- </Dropdown.Item>
+ />
);
}}
</For>
@@ -1120,6 +939,7 @@ export const UnifiedFilterDropdown = (
placeholder="Filter by tag..."
/>
</Show>
+ {props.children}
</Dropdown.Group>
</Dropdown.Content>
</Dropdown>
diff --git a/apps/web/src/features/property/tags/use-tag-filter-group.tsx b/apps/web/src/features/property/tags/use-tag-filter-group.tsx
index 4875991f86..f10012b7f8 100644
--- a/apps/web/src/features/property/tags/use-tag-filter-group.tsx
+++ b/apps/web/src/features/property/tags/use-tag-filter-group.tsx
@@ -17,6 +17,7 @@ export function useTagFilterGroup(): Accessor<TagFilterGroup> {
(): TagFilterGroup => ({
id: TAG_FACET_ID,
label: 'Tags',
+ searchPlaceholder: 'Filter by tag...',
options: tagOptions().map((tag) => ({
id: tag.id,
label: tag.label,
diff --git a/apps/web/src/features/tasks-view/filters/use-task-filters.tsx b/apps/web/src/features/tasks-view/filters/use-task-filters.tsx
index 419b212c98..33ccd13518 100644
--- a/apps/web/src/features/tasks-view/filters/use-task-filters.tsx
+++ b/apps/web/src/features/tasks-view/filters/use-task-filters.tsx
@@ -24,8 +24,10 @@ export function useTaskFilters() {
const tagGroup = useTagFilterGroup();
const peopleOptions = createMemo(() => {
- const people = [...contacts()];
const me = currentUserId();
+ const people = [...contacts()].sort(
+ (a, b) => Number(b.id === me) - Number(a.id === me)
+ );
if (me && !people.some((person) => person.id === me)) {
people.unshift({ id: me, email: '', name: idToDisplayName(me) });
}
@@ -80,15 +82,17 @@ export function useTaskFilters() {
},
{
id: 'assignees',
- label: 'Assignees',
+ label: 'Assignee',
+ searchPlaceholder: 'Search assignees...',
options: peopleOptions(),
},
{
id: 'created-by',
label: 'Created by',
+ searchPlaceholder: 'Search creators...',
options: peopleOptions(),
},
- tagGroup(),
+ ...(tagGroup().options.length > 0 ? [tagGroup()] : []),
]
);
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 0d858b6894..49839cb7ff 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -65,13 +65,16 @@ With the new app views enabled, Home defaults to a Signal feed merging
notifications with Activity's `touched_by_me` recents, including sent emails and
AI chats. Each entity appears once, ordered by its latest notification or own
action. On desktop, the funnel button to the right of **Home** opens **Filter Home**.
-The first menu row is an **Unread only** toggle: on shows unread items; off shows
-all items. Entity type checkboxes start checked. Unchecking **Email** hides received
+The menu shares the legacy compact submenus: **Status** offers **Unread**, **Read**,
+and **All**, and **Type** contains the entity checkboxes. Status closes the menu
+after selection; type selections leave it open. Press **f** to open the menu.
+Entity type checkboxes start checked. Unchecking **Email** hides received
and sent mail. **Channels** controls
both channels and reply threads; **Chats** and **Agents** have separate toggles.
Unchecking every type shows an empty feed. **Reset filters** shows every type and
both read states again. A badge counts hidden types plus an active status filter.
-Older saved read-only selections restore as All. The mobile drawer uses the same toggle.
+Read status and type selections persist. The mobile drawer offers the same
+Status choices and type checkboxes.
There are no desktop Signal/Noise tabs. A **Home** heading
labels the top left of the block, matching the **Email**, **Tasks**, **Chat**, and
**Agents** sidebar headings. The full-width **New chat** plus pill below the heading clears the preview and returns to the Home
@@ -206,6 +209,15 @@ Full email client. Tabs: `Signal` / `Noise` / `Sent` / `Calendar` / `Drafts` / `
shows `Connect your email` (Gmail/Google Workspace OAuth) — most functionality needs a
connected account. Search is `Ctrl+F` within the surface.
+The new views reuse the legacy filter option rows and searchable submenus.
+Their triggers are icon-only buttons matching the surrounding view controls;
+Clear/Reset filters and the mobile Clear all action use destructive text styling.
+Both layouts show a small accent dot beside categories with active refinements;
+default All selections are not marked.
+Email Status and Done are single choices that close the menu; attachment filters
+stay open for multiple selections. Tags supports search, pins selected tags first
+on opening, and is omitted when no tags exist. **f** opens the filter menu.
+
### Cached Mail filtering
With GraphQL caching enabled (browser or native Tauri) and the email metadata backfill synchronized,
@@ -370,8 +382,11 @@ and navigate to ancestors. Empty folders show `This folder is empty` and a
`Back to Drive` action that returns to the folder overview. Folder
search retains matching descendants' ancestors and reveals their branches.
-`Search Drive` searches the current tab or folder. `Filter files` includes all-files
-and email-attachment scopes; `Sort files` offers modified, created, and viewed dates.
+`Search Drive` searches the current tab or folder. The **Filter** menu reuses the
+legacy **Type**, searchable **Tags**, and **Created by** submenus alongside **Files**
+for Default, All files, and Email attachments. Created by is hidden while My Files
+is restricted to your own files. Recent offers only file-scope filtering.
+`Sort files` offers modified, created, and viewed dates.
Recent uses the viewer's own interaction order and does not offer a sort override.
The New menu and drag/drop uploads target the selected folder. File rows retain
selection and context menus; ordinary folder clicks and Enter browse inside Drive,
diff --git a/docs/AGENT_GUIDE/tasks.md b/docs/AGENT_GUIDE/tasks.md
index 58ef1fcba8..437a21a5d8 100644
--- a/docs/AGENT_GUIDE/tasks.md
+++ b/docs/AGENT_GUIDE/tasks.md
@@ -4,7 +4,9 @@
`Go to Tasks` → `/app/component/tasks`. Tabs: `My tasks`, `Created by me`, and `Team tasks`.
The desktop toolbar contains search (`Ctrl+F`), `Sort`, `Group`, and `Filter`;
-task creation is available from the `New` button in the Tasks sidebar. Below the tabs the
+the filter uses the legacy compact option rows and searchable Assignee, Created by,
+and Tags submenus. Multi-select choices keep the menu open; Escape dismisses it.
+Task creation is available from the `New` button in the Tasks sidebar. Below the tabs the
sidebar has a collapsible `Tags` section listing every personal and team tag, with a
`New tag` button beside the heading. Clicking a tag narrows the current tab to tasks
carrying it (the same selection as the `Tags` group of the `Filter` menu); clicking it again