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: sidebar and new soup layout (#1676)

dev-rb09f3e9931c28
diff --git a/js/app/packages/app/component/EntityNavigationIndicator.tsx b/js/app/packages/app/component/EntityNavigationIndicator.tsx
index d62621af9f..36e0ddc94c 100644
--- a/js/app/packages/app/component/EntityNavigationIndicator.tsx
+++ b/js/app/packages/app/component/EntityNavigationIndicator.tsx
@@ -1,5 +1,6 @@
import { useSoup } from '@app/component/next-soup/soup-context';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
+import { isListViewID } from '@app/constants/list-views';
import { DeprecatedIconButton } from '@core/component/DeprecatedIconButton';
import { TOKENS } from '@core/hotkey/tokens';
import { getActiveCommandByToken, runCommand } from '@core/hotkey/utils';
@@ -16,7 +17,7 @@ const EntityNavigationIndicator = () => {
return (
<Show
when={
- panel.handle.referredFrom() === 'unified-list' &&
+ isListViewID(panel.handle.referredFrom()) &&
soup.data()?.length &&
selectedEntity() &&
panel.handle.content().type !== 'component' &&
diff --git a/js/app/packages/app/component/GlobalHotkeys.tsx b/js/app/packages/app/component/GlobalHotkeys.tsx
index 31ab83001e..ab32b90955 100644
--- a/js/app/packages/app/component/GlobalHotkeys.tsx
+++ b/js/app/packages/app/component/GlobalHotkeys.tsx
@@ -97,14 +97,12 @@ export default function GlobalShortcuts() {
const { openWithSplit } = useSplitLayout();
const createNewSplit = () => {
- openWithSplit(
- { type: 'component', id: 'unified-list' },
- {
- referredFrom: 'hotkey',
- allowDuplicate: true,
- preferNewSplit: true,
- }
- );
+ const active = globalSplitManager()?.activeSplit()?.content();
+ openWithSplit(active ?? { type: 'component', id: 'inbox' }, {
+ referredFrom: 'hotkey',
+ allowDuplicate: true,
+ preferNewSplit: true,
+ });
return true;
};
diff --git a/js/app/packages/app/component/Layout.tsx b/js/app/packages/app/component/Layout.tsx
index 1c759937b5..cd9f50202c 100644
--- a/js/app/packages/app/component/Layout.tsx
+++ b/js/app/packages/app/component/Layout.tsx
@@ -12,7 +12,7 @@ import { updateCookie } from '@core/util/cookies';
import { type RouteSectionProps, useLocation } from '@solidjs/router';
import { cn } from '@ui/utils/classname';
import { attachGlobalDOMScope } from 'core/hotkey/hotkeys';
-import { createEffect, onMount, Show, Suspense } from 'solid-js';
+import { createEffect, createSignal, onMount, Show, Suspense } from 'solid-js';
import Banner from './banner/Banner';
import { GlobalBulkEditEntityModal } from './bulk-edit-entity/BulkEditEntityModal';
import { GlobalShareModal } from './global-share-modal/GlobalShareModal';
@@ -25,6 +25,11 @@ import { PropertyEditorModal } from './property-edit-modal/PropertyEditorModal';
import { SettingsWrapper } from './settings/SettingsWrapper';
import { ShortcutsHelper } from './settings/ShortcutsHelper';
import { useAppSquishHandlers } from './useAppSquishHandlers';
+import {
+ AppSidebar,
+ type SidebarState,
+} from '@app/component/app-sidebar/sidebar';
+import { isMobile } from '@core/mobile/isMobile';
const AUTH_URLS = [
`${ROUTER_BASE_CONCAT}login`,
@@ -35,6 +40,10 @@ const AUTH_URLS = [
`${ROUTER_BASE_CONCAT}email-signup-callback`,
];
+export const [sidebarState, setSidebarState] = createSignal<SidebarState>(
+ !isMobile() ? 'expanded' : 'hidden'
+);
+
export function Layout(props: RouteSectionProps) {
const isAuthenticated = useIsAuthenticated();
const { paywallOpen, showPaywall } = usePaywallState();
@@ -119,7 +128,19 @@ export function Layout(props: RouteSectionProps) {
<Show when={paywallOpen()}>
<Paywall />
</Show>
- <div class="grow-1">
+ <div class="max-h-full grow-1 flex">
+ <AppSidebar
+ sidebarState={sidebarState()}
+ onOpenChange={(open) => {
+ if (!open) {
+ setSidebarState(isMobile() ? 'hidden' : 'slim');
+ return;
+ }
+
+ setSidebarState('expanded');
+ }}
+ />
+
<Resize.Zone
gutter={4}
direction="horizontal"
@@ -127,10 +148,12 @@ export function Layout(props: RouteSectionProps) {
id={'main-layout'}
>
<ItemDndProvider>
- <Resize.Panel id={LAYOUT_CONTEXT_ID} minSize={250}>
- {props.children}
- </Resize.Panel>
- <SettingsWrapper />
+ <Show when={isAuthenticated()}>
+ <Resize.Panel id={LAYOUT_CONTEXT_ID} minSize={250}>
+ {props.children}
+ </Resize.Panel>
+ <SettingsWrapper />
+ </Show>
</ItemDndProvider>
</Resize.Zone>
</div>
diff --git a/js/app/packages/app/component/Root.tsx b/js/app/packages/app/component/Root.tsx
index 3c511f9b1d..05741cb3bf 100644
--- a/js/app/packages/app/component/Root.tsx
+++ b/js/app/packages/app/component/Root.tsx
@@ -199,6 +199,37 @@ const { EmailSignUp, EmailCallback, CALLBACK_PATH } = makeEmailAuthComponents({
const ROUTES: RouteDefinition[] = [
LAYOUT_ROUTE,
+ /** BEGIN - APP ROUTES */
+ {
+ path: '/inbox',
+ component: LAYOUT_ROUTE.component,
+ },
+ {
+ path: '/agents',
+ component: LAYOUT_ROUTE.component,
+ },
+ {
+ path: '/mail',
+ component: LAYOUT_ROUTE.component,
+ },
+ {
+ path: '/documents',
+ component: LAYOUT_ROUTE.component,
+ },
+ {
+ path: '/tasks',
+ component: LAYOUT_ROUTE.component,
+ },
+ {
+ path: '/channels',
+ component: LAYOUT_ROUTE.component,
+ },
+ {
+ path: '/files',
+ component: LAYOUT_ROUTE.component,
+ },
+ /** END - APP ROUTES */
+
{
path: '/',
component: BasePathComponent,
diff --git a/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx b/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx
new file mode 100644
index 0000000000..9817726e00
--- /dev/null
+++ b/js/app/packages/app/component/app-sidebar/channels-unread-widget.tsx
@@ -0,0 +1,185 @@
+import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
+import type { UnifiedNotification } from '@notifications/types';
+import { For, Show, createSignal, createMemo, onMount } from 'solid-js';
+import {
+ EntityIcon,
+ type EntityWithValidIcon,
+} from '@core/component/EntityIcon';
+import { UserIcon } from '@core/component/UserIcon';
+import {
+ isChannelNotification,
+ useSenderName,
+} from '@app/component/app-sidebar/utils';
+
+function getChannelInfo(notification: UnifiedNotification): {
+ channelName: string | null;
+ channelType: string | null;
+ isDM: boolean;
+} {
+ const metadata = notification.notification_metadata;
+
+ if (
+ metadata.tag === 'channel_mention' ||
+ metadata.tag === 'channel_message_send' ||
+ metadata.tag === 'channel_message_reply'
+ ) {
+ const channelType = metadata.content.channelType;
+ const isDM = channelType === 'directMessage';
+ return {
+ channelName:
+ 'channelName' in metadata.content
+ ? (metadata.content.channelName ?? null)
+ : null,
+ channelType,
+ isDM,
+ };
+ }
+
+ return { channelName: null, channelType: null, isDM: false };
+}
+
+interface ChannelGroup {
+ entityId: string;
+ channelName: string | null;
+ channelType: string | null;
+ isDM: boolean;
+ notifications: UnifiedNotification[];
+ latestSenderId: string | null;
+}
+
+function groupByChannel(
+ notifications: UnifiedNotification[]
+): Map<string, ChannelGroup> {
+ const groups = new Map<string, ChannelGroup>();
+
+ for (const notification of notifications) {
+ if (!isChannelNotification(notification)) continue;
+
+ const entityId = notification.entity_id;
+ const info = getChannelInfo(notification);
+
+ if (!groups.has(entityId)) {
+ groups.set(entityId, {
+ entityId,
+ channelName: info.channelName,
+ channelType: info.channelType,
+ isDM: info.isDM,
+ notifications: [],
+ latestSenderId: null,
+ });
+ }
+
+ const group = groups.get(entityId)!;
+ group.notifications.push(notification);
+
+ // Track latest sender for DMs
+ if (info.isDM && notification.sender_id) {
+ group.latestSenderId = notification.sender_id;
+ }
+ }
+
+ return groups;
+}
+
+function ChannelGroupItem(props: { group: ChannelGroup; animate?: boolean }) {
+ const [isVisible, setIsVisible] = createSignal(!props.animate);
+
+ onMount(() => {
+ if (props.animate) {
+ requestAnimationFrame(() => {
+ setIsVisible(true);
+ });
+ }
+ });
+
+ const senderName = useSenderName(props.group.latestSenderId);
+ const count = () => props.group.notifications.length;
+
+ const displayName = () => {
+ if (props.group.isDM) {
+ return senderName() ?? 'Direct Message';
+ }
+ return props.group.channelName
+ ? `#${props.group.channelName}`
+ : 'Unknown Channel';
+ };
+
+ return (
+ <div
+ class="flex items-center gap-3 p-2 hover:bg-surface-hover cursor-pointer transition-all duration-300 ease-out"
+ classList={{
+ 'opacity-0 -translate-y-2': !isVisible(),
+ 'opacity-100 translate-y-0': isVisible(),
+ }}
+ >
+ <div class="flex-shrink-0">
+ <Show
+ when={props.group.isDM && props.group.latestSenderId}
+ fallback={
+ <EntityIcon
+ targetType={
+ (props.group.channelType ?? 'channel') as EntityWithValidIcon
+ }
+ size="xs"
+ />
+ }
+ >
+ <UserIcon
+ id={props.group.latestSenderId!}
+ size="xs"
+ suppressClick
+ showTooltip={false}
+ />
+ </Show>
+ </div>
+
+ <span class="flex-1 text-sm font-medium text-ink truncate">
+ {displayName()}
+ </span>
+
+ <Show when={count() > 0}>
+ <span class="flex-shrink-0 min-w-5 h-5 px-1.5 flex items-center justify-center text-xs font-medium bg-accent/10 text-accent rounded">
+ {count()}
+ </span>
+ </Show>
+ </div>
+ );
+}
+
+function filterUnreadNotDone(notifications: UnifiedNotification[]) {
+ return notifications.filter((n) => !n.viewed_at && !n.done);
+}
+
+export const ChannelsUnreadWidget = () => {
+ const notificationSource = useGlobalNotificationSource();
+ const allNotifications = () => [...notificationSource.notifications()];
+
+ const filteredNotifications = () => filterUnreadNotDone(allNotifications());
+
+ const channelGroups = createMemo(() => {
+ const groups = groupByChannel(filteredNotifications());
+ // Convert to array and sort by most recent notification
+ return Array.from(groups.values()).sort((a, b) => {
+ const aTime = new Date(a.notifications[0]?.created_at ?? 0).getTime();
+ const bTime = new Date(b.notifications[0]?.created_at ?? 0).getTime();
+ return bTime - aTime;
+ });
+ });
+
+ return (
+ <section class="w-full h-full px-2 py-1.5 flex flex-col justify-center">
+ <header class="text-xs font-medium text-ink-muted tracking-wide">
+ <h1>Unread</h1>
+ </header>
+
+ <div class="flex-1 overflow-y-auto">
+ <For
+ each={channelGroups()}
+ fallback={<span class="text-ink/80 text-xs">No unread messages</span>}
+ >
+ {(group) => <ChannelGroupItem group={group} animate={false} />}
+ </For>
+ </div>
+ </section>
+ );
+};
diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsx
new file mode 100644
index 0000000000..8efe6bed60
--- /dev/null
+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx
@@ -0,0 +1,358 @@
+import GearIcon from '@phosphor-icons/core/regular/gear.svg?component-solid';
+import { type Component, createSignal, For, type JSX, Show } from 'solid-js';
+import { Dynamic } from 'solid-js/web';
+import SidebarIcon from '@phosphor-icons/core/fill/sidebar-simple-fill.svg?component-solid';
+import TrayIcon from '@phosphor-icons/core/bold/tray-bold.svg?component-solid';
+import { AnimatedStarIcon } from '@macro-icons/wide/animating/star';
+import { AnimatedEmailIcon } from '@macro-icons/wide/animating/email';
+import { AnimatedTaskIcon } from '@macro-icons/wide/animating/task';
+import { AnimatedChannelIcon } from '@macro-icons/wide/animating/channel';
+import { AnimatedFileMdIcon } from '@macro-icons/wide/animating/fileMd';
+import { AnimatedFolderIcon } from '@macro-icons/wide/animating/folder';
+import { useLocation } from '@solidjs/router';
+import LogoIcon from '@macro-icons/macro-logo.svg';
+import PlusIcon from '@macro-icons/wide/plus.svg';
+import SearchIcon from '@phosphor-icons/core/regular/magnifying-glass.svg?component-solid';
+import CommandIcon from '@phosphor-icons/core/assets/regular/command.svg';
+import { LIST_VIEW_PATHS, type ListView } from '@app/constants/list-views';
+import { LabelAndHotKey, Tooltip } from '@core/component/Tooltip';
+import { setCreateMenuOpen } from '@app/component/Launcher';
+import { CommandState } from '@app/component/command';
+import { cn } from '@ui/utils/classname';
+import { Button } from '@app/component/next-soup/soup-view/filters-bar/button';
+import { useSplitLayout } from '@app/component/split-layout/layout';
+import { ChannelsUnreadWidget } from '@app/component/app-sidebar/channels-unread-widget';
+import { globalSplitManager } from '@app/signal/splitLayout';
+import { isMobile } from '@core/mobile/isMobile';
+import { useSettingsState } from '@core/constant/SettingsState';
+import type { ValidHotkey } from '@core/hotkey/types';
+import { registerHotkey } from '@core/hotkey/hotkeys';
+import { GO_TO_COMMAND_SCOPE, GO_TO_LEADER_KEY } from '@app/constants/hotkeys';
+import { ROUTER_BASE } from '@app/constants/routerBase';
+
+interface SidebarItem {
+ id: ListView;
+ label: string;
+ href: string;
+ icon?: Component<
+ JSX.SvgSVGAttributes<SVGSVGElement> | { triggerAnimation?: boolean }
+ >;
+ hotkey: ValidHotkey;
+}
+
+export const SIDEBAR_LINKS = [
+ {
+ id: 'inbox',
+ label: 'Inbox',
+ href: LIST_VIEW_PATHS.inbox,
+ icon: TrayIcon,
+ hotkey: 'i',
+ },
+ {
+ id: 'agents',
+ label: 'Agents',
+ href: LIST_VIEW_PATHS.agents,
+ icon: AnimatedStarIcon,
+ hotkey: 'a',
+ },
+ {
+ id: 'mail',
+ label: 'Email',
+ href: LIST_VIEW_PATHS.mail,
+ icon: AnimatedEmailIcon,
+ hotkey: 'e',
+ },
+ {
+ id: 'documents',
+ label: 'Documents',
+ href: LIST_VIEW_PATHS.documents,
+ icon: AnimatedFileMdIcon,
+ hotkey: 'd',
+ },
+ {
+ id: 'tasks',
+ label: 'Tasks',
+ href: LIST_VIEW_PATHS.tasks,
+ icon: AnimatedTaskIcon,
+ hotkey: 't',
+ },
+ {
+ id: 'channels',
+ label: 'Channels',
+ href: LIST_VIEW_PATHS.channels,
+ icon: AnimatedChannelIcon,
+ hotkey: 'c',
+ },
+ {
+ id: 'files',
+ label: 'Files',
+ href: LIST_VIEW_PATHS.files,
+ icon: AnimatedFolderIcon,
+ hotkey: 'f',
+ },
+] as const satisfies SidebarItem[];
+
+export type SidebarState = 'hidden' | 'expanded' | 'slim';
+
+type AppSidebarProps = {
+ sidebarState?: SidebarState;
+ onOpenChange: (open: boolean) => void;
+};
+
+export const AppSidebar = (props: AppSidebarProps) => {
+ const layout = useSplitLayout();
+ const { toggleSettings } = useSettingsState();
+
+ const handleCommandPaletteClick = () => {
+ CommandState.toggle();
+ };
+
+ const handleCreateClick = () => {
+ setCreateMenuOpen((p) => !p);
+ };
+
+ const registerHotkeys = () => {
+ // Register 'g' as a leader key that activates the global GO_TO command scope
+ registerHotkey({
+ hotkey: GO_TO_LEADER_KEY,
+ scopeId: 'global',
+ description: 'Go to page',
+ keyDownHandler: () => false,
+ activateCommandScopeId: GO_TO_COMMAND_SCOPE,
+ hide: true,
+ registrationType: 'add',
+ });
+
+ // Register navigation shortcuts in the global GO_TO command scope
+ for (const link of SIDEBAR_LINKS) {
+ registerHotkey({
+ hotkey: link.hotkey,
+ scopeId: GO_TO_COMMAND_SCOPE,
+ description: `Go to ${link.label}`,
+ keyDownHandler: (e) => {
+ e?.preventDefault();
+ layout.openWithSplit(
+ {
+ type: 'component',
+ id: link.id,
+ },
+ {
+ preferNewSplit: e?.shiftKey,
+ mergeHistory: true,
+ }
+ );
+ return true;
+ },
+ });
+ }
+ };
+
+ registerHotkeys();
+
+ const isExpanded = () => props.sidebarState === 'expanded';
+ const isSlim = () => props.sidebarState === 'slim';
+
+ return (
+ <>
+ <Show when={isMobile() && isExpanded()}>
+ <div
+ class="absolute z-modal-overlay pattern-panel pattern-diagonal-4 w-screen h-full inset-0 bg-edge-muted mask-l-from-0 pointer-events-[all] transition-opacity opacity-100"
+ onClick={() => props.onOpenChange(false)}
+ />
+ </Show>
+ <div
+ class={cn(
+ 'h-full bg-page pt-2 flex flex-col gap-4 mobile:absolute mobile:z-modal-content transition-[width_transform_opacity] duration-200 ease-in-out',
+ isExpanded() &&
+ 'max-w-56 w-full mobile:max-w-2/3 translate-x-0 opacity-100',
+ props.sidebarState === 'hidden' &&
+ '-translate-x-full overflow-hidden opacity-0',
+
+ isSlim() &&
+ 'max-w-10 w-full mobile:max-w-2/3 translate-x-0 opacity-100'
+ )}
+ >
+ <div
+ class={cn(
+ 'flex items-center justify-between py-2 pl-3 pr-2',
+ isSlim() && 'flex-col gap-2 px-2 justify-center'
+ )}
+ >
+ <LogoIcon class="size-6 text-accent" />
+ <div class="flex items-center gap-1">
+ <Show when={isExpanded()}>
+ <Tooltip tooltip={<LabelAndHotKey label="Search" shortcut="/" />}>
+ <Button
+ as="a"
+ class="cursor-default"
+ variant="tertiary"
+ size="icon-sm"
+ href={`/component/search`}
+ onClick={(e) => {
+ // Middle mouse handling
+ if (e.button === 1) return;
+
+ e.preventDefault();
+ layout.openWithSplit(
+ {
+ type: 'component',
+ id: 'search',
+ },
+ {
+ preferNewSplit: e.shiftKey,
+ mergeHistory: true,
+ }
+ );
+ }}
+ >
+ <SearchIcon />
+ </Button>
+ </Tooltip>
+ <Tooltip
+ tooltip={
+ <LabelAndHotKey label="Command palette" shortcut="⌘K" />
+ }
+ >
+ <Button
+ variant="tertiary"
+ size="icon-sm"
+ onClick={handleCommandPaletteClick}
+ >
+ <CommandIcon />
+ </Button>
+ </Tooltip>
+ <Tooltip
+ tooltip={<LabelAndHotKey label="Create new" shortcut="c" />}
+ >
+ <Button
+ variant="tertiary"
+ size="icon-sm"
+ onClick={handleCreateClick}
+ >
+ <PlusIcon />
+ </Button>
+ </Tooltip>
+ <Tooltip
+ tooltip={
+ <LabelAndHotKey
+ label="Settings"
+ hotkeyToken="global.toggleSettings"
+ />
+ }
+ >
+ <Button
+ variant="tertiary"
+ size="icon-sm"
+ onClick={toggleSettings}
+ >
+ <GearIcon />
+ </Button>
+ </Tooltip>
+ </Show>
+ <Show when={!isMobile()}>
+ <Tooltip tooltip={isSlim() ? 'Expand sidebar' : 'Shrink sidebar'}>
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ onClick={() => props.onOpenChange(isSlim())}
+ >
+ <SidebarIcon />
+ </Button>
+ </Tooltip>
+ </Show>
+ </div>
+ </div>
+
+ <nav>
+ <ul class="w-full h-full px-2 flex flex-col gap-1">
+ <For each={SIDEBAR_LINKS}>
+ {(link) => (
+ <li class="flex items-center justify-center">
+ <SidebarLink
+ {...link}
+ sidebarState={props.sidebarState ?? 'expanded'}
+ />
+ </li>
+ )}
+ </For>
+ </ul>
+ </nav>
+ <Show when={isExpanded()}>
+ <div class="block max-h-[clamp(10%,60%,20rem)]">
+ <ChannelsUnreadWidget />
+ </div>
+
+ {/* <div class="block max-h-[clamp(10%,60%,20rem)] mt-auto"> */}
+ {/* <UnreadNotificationsWidget /> */}
+ {/* </div> */}
+ </Show>
+ </div>
+ </>
+ );
+};
+
+interface SidebarLinkProps extends SidebarItem {
+ sidebarState: SidebarState;
+}
+
+const SidebarLink = (props: SidebarLinkProps) => {
+ const [isHovering, setIsHovering] = createSignal(false);
+
+ const layout = useSplitLayout();
+ const layoutManager = globalSplitManager();
+
+ const location = useLocation();
+
+ const isActive = () => {
+ const activeContent = layoutManager?.activeSplit()?.content();
+
+ // In case we can't match on the active split, use the url path to determine
+ // if this link is active
+ if (!activeContent) {
+ const paths = location.pathname.split('/').filter(Boolean);
+ return paths.includes(props.id);
+ }
+
+ return activeContent?.id === props.id;
+ };
+
+ return (
+ <Button
+ as="a"
+ variant="ghost"
+ size={props.sidebarState === 'slim' ? 'icon-sm' : 'sm'}
+ class={cn(
+ 'flex items-center justify-start text-sm gap-2 cursor-default',
+ isActive() && 'bg-ink/15 not-disabled:hover:bg-ink/15 text-ink',
+ props.sidebarState === 'slim' && 'justify-center aspect-square',
+ props.sidebarState !== 'slim' && 'w-full'
+ )}
+ href={`${ROUTER_BASE}/component${props.href}`}
+ onMouseEnter={() => setIsHovering(true)}
+ onMouseLeave={() => setIsHovering(false)}
+ onClick={(e) => {
+ // Middle mouse handling
+ if (e.button === 1) return;
+
+ e.preventDefault();
+ layout.openWithSplit(
+ {
+ type: 'component',
+ id: props.id,
+ },
+ {
+ preferNewSplit: e.shiftKey,
+ mergeHistory: true,
+ }
+ );
+ }}
+ >
+ <Show when={props.icon}>
+ <div class="shrink-0 [&_svg]:size-4">
+ <Dynamic component={props.icon} triggerAnimation={isHovering()} />
+ </div>
+ </Show>
+ <Show when={props.sidebarState === 'expanded'}>{props.label}</Show>
+ </Button>
+ );
+};
diff --git a/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts b/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts
new file mode 100644
index 0000000000..91f53343b6
--- /dev/null
+++ b/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts
@@ -0,0 +1,267 @@
+import {
+ QUERY_FILTERS,
+ type FilterID,
+} from '@app/component/next-soup/filters/filters';
+import {
+ applyInboxQueryFilters,
+ applyOtherQueryFilters,
+} from '@app/component/next-soup/filters/inbox-query-filters';
+import type { ListView } from '@app/constants/list-views';
+import type { SoupItemsQueryFilters } from '@queries/soup/items';
+
+export type SoupFiltersPreset = {
+ queryFilters: SoupItemsQueryFilters;
+ clientFilters: {
+ and?: FilterID[];
+ or?: FilterID[];
+ };
+};
+
+// Tab preset configuration types
+export type PresetContext = {
+ userId: string | undefined;
+ email: string | undefined;
+};
+
+export type TabPresetResolver = (
+ ctx: PresetContext
+) => SoupFiltersPreset | undefined;
+
+export type TabConfig = Record<string, TabPresetResolver>;
+
+export type ViewTabConfig = {
+ default: string;
+ tabs: TabConfig;
+};
+
+export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {
+ inbox: {
+ default: 'signal',
+ tabs: {
+ signal: () => ({
+ queryFilters: applyInboxQueryFilters({}),
+ clientFilters: { and: ['signal', 'not-done'] },
+ }),
+ noise: () => ({
+ queryFilters: applyOtherQueryFilters({}),
+ clientFilters: { and: ['noise', 'not-done'] },
+ }),
+ all: () => ({
+ queryFilters: {},
+ clientFilters: { and: ['explicit-noise'] },
+ }),
+ },
+ },
+ agents: {
+ default: 'owned',
+ tabs: {
+ owned: (ctx) => {
+ if (!ctx.userId) return undefined;
+ return {
+ queryFilters: {
+ ...QUERY_FILTERS.agent,
+ chat_filters: { owners: [ctx.userId] },
+ },
+ clientFilters: { and: ['agent'] },
+ };
+ },
+ running: () => ({
+ queryFilters: QUERY_FILTERS.agent,
+ clientFilters: { and: ['agent'] },
+ }),
+ shared: () => ({
+ queryFilters: QUERY_FILTERS.agent,
+ clientFilters: { and: ['agent', 'shared-agent'] },
+ }),
+ },
+ },
+ mail: {
+ default: 'important',
+ tabs: {
+ important: () => ({
+ queryFilters: {
+ ...QUERY_FILTERS.email,
+ email_filters: { importance: true },
+ },
+ clientFilters: { and: ['email', 'no-drafts'] },
+ }),
+ noise: () => ({
+ queryFilters: {
+ ...QUERY_FILTERS.email,
+ email_filters: { importance: false },
+ },
+ clientFilters: { and: ['email', 'no-drafts'] },
+ }),
+ drafts: () => ({
+ queryFilters: QUERY_FILTERS.email,
+ clientFilters: { and: ['email-drafts'] },
+ }),
+ sent: (ctx) => {
+ if (!ctx.email) return undefined;
+ return {
+ queryFilters: {
+ ...QUERY_FILTERS.email,
+ email_filters: { senders: [ctx.email] },
+ },
+ clientFilters: { and: ['email', 'no-drafts'] },
+ };
+ },
+ },
+ },
+ documents: {
+ default: 'owned',
+ tabs: {
+ owned: (ctx) => {
+ if (!ctx.userId) return undefined;
+ return {
+ queryFilters: {
+ ...QUERY_FILTERS.document,
+ document_filters: { owners: [ctx.userId] },
+ },
+ clientFilters: { and: ['document'] },
+ };
+ },
+ shared: () => ({
+ queryFilters: QUERY_FILTERS.document,
+ clientFilters: { and: ['document', 'shared-entity'] },
+ }),
+ all: () => ({
+ queryFilters: QUERY_FILTERS.document,
+ clientFilters: { and: ['document'] },
+ }),
+ },
+ },
+ tasks: {
+ default: 'assigned-to-me',
+ tabs: {
+ 'assigned-to-me': (ctx) => {
+ if (!ctx.userId) return undefined;
+ return {
+ queryFilters: {
+ ...QUERY_FILTERS.task,
+ document_filters: { owners: [ctx.userId] },
+ },
+ clientFilters: { and: ['task', 'assigned-to'] },
+ };
+ },
+ 'created-by-me': (ctx) => {
+ if (!ctx.userId) return undefined;
+ return {
+ queryFilters: {
+ ...QUERY_FILTERS.task,
+ document_filters: { owners: [ctx.userId] },
+ },
+ clientFilters: { and: ['task'] },
+ };
+ },
+ all: () => ({
+ queryFilters: QUERY_FILTERS.task,
+ clientFilters: { and: ['task'] },
+ }),
+ },
+ },
+ channels: {
+ default: 'recent',
+ tabs: {
+ recent: () => ({
+ queryFilters: {
+ ...QUERY_FILTERS.channels,
+ channel_filters: { importance: true },
+ },
+ clientFilters: { and: ['channels'] },
+ }),
+ people: () => ({
+ queryFilters: QUERY_FILTERS.people,
+ clientFilters: { and: ['people'] },
+ }),
+ teams: () => ({
+ queryFilters: QUERY_FILTERS.teams,
+ clientFilters: { and: ['teams'] },
+ }),
+ },
+ },
+ files: {
+ default: 'owned',
+ tabs: {
+ owned: (ctx) => {
+ if (!ctx.userId) return undefined;
+ return {
+ queryFilters: {
+ ...QUERY_FILTERS.file,
+ document_filters: {
+ ...QUERY_FILTERS.file.document_filters,
+ owners: [ctx.userId],
+ },
+ project_filters: { owners: [ctx.userId] },
+ },
+ clientFilters: { and: ['file-folder'] },
+ };
+ },
+ shared: () => ({
+ queryFilters: QUERY_FILTERS.file,
+ clientFilters: { and: ['file-folder', 'shared-entity'] },
+ }),
+ all: () => ({
+ queryFilters: {
+ ...QUERY_FILTERS.file,
+ project_filters: {},
+ },
+ clientFilters: { and: ['file-folder'] },
+ }),
+ },
+ },
+ search: {
+ default: 'all',
+ tabs: {
+ all: () => ({
+ queryFilters: {
+ ...QUERY_FILTERS.default,
+ },
+ clientFilters: { and: [], or: [] },
+ }),
+ },
+ },
+};
+
+/** Views whose default tab requires user context */
+type ContextRequiredView = 'agents' | 'documents' | 'tasks' | 'files';
+
+/** Views whose default tab works without user context */
+type ContextOptionalView = Exclude<ListView, ContextRequiredView>;
+
+/**
+ * Returns the default filter preset for a list view.
+ * Uses the view's default tab, falling back to the first available tab
+ * if the default requires context values that aren't provided.
+ *
+ * @param view - The list view to get the preset for
+ * @param ctx - User context (required for agents, documents, tasks, files)
+ */
+export function getDefaultListViewPreset(
+ view: ContextRequiredView,
+ ctx: PresetContext
+): SoupFiltersPreset;
+export function getDefaultListViewPreset(
+ view: ContextOptionalView,
+ ctx?: PresetContext
+): SoupFiltersPreset;
+export function getDefaultListViewPreset(
+ view: ListView,
+ ctx: PresetContext = { userId: undefined, email: undefined }
+): SoupFiltersPreset {
+ const config = VIEW_TAB_PRESETS[view];
+ const defaultResolver = config.tabs[config.default];
+
+ // Try default tab with provided context
+ const resolved = defaultResolver(ctx);
+ if (resolved) return resolved;
+
+ // Fallback: find first tab that works with provided context
+ for (const resolver of Object.values(config.tabs)) {
+ const fallback = resolver(ctx);
+ if (fallback) return fallback;
+ }
+
+ // Last resort: empty filters
+ return { queryFilters: {}, clientFilters: {} };
+}
diff --git a/js/app/packages/app/component/app-sidebar/unread-notifications-widget.tsx b/js/app/packages/app/component/app-sidebar/unread-notifications-widget.tsx
new file mode 100644
index 0000000000..ebdaff9577
--- /dev/null
+++ b/js/app/packages/app/component/app-sidebar/unread-notifications-widget.tsx
@@ -0,0 +1,295 @@
+import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
+import type { EntityType, NotificationType } from '@core/types';
+import type { UnifiedNotification } from '@notifications/types';
+import { For, Show, createMemo, createSignal, onMount } from 'solid-js';
+import { match } from 'ts-pattern';
+import {
+ EntityIcon,
+ type EntityWithValidIcon,
+} from '@core/component/EntityIcon';
+import { UserIcon } from '@core/component/UserIcon';
+import ArrowBendUpLeftIcon from '@icon/regular/arrow-bend-up-left.svg';
+import UserPlusIcon from '@icon/regular/user-plus.svg';
+import { Dynamic } from 'solid-js/web';
+import { useSenderName } from '@app/component/app-sidebar/utils';
+
+const UNELIGIBLE_ENTITY_TYPES: EntityType[] = ['email', 'email_thread'];
+
+type NotificationIconResult =
+ | { type: 'entity'; icon: EntityWithValidIcon }
+ | { type: 'svg'; icon: typeof ArrowBendUpLeftIcon }
+ | { type: 'user' };
+
+function getNotificationIcon(
+ type: NotificationType,
+ notification: UnifiedNotification
+): NotificationIconResult {
+ // Check if this is a DM - use user icon instead
+ const isDM =
+ type === 'channel_message_send' &&
+ notification.notification_metadata.tag === 'channel_message_send' &&
+ notification.notification_metadata.content.channelType === 'directMessage';
+
+ if (isDM) {
+ return { type: 'user' };
+ }
+
+ return match(type)
+ .with('channel_mention', () => ({
+ type: 'entity' as const,
+ icon: 'channel' as EntityWithValidIcon,
+ }))
+ .with('mentioned_in_document_comment', () => ({
+ type: 'entity' as const,
+ icon: 'write' as EntityWithValidIcon,
+ }))
+ .with('channel_message_reply', () => ({
+ type: 'svg' as const,
+ icon: ArrowBendUpLeftIcon,
+ }))
+ .with('channel_message_send', () => ({
+ type: 'entity' as const,
+ icon: 'chat' as EntityWithValidIcon,
+ }))
+ .with('channel_invite', () => ({
+ type: 'svg' as const,
+ icon: UserPlusIcon,
+ }))
+ .with('invite_to_team', () => ({
+ type: 'svg' as const,
+ icon: UserPlusIcon,
+ }))
+ .with('task_assigned', () => ({
+ type: 'entity' as const,
+ icon: 'task' as EntityWithValidIcon,
+ }))
+ .otherwise(() => ({
+ type: 'entity' as const,
+ icon: 'chat' as EntityWithValidIcon,
+ }));
+}
+
+function getNotificationLabel(type: NotificationType): string {
+ return match(type)
+ .with('channel_mention', () => '@You')
+ .with('mentioned_in_document_comment', () => '@You')
+ .with('channel_message_reply', () => '') // Show sender name instead
+ .with('channel_message_send', () => '') // Show sender name instead for DMs
+ .with('channel_invite', () => 'Channel invite')
+ .with('invite_to_team', () => 'Team invite')
+ .with('task_assigned', () => 'New task')
+ .otherwise(() => '');
+}
+
+function getNotificationContent(notification: UnifiedNotification): string {
+ const metadata = notification.notification_metadata;
+
+ return match(metadata)
+ .with({ tag: 'channel_mention' }, (m) => m.content.messageContent ?? '')
+ .with(
+ { tag: 'channel_message_send' },
+ (m) => m.content.messageContent ?? ''
+ )
+ .with(
+ { tag: 'channel_message_reply' },
+ (m) => m.content.messageContent ?? ''
+ )
+ .with(
+ { tag: 'channel_invite' },
+ (m) => m.content.channelName ?? 'a channel'
+ )
+ .with({ tag: 'mentioned_in_document_comment' }, (m) => m.content.text ?? '')
+ .with({ tag: 'invite_to_team' }, (m) => m.content.teamName ?? '')
+ .with({ tag: 'task_assigned' }, (m) => m.content.taskName ?? 'a task')
+ .otherwise(() => '');
+}
+
+/** Gets contextual info like channel name or document name */
+function getNotificationContext(
+ notification: UnifiedNotification
+): string | null {
+ const metadata = notification.notification_metadata;
+
+ return match(metadata)
+ .with({ tag: 'channel_mention' }, (m) =>
+ m.content.channelName ? `#${m.content.channelName}` : null
+ )
+ .with({ tag: 'channel_message_send' }, (m) =>
+ m.content.channelName ? `#${m.content.channelName}` : 'DM'
+ )
+ .with({ tag: 'channel_message_reply' }, (m) =>
+ m.content.channelName ? `#${m.content.channelName}` : null
+ )
+ .with({ tag: 'channel_invite' }, () => null)
+ .with(
+ { tag: 'mentioned_in_document_comment' },
+ (m) => m.content.documentName ?? null
+ )
+ .with({ tag: 'invite_to_team' }, (m) =>
+ m.content.invitedBy ? `by ${m.content.invitedBy}` : null
+ )
+ .with({ tag: 'task_assigned' }, (m) =>
+ m.content.assignedBy ? `by ${m.content.assignedBy}` : null
+ )
+ .otherwise(() => null);
+}
+
+/** Renders the icon for a notification */
+function NotificationItemIcon(props: {
+ type: NotificationType;
+ notification: UnifiedNotification;
+}) {
+ const iconResult = () => getNotificationIcon(props.type, props.notification);
+
+ return (
+ <Show
+ when={iconResult().type === 'entity'}
+ fallback={
+ <Show
+ when={iconResult().type === 'user'}
+ fallback={
+ <Dynamic
+ component={
+ (
+ iconResult() as {
+ type: 'svg';
+ icon: typeof ArrowBendUpLeftIcon;
+ }
+ ).icon
+ }
+ class="size-4 text-ink-muted"
+ />
+ }
+ >
+ <Show when={props.notification.sender_id}>
+ {(senderId) => (
+ <UserIcon
+ id={senderId()}
+ size="xs"
+ suppressClick
+ showTooltip={false}
+ />
+ )}
+ </Show>
+ </Show>
+ }
+ >
+ <EntityIcon
+ targetType={
+ (iconResult() as { type: 'entity'; icon: EntityWithValidIcon }).icon
+ }
+ size="xs"
+ />
+ </Show>
+ );
+}
+
+function NotificationItem(props: {
+ notification: UnifiedNotification;
+ animate?: boolean;
+}) {
+ const [isVisible, setIsVisible] = createSignal(!props.animate);
+
+ onMount(() => {
+ if (props.animate) {
+ // Small delay to ensure the initial state is rendered first
+ requestAnimationFrame(() => {
+ setIsVisible(true);
+ });
+ }
+ });
+
+ const type = () =>
+ props.notification.notification_event_type as NotificationType;
+
+ const notificationContent = () => getNotificationContent(props.notification);
+
+ const notificationContext = () => getNotificationContext(props.notification);
+
+ const senderName = useSenderName(props.notification.sender_id);
+
+ const isDM = () =>
+ type() === 'channel_message_send' &&
+ props.notification.notification_metadata.tag === 'channel_message_send' &&
+ props.notification.notification_metadata.content.channelType ===
+ 'directMessage';
+
+ const isReply = () => type() === 'channel_message_reply';
+
+ const showSenderName = () => isDM() || isReply();
+
+ return (
+ <div
+ class="flex items-start gap-3 p-2 hover:bg-surface-hover cursor-pointer transition-all duration-300 ease-out"
+ classList={{
+ 'opacity-0 -translate-y-2': !isVisible(),
+ 'opacity-100 translate-y-0': isVisible(),
+ }}
+ >
+ <div class="flex-shrink-0 mt-1">
+ <NotificationItemIcon type={type()} notification={props.notification} />
+ </div>
+
+ <div class="flex-1 min-w-0 flex flex-col gap-0.5">
+ <span class="text-sm font-medium text-ink truncate">
+ <Show when={showSenderName()} fallback={getNotificationLabel(type())}>
+ {senderName()}
+ </Show>
+ </span>
+
+ <Show when={notificationContext()}>
+ <span class="text-xs text-ink-muted truncate">
+ {notificationContext()}
+ </span>
+ </Show>
+
+ <Show when={notificationContent()}>
+ <p class="text-xs text-ink-muted truncate">{notificationContent()}</p>
+ </Show>
+ </div>
+ </div>
+ );
+}
+
+function filterUnreadNotDone(notifications: UnifiedNotification[]) {
+ return notifications.filter(
+ (n) =>
+ !n.viewed_at &&
+ !n.done &&
+ !UNELIGIBLE_ENTITY_TYPES.includes(n.entity_type)
+ );
+}
+
+export const UnreadNotificationsWidget = () => {
+ const notificationSource = useGlobalNotificationSource();
+
+ const allNotifications = () => [...notificationSource.notifications()];
+ const filteredNotifications = createMemo(() =>
+ filterUnreadNotDone(allNotifications())
+ );
+
+ return (
+ <section class="w-full h-full flex flex-col">
+ <header class="flex items-center justify-between py-1 px-2">
+ <h1 class="text-sm font-medium text-ink-muted tracking-wide">
+ Notifications
+ </h1>
+ <span class="flex-shrink-0 min-w-5 h-5 px-1.5 flex items-center justify-center text-xs font-medium bg-accent/10 text-accent rounded">
+ {filteredNotifications().length}
+ </span>
+ </header>
+ <div class="flex-1 overflow-y-auto pb-2 px-2">
+ <For
+ each={filteredNotifications()}
+ fallback={
+ <span class="text-ink/80 text-xs">No new notifications</span>
+ }
+ >
+ {(notification) => (
+ <NotificationItem notification={notification} animate={false} />
+ )}
+ </For>
+ </div>
+ </section>
+ );
+};
diff --git a/js/app/packages/app/component/app-sidebar/utils.ts b/js/app/packages/app/component/app-sidebar/utils.ts
new file mode 100644
index 0000000000..4322c1a885
--- /dev/null
+++ b/js/app/packages/app/component/app-sidebar/utils.ts
@@ -0,0 +1,39 @@
+import { tryMacroId, useDisplayNameParts } from '@core/user';
+import type { UnifiedNotification } from '@notifications';
+
+export function useSenderName(senderId: string | null | undefined) {
+ const nameParts = useDisplayNameParts(tryMacroId(senderId ?? ''));
+ return () => {
+ const firstName = nameParts.firstName();
+ const fullName = nameParts.fullName();
+ if (firstName || fullName) {
+ return firstName || fullName;
+ }
+ // Fallback: extract name from macro ID format (macro|[email protected])
+ if (senderId?.startsWith('macro|')) {
+ const email = senderId.slice(6);
+ const namePart = email.split('@')[0];
+
+ return namePart;
+ }
+ return null;
+ };
+}
+
+const CHANNEL_NOTIFICATION_TYPES = [
+ 'channel_mention',
+ 'channel_message_send',
+ 'channel_message_reply',
+] as const;
+
+type ChannelNotificationType = (typeof CHANNEL_NOTIFICATION_TYPES)[number];
+
+export function isChannelNotification(
+ notification: UnifiedNotification
+): notification is UnifiedNotification & {
+ notification_event_type: ChannelNotificationType;
+} {
+ return CHANNEL_NOTIFICATION_TYPES.includes(
+ notification.notification_event_type as ChannelNotificationType
+ );
+}
diff --git a/js/app/packages/app/component/command/CommandMenu.tsx b/js/app/packages/app/component/command/CommandMenu.tsx
index e00a6c345a..d10c41c299 100644
--- a/js/app/packages/app/component/command/CommandMenu.tsx
+++ b/js/app/packages/app/component/command/CommandMenu.tsx
@@ -34,7 +34,7 @@ import { debouncedDependent } from '@core/util/debounce';
import { Hotkey } from '@core/component/Hotkey';
import { InlineEntity, type EntityData } from '@entity';
import { globalSplitManager } from '@app/signal/splitLayout';
-import { createIsActiveSplitContentMemo } from '../split-layout/layoutUtils';
+import { isListViewID } from '@app/constants/list-views';
const CATEGORIES: { id: CategoryFilter; label: string }[] = [
{ id: 'all', label: 'All' },
@@ -65,11 +65,7 @@ export function CommandMenu() {
const [commandMenuRef, setCommandMenuRef] = createSignal<HTMLDivElement>();
const splitManager = globalSplitManager();
const isListMode = splitManager
- ? createIsActiveSplitContentMemo(
- splitManager.activeSplit,
- 'component',
- 'unified-list'
- )
+ ? () => isListViewID(splitManager.activeSplit()?.content().id)
: () => true; // assume list mode
createEffect(() => {
diff --git a/js/app/packages/app/component/mobile/MobileDock.tsx b/js/app/packages/app/component/mobile/MobileDock.tsx
index fa58c8c3fa..42dbf32c8f 100644
--- a/js/app/packages/app/component/mobile/MobileDock.tsx
+++ b/js/app/packages/app/component/mobile/MobileDock.tsx
@@ -4,12 +4,11 @@ import WideFolder from '@macro-icons/wide/folder.svg';
import WidePlus from '@macro-icons/wide/plus.svg';
import WideTask from '@macro-icons/wide/task.svg';
import { impactFeedback } from '@tauri-apps/plugin-haptics';
-import { batch, type Component, type JSX } from 'solid-js';
+import type { Component, JSX } from 'solid-js';
import { cn } from '@ui/utils/classname';
import { setCreateMenuOpen } from '../Launcher';
import { useSplitPanelOrThrow } from '../split-layout/layoutUtils';
import { useSoup } from '@app/component/next-soup/soup-context';
-import type { FilterID } from '@app/component/next-soup/filters/filters';
type MobileDockButtonProps = {
icon: Component<JSX.SvgSVGAttributes<SVGSVGElement>>;
@@ -69,26 +68,16 @@ export function MobileDock() {
!isTasksActive() &&
splitIsUnifiedList();
- const activateFilter = (filter: FilterID) => {
- soup.filters.activate(filter);
- };
-
- const toggleSignalFilter = (value: boolean) => {
+ const setSignalFilter = (value: boolean) => {
// If we're going to be removing the signal filter,
// we should replace it with the explicit-noise filter
if (!value) {
- activateFilter('explicit-noise');
- soup.filters.deactivate('not-done');
+ soup.filters.set({ and: ['explicit-noise'] });
} else {
- activateFilter('signal');
- activateFilter('not-done');
+ soup.filters.set({ and: ['signal', 'not-done'] });
}
};
- const clearSearchFilters = () => {
- soup.filters.clear();
- };
-
return (
<div class="flex flex-row justify-between bg-page border-t border-edge-muted">
<MobileDockButton
@@ -97,7 +86,7 @@ export function MobileDock() {
active={isAllActive()}
onClick={() => {
ensureUnifiedList();
- clearSearchFilters();
+ soup.filters.clear();
}}
/>
<MobileDockButton
@@ -106,10 +95,7 @@ export function MobileDock() {
active={isInboxActive()}
onClick={() => {
ensureUnifiedList();
- batch(() => {
- clearSearchFilters();
- toggleSignalFilter(true);
- });
+ setSignalFilter(true);
}}
/>
<MobileDockButton
@@ -118,10 +104,7 @@ export function MobileDock() {
active={isPeopleTeamsActive()}
onClick={() => {
ensureUnifiedList();
- batch(() => {
- toggleSignalFilter(false);
- activateFilter('channels');
- });
+ soup.filters.set({ and: ['explicit-noise', 'channels'] });
}}
/>
<MobileDockButton
@@ -130,10 +113,7 @@ export function MobileDock() {
active={isTasksActive()}
onClick={() => {
ensureUnifiedList();
- batch(() => {
- toggleSignalFilter(false);
- activateFilter('task');
- });
+ soup.filters.set({ and: ['explicit-noise', 'task'] });
}}
/>
<MobileDockButton
diff --git a/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts b/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
index 2bfdd2ec67..650ebb061e 100644
--- a/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
+++ b/js/app/packages/app/component/next-soup/actions/use-entity-action-hotkeys.ts
@@ -19,6 +19,7 @@ import { createHotkeyGroup, registerHotkey } from '@core/hotkey/hotkeys';
import type { SplitHandle } from '@app/component/split-layout/layoutManager';
import { openEntityInSplitFromUnifiedList } from '@app/component/next-soup/utils';
import { onCleanup } from 'solid-js';
+import { isListViewID } from '@app/constants/list-views';
type UseEntityActionHotkeysOptions = {
scopeId: string;
@@ -61,7 +62,7 @@ export const useEntityActionHotkeys = (
const getEntitiesForAction = (): EntityData[] => {
if (
splitHandle?.content().type === 'component' &&
- splitHandle?.content().id === 'unified-list'
+ isListViewID(splitHandle?.content().id)
) {
const selected = soup.selection.selected();
if (selected.length > 0) return selected;
diff --git a/js/app/packages/app/component/next-soup/create-soup-state.ts b/js/app/packages/app/component/next-soup/create-soup-state.ts
index b0c8477941..cd7bf6c372 100644
--- a/js/app/packages/app/component/next-soup/create-soup-state.ts
+++ b/js/app/packages/app/component/next-soup/create-soup-state.ts
@@ -1,15 +1,16 @@
+import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import { createSortState } from '@app/component/next-soup/create-sort-state';
import {
createFilterState,
+ createSoupFilters,
+ SOUP_FILTER_GROUPS,
type FilterConfig,
+ type FilterGroupConfig,
+ type FilterID,
} from '@app/component/next-soup/filters';
-import {
- FILTER_GROUPS,
- type FilterGroup,
- SOUP_FILTERS,
-} from '@app/component/next-soup/filters/filters';
import { createSelectionState } from '@app/component/next-soup/selection-state';
import { SORT_CONFIGS } from '@app/component/next-soup/soup-view/sort-options';
+import { useUserContext } from '@core/context/user';
import { isModality } from '@core/mobile/inputModality';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import type { EntityData, WithSearch } from '@entity';
@@ -29,36 +30,36 @@ export type SortConfig<T> = {
fn: (a: T, b: T) => number;
};
-interface SoupContextOptions<
- TFilter extends Readonly<FilterConfig<SoupEntity>>,
-> {
+interface SoupContextOptions<TId extends string = FilterID> {
initialData?: SoupEntity[];
- initialFilters?: TFilter['id'][];
- filterConfigs?: TFilter[];
- filterGroups?: FilterGroup[];
+ initialFilters?: TId[];
+ filterConfigs?: FilterConfig<SoupEntity>[];
+ filterGroups?: FilterGroupConfig[];
wrapNavigation?: boolean;
}
-export const createSoupState = <
- TFilter extends Readonly<FilterConfig<SoupEntity>>,
->(
- {
+export const createSoupState = <TId extends string = FilterID>(
+ options: SoupContextOptions<TId> = { wrapNavigation: false }
+) => {
+ const {
wrapNavigation,
initialData,
initialFilters,
filterConfigs,
filterGroups,
- }: SoupContextOptions<TFilter> = {
- wrapNavigation: false,
- }
-) => {
+ } = options;
+
const selection = createSelectionState<SoupEntity>({
getItemId: (i) => i.id,
});
- const filters = createFilterState<SoupEntity, FilterConfig<SoupEntity>>({
- filters: filterConfigs ?? SOUP_FILTERS,
- groups: filterGroups ?? FILTER_GROUPS,
+ const notificationSource = useGlobalNotificationSource();
+ const user = useUserContext();
+
+ const filters = createFilterState({
+ filters:
+ filterConfigs ?? createSoupFilters(notificationSource, user.userId),
+ groups: filterGroups ?? SOUP_FILTER_GROUPS,
initialFilters,
});
diff --git a/js/app/packages/app/component/next-soup/filters/create-filter-state.ts b/js/app/packages/app/component/next-soup/filters/create-filter-state.ts
index 8cec885e21..5235f30fce 100644
--- a/js/app/packages/app/component/next-soup/filters/create-filter-state.ts
+++ b/js/app/packages/app/component/next-soup/filters/create-filter-state.ts
@@ -1,9 +1,9 @@
import { createMemo, createSignal, type Accessor } from 'solid-js';
-export type FilterPredicate<T> = (entity: T, ...args: any[]) => boolean;
+export type FilterPredicate<T> = (entity: T) => boolean;
-export type FilterConfig<T> = {
- readonly id: string;
+export type FilterConfig<T, TId extends string = string> = {
+ readonly id: TId;
readonly predicate: FilterPredicate<T>;
readonly group?: string;
};
@@ -13,174 +13,251 @@ export type FilterGroupConfig = {
readonly allowMultiple?: boolean;
};
-export type CreateFilterStateOptions<T, TFilter extends FilterConfig<T>> = {
+type FilterIdInput<TId extends string> = TId | (string & {});
+
+export type SetFiltersInput<
+ TFilter extends FilterConfig<unknown>,
+ TId extends string = TFilter['id'],
+> = {
+ /** Filters that must ALL pass (AND logic) */
+ readonly and?: readonly (TFilter | FilterIdInput<TId>)[];
+ /** Filters where ANY must pass (OR logic) */
+ readonly or?: readonly (TFilter | FilterIdInput<TId>)[];
+};
+
+export type CurrentFilterState<TId extends string> = {
+ readonly andIds: readonly TId[];
+ readonly orIds: readonly TId[];
+};
+
+/**
+ * Callback function for updating filters based on current state.
+ */
+export type SetFiltersCallback<
+ TFilter extends FilterConfig<unknown>,
+ TId extends string,
+> = (current: CurrentFilterState<TId>) => SetFiltersInput<TFilter, TId>;
+
+/** Internal representation of active filters */
+type ActiveFiltersState<TFilter> = {
+ readonly andFilters: readonly TFilter[];
+ readonly orFilters: readonly TFilter[];
+};
+
+export type FilterStateOptions<T, TFilter extends FilterConfig<T, string>> = {
/** All available filter configurations */
readonly filters: readonly TFilter[];
- /** Filter group configurations */
+ /** Filter group configurations for controlling mutual exclusivity */
readonly groups?: readonly FilterGroupConfig[];
- /** Initial active filter IDs */
+ /** Initial active filter IDs (applied as AND filters) */
readonly initialFilters?: readonly string[];
- /** Callback when filters change */
- readonly onChange?: (filters: TFilter[]) => void;
};
-/** Filter state return type */
-export type FilterState<T, TFilter extends FilterConfig<T>> = {
- /** Currently active filter configs */
- readonly active: Accessor<TFilter[]>;
+export type FilterState<
+ T,
+ TFilter extends FilterConfig<T, string>,
+ TId extends string = TFilter['id'],
+> = {
+ /** Currently active AND filter configs */
+ readonly andFilters: Accessor<readonly TFilter[]>;
+ /** Currently active OR filter configs */
+ readonly orFilters: Accessor<readonly TFilter[]>;
+ /** All currently active filter configs (both AND and OR) */
+ readonly active: Accessor<readonly TFilter[]>;
/** IDs of currently active filters */
- readonly activeIds: Accessor<string[]>;
+ readonly activeIds: Accessor<readonly TId[]>;
/** Check if a filter is active by ID */
- readonly isActive: (id: string) => boolean;
- /** Toggle a filter on/off */
- readonly toggle: (id: string) => void;
- /** Set a filter as active (respecting group exclusivity) */
- readonly activate: (id: string) => void;
- /** Remove a filter from active filters */
- readonly deactivate: (id: string) => void;
+ readonly isActive: (id: FilterIdInput<TId>) => boolean;
/** Clear all active filters */
readonly clear: () => void;
- /** Set filters directly */
- readonly set: (filters: TFilter[]) => void;
+ /** Toggle filters on/off. Respects group exclusivity. */
+ readonly toggle: (
+ input: SetFiltersInput<TFilter, TId> | SetFiltersCallback<TFilter, TId>
+ ) => void;
+ /** Set filters with explicit AND/OR grouping. Replaces all current filters. */
+ readonly set: (
+ input: SetFiltersInput<TFilter, TId> | SetFiltersCallback<TFilter, TId>
+ ) => void;
/** Get a filter config by ID */
- readonly getFilter: (id: string) => TFilter | undefined;
+ readonly getFilter: (id: FilterIdInput<TId>) => TFilter | undefined;
/** All available filter configs */
readonly available: readonly TFilter[];
+ /** Test if an entity passes the active filters. */
+ readonly test: (entity: T) => boolean;
};
-/**
- * Creates reactive filter state.
- *
- * Handles filter toggling with group-based mutual exclusivity:
- * - Filters without a group can be combined freely
- * - Filters with a group replace other filters in the same group
- *
- * @example
- * ```ts
- * const filters = createFilterState({
- * filters: SOUP_FILTERS,
- * initialFilters: ['signal'],
- * onChange: (filters) => console.log('Filters changed:', filters),
- * });
- *
- * // Toggle a filter
- * filters.toggle('email');
- *
- * // Check active state
- * const isEmailActive = filters.isActive('email');
- *
- * // Get active filter configs for predicates
- * const activeFilters = filters.active();
- * ```
- */
-export function createFilterState<T, TFilter extends FilterConfig<T>>(
- options: CreateFilterStateOptions<T, TFilter>
-): FilterState<T, TFilter> {
+export function createFilterState<
+ T,
+ TFilter extends FilterConfig<T>,
+ TId extends string = TFilter['id'],
+>(options: FilterStateOptions<T, TFilter>): FilterState<T, TFilter, TId> {
const {
filters: availableFilters,
groups = [],
initialFilters = [],
- onChange,
} = options;
const filterMap = new Map<string, TFilter>(
availableFilters.map((f) => [f.id, f])
);
+
const groupMap = new Map<string, FilterGroupConfig>(
groups.map((g) => [g.id, g])
);
- // Initialize with initial filters
- const initialActiveFilters = initialFilters
+ // Initialize with initial filters (as AND filters)
+ const initialAndFilters = initialFilters
.map((id) => filterMap.get(id))
.filter((f): f is TFilter => f !== undefined);
- const [activeFilters, setActiveFilters] =
- createSignal<TFilter[]>(initialActiveFilters);
+ const [state, setState] = createSignal<ActiveFiltersState<TFilter>>({
+ andFilters: initialAndFilters,
+ orFilters: [],
+ });
- // Computed: active filter IDs
- const activeIds = createMemo(() => activeFilters().map((f) => f.id));
+ const andFilters = createMemo(() => state().andFilters);
+ const orFilters = createMemo(() => state().orFilters);
- // Helper: get filter by ID
- const getFilter = (id: string): TFilter | undefined => filterMap.get(id);
+ const active = createMemo(() => [
+ ...state().andFilters,
+ ...state().orFilters,
+ ]);
+ const activeIds = createMemo(() => active().map((f) => f.id) as TId[]);
- // Helper: check if filter is active
- const isActive = (id: string): boolean => activeIds().includes(id);
+ const getFilter = (id: FilterIdInput<TId>): TFilter | undefined =>
+ filterMap.get(id);
- // Helper: update filters with onChange callback
- const updateFilters = (next: TFilter[]) => {
- setActiveFilters(next);
- onChange?.(next);
- };
+ const isActive = (id: FilterIdInput<TId>): boolean =>
+ activeIds().includes(id as TId);
- // Activate a filter (respecting group exclusivity based on allowMultiple)
- const activate = (id: string) => {
- const config = getFilter(id);
- if (!config) {
- console.warn(`Filter not found: ${id}`);
- return;
+ const resolveFilters = (
+ input: readonly (TFilter | FilterIdInput<TId>)[] | undefined
+ ): TFilter[] => {
+ if (!input) return [];
+
+ const resolved: TFilter[] = [];
+ for (const item of input) {
+ if (typeof item === 'string') {
+ const filter = getFilter(item);
+ if (filter) resolved.push(filter);
+ } else {
+ resolved.push(item);
+ }
}
+ return resolved;
+ };
- // Already active, nothing to do
- if (isActive(id)) return;
+ const set = (
+ input: SetFiltersInput<TFilter, TId> | SetFiltersCallback<TFilter, TId>
+ ) => {
+ const resolved =
+ typeof input === 'function'
+ ? input({
+ andIds: state().andFilters.map((f) => f.id) as TId[],
+ orIds: state().orFilters.map((f) => f.id) as TId[],
+ })
+ : input;
- const current = activeFilters();
+ const newState: ActiveFiltersState<TFilter> = {
+ andFilters: resolveFilters(resolved.and),
+ orFilters: resolveFilters(resolved.or),
+ };
+ setState(newState);
+ };
- if (config.group) {
- const groupConfig = groupMap.get(config.group);
- const allowMultiple = groupConfig?.allowMultiple ?? false;
+ const toggleFilters = (
+ currentFilters: readonly TFilter[],
+ toToggle: readonly TFilter[]
+ ): TFilter[] => {
+ let result = [...currentFilters];
- if (allowMultiple) {
- // Allow multiple selections in this group
- updateFilters([...current, config]);
+ for (const filter of toToggle) {
+ const isCurrentlyActive = result.some((f) => f.id === filter.id);
+
+ if (isCurrentlyActive) {
+ // Deactivate
+ result = result.filter((f) => f.id !== filter.id);
} else {
- // Mutual exclusivity: remove other filters in same group
- const withoutSameGroup = current.filter(
- (f) => f.group !== config.group
- );
- updateFilters([...withoutSameGroup, config]);
+ // Activate - handle group exclusivity based on allowMultiple
+ if (filter.group) {
+ const groupConfig = groupMap.get(filter.group);
+ const allowMultiple = groupConfig?.allowMultiple ?? false;
+
+ if (!allowMultiple) {
+ // Remove other filters in the same group
+ result = result.filter((f) => f.group !== filter.group);
+ }
+ }
+ result.push(filter);
}
- } else {
- // No group, just add
- updateFilters([...current, config]);
}
- };
- // Deactivate a filter
- const deactivate = (id: string) => {
- if (!isActive(id)) return;
- updateFilters(activeFilters().filter((f) => f.id !== id));
+ return result;
};
- // Toggle a filter on/off
- const toggle = (id: string) => {
- if (isActive(id)) {
- deactivate(id);
- } else {
- activate(id);
- }
+ const toggle = (
+ input: SetFiltersInput<TFilter, TId> | SetFiltersCallback<TFilter, TId>
+ ) => {
+ const resolved =
+ typeof input === 'function'
+ ? input({
+ andIds: state().andFilters.map((f) => f.id) as TId[],
+ orIds: state().orFilters.map((f) => f.id) as TId[],
+ })
+ : input;
+
+ const andToToggle = resolveFilters(resolved.and);
+ const orToToggle = resolveFilters(resolved.or);
+
+ const current = state();
+
+ setState({
+ andFilters: toggleFilters(current.andFilters, andToToggle),
+ orFilters: toggleFilters(current.orFilters, orToToggle),
+ });
};
- // Clear all filters
const clear = () => {
- updateFilters([]);
+ setState({
+ andFilters: [],
+ orFilters: [],
+ });
};
- // Set filters directly
- const set = (filters: TFilter[]) => {
- updateFilters(filters);
+ const test = (entity: T): boolean => {
+ const { andFilters: andList, orFilters: orList } = state();
+
+ // If no filters are active, everything passes
+ if (andList.length === 0 && orList.length === 0) {
+ return true;
+ }
+
+ // All AND filters must pass
+ if (andList.length > 0) {
+ const passesAnd = andList.every((f) => f.predicate(entity));
+ if (!passesAnd) return false;
+ }
+
+ // At least one OR filter must pass (if any OR filters are active)
+ if (orList.length > 0) {
+ const passesOr = orList.some((f) => f.predicate(entity));
+ if (!passesOr) return false;
+ }
+
+ return true;
};
return {
- active: activeFilters,
+ andFilters,
+ orFilters,
+ active,
activeIds,
isActive,
toggle,
- activate,
- deactivate,
clear,
set,
getFilter,
available: availableFilters,
+ test,
};
}
diff --git a/js/app/packages/app/component/next-soup/filters/filters.ts b/js/app/packages/app/component/next-soup/filters/filters.ts
index cf76c6f100..a6c5e1cc43 100644
--- a/js/app/packages/app/component/next-soup/filters/filters.ts
+++ b/js/app/packages/app/component/next-soup/filters/filters.ts
@@ -1,4 +1,15 @@
-import { isTaskEntity, type EntityData, type WithNotification } from '@entity';
+import {
+ getEntityProjectId,
+ getTaskAssigneeIds,
+ isTaskEntity,
+ type TaskEntityWithProperties,
+ type EntityData,
+ type WithNotification,
+ isChannelEntity,
+ isChatEntity,
+ isDocumentEntity,
+ isEmailEntity,
+} from '@entity';
import {
signalFilter,
noiseFilter,
@@ -9,9 +20,12 @@ import {
getIconConfig,
} from '@core/component/EntityIcon';
import type { SoupBody, SoupItemsQueryFilters } from '@queries/soup/items';
-import type { SoupApiItem } from '@service-storage/generated/schemas';
+import type {
+ SoupApiItem,
+ SoupProperty,
+} from '@service-storage/generated/schemas';
import { codeFileExtensions } from '@block-code/util/languageSupport';
-import type { FilterConfig } from './create-filter-state';
+import type { FilterConfig, FilterGroupConfig } from './create-filter-state';
import type { Component } from 'solid-js';
import { AnimatedChannelIcon } from '@macro-icons/wide/animating/channel';
import { AnimatedChatIcon } from '@macro-icons/wide/animating/chat';
@@ -22,23 +36,25 @@ import { AnimatedStarIcon } from '@macro-icons/wide/animating/star';
import { AnimatedTaskIcon } from '@macro-icons/wide/animating/task';
import { ChannelTypeEnum } from '@service-comms/client';
import { match } from 'ts-pattern';
+import { compositeEntity, type NotificationSource } from '@notifications';
+import {
+ PROPERTY_OPTION_IDS,
+ SYSTEM_PROPERTY_IDS,
+} from '@core/component/Properties/constants';
export const NIL_UUID = '00000000-0000-0000-0000-000000000000';
-/**
- * Array containing NIL_UUID, used to exclude an entity type from query results.
- *
- * @example
- * ```ts
- * filters.set({
- * query: {
- * chat_filters: { chat_ids: EXCLUDE }, // Exclude all chats
- * }
- * });
- * ```
- */
export const EXCLUDE: string[] = [NIL_UUID];
+/** Base filter that excludes all entity types by default */
+export const QUERY_FILTERS_BASE: SoupItemsQueryFilters = {
+ channel_filters: { channel_ids: EXCLUDE },
+ chat_filters: { chat_ids: EXCLUDE },
+ document_filters: { document_ids: EXCLUDE },
+ email_filters: { recipients: EXCLUDE },
+ project_filters: { project_ids: EXCLUDE },
+};
+
function isIdFilteredOut(ids: string[] | undefined, value: string): boolean {
if (!ids || ids.length === 0) return false;
return !ids.includes(value);
@@ -76,6 +92,8 @@ export function filterSoupItemByRequestBody(
.exhaustive();
}
+type EntityFilterConfig = FilterConfig<EntityData> & { label?: string };
+
/**
* Unread filter - entity has unread content.
*
@@ -83,11 +101,16 @@ export function filterSoupItemByRequestBody(
* - Emails: Uses `isRead` boolean field
* - Everything else: Has at least one notification with viewedAt === null
*/
-export function unreadFilter(entity: EnhancedEntity): boolean {
- if (entity.type === 'email') {
- return !entity.isRead;
- }
- return entity.notifications?.()?.some((n) => !n.viewed_at) ?? false;
+export function unreadFilter(notificationSource: NotificationSource) {
+ return function (entity: EnhancedEntity): boolean {
+ if (entity.type === 'email') {
+ return !entity.isRead;
+ }
+ const notifications =
+ notificationSource.notificationsByEntity()[compositeEntity(entity)];
+
+ return notifications?.some((n) => !n.viewed_at) ?? false;
+ };
}
/**
@@ -97,27 +120,18 @@ export function unreadFilter(entity: EnhancedEntity): boolean {
* - Emails: Uses `done` field (derived from !inboxVisible - email is "not done" when in inbox)
* - Everything else: Has at least one notification with done === false
*/
-export function notDoneFilter(entity: WithNotification<EntityData>) {
- if (entity.type === 'email') return !entity.done;
- // Tasks are handled by signalFilter based on assignee/status, not notifications
- if (isTaskEntity(entity)) return true;
+export function notDoneFilter(notificationSource: NotificationSource) {
+ return function (entity: WithNotification<EntityData>) {
+ if (entity.type === 'email') return !entity.done;
+ // Tasks are handled by signalFilter based on assignee/status, not notifications
+ if (isTaskEntity(entity)) return true;
- return (
- !!entity.notifications && entity.notifications().some(({ done }) => !done)
- );
-}
+ const notifications =
+ notificationSource.notificationsByEntity()[compositeEntity(entity)];
-/** Filter group configuration */
-export type FilterGroup = {
- readonly id: string;
- readonly allowMultiple?: boolean;
-};
-
-/** Filter group configurations */
-export const FILTER_GROUPS: readonly FilterGroup[] = [
- { id: 'focus', allowMultiple: false },
- { id: 'type', allowMultiple: false },
-];
+ return notifications?.some(({ done }) => !done);
+ };
+}
type EnhancedEntity = WithNotification<EntityData>;
@@ -170,91 +184,757 @@ export function channelsFilter(entity: EntityData): boolean {
return entity.type === 'channel';
}
-export const SOUP_FILTERS = [
- // Focus filters (mutually exclusive)
- {
- id: 'signal',
- label: 'Inbox',
- predicate: signalFilter,
- group: 'focus',
- },
- {
- id: 'noise',
- label: 'Other',
- predicate: noiseFilter,
- group: 'focus',
- },
- {
- id: 'explicit-noise',
- label: 'Explicit Noise',
- predicate: (entity: EntityData) => !explicitNoiseFilter(entity),
- group: 'focus',
- },
+export function filesAndFolderFilter(entity: EntityData): boolean {
+ if (entity.type !== 'project' && entity.type !== 'document') return false;
- // Notification filters
- {
- id: 'unread',
- label: 'Unread',
- predicate: unreadFilter,
- },
- {
- id: 'not-done',
- label: 'Not done',
- predicate: notDoneFilter,
- },
+ if (entity.type === 'document') {
+ const fileType = entity.fileType ?? '';
+ return !['md', 'canvas'].includes(fileType);
+ }
+
+ return true;
+}
+
+export function activeAgentFilter(entity: EntityData): boolean {
+ if (entity.type !== 'chat') return false;
+
+ // [TODO] Check status of agent
+ return true;
+}
+
+export function emailDraftsFilter(entity: EntityData): boolean {
+ if (entity.type !== 'email') return false;
+
+ return entity.isDraft;
+}
+
+export function noDraftsFilter(entity: EntityData): boolean {
+ if (entity.type !== 'email') return false;
+
+ return !entity.isDraft;
+}
+
+export function hasCalendarInviteFilter(entity: EntityData): boolean {
+ if (entity.type !== 'email') return false;
+
+ return entity.hasIcsAttachment === true;
+}
+
+export function hasAttachmentFilter(entity: EntityData): boolean {
+ if (entity.type !== 'email') return false;
+
+ return (entity.attachments?.length ?? 0) > 0;
+}
+
+const PDF_MIME_TYPES = ['application/pdf'];
+const IMAGE_MIME_TYPES = [
+ 'image/png',
+ 'image/jpeg',
+ 'image/gif',
+ 'image/webp',
+ 'image/svg+xml',
+];
+const DOCUMENT_MIME_TYPES = [
+ 'application/msword',
+ 'application/vnd.openxmlformats-officedocument.wordprocessingml.document',
+ 'application/vnd.ms-excel',
+ 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
+ 'application/vnd.ms-powerpoint',
+ 'application/vnd.openxmlformats-officedocument.presentationml.presentation',
+ 'text/plain',
+ 'text/csv',
+];
+
+function hasAttachmentOfType(entity: EntityData, mimeTypes: string[]): boolean {
+ if (entity.type !== 'email') return false;
+ if (!entity.attachments?.length) return false;
+
+ return entity.attachments.some((a) => {
+ if (!a.mimeType) return false;
+ return mimeTypes.some((type) => a.mimeType?.startsWith(type));
+ });
+}
+
+export function hasPdfAttachmentFilter(entity: EntityData): boolean {
+ return hasAttachmentOfType(entity, PDF_MIME_TYPES);
+}
+
+export function hasImageAttachmentFilter(entity: EntityData): boolean {
+ return hasAttachmentOfType(entity, IMAGE_MIME_TYPES);
+}
+
+export function hasDocumentAttachmentFilter(entity: EntityData): boolean {
+ return hasAttachmentOfType(entity, DOCUMENT_MIME_TYPES);
+}
+
+export function sharedEntity(getUserID: () => string | undefined) {
+ return function (entity: EntityData): boolean {
+ const userID = getUserID();
+ if (userID == null) return false;
+ return entity.ownerId !== userID;
+ };
+}
+
+/** Filter for agents (chats) owned by the current user */
+export function ownedAgentFilter(getUserID: () => string | undefined) {
+ return function (entity: EntityData): boolean {
+ if (entity.type !== 'chat') return false;
+ const userID = getUserID();
+ if (userID == null) return false;
+
+ return entity.ownerId === userID;
+ };
+}
+
+/** Filter for agents (chats) shared with the current user (owned by someone else) */
+export function sharedAgentFilter(getUserID: () => string | undefined) {
+ return function (entity: EntityData): boolean {
+ if (entity.type !== 'chat') return false;
+ const userID = getUserID();
+ if (userID == null) return false;
+
+ return entity.ownerId !== userID;
+ };
+}
+
+export function taskAssignedToUserFilter(getUserID: () => string | undefined) {
+ return function (entity: EntityData): boolean {
+ const userID = getUserID();
+ if (!isTaskEntity(entity) || userID == null) return false;
+
+ const taskEntity = entity as unknown as TaskEntityWithProperties;
+ return getTaskAssigneeIds(taskEntity).includes(userID);
+ };
+}
+
+export function hasProperties(
+ entity: EntityData
+): entity is EntityData & { properties: SoupProperty[] } {
+ return 'properties' in entity && Array.isArray(entity.properties);
+}
+
+export function getPropertyById(
+ entity: EntityData,
+ propertyId: string
+): SoupProperty | undefined {
+ if (!hasProperties(entity)) return undefined;
+
+ return entity.properties.find((p) => p.definition.id === propertyId);
+}
+
+export function hasAssignees(entity: EntityData): boolean {
+ if (!isTaskEntity(entity)) return false;
+ return getTaskAssigneeIds(entity).length > 0;
+}
+
+export function isAssignedTo(entity: EntityData, userId: string): boolean {
+ if (!isTaskEntity(entity)) return false;
+
+ const assigneeIds = getTaskAssigneeIds(entity);
+ // If no assignees, consider it assigned to everyone (or unassigned)
+ if (assigneeIds.length === 0) return false;
+ return assigneeIds.includes(userId);
+}
+
+export function isUnassigned(entity: EntityData): boolean {
+ if (!isTaskEntity(entity)) return false;
+ return getTaskAssigneeIds(entity).length === 0;
+}
+
+export function getStatusOptionId(entity: EntityData): string | undefined {
+ if (!isTaskEntity(entity)) return undefined;
+ const taskWithProps = entity as TaskEntityWithProperties;
+
+ const properties = taskWithProps.properties;
+
+ if (!properties) return undefined;
+
+ const statusProperty = properties.find(
+ (p) => p.definition.id === SYSTEM_PROPERTY_IDS.STATUS
+ );
+
+ if (!statusProperty?.value) return undefined;
+
+ const value = statusProperty.value;
+
+ if (value.type === 'SelectOption') {
+ return value.value[0];
+ }
+
+ return undefined;
+}
+
+export function hasStatus(entity: EntityData, statusOptionId: string): boolean {
+ return getStatusOptionId(entity) === statusOptionId;
+}
+
+export function isNotStarted(entity: EntityData): boolean {
+ return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.NOT_STARTED);
+}
+
+export function isInProgress(entity: EntityData): boolean {
+ return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS);
+}
+
+export function isInReview(entity: EntityData): boolean {
+ return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.IN_REVIEW);
+}
+
+export function isCompleted(entity: EntityData): boolean {
+ if (!isTaskEntity(entity)) return false;
+ // Check both the subType flag and status property
+ if (entity.subType?.is_completed) return true;
+ return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.COMPLETED);
+}
+
+export function isCanceled(entity: EntityData): boolean {
+ return hasStatus(entity, PROPERTY_OPTION_IDS.STATUS.CANCELED);
+}
+
+export function isClosed(entity: EntityData): boolean {
+ return isCompleted(entity) || isCanceled(entity);
+}
+
+export function isOpen(entity: EntityData): boolean {
+ if (!isTaskEntity(entity)) return false;
+ return !isClosed(entity);
+}
+
+export function getPriorityOptionId(entity: EntityData): string | undefined {
+ if (!isTaskEntity(entity)) return undefined;
+ const taskWithProps = entity as TaskEntityWithProperties;
+
+ const properties = taskWithProps.properties;
+
+ if (!properties) return undefined;
+
+ const priorityProperty = properties.find(
+ (p) => p.definition.id === SYSTEM_PROPERTY_IDS.PRIORITY
+ );
+
+ if (!priorityProperty?.value) return undefined;
+
+ const value = priorityProperty.value;
+
+ if (value.type === 'SelectOption') {
+ return value.value[0];
+ }
+
+ return undefined;
+}
+
+export function hasPriority(
+ entity: EntityData,
+ priorityOptionId: string
+): boolean {
+ return getPriorityOptionId(entity) === priorityOptionId;
+}
+
+export function isUrgentPriority(entity: EntityData): boolean {
+ return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.URGENT);
+}
+
+export function isHighPriority(entity: EntityData): boolean {
+ return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.HIGH);
+}
+
+export function isMediumPriority(entity: EntityData): boolean {
+ return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.MEDIUM);
+}
+
+export function isLowPriority(entity: EntityData): boolean {
+ return hasPriority(entity, PROPERTY_OPTION_IDS.PRIORITY.LOW);
+}
+
+export function hasNoPriority(entity: EntityData): boolean {
+ if (!isTaskEntity(entity)) return false;
+ return getPriorityOptionId(entity) === undefined;
+}
+
+export const ENTITY_TYPE_FILTER_CONFIGS = [
// Entity type filters (mutually exclusive)
{
id: 'document',
label: 'Docs',
predicate: documentFilter,
- group: 'type',
+ group: 'entity-type',
},
{
id: 'agent',
label: 'Agents',
predicate: agentFilter,
- group: 'type',
+ group: 'entity-type',
},
{
id: 'people',
label: 'People',
predicate: peopleFilter,
- group: 'type',
+ group: 'entity-type',
},
{
id: 'teams',
label: 'Teams',
predicate: teamsFilter,
- group: 'type',
+ group: 'entity-type',
},
{
id: 'task',
label: 'Tasks',
predicate: taskFilter,
- group: 'type',
+ group: 'entity-type',
},
{
id: 'email',
label: 'Mail',
predicate: emailFilter,
- group: 'type',
+ group: 'entity-type',
},
{
id: 'file',
label: 'Files',
predicate: fileFilter,
- group: 'type',
+ group: 'entity-type',
},
+] as const;
+
+export const EMAIL_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [
{
- id: 'channels',
- label: 'Channels',
- predicate: channelsFilter,
- group: 'type',
+ id: 'email-unread',
+ label: 'Unread',
+ predicate: (entity) => isEmailEntity(entity) && !entity.isRead,
},
-] as const;
+ {
+ id: 'email-read',
+ label: 'Read',
+ predicate: (entity) => isEmailEntity(entity) && entity.isRead,
+ },
+ {
+ id: 'email-done',
+ label: 'Done',
+ predicate: (entity) => isEmailEntity(entity) && entity.done,
+ },
+ {
+ id: 'email-not-done',
+ label: 'Not Done',
+ predicate: (entity) => isEmailEntity(entity) && !entity.done,
+ },
+];
+
+export const TASK_STATUS_FILTERS: EntityFilterConfig[] = [
+ {
+ id: 'task-not-started',
+ label: 'Not Started',
+ predicate: isNotStarted,
+ },
+ {
+ id: 'task-in-progress',
+ label: 'In Progress',
+ predicate: isInProgress,
+ },
+ {
+ id: 'task-in-review',
+ label: 'In Review',
+ predicate: isInReview,
+ },
+ {
+ id: 'task-completed',
+ label: 'Completed',
+ predicate: isCompleted,
+ },
+ {
+ id: 'task-canceled',
+ label: 'Canceled',
+ predicate: isCanceled,
+ },
+];
+
+export const TASK_PRIORITY_FILTERS: EntityFilterConfig[] = [
+ {
+ id: 'task-critical',
+ label: 'Critical',
+ predicate: isUrgentPriority,
+ },
+ {
+ id: 'task-high-priority',
+ label: 'High Priority',
+ predicate: isHighPriority,
+ },
+ {
+ id: 'task-medium-priority',
+ label: 'Medium Priority',
+ predicate: isMediumPriority,
+ },
+ {
+ id: 'task-low-priority',
+ label: 'Low Priority',
+ predicate: isLowPriority,
+ },
+ {
+ id: 'task-no-priority',
+ label: 'No Priority',
+ predicate: hasNoPriority,
+ },
+];
+
+export const TASK_ASSIGNEE_FILTERS: EntityFilterConfig[] = [
+ {
+ id: 'task-has-assignee',
+ label: 'Has Assignee',
+ predicate: hasAssignees,
+ },
+ {
+ id: 'task-unassigned',
+ label: 'Unassigned',
+ predicate: isUnassigned,
+ },
+];
+
+export const TASK_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [
+ ...TASK_STATUS_FILTERS,
+ ...TASK_PRIORITY_FILTERS,
+ ...TASK_ASSIGNEE_FILTERS,
+];
+
+export const DOCUMENT_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [
+ {
+ id: 'doc-recent',
+ label: 'Recently Edited',
+ predicate: (entity) => {
+ if (!isDocumentEntity(entity)) return false;
+ const updatedAt = entity.updatedAt
+ ? new Date(entity.updatedAt)
+ : undefined;
+ if (!updatedAt) return false;
+ const dayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);
+ return updatedAt > dayAgo;
+ },
+ },
+ {
+ id: 'doc-edited-this-week',
+ label: 'Edited This Week',
+ predicate: (entity) => {
+ if (!isDocumentEntity(entity)) return false;
+ const updatedAt = entity.updatedAt
+ ? new Date(entity.updatedAt)
+ : undefined;
+ if (!updatedAt) return false;
+ const weekAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
+ return updatedAt > weekAgo;
+ },
+ },
+ {
+ id: 'in-folder',
+ label: 'In Folder',
+ predicate: (entity) => !!getEntityProjectId(entity),
+ },
+ {
+ id: 'doc-markdown',
+ label: 'Markdown',
+ predicate: (entity) => isDocumentEntity(entity) && entity.fileType === 'md',
+ },
+ {
+ id: 'doc-canvas',
+ label: 'Canvas',
+ predicate: (entity) =>
+ isDocumentEntity(entity) && entity.fileType === 'canvas',
+ },
+];
+
+export const CHANNEL_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [
+ {
+ id: 'channel-recent-activity',
+ label: 'Recent Activity',
+ predicate: (entity) => {
+ if (!isChannelEntity(entity)) return false;
+ const interactedAt = entity.interactedAt
+ ? new Date(entity.interactedAt)
+ : undefined;
+ if (!interactedAt) return false;
+ const dayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);
+ return interactedAt > dayAgo;
+ },
+ },
+ {
+ id: 'channel-public',
+ label: 'Public',
+ predicate: (entity) =>
+ isChannelEntity(entity) && entity.channelType === 'public',
+ },
+ {
+ id: 'channel-private',
+ label: 'Private',
+ predicate: (entity) =>
+ isChannelEntity(entity) && entity.channelType === 'private',
+ },
+];
+
+export const CHAT_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [
+ {
+ id: 'chat-recent',
+ label: 'Recent',
+ predicate: (entity) => {
+ if (!isChatEntity(entity)) return false;
+ const updatedAt = entity.updatedAt
+ ? new Date(entity.updatedAt)
+ : undefined;
+ if (!updatedAt) return false;
+ const dayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);
+ return updatedAt > dayAgo;
+ },
+ },
+];
+
+/**
+ * Agent ownership filter options for the filter bar.
+ * Note: The actual predicates are registered in createSoupFilters with getUserID closure.
+ * These are just the IDs and labels for building filter UI options.
+ */
+export const AGENT_OWNERSHIP_FILTERS: readonly { id: string; label: string }[] =
+ [
+ { id: 'owned-agent', label: 'Owned by me' },
+ { id: 'shared-agent', label: 'Shared with me' },
+ ] as const;
+
+export const GENERAL_CONTEXTUAL_FILTERS: EntityFilterConfig[] = [
+ {
+ id: 'recently-viewed',
+ label: 'Recently Viewed',
+ predicate: (entity) => {
+ const viewedAt = entity.viewedAt ? new Date(entity.viewedAt) : undefined;
+ if (!viewedAt) return false;
+ const hourAgo = new Date(Date.now() - 60 * 60 * 1000);
+ return viewedAt > hourAgo;
+ },
+ },
+ {
+ id: 'recently-created',
+ label: 'Recently Created',
+ predicate: (entity) => {
+ const createdAt = entity.createdAt
+ ? new Date(entity.createdAt)
+ : undefined;
+ if (!createdAt) return false;
+ const weekAgo = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000);
+ return createdAt > weekAgo;
+ },
+ },
+ {
+ id: 'recently-updated',
+ label: 'Recently Updated',
+ predicate: (entity) => {
+ const updatedAt = entity.updatedAt
+ ? new Date(entity.updatedAt)
+ : undefined;
+ if (!updatedAt) return false;
+ const dayAgo = new Date(Date.now() - 24 * 60 * 60 * 1000);
+ return updatedAt > dayAgo;
+ },
+ },
+ {
+ id: 'high-frecency',
+ label: 'Frequently Used',
+ predicate: (entity) => {
+ const score = entity.frecencyScore ?? 0;
+ return score > 100; // High frecency threshold
+ },
+ },
+];
+
+const IMAGE_EXTENSIONS = ['png', 'jpg', 'jpeg', 'gif', 'svg', 'webp'] as const;
+
+export const FILE_TYPE_FILTERS: EntityFilterConfig[] = [
+ {
+ id: 'file-code',
+ label: 'Code',
+ predicate: (entity) => {
+ if (entity.type !== 'document') return false;
+ const fileType = entity.fileType ?? '';
+ return (codeFileExtensions as readonly string[]).includes(fileType);
+ },
+ },
+ {
+ id: 'file-image',
+ label: 'Images',
+ predicate: (entity) => {
+ if (entity.type !== 'document') return false;
+ const fileType = entity.fileType ?? '';
+ return (IMAGE_EXTENSIONS as readonly string[]).includes(fileType);
+ },
+ },
+ {
+ id: 'file-pdf',
+ label: 'PDFs',
+ predicate: (entity) => {
+ if (entity.type !== 'document') return false;
+ return entity.fileType === 'pdf';
+ },
+ },
+ {
+ id: 'file-other',
+ label: 'Other',
+ predicate: (entity) => {
+ if (entity.type !== 'document') return false;
+ const fileType = entity.fileType ?? '';
+ // Exclude markdown, canvas, code, images, and PDFs
+ if (['md', 'canvas'].includes(fileType)) return false;
+ if ((codeFileExtensions as readonly string[]).includes(fileType))
+ return false;
+ if ((IMAGE_EXTENSIONS as readonly string[]).includes(fileType))
+ return false;
+ if (fileType === 'pdf') return false;
+ return true;
+ },
+ },
+];
-export type FilterID = (typeof SOUP_FILTERS)[number]['id'];
+export const createSoupFilters = (
+ notificationSource: NotificationSource,
+ getUserID: () => string | undefined
+) => {
+ const list = [
+ // Focus filters (mutually exclusive)
+ {
+ id: 'signal',
+ label: 'Inbox',
+ predicate: signalFilter,
+ group: 'focus',
+ },
+ {
+ id: 'noise',
+ label: 'Other',
+ predicate: noiseFilter,
+ group: 'focus',
+ },
+ {
+ id: 'explicit-noise',
+ label: 'Explicit Noise',
+ predicate: (entity: EntityData) => !explicitNoiseFilter(entity),
+ group: 'focus',
+ },
+
+ // Notification filters
+ {
+ id: 'unread',
+ label: 'Unread',
+ predicate: unreadFilter(notificationSource),
+ },
+ {
+ id: 'read',
+ label: 'Read',
+ predicate: (entity: EntityData) =>
+ !unreadFilter(notificationSource)(entity),
+ },
+ {
+ id: 'not-done',
+ label: 'Not done',
+ predicate: notDoneFilter(notificationSource),
+ },
+ {
+ id: 'done',
+ label: 'Done',
+ predicate: (entity: EntityData) =>
+ !notDoneFilter(notificationSource)(entity),
+ },
+ ...ENTITY_TYPE_FILTER_CONFIGS,
+ {
+ id: 'channels',
+ label: 'Channels',
+ predicate: channelsFilter,
+ },
+ {
+ id: 'file-folder',
+ label: 'Files & Folders',
+ predicate: filesAndFolderFilter,
+ },
+ {
+ id: 'folders',
+ label: 'Folders',
+ predicate: projectFilter,
+ },
+ {
+ id: 'active-agent',
+ label: 'Running agents',
+ predicate: activeAgentFilter,
+ },
+ {
+ id: 'email-drafts',
+ label: 'Email drafts',
+ predicate: emailDraftsFilter,
+ },
+ {
+ id: 'no-drafts',
+ label: 'No drafts',
+ predicate: noDraftsFilter,
+ },
+ {
+ id: 'has-calendar-invite',
+ label: 'Has calendar invite',
+ predicate: hasCalendarInviteFilter,
+ },
+ {
+ id: 'has-attachment',
+ label: 'Has attachment',
+ predicate: hasAttachmentFilter,
+ },
+ {
+ id: 'attachment-pdf',
+ label: 'PDF attachment',
+ predicate: hasPdfAttachmentFilter,
+ },
+ {
+ id: 'attachment-image',
+ label: 'Image attachment',
+ predicate: hasImageAttachmentFilter,
+ },
+ {
+ id: 'attachment-document',
+ label: 'Document attachment',
+ predicate: hasDocumentAttachmentFilter,
+ },
+ {
+ id: 'shared-entity',
+ label: 'Shared entities',
+ predicate: sharedEntity(getUserID),
+ },
+ {
+ id: 'owned-agent',
+ label: 'Owned by me',
+ predicate: ownedAgentFilter(getUserID),
+ },
+ {
+ id: 'shared-agent',
+ label: 'Shared with me',
+ predicate: sharedAgentFilter(getUserID),
+ },
+ {
+ id: 'assigned-to',
+ label: 'Task assigned to user',
+ predicate: taskAssignedToUserFilter(getUserID),
+ },
+ ...TASK_PRIORITY_FILTERS,
+ ...DOCUMENT_CONTEXTUAL_FILTERS,
+ ...CHANNEL_CONTEXTUAL_FILTERS,
+ ...CHAT_CONTEXTUAL_FILTERS,
+ ...FILE_TYPE_FILTERS,
+ ] as const satisfies EntityFilterConfig[];
+
+ return list;
+};
+
+/**
+ * Default filter group configurations for soup filters.
+ * - 'focus': Mutually exclusive (signal/noise/explicit-noise)
+ * - 'entity-type': Mutually exclusive by default
+ */
+export const SOUP_FILTER_GROUPS: FilterGroupConfig[] = [
+ { id: 'focus', allowMultiple: false },
+ { id: 'entity-type', allowMultiple: false },
+];
+
+type SoupFilter = ReturnType<typeof createSoupFilters>[number];
+
+export type FilterID = Extract<SoupFilter, { id: string & {} }>['id'];
const ENTITY_TYPE_FILTERS = [
'document',
@@ -264,23 +944,10 @@ const ENTITY_TYPE_FILTERS = [
'teams',
'agent',
'file',
-] as const;
+] as const satisfies FilterID[];
type EntityTypeFilters = (typeof ENTITY_TYPE_FILTERS)[number];
-export const isEntityTypeFilter = (
- filter: FilterConfig<EntityData>
-): filter is Extract<
- (typeof SOUP_FILTERS)[number],
- { readonly id: EntityTypeFilters }
-> => {
- return ENTITY_TYPE_FILTERS.includes(filter.id as EntityTypeFilters);
-};
-
-export const ENTITY_TYPE_FILTER_CONFIGS = SOUP_FILTERS.filter((f) =>
- isEntityTypeFilter(f)
-);
-
const ENTITY_TYPE_TO_ICON_TYPE: Record<EntityTypeFilters, EntityWithValidIcon> =
{
document: 'md',
@@ -312,14 +979,6 @@ export const ANIMATED_ICONS: Partial<
file: AnimatedFolderIcon,
};
-export const getFilterWithID = (filterID: FilterID) => {
- const found = SOUP_FILTERS.find((f) => f.id === filterID);
-
- if (!found) return;
-
- return found;
-};
-
export const FILE_ASSOCIATION_TYPES = [
'code',
'image',
diff --git a/js/app/packages/app/component/next-soup/filters/index.ts b/js/app/packages/app/component/next-soup/filters/index.ts
index 80c153114b..dbcb57d8fd 100644
--- a/js/app/packages/app/component/next-soup/filters/index.ts
+++ b/js/app/packages/app/component/next-soup/filters/index.ts
@@ -3,15 +3,23 @@ export {
documentFilter,
emailFilter,
fileFilter,
- FILTER_GROUPS,
- type FilterGroup,
notDoneFilter,
peopleFilter,
projectFilter,
taskFilter,
teamsFilter,
unreadFilter,
- SOUP_FILTERS,
+ createSoupFilters,
+ SOUP_FILTER_GROUPS,
+ TASK_STATUS_FILTERS,
+ TASK_PRIORITY_FILTERS,
+ TASK_ASSIGNEE_FILTERS,
+ TASK_CONTEXTUAL_FILTERS,
+ DOCUMENT_CONTEXTUAL_FILTERS,
+ CHANNEL_CONTEXTUAL_FILTERS,
+ CHAT_CONTEXTUAL_FILTERS,
+ FILE_TYPE_FILTERS,
+ type FilterID,
} from './filters';
export {
@@ -22,6 +30,12 @@ export {
export {
createFilterState,
+ type FilterState,
+ type FilterStateOptions,
+ type SetFiltersInput,
+ type SetFiltersCallback,
+ type CurrentFilterState,
type FilterConfig,
+ type FilterGroupConfig,
type FilterPredicate,
} from './create-filter-state';
diff --git a/js/app/packages/app/component/next-soup/soup-view/empty-states.tsx b/js/app/packages/app/component/next-soup/soup-view/empty-states.tsx
index e0937286f4..ef5ac153b9 100644
--- a/js/app/packages/app/component/next-soup/soup-view/empty-states.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/empty-states.tsx
@@ -39,6 +39,7 @@ export function EmptyState(props: {
viewId?: ViewId;
search?: boolean;
hasRefinementsFromBase?: boolean;
+ onClearFilters?: () => void;
}) {
const emailActive = useEmailLinksStatus();
@@ -48,7 +49,14 @@ export function EmptyState(props: {
<EmptyStateInner message={'No results.'} />
</Match>
<Match when={props.hasRefinementsFromBase}>
- <EmptyStateInner />
+ <EmptyStateInner
+ message="No items match your filters."
+ cta={
+ props.onClearFilters
+ ? { label: 'Clear filters', onClick: props.onClearFilters }
+ : undefined
+ }
+ />
</Match>
<Match when={props.viewId === 'noise' && !emailActive()}>
<EmptyStateInner message={'Email not connected.'} />
@@ -121,12 +129,12 @@ export function EmptyStateInner(props: EmptyStateInnerProps) {
</p>
<Show when={props.cta}>
{(cta) => (
- <div class="w-full flex justify-start pt-4">
+ <div class="w-full flex justify-center pt-4">
<button
onMouseDown={cta().onClick}
- class="cta py-2 px-2 bg-accent/75 text-panel"
+ class="py-2 px-4 rounded-md bg-accent/15 text-accent hover:bg-accent/25 transition-colors"
>
- <span class="font-medium">{cta().label.toUpperCase()}</span>
+ <span class="font-medium text-sm">{cta().label}</span>
</button>
</div>
)}
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/button.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/button.tsx
new file mode 100644
index 0000000000..0aa4695c07
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/button.tsx
@@ -0,0 +1,82 @@
+import { Button as KButton, type ButtonRootProps } from '@kobalte/core/button';
+import type { PolymorphicProps } from '@kobalte/core/polymorphic';
+import { cn } from '@ui/utils/classname';
+import { type ParentProps, splitProps, type ValidComponent } from 'solid-js';
+
+export type ButtonVariant =
+ | 'primary'
+ | 'secondary'
+ | 'tertiary'
+ | 'destructive'
+ | 'ghost'
+ | 'link';
+export type ButtonSize = 'sm' | 'md' | 'lg' | 'icon-sm' | 'icon-md' | 'icon-lg';
+
+export type ButtonProps<T extends ValidComponent = 'button'> = ParentProps<
+ PolymorphicProps<T, ButtonRootProps<T>> & {
+ variant?: ButtonVariant;
+ size?: ButtonSize;
+ class?: string;
+ }
+>;
+
+const variantStyles: Record<ButtonVariant, string> = {
+ // High emphasis - main actions (submit, confirm, save)
+ primary:
+ 'bg-ink text-page not-disabled:hover:bg-ink/90 not-disabled:active:bg-ink/80',
+ // Medium emphasis - secondary actions (cancel, back)
+ secondary:
+ 'bg-transparent text-ink border border-edge not-disabled:hover:bg-ink/10 not-disabled:active:bg-ink/12',
+ // Low emphasis - minimal actions (less important options)
+ tertiary:
+ 'bg-ink/10 text-ink-muted not-disabled:hover:bg-ink/20 not-disabled:hover:text-ink not-disabled:active:bg-ink/15',
+ // Dangerous actions (delete, remove, disconnect)
+ destructive:
+ 'bg-transparent text-failure border border-failure/50 not-disabled:hover:bg-failure/10 not-disabled:active:bg-failure/20',
+ // Minimal - no background, appears on hover
+ ghost:
+ 'bg-transparent text-ink-muted not-disabled:hover:bg-ink/10 not-disabled:hover:text-ink not-disabled:active:bg-ink/12',
+ // Text link style
+ link: 'bg-transparent text-accent underline-offset-2 not-disabled:hover:underline not-disabled:active:text-accent/80',
+};
+
+const sizeStyles: Record<ButtonSize, string> = {
+ sm: 'px-2 py-1.5 text-xs gap-1',
+ md: 'px-3 py-2 text-sm gap-1.5',
+ lg: 'px-4 py-2.5 text-base gap-2',
+ // Icon sizes - square buttons for icon-only use
+ // TODO: Remove if not needed - these can be replaced with `size="sm" class="aspect-square"`
+ 'icon-sm': 'p-1.5 size-7 [&_svg]:size-3.5',
+ 'icon-md': 'p-2 size-9 [&_svg]:size-4',
+ 'icon-lg': 'p-2.5 size-11 [&_svg]:size-5',
+};
+
+export const Button = <T extends ValidComponent = 'button'>(
+ props: ButtonProps<T>
+) => {
+ const [local, others] = splitProps(props as ButtonProps<'button'>, [
+ 'variant',
+ 'size',
+ 'class',
+ 'children',
+ ]);
+
+ const variant = () => local.variant ?? 'primary';
+ const size = () => local.size ?? 'md';
+
+ return (
+ <KButton
+ class={cn(
+ 'inline-flex items-center justify-center font-medium rounded-md transition-colors',
+ 'focus-visible:outline-none',
+ 'data-[disabled]:cursor-not-allowed data-[disabled]:opacity-50',
+ variantStyles[variant()],
+ sizeStyles[size()],
+ local.class
+ )}
+ {...others}
+ >
+ {local.children}
+ </KButton>
+ );
+};
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-controls.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-controls.tsx
new file mode 100644
index 0000000000..2137a7a07c
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-controls.tsx
@@ -0,0 +1,597 @@
+import CircleDashedIcon from '@icon/regular/circle-dashed.svg';
+import FileCodeIcon from '@icon/regular/file-code.svg';
+import FileImageIcon from '@icon/regular/file-image.svg';
+import FilePdfIcon from '@icon/regular/file-pdf.svg';
+import FileIcon from '@icon/regular/file.svg';
+import FolderIcon from '@icon/regular/folder.svg';
+import { createMemo, Show } from 'solid-js';
+import { VIEW_TAB_PRESETS } from '@app/component/app-sidebar/soup-filter-presets';
+import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
+import { UserIcon } from '@core/component/UserIcon';
+import { useContacts } from '@queries/contacts/contacts';
+import { useUserId } from '@core/context/user';
+import { NO_ASSIGNEE } from '@app/component/next-soup/soup-view/task-sub-filter-matcher';
+import { PropertyValueIcon } from '@core/component/Properties/component/propertyValue/PropertyValueIcon';
+import { PROPERTY_OPTION_IDS } from '@core/component/Properties/constants';
+import { EntityIcon } from '@core/component/EntityIcon';
+import { TASK_STATUS_OPTIONS } from '@entity';
+import { useProjectsQuery } from '@queries/storage/projects';
+import {
+ getFileAssociations,
+ QUERY_FILTERS_BASE,
+} from '@app/component/next-soup/filters/filters';
+import { ChannelTypeEnum } from '@service-comms/client';
+import type { ChannelType } from '@service-comms/generated/models';
+import type { SoupItemsQueryFilters } from '@queries/soup/items';
+import {
+ FilterChipGroup,
+ FilterCombobox,
+ FilterSelect,
+ type Option,
+} from './filter-primitives';
+import { useFilterOptions } from './use-filter-options';
+
+export const AssigneeFilter = () => {
+ const { assigneeFilter, setAssigneeFilter } = useSoupView();
+ const contacts = useContacts();
+ const userId = useUserId();
+
+ const assigneeOptions = createMemo((): Option[] => {
+ const currentUserId = userId();
+ const noAssigneeOption: Option = {
+ value: NO_ASSIGNEE,
+ label: 'No Assignee',
+ icon: () => <CircleDashedIcon class="size-4 text-ink-muted" />,
+ };
+ const contactOptions = contacts().map((contact) => ({
+ value: contact.id,
+ label:
+ contact.id === currentUserId
+ ? contact.name
+ ? `${contact.name} (me)`
+ : 'Me'
+ : contact.name || contact.id,
+ icon: () => (
+ <UserIcon id={contact.id} size="xs" suppressClick showTooltip={false} />
+ ),
+ }));
+ return [noAssigneeOption, ...contactOptions];
+ });
+
+ const activeAssignee = createMemo((): Option[] => {
+ const current = assigneeFilter();
+ const options = assigneeOptions();
+ return options.filter((o) => current.includes(o.value));
+ });
+
+ const handleAssigneeChange = (options: Option[]) => {
+ setAssigneeFilter(options.map((o) => o.value));
+ };
+
+ return (
+ <FilterCombobox
+ label="Assignee"
+ options={assigneeOptions()}
+ active={activeAssignee()}
+ onChange={handleAssigneeChange}
+ placeholder="Search assignees..."
+ />
+ );
+};
+
+const getEntityTypeQueryFilters = (
+ selectedIds: string[],
+ currentFilters: SoupItemsQueryFilters
+): SoupItemsQueryFilters => {
+ if (selectedIds.length === 0) return currentFilters;
+
+ const result: SoupItemsQueryFilters = { ...QUERY_FILTERS_BASE };
+ const selected = new Set(selectedIds);
+
+ if (selected.has('agent')) {
+ result.chat_filters = { ...currentFilters.chat_filters };
+ }
+
+ if (selected.has('email')) {
+ result.email_filters = { ...currentFilters.email_filters };
+ }
+
+ const includesPeople = selected.has('people');
+ const includesTeams = selected.has('teams');
+ if (includesPeople || includesTeams) {
+ const channelTypes: ChannelType[] = [];
+ if (includesPeople) {
+ channelTypes.push(ChannelTypeEnum.DirectMessage);
+ }
+ if (includesTeams) {
+ channelTypes.push(
+ ChannelTypeEnum.Private,
+ ChannelTypeEnum.Organization,
+ ChannelTypeEnum.Public
+ );
+ }
+ result.channel_filters = {
+ ...currentFilters.channel_filters,
+ channel_types: channelTypes,
+ };
+ }
+
+ const includesDocuments = selected.has('document');
+ const includesTasks = selected.has('task');
+ const includesFiles = selected.has('file');
+ if (includesDocuments || includesTasks || includesFiles) {
+ const fileTypes: string[] = [];
+ if (includesDocuments) {
+ fileTypes.push('md', 'canvas');
+ }
+ if (includesTasks) {
+ fileTypes.push('md');
+ }
+ if (includesFiles) {
+ fileTypes.push(...getFileAssociations('soup'));
+ }
+ result.document_filters = {
+ ...currentFilters.document_filters,
+ file_types: [...new Set(fileTypes)],
+ };
+ }
+
+ return result;
+};
+
+export const EntityTypeFilter = () => {
+ const { activeTab } = useSoupView();
+
+ const baseQueryFilters = createMemo(() => {
+ const tabId = activeTab() ?? VIEW_TAB_PRESETS.inbox.default;
+ const resolver = VIEW_TAB_PRESETS.inbox.tabs[tabId];
+ return (
+ resolver?.({ userId: undefined, email: undefined })?.queryFilters ?? {}
+ );
+ });
+
+ const entityTypeOptions: Option[] = [
+ {
+ value: 'document',
+ label: 'Docs',
+ icon: () => <EntityIcon targetType="md" size="xs" />,
+ },
+ {
+ value: 'agent',
+ label: 'Agents',
+ icon: () => <EntityIcon targetType="chat" size="xs" />,
+ },
+ {
+ value: 'people',
+ label: 'People',
+ icon: () => <EntityIcon targetType="direct_message" size="xs" />,
+ },
+ {
+ value: 'teams',
+ label: 'Teams',
+ icon: () => <EntityIcon targetType="channel" size="xs" />,
+ },
+ {
+ value: 'task',
+ label: 'Tasks',
+ icon: () => <EntityIcon targetType="task" size="xs" />,
+ },
+ {
+ value: 'email',
+ label: 'Mail',
+ icon: () => <EntityIcon targetType="email" size="xs" />,
+ },
+ {
+ value: 'file',
+ label: 'Files',
+ icon: () => <EntityIcon targetType="unknown" size="xs" />,
+ },
+ ];
+
+ const entityType = useFilterOptions(entityTypeOptions, {
+ getQueryFilters: (selectedIds) =>
+ getEntityTypeQueryFilters(selectedIds, baseQueryFilters()),
+ });
+
+ return (
+ <FilterSelect
+ label="Type"
+ options={entityTypeOptions}
+ active={entityType.active()}
+ onChange={entityType.onChange}
+ />
+ );
+};
+
+type FolderFilterTarget = 'chat' | 'document';
+
+interface FolderFilterProps {
+ target: FolderFilterTarget;
+ label?: string;
+}
+
+export const FolderFilter = (props: FolderFilterProps) => {
+ const { setQueryFilters, queryFilters } = useSoupView();
+ const projects = useProjectsQuery();
+
+ const label = () => props.label ?? 'Folder';
+
+ const projectOptions = createMemo((): Option[] => {
+ const data = projects.data;
+ if (!data) return [];
+ return data.map((project) => ({
+ value: project.id,
+ label: project.name,
+ }));
+ });
+
+ const activeProjectFilter = createMemo((): Option[] => {
+ const filters = queryFilters();
+
+ const projectIds =
+ props.target === 'chat'
+ ? filters.chat_filters?.project_ids
+ : filters.document_filters?.project_ids;
+
+ if (!projectIds?.length) return [];
+
+ const options = projectOptions();
+
+ return options.filter((opt) => projectIds.includes(opt.value));
+ });
+
+ const handleProjectChange = (selected: Option[]) => {
+ const projectIds = selected.map((opt) => opt.value);
+
+ const newProjectIds = projectIds.length > 0 ? projectIds : undefined;
+
+ setQueryFilters((prev) => {
+ if (props.target === 'chat') {
+ return {
+ ...prev,
+ chat_filters: {
+ ...prev.chat_filters,
+ project_ids: newProjectIds,
+ },
+ };
+ }
+
+ return {
+ ...prev,
+ document_filters: {
+ ...prev.document_filters,
+ project_ids: newProjectIds,
+ },
+ };
+ });
+ };
+
+ return (
+ <Show when={projectOptions().length > 0}>
+ <FilterCombobox
+ label={label()}
+ options={projectOptions()}
+ active={activeProjectFilter()}
+ onChange={handleProjectChange}
+ placeholder="Search folders..."
+ />
+ </Show>
+ );
+};
+
+export const ProjectFilter = () => {
+ return <FolderFilter target="chat" label="Folder" />;
+};
+
+export const StatusFilter = () => {
+ const statusOptions: Option[] = [
+ { value: 'unread', label: 'Unread' },
+ { value: 'read', label: 'Read' },
+ { value: 'not-done', label: 'Not Done' },
+ { value: 'done', label: 'Done' },
+ ];
+
+ const status = useFilterOptions(statusOptions, { target: 'and' });
+
+ return (
+ <FilterSelect
+ label="Status"
+ options={statusOptions}
+ active={status.active()}
+ onChange={status.onChange}
+ />
+ );
+};
+
+export const DocumentTypeFilter = () => {
+ const typeOptions: Option[] = [
+ { value: 'doc-markdown', label: 'Markdown' },
+ { value: 'doc-canvas', label: 'Canvas' },
+ ];
+
+ const type = useFilterOptions(typeOptions);
+
+ return (
+ <FilterSelect
+ label="Type"
+ options={typeOptions}
+ active={type.active()}
+ onChange={type.onChange}
+ />
+ );
+};
+
+export const DocumentFolderFilter = () => {
+ return <FolderFilter target="document" label="Folder" />;
+};
+
+export const TaskStatusFilter = () => {
+ const { statusFilter, setStatusFilter } = useSoupView();
+
+ const statusOptions: Option[] = TASK_STATUS_OPTIONS.map((o) => ({
+ value: o.value,
+ label: o.label,
+ icon: () => <PropertyValueIcon optionId={o.value} class="size-3.5" />,
+ }));
+
+ const activeStatus = createMemo((): Option[] => {
+ const current = statusFilter();
+ return statusOptions.filter((o) => current.includes(o.value));
+ });
+
+ const handleStatusChange = (options: Option[]) => {
+ setStatusFilter(options.map((o) => o.value));
+ };
+
+ return (
+ <FilterSelect
+ label="Status"
+ options={statusOptions}
+ active={activeStatus()}
+ onChange={handleStatusChange}
+ />
+ );
+};
+
+export const TaskPriorityFilter = () => {
+ const priorityOptions: Option[] = [
+ {
+ value: 'task-critical',
+ label: 'Critical',
+ icon: () => (
+ <PropertyValueIcon
+ optionId={PROPERTY_OPTION_IDS.PRIORITY.URGENT}
+ class="size-3.5"
+ />
+ ),
+ },
+ {
+ value: 'task-high-priority',
+ label: 'High Priority',
+ icon: () => (
+ <PropertyValueIcon
+ optionId={PROPERTY_OPTION_IDS.PRIORITY.HIGH}
+ class="size-3.5"
+ />
+ ),
+ },
+ {
+ value: 'task-medium-priority',
+ label: 'Medium Priority',
+ icon: () => (
+ <PropertyValueIcon
+ optionId={PROPERTY_OPTION_IDS.PRIORITY.MEDIUM}
+ class="size-3.5"
+ />
+ ),
+ },
+ {
+ value: 'task-low-priority',
+ label: 'Low Priority',
+ icon: () => (
+ <PropertyValueIcon
+ optionId={PROPERTY_OPTION_IDS.PRIORITY.LOW}
+ class="size-3.5"
+ />
+ ),
+ },
+ {
+ value: 'task-no-priority',
+ label: 'No Priority',
+ },
+ ];
+
+ const priority = useFilterOptions(priorityOptions);
+
+ return (
+ <FilterSelect
+ label="Priority"
+ options={priorityOptions}
+ active={priority.active()}
+ onChange={priority.onChange}
+ />
+ );
+};
+
+export const ChannelVisibilityFilter = () => {
+ const visibilityOptions: Option[] = [
+ { value: 'channel-public', label: 'Public' },
+ { value: 'channel-private', label: 'Private' },
+ ];
+
+ const visibility = useFilterOptions(visibilityOptions);
+
+ return (
+ <FilterSelect
+ label="Visibility"
+ options={visibilityOptions}
+ active={visibility.active()}
+ onChange={visibility.onChange}
+ />
+ );
+};
+
+export const FileTypeFilter = () => {
+ const fileTypeOptions: Option[] = [
+ {
+ value: 'file-code',
+ label: 'Code',
+ icon: () => <FileCodeIcon class="size-3.5" />,
+ },
+ {
+ value: 'file-image',
+ label: 'Images',
+ icon: () => <FileImageIcon class="size-3.5" />,
+ },
+ {
+ value: 'file-pdf',
+ label: 'PDFs',
+ icon: () => <FilePdfIcon class="size-3.5" />,
+ },
+ {
+ value: 'file-other',
+ label: 'Other',
+ icon: () => <FileIcon class="size-3.5" />,
+ },
+ ];
+
+ const fileType = useFilterOptions(fileTypeOptions);
+
+ return (
+ <FilterChipGroup
+ options={fileTypeOptions}
+ active={fileType.active()}
+ onChange={fileType.onChange}
+ />
+ );
+};
+
+export const FoldersFilter = () => {
+ const foldersOptions: Option[] = [
+ {
+ value: 'folders',
+ label: 'Folders',
+ icon: () => <FolderIcon class="size-3.5" />,
+ },
+ ];
+
+ const folders = useFilterOptions(foldersOptions);
+
+ return (
+ <FilterChipGroup
+ options={foldersOptions}
+ active={folders.active()}
+ onChange={folders.onChange}
+ />
+ );
+};
+
+export const FromSenderFilter = () => {
+ const { setQueryFilters, queryFilters } = useSoupView();
+ const contacts = useContacts();
+
+ const senderOptions = createMemo((): Option[] => {
+ return contacts().map((contact) => ({
+ value: contact.email ?? contact.id,
+ label: contact.name || contact.email || contact.id,
+ icon: () => (
+ <UserIcon id={contact.id} size="xs" suppressClick showTooltip={false} />
+ ),
+ }));
+ });
+
+ const activeSenderFilter = createMemo((): Option[] => {
+ const senders = queryFilters().email_filters?.senders;
+ if (!senders?.length) return [];
+
+ const options = senderOptions();
+ return options.filter((opt) => senders.includes(opt.value));
+ });
+
+ const handleSenderChange = (selected: Option[]) => {
+ const senders = selected.map((opt) => opt.value);
+ const newSenders = senders.length > 0 ? senders : undefined;
+
+ setQueryFilters((prev) => ({
+ ...prev,
+ email_filters: {
+ ...prev.email_filters,
+ senders: newSenders,
+ },
+ }));
+ };
+
+ return (
+ <Show when={senderOptions().length > 0}>
+ <FilterCombobox
+ label="From"
+ options={senderOptions()}
+ active={activeSenderFilter()}
+ onChange={handleSenderChange}
+ placeholder="Search contacts..."
+ />
+ </Show>
+ );
+};
+
+export const HasCalendarInviteFilter = () => {
+ const calendarInviteOptions: Option[] = [
+ { value: 'has-calendar-invite', label: 'Has Calendar Invite' },
+ ];
+
+ const calendarInvite = useFilterOptions(calendarInviteOptions);
+
+ return (
+ <FilterChipGroup
+ options={calendarInviteOptions}
+ active={calendarInvite.active()}
+ onChange={calendarInvite.onChange}
+ />
+ );
+};
+
+export const HasAttachmentFilter = () => {
+ const attachmentOptions: Option[] = [
+ { value: 'has-attachment', label: 'Has Attachment' },
+ ];
+
+ const attachment = useFilterOptions(attachmentOptions, { target: 'and' });
+
+ return (
+ <FilterChipGroup
+ options={attachmentOptions}
+ active={attachment.active()}
+ onChange={attachment.onChange}
+ />
+ );
+};
+
+export const AttachmentTypeFilter = () => {
+ const attachmentTypeOptions: Option[] = [
+ {
+ value: 'attachment-pdf',
+ label: 'PDFs',
+ icon: () => <FilePdfIcon class="size-3.5" />,
+ },
+ {
+ value: 'attachment-image',
+ label: 'Images',
+ icon: () => <FileImageIcon class="size-3.5" />,
+ },
+ {
+ value: 'attachment-document',
+ label: 'Documents',
+ icon: () => <FileIcon class="size-3.5" />,
+ },
+ ];
+
+ const attachmentType = useFilterOptions(attachmentTypeOptions);
+
+ return (
+ <FilterChipGroup
+ options={attachmentTypeOptions}
+ active={attachmentType.active()}
+ onChange={attachmentType.onChange}
+ />
+ );
+};
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-primitives.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-primitives.tsx
new file mode 100644
index 0000000000..a5adcf2381
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/filter-primitives.tsx
@@ -0,0 +1,353 @@
+import ChevronDownIcon from '@icon/regular/caret-down.svg';
+import CheckIcon from '@icon/regular/check.svg';
+import SearchIcon from '@icon/regular/magnifying-glass.svg';
+import { Combobox } from '@kobalte/core/combobox';
+import { Select as KSelect } from '@kobalte/core/select';
+import { cn } from '@ui/utils/classname';
+import { Button } from '@app/component/next-soup/soup-view/filters-bar/button';
+import { createMemo, createSignal, For, type JSX, Show } from 'solid-js';
+import type { CollectionNode } from '@kobalte/core';
+
+export type Option = {
+ value: string;
+ label: string;
+ icon?: () => JSX.Element;
+};
+
+interface FilterSelectProps {
+ label: string;
+ options: Option[];
+ active: Option[];
+ onChange: (options: Option[]) => void;
+ multiple?: boolean;
+}
+
+export const FilterSelect = (props: FilterSelectProps) => {
+ const multiple = () => props.multiple ?? true;
+
+ const activeFilters = createMemo(() => props.active);
+ const activeCount = createMemo(() => activeFilters().length);
+ const hasActiveFilters = createMemo(() => activeCount() > 0);
+
+ const renderItem = (itemProps: { item: CollectionNode<Option> }) => (
+ <KSelect.Item
+ item={itemProps.item}
+ class="w-full flex items-center gap-2.5 px-3 py-2 rounded-md text-left text-xs transition-colors hover:bg-ink/5 group"
+ >
+ <span class="size-4 flex items-center justify-center shrink-0 rounded border border-edge transition-colors group-data-[selected]:bg-accent group-data-[selected]:border-accent">
+ <KSelect.ItemIndicator>
+ <CheckIcon class="size-2.5 text-page" />
+ </KSelect.ItemIndicator>
+ </span>
+
+ <Show when={itemProps.item.rawValue.icon}>
+ {(icon) => (
+ <span class="size-4 flex items-center justify-center shrink-0">
+ {icon()()}
+ </span>
+ )}
+ </Show>
+
+ <KSelect.ItemLabel class="flex-1 truncate text-ink-muted group-data-[selected]:text-ink">
+ {itemProps.item.rawValue.label}
+ </KSelect.ItemLabel>
+ </KSelect.Item>
+ );
+
+ // For single select: convert to/from array format
+ const value = () =>
+ multiple() ? activeFilters() : (activeFilters()[0] ?? null);
+ const handleChange = (selected: Option | Option[] | null) => {
+ if (multiple()) {
+ props.onChange(selected as Option[]);
+ } else {
+ props.onChange(selected ? [selected as Option] : []);
+ }
+ };
+
+ return (
+ <KSelect<Option>
+ options={props.options}
+ value={value() as Option & Option[]}
+ onChange={handleChange as (value: Option & Option[]) => void}
+ optionTextValue="label"
+ optionValue="value"
+ gutter={4}
+ multiple={multiple()}
+ placement="bottom-start"
+ itemComponent={renderItem}
+ >
+ <KSelect.Trigger
+ as={Button}
+ variant="secondary"
+ size="sm"
+ class={cn(
+ 'relative transition-none',
+ hasActiveFilters() &&
+ 'bg-accent/15 text-accent border border-accent/30 hover:bg-accent/25'
+ )}
+ >
+ <span class="font-medium">{props.label}</span>
+ <Show when={multiple() && hasActiveFilters()}>
+ <span class="absolute -top-2 -right-2 flex items-center justify-center size-4 rounded-full text-xs font-semibold bg-accent text-page">
+ {activeCount()}
+ </span>
+ </Show>
+ <ChevronDownIcon class="size-3" />
+ </KSelect.Trigger>
+ <KSelect.Portal>
+ <KSelect.Content class="z-action-menu bg-surface-0 border border-edge-muted rounded-lg shadow-xl min-w-[var(--kb-popper-anchor-width)] p-1">
+ <KSelect.Listbox />
+ <div class="w-full pt-1 mt-1 flex items-center border-t border-t-edge-muted">
+ <Button
+ variant="primary"
+ size="sm"
+ class="ml-auto"
+ onClick={() => props.onChange([])}
+ >
+ Clear
+ </Button>
+ </div>
+ </KSelect.Content>
+ </KSelect.Portal>
+ </KSelect>
+ );
+};
+
+interface FilterComboboxProps {
+ label: string;
+ options: Option[];
+ active: Option[];
+ onChange: (options: Option[]) => void;
+ placeholder?: string;
+}
+
+export const FilterCombobox = (props: FilterComboboxProps) => {
+ const [searchQuery, setSearchQuery] = createSignal('');
+ const [listboxRef, setListboxRef] = createSignal<HTMLElement | undefined>();
+
+ const activeFilters = createMemo(() => props.active);
+ const activeCount = createMemo(() => activeFilters().length);
+ const hasActiveFilters = createMemo(() => activeCount() > 0);
+
+ const filteredOptions = createMemo(() => {
+ const query = searchQuery().toLowerCase().trim();
+ if (!query) return props.options;
+ return props.options.filter((opt) =>
+ opt.label.toLowerCase().includes(query)
+ );
+ });
+
+ const dispatchKeyToListbox = (key: string) => {
+ listboxRef()?.dispatchEvent(
+ new KeyboardEvent('keydown', { bubbles: true, key })
+ );
+ };
+
+ const handleKeyDown = (e: KeyboardEvent) => {
+ switch (e.key) {
+ case 'j': {
+ if (!e.ctrlKey) return;
+ e.preventDefault();
+ dispatchKeyToListbox('ArrowDown');
+ break;
+ }
+ case 'k': {
+ if (!e.ctrlKey) return;
+ e.preventDefault();
+ dispatchKeyToListbox('ArrowUp');
+ break;
+ }
+ }
+ };
+
+ const onInputChange = (value: string) => {
+ setSearchQuery(value);
+ queueMicrotask(() => {
+ dispatchKeyToListbox('ArrowDown');
+ });
+ };
+
+ const onOpenChange = (open: boolean) => {
+ if (!open) {
+ setSearchQuery('');
+ }
+ };
+
+ return (
+ <Combobox<Option>
+ class="max-h-full"
+ multiple
+ options={filteredOptions()}
+ value={activeFilters()}
+ onChange={props.onChange}
+ onOpenChange={onOpenChange}
+ onInputChange={onInputChange}
+ optionValue="value"
+ optionTextValue="label"
+ optionLabel="label"
+ allowsEmptyCollection
+ placement="bottom-start"
+ gutter={4}
+ itemComponent={(itemProps) => (
+ <Combobox.Item
+ item={itemProps.item}
+ class="w-full flex items-center gap-2.5 px-3 py-2 rounded-md text-left text-xs transition-colors hover:bg-ink/5 data-[highlighted]:bg-ink/5 group"
+ >
+ <span class="size-4 flex items-center justify-center shrink-0 rounded border border-edge transition-colors group-data-[selected]:bg-accent group-data-[selected]:border-accent">
+ <Combobox.ItemIndicator>
+ <CheckIcon class="size-2.5 text-page" />
+ </Combobox.ItemIndicator>
+ </span>
+
+ <Show when={itemProps.item.rawValue.icon}>
+ {(icon) => (
+ <span class="size-4 flex items-center justify-center shrink-0">
+ {icon()()}
+ </span>
+ )}
+ </Show>
+
+ <Combobox.ItemLabel class="flex-1 truncate text-ink-muted group-data-[selected]:text-ink">
+ {itemProps.item.rawValue.label}
+ </Combobox.ItemLabel>
+ </Combobox.Item>
+ )}
+ >
+ <Combobox.Control class="flex">
+ <Combobox.Trigger
+ as={Button}
+ variant="secondary"
+ size="sm"
+ class={cn(
+ 'relative transition-none',
+ hasActiveFilters() &&
+ 'bg-accent/15 text-accent border border-accent/30 hover:bg-accent/25'
+ )}
+ >
+ <span class="font-medium">{props.label}</span>
+ <Show when={hasActiveFilters()}>
+ <span class="absolute -top-2 -right-2 flex items-center justify-center size-4 rounded-full text-xs font-semibold bg-accent text-page">
+ {activeCount()}
+ </span>
+ </Show>
+ <ChevronDownIcon class="size-3" />
+ </Combobox.Trigger>
+ <Combobox.Input class="sr-only" />
+ </Combobox.Control>
+
+ <Combobox.Portal>
+ <Combobox.Content
+ class="z-action-menu bg-surface-0 border border-edge-muted rounded-lg shadow-xl min-w-[220px] overflow-hidden"
+ on:keydown={handleKeyDown}
+ >
+ <div class="flex items-center gap-2 px-3 py-2 border-b border-edge-muted">
+ <SearchIcon class="size-3.5 text-ink-muted shrink-0" />
+ <Combobox.Input
+ class="flex-1 text-xs bg-transparent outline-none caret-accent placeholder:text-ink-faint"
+ placeholder={
+ props.placeholder ?? `Search ${props.label.toLowerCase()}...`
+ }
+ />
+ </div>
+
+ <div class="p-1">
+ <Show
+ when={filteredOptions().length > 0}
+ fallback={
+ <div class="py-3 px-2 text-center text-xs text-ink-muted whitespace-break-spaces break-words">
+ No options match "{searchQuery()}"
+ </div>
+ }
+ >
+ <Combobox.Listbox
+ ref={setListboxRef}
+ class="max-h-[200px] overflow-y-auto"
+ />
+ </Show>
+ </div>
+
+ <Show when={hasActiveFilters()}>
+ <div class="w-full pt-1 px-1 pb-1 flex items-center border-t border-t-edge-muted">
+ <Button
+ variant="primary"
+ size="sm"
+ class="ml-auto"
+ onClick={() => props.onChange([])}
+ >
+ Clear
+ </Button>
+ </div>
+ </Show>
+ </Combobox.Content>
+ </Combobox.Portal>
+ </Combobox>
+ );
+};
+
+interface FilterChipGroupProps {
+ options: Option[];
+ active: Option[];
+ onChange: (options: Option[]) => void;
+ multiple?: boolean;
+}
+
+export const FilterChipGroup = (props: FilterChipGroupProps) => {
+ const multiple = () => props.multiple ?? true;
+
+ const activeSet = createMemo(() => new Set(props.active.map((o) => o.value)));
+
+ const isActive = (value: string) => activeSet().has(value);
+
+ const handleClick = (option: Option) => {
+ const currentlyActive = isActive(option.value);
+
+ if (!multiple()) {
+ props.onChange(currentlyActive ? [] : [option]);
+ return;
+ }
+
+ if (currentlyActive) {
+ props.onChange(props.active.filter((o) => o.value !== option.value));
+ } else {
+ props.onChange([...props.active, option]);
+ }
+ };
+
+ return (
+ <div class="flex items-center gap-1 flex-wrap">
+ <For each={props.options}>
+ {(option) => (
+ <button
+ type="button"
+ class={cn(
+ 'flex items-center gap-1.5 px-2 py-1 text-xs rounded-md border transition-all',
+ isActive(option.value)
+ ? 'bg-accent/15 text-accent border-accent/30 hover:bg-accent/25'
+ : 'bg-ink/8 text-ink-muted border-transparent hover:bg-ink/12 hover:text-ink'
+ )}
+ onClick={() => handleClick(option)}
+ >
+ <Show
+ when={option.icon}
+ fallback={
+ <Show when={isActive(option.value)}>
+ <CheckIcon class="size-3.5 shrink-0" />
+ </Show>
+ }
+ >
+ {(icon) => (
+ <span class="size-3.5 flex items-center justify-center shrink-0">
+ <Show when={isActive(option.value)} fallback={icon()()}>
+ <CheckIcon class="size-3.5" />
+ </Show>
+ </span>
+ )}
+ </Show>
+ <span class="font-medium">{option.label}</span>
+ </button>
+ )}
+ </For>
+ </div>
+ );
+};
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/sort-dropdown.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/sort-dropdown.tsx
new file mode 100644
index 0000000000..6182edda95
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/sort-dropdown.tsx
@@ -0,0 +1,91 @@
+import { type Component, For, Show } from 'solid-js';
+import { DropdownMenu } from '@kobalte/core/dropdown-menu';
+import CheckIcon from '@icon/regular/check.svg';
+import ChevronDownIcon from '@icon/regular/caret-down.svg';
+import {
+ SORT_OPTIONS,
+ type SortOption,
+ type SystemSortOption,
+} from '@app/component/next-soup/soup-view/sort-options';
+import { Button } from '@app/component/next-soup/soup-view/filters-bar/button';
+
+export interface SortDropdownProps {
+ /** Current sort value */
+ value: () => SystemSortOption;
+ /** Handler for sort change */
+ onChange: (value: SystemSortOption) => void;
+ /** Available sort options (defaults to SORT_OPTIONS) */
+ options?: SortOption[];
+ /** Controlled open state (optional - uses internal state if not provided) */
+ open?: boolean;
+ /** Controlled open state setter (optional - uses internal state if not provided) */
+ onOpenChange?: (open: boolean) => void;
+}
+
+export const SortDropdown: Component<SortDropdownProps> = (props) => {
+ const options = () => props.options ?? SORT_OPTIONS;
+
+ const currentOption = () => options().find((o) => o.value === props.value());
+
+ const currentLabel = () => currentOption()?.label ?? 'Sort';
+
+ return (
+ <DropdownMenu
+ open={props.open}
+ onOpenChange={props.onOpenChange}
+ placement="bottom-start"
+ gutter={4}
+ >
+ <DropdownMenu.Trigger
+ as={Button}
+ variant="secondary"
+ size="sm"
+ class="whitespace-nowrap"
+ >
+ <Show when={currentOption()?.icon}>
+ {(icon) => (
+ <span class="size-3.5 flex items-center justify-center shrink-0">
+ {icon()()}
+ </span>
+ )}
+ </Show>
+ <span class="font-medium">{currentLabel()}</span>
+ <ChevronDownIcon class="size-3" />
+ </DropdownMenu.Trigger>
+ <DropdownMenu.Portal>
+ <DropdownMenu.Content class="z-action-menu bg-surface-0 border border-edge-muted rounded-lg shadow-xl min-w-[140px] p-1">
+ <For each={options()}>
+ {(option) => (
+ <DropdownMenu.Item
+ class="w-full flex items-center gap-2 px-2 py-2 text-left text-xs transition-colors hover:bg-ink/5 focus:bg-ink/5 outline-none cursor-default rounded-md"
+ onSelect={() => props.onChange(option.value)}
+ >
+ <Show when={option.icon}>
+ {(icon) => (
+ <span class="size-3.5 flex items-center justify-center shrink-0 text-ink-muted">
+ {icon()()}
+ </span>
+ )}
+ </Show>
+ <span
+ class="flex-1 truncate"
+ classList={{
+ 'text-ink font-medium': props.value() === option.value,
+ 'text-ink-muted': props.value() !== option.value,
+ }}
+ >
+ {option.label}
+ </span>
+ <span class="size-3.5 flex items-center justify-center shrink-0">
+ <Show when={props.value() === option.value}>
+ <CheckIcon class="size-3 text-accent" />
+ </Show>
+ </span>
+ </DropdownMenu.Item>
+ )}
+ </For>
+ </DropdownMenu.Content>
+ </DropdownMenu.Portal>
+ </DropdownMenu>
+ );
+};
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
new file mode 100644
index 0000000000..2648289d19
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx
@@ -0,0 +1,56 @@
+import { Button } from '@app/component/next-soup/soup-view/filters-bar/button';
+import { SoupViewContextFilters } from '@app/component/next-soup/soup-view/filters-bar/soup-view-context-filters';
+import { SoupViewContextSort } from '@app/component/next-soup/soup-view/filters-bar/soup-view-context-sort';
+import { SoupSearchbar } from '@app/component/next-soup/soup-view/filters-bar/soup-view-search-bar';
+import { useFilterRefinements } from '@app/component/next-soup/soup-view/filters-bar/use-filter-refinements';
+import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
+import type { ListView } from '@app/constants/list-views';
+import XIcon from '@icon/regular/x.svg';
+import { createMemo, Match, Show, Switch } from 'solid-js';
+
+export const SoupFiltersBar = () => {
+ const { hasActiveRefinements, resetToTabDefaults } = useFilterRefinements();
+
+ const panel = useSplitPanelOrThrow();
+
+ const component = createMemo(() => {
+ const content = panel.handle.content();
+
+ if (content.type !== 'component') return;
+
+ return content.id;
+ });
+
+ const isComponentListView = (listView: ListView) => {
+ return component() === listView;
+ };
+
+ return (
+ <Switch>
+ <Match when={isComponentListView('search')}>
+ <div class="w-full flex flex-col gap-2 p-2">
+ <SoupSearchbar autoFocus />
+ </div>
+ </Match>
+ <Match when={true}>
+ <div class="@container w-full overflow-hidden flex gap-2 flex-wrap py-2 pl-2 pr-1">
+ <SoupViewContextFilters />
+ <Show when={hasActiveRefinements()}>
+ <Button variant="ghost" size="sm" onClick={resetToTabDefaults}>
+ <XIcon class="size-3" />
+ <span>Clear all</span>
+ </Button>
+ </Show>
+
+ <div class="flex-1" />
+
+ <div class="max-w-60 w-full">
+ <SoupSearchbar />
+ </div>
+
+ <SoupViewContextSort />
+ </div>
+ </Match>
+ </Switch>
+ );
+};
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-filters.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-filters.tsx
new file mode 100644
index 0000000000..687e1c7427
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-filters.tsx
@@ -0,0 +1,145 @@
+import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
+import type { ListView } from '@app/constants/list-views';
+import { createMemo, Match, Show, Switch } from 'solid-js';
+import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
+import {
+ AssigneeFilter,
+ AttachmentTypeFilter,
+ ChannelVisibilityFilter,
+ DocumentFolderFilter,
+ DocumentTypeFilter,
+ EntityTypeFilter,
+ FileTypeFilter,
+ FoldersFilter,
+ FromSenderFilter,
+ HasAttachmentFilter,
+ HasCalendarInviteFilter,
+ ProjectFilter,
+ StatusFilter,
+ TaskPriorityFilter,
+ TaskStatusFilter,
+} from './filter-controls';
+
+const FilterDivider = () => (
+ <div class="flex items-center self-stretch mx-1">
+ <div class="w-px h-4 bg-edge-muted" />
+ </div>
+);
+
+export const SoupViewContextFilters = () => {
+ const panel = useSplitPanelOrThrow();
+
+ const component = createMemo(() => {
+ const content = panel.handle.content();
+
+ if (content.type !== 'component') return;
+
+ return content.id;
+ });
+
+ const isComponentListView = (listView: ListView) => {
+ return component() === listView;
+ };
+
+ return (
+ <Switch>
+ <Match when={isComponentListView('inbox')}>
+ <InboxFilters />
+ </Match>
+ <Match when={isComponentListView('agents')}>
+ <AgentsFilters />
+ </Match>
+ <Match when={isComponentListView('mail')}>
+ <MailFilters />
+ </Match>
+ <Match when={isComponentListView('documents')}>
+ <DocumentsFilters />
+ </Match>
+ <Match when={isComponentListView('tasks')}>
+ <TasksFilters />
+ </Match>
+ <Match when={isComponentListView('channels')}>
+ <ChannelsFilters />
+ </Match>
+ <Match when={isComponentListView('files')}>
+ <FilesFilters />
+ </Match>
+ </Switch>
+ );
+};
+
+const InboxFilters = () => {
+ return <EntityTypeFilter />;
+};
+
+const AgentsFilters = () => {
+ return <ProjectFilter />;
+};
+
+const MailFilters = () => {
+ const { activeTab, soup } = useSoupView();
+
+ const isDraftsTab = () => activeTab() === 'drafts';
+ const isSentTab = () => activeTab() === 'sent';
+ const hasAttachmentActive = () => soup.filters.isActive('has-attachment');
+
+ return (
+ <>
+ <Show when={!isDraftsTab()}>
+ <StatusFilter />
+ </Show>
+
+ <Show when={!isSentTab() && !isDraftsTab()}>
+ <FromSenderFilter />
+ <FilterDivider />
+ </Show>
+
+ <HasAttachmentFilter />
+
+ <Show when={hasAttachmentActive()}>
+ <AttachmentTypeFilter />
+ </Show>
+
+ <HasCalendarInviteFilter />
+ </>
+ );
+};
+
+const DocumentsFilters = () => {
+ return (
+ <>
+ <DocumentTypeFilter />
+ <FilterDivider />
+ <DocumentFolderFilter />
+ </>
+ );
+};
+
+const TasksFilters = () => {
+ const { soup } = useSoupView();
+
+ return (
+ <>
+ <TaskStatusFilter />
+ <TaskPriorityFilter />
+ <Show when={!soup.filters.isActive('assigned-to')}>
+ <FilterDivider />
+ <AssigneeFilter />
+ </Show>
+ </>
+ );
+};
+
+const ChannelsFilters = () => {
+ return <ChannelVisibilityFilter />;
+};
+
+const FilesFilters = () => {
+ return (
+ <>
+ <FoldersFilter />
+ <FilterDivider />
+ <FileTypeFilter />
+ </>
+ );
+};
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-sort.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-sort.tsx
new file mode 100644
index 0000000000..a5ebfe4e2f
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-context-sort.tsx
@@ -0,0 +1,151 @@
+import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
+import type { ListView } from '@app/constants/list-views';
+import { SortDropdown } from '@app/component/next-soup/soup-view/filters-bar/sort-dropdown';
+import {
+ SORT_OPTIONS,
+ TASK_SORT_OPTIONS,
+ type SortOption,
+ type SystemSortOption,
+} from '@app/component/next-soup/soup-view/sort-options';
+import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
+import { createMemo, Switch, Match } from 'solid-js';
+
+export const SoupViewContextSort = () => {
+ const panel = useSplitPanelOrThrow();
+
+ const component = createMemo(() => {
+ const content = panel.handle.content();
+
+ if (content.type !== 'component') return;
+
+ return content.id;
+ });
+
+ const isComponentListView = (listView: ListView) => {
+ return component() === listView;
+ };
+
+ return (
+ <Switch>
+ <Match when={isComponentListView('inbox')}>
+ <InboxSort />
+ </Match>
+ <Match when={isComponentListView('agents')}>
+ <AgentsSort />
+ </Match>
+ <Match when={isComponentListView('mail')}>
+ <MailSort />
+ </Match>
+ <Match when={isComponentListView('documents')}>
+ <DocumentsSort />
+ </Match>
+ <Match when={isComponentListView('tasks')}>
+ <TasksSort />
+ </Match>
+ <Match when={isComponentListView('channels')}>
+ <ChannelsSort />
+ </Match>
+ <Match when={isComponentListView('files')}>
+ <FilesSort />
+ </Match>
+ </Switch>
+ );
+};
+
+const useSortDropdown = (options: SortOption[] = SORT_OPTIONS) => {
+ const { soup } = useSoupView();
+
+ const value = createMemo(
+ () => (soup.sort.active()[0]?.id as SystemSortOption) ?? 'updated_at'
+ );
+
+ const onChange = (sortOption: SystemSortOption) => {
+ soup.sort.setAll([sortOption]);
+ };
+
+ return { value, onChange, options };
+};
+
+const InboxSort = () => {
+ const sort = useSortDropdown();
+
+ return (
+ <SortDropdown
+ value={sort.value}
+ onChange={sort.onChange}
+ options={sort.options}
+ />
+ );
+};
+
+const AgentsSort = () => {
+ const sort = useSortDropdown();
+
+ return (
+ <SortDropdown
+ value={sort.value}
+ onChange={sort.onChange}
+ options={sort.options}
+ />
+ );
+};
+
+const MailSort = () => {
+ const sort = useSortDropdown();
+
+ return (
+ <SortDropdown
+ value={sort.value}
+ onChange={sort.onChange}
+ options={sort.options}
+ />
+ );
+};
+
+const DocumentsSort = () => {
+ const sort = useSortDropdown();
+
+ return (
+ <SortDropdown
+ value={sort.value}
+ onChange={sort.onChange}
+ options={sort.options}
+ />
+ );
+};
+
+const TasksSort = () => {
+ const sort = useSortDropdown(TASK_SORT_OPTIONS);
+
+ return (
+ <SortDropdown
+ value={sort.value}
+ onChange={sort.onChange}
+ options={sort.options}
+ />
+ );
+};
+
+const ChannelsSort = () => {
+ const sort = useSortDropdown();
+
+ return (
+ <SortDropdown
+ value={sort.value}
+ onChange={sort.onChange}
+ options={sort.options}
+ />
+ );
+};
+
+const FilesSort = () => {
+ const sort = useSortDropdown();
+
+ return (
+ <SortDropdown
+ value={sort.value}
+ onChange={sort.onChange}
+ options={sort.options}
+ />
+ );
+};
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx
new file mode 100644
index 0000000000..1ebe0e6354
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-view-search-bar.tsx
@@ -0,0 +1,144 @@
+import XIcon from '@icon/regular/x.svg?component-solid';
+import SearchIcon from '@macro-icons/macro-magnifying-glass.svg';
+import { cn } from '@ui/utils/classname';
+import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
+import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
+import { Hotkey } from '@core/component/Hotkey';
+import { LabelAndHotKey, Tooltip } from '@core/component/Tooltip';
+import { registerHotkey } from '@core/hotkey/hotkeys';
+import { createSignal, createEffect, onCleanup, Show } from 'solid-js';
+
+type SearchbarVariant = 'filled' | 'secondary';
+
+interface SoupSearchbarProps {
+ variant?: SearchbarVariant;
+ autoFocus?: boolean;
+}
+
+const variantStyles: Record<SearchbarVariant, string> = {
+ filled:
+ 'bg-ink/8 text-ink-muted hover:bg-ink/12 hover:text-ink border-transparent focus-within:bg-ink/12 focus-within:text-ink',
+ secondary:
+ 'bg-transparent text-ink-muted border-edge hover:bg-ink/8 hover:text-ink focus-within:bg-ink/8 focus-within:text-ink',
+};
+
+export const SoupSearchbar = (props: SoupSearchbarProps) => {
+ const { searchText, setSearchText } = useSoupView();
+ const panel = useSplitPanelOrThrow();
+
+ const [ref, setRef] = createSignal<HTMLInputElement | undefined>();
+ let measureSpan: HTMLSpanElement | undefined;
+
+ const [searchFocused, setSearchFocused] = createSignal(false);
+ const [measuredWidth, setMeasuredWidth] = createSignal(0);
+
+ createEffect(() => {
+ if (measureSpan) {
+ measureSpan.textContent = searchText() || '';
+ setMeasuredWidth(measureSpan.scrollWidth);
+ }
+ });
+
+ createEffect(() => {
+ ref();
+ if (props.autoFocus) {
+ queueMicrotask(() => {
+ ref()?.focus();
+ });
+ }
+ });
+
+ const searchHotkey = registerHotkey({
+ hotkey: ['cmd+f'],
+ scopeId: panel.splitHotkeyScope,
+ description: 'Search',
+ keyDownHandler: () => {
+ ref()?.focus();
+ return true;
+ },
+ });
+
+ onCleanup(searchHotkey.dispose);
+
+ const MIN_INPUT_WIDTH = 48;
+
+ const inputWidth = () => {
+ if (!searchText() && !searchFocused()) return 0;
+ return Math.max(MIN_INPUT_WIDTH, measuredWidth());
+ };
+
+ return (
+ <div class="w-full flex items-center shrink-0 grow min-w-0 mobile:-order-2">
+ <Tooltip
+ class="w-full"
+ placement="bottom-start"
+ tooltip={<LabelAndHotKey label="Search" shortcut="⌘F" />}
+ >
+ <div
+ class={cn(
+ 'relative flex items-center gap-1 rounded-md py-1.5 mobile:h-9 pl-2 pr-1 mobile:min-w-35 border text-xs',
+ variantStyles[props.variant ?? 'secondary']
+ )}
+ onMouseDown={(e) => {
+ if (e.target !== ref()) {
+ e.preventDefault();
+ ref()?.focus();
+ }
+ }}
+ >
+ <SearchIcon class="size-4 shrink-0" />
+ <span
+ ref={(el) => {
+ measureSpan = el;
+ }}
+ class="invisible absolute whitespace-pre"
+ aria-hidden="true"
+ />
+ <input
+ ref={setRef}
+ type="text"
+ value={searchText()}
+ onInput={(e) => setSearchText(e.currentTarget.value)}
+ onFocus={() => setSearchFocused(true)}
+ onBlur={() => setSearchFocused(false)}
+ onKeyDown={(e) => {
+ if (
+ e.key === 'Escape' ||
+ e.key === 'Enter' ||
+ e.key === 'ArrowDown'
+ ) {
+ e.preventDefault();
+ e.currentTarget.blur();
+ }
+ }}
+ class="peer p-0 bg-transparent border-none outline-none ring-0 focus:outline-none focus:ring-0 cursor-default w-full"
+ style={{ width: `${inputWidth()}px` }}
+ />
+ <Show when={!searchText()}>
+ <span class="text-ink-placeholder leading-none pointer-events-none text-sm peer-focus:hidden">
+ Search
+ </span>
+ </Show>
+ <Show when={!searchText()}>
+ <div class="absolute -right-2 top-1/2 -translate-1/2 flex border border-edge text-xs rounded-md items-center px-1 py-px peer-focus:hidden">
+ <Hotkey shortcut="cmd+f" />
+ </div>
+ </Show>
+ <Show when={searchText()}>
+ <button
+ type="button"
+ class="ml-auto size-4 shrink-0 hover:opacity-60"
+ onMouseDown={(e) => {
+ e.preventDefault();
+ e.stopPropagation();
+ setSearchText('');
+ }}
+ >
+ <XIcon class="size-4" />
+ </button>
+ </Show>
+ </div>
+ </Tooltip>
+ </div>
+ );
+};
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-options.ts b/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-options.ts
new file mode 100644
index 0000000000..1362ae0abe
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-options.ts
@@ -0,0 +1,60 @@
+import { batch, createMemo } from 'solid-js';
+import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
+import type { SoupItemsQueryFilters } from '@queries/soup/items';
+import type { Option } from './filter-primitives';
+
+type UseFilterOptionsConfig = {
+ multiple?: boolean;
+ target?: 'and' | 'or';
+ /** Optional function to compute query filters based on selected option values */
+ getQueryFilters?: (selectedIds: string[]) => SoupItemsQueryFilters;
+};
+
+export const useFilterOptions = (
+ options: Option[],
+ config: UseFilterOptionsConfig = {}
+) => {
+ const { multiple = true, target = 'or', getQueryFilters } = config;
+ const { soup, setQueryFilters } = useSoupView();
+
+ const optionIds = options.map((opt) => opt.value);
+
+ const active = createMemo(() =>
+ options.filter((opt) => soup.filters.isActive(opt.value))
+ );
+
+ const onChange = (selected: Option[]) => {
+ const selectedIds = multiple
+ ? selected.map((opt) => opt.value)
+ : selected.length > 0
+ ? [selected[selected.length - 1].value]
+ : [];
+
+ batch(() => {
+ soup.filters.set((cur) => {
+ if (target === 'and') {
+ return {
+ and: [
+ ...cur.andIds.filter((id) => !optionIds.includes(id)),
+ ...selectedIds,
+ ],
+ or: cur.orIds,
+ };
+ }
+ return {
+ and: cur.andIds,
+ or: [
+ ...cur.orIds.filter((id) => !optionIds.includes(id)),
+ ...selectedIds,
+ ],
+ };
+ });
+
+ if (getQueryFilters) {
+ setQueryFilters(getQueryFilters(selectedIds));
+ }
+ });
+ };
+
+ return { active, onChange };
+};
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.ts b/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.ts
new file mode 100644
index 0000000000..4aec03672d
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/use-filter-refinements.ts
@@ -0,0 +1,98 @@
+import {
+ VIEW_TAB_PRESETS,
+ type PresetContext,
+} from '@app/component/app-sidebar/soup-filter-presets';
+import type { FilterID } from '@app/component/next-soup/filters/filters';
+import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
+import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
+import { isListViewID } from '@app/constants/list-views';
+import { useUserContext } from '@core/context/user';
+import { deepEqual } from '@core/util/compareUtils';
+import { batch, createMemo } from 'solid-js';
+
+/**
+ * Hook that provides detection of active filter refinements beyond tab defaults,
+ * and a function to reset filters to the current tab's default state.
+ */
+export function useFilterRefinements() {
+ const {
+ soup,
+ queryFilters,
+ setQueryFilters,
+ statusFilter,
+ setStatusFilter,
+ assigneeFilter,
+ setAssigneeFilter,
+ activeTab,
+ } = useSoupView();
+ const panel = useSplitPanelOrThrow();
+ const user = useUserContext();
+
+ const getPresetContext = (): PresetContext => ({
+ userId: user.userId(),
+ email: user.email(),
+ });
+
+ const currentView = createMemo(() => {
+ const content = panel.handle.content();
+
+ if (content.type !== 'component' || !isListViewID(content.id)) return;
+
+ return content.id;
+ });
+
+ const currentPreset = createMemo(() => {
+ const view = currentView();
+ if (!view) return undefined;
+
+ const viewConfig = VIEW_TAB_PRESETS[view];
+ if (!viewConfig) return undefined;
+
+ const tab = activeTab() ?? viewConfig.default;
+ const resolver = viewConfig.tabs[tab];
+ if (!resolver) return undefined;
+
+ return resolver(getPresetContext());
+ });
+
+ const hasActiveRefinements = createMemo(() => {
+ const preset = currentPreset();
+ if (!preset) return false;
+
+ const expectedIds = new Set([
+ ...(preset.clientFilters.and ?? []),
+ ...(preset.clientFilters.or ?? []),
+ ]);
+
+ const currentIds = new Set(soup.filters.activeIds() as FilterID[]);
+
+ const hasClientFilterDiff =
+ expectedIds.size !== currentIds.size ||
+ [...expectedIds].some((id) => !currentIds.has(id as FilterID));
+
+ const hasQueryFilterDiff = !deepEqual(queryFilters(), preset.queryFilters);
+
+ const hasSubFilters =
+ statusFilter().length > 0 || assigneeFilter().length > 0;
+
+ return hasClientFilterDiff || hasQueryFilterDiff || hasSubFilters;
+ });
+
+ const resetToTabDefaults = () => {
+ const preset = currentPreset();
+ if (!preset) return;
+
+ batch(() => {
+ soup.filters.set(preset.clientFilters);
+ setQueryFilters(preset.queryFilters);
+ setStatusFilter([]);
+ setAssigneeFilter([]);
+ });
+ };
+
+ return {
+ hasActiveRefinements,
+ resetToTabDefaults,
+ currentView,
+ };
+}
diff --git a/js/app/packages/app/component/next-soup/soup-view/sort-dropdown.tsx b/js/app/packages/app/component/next-soup/soup-view/sort-dropdown.tsx
deleted file mode 100644
index 4aa531630e..0000000000
--- a/js/app/packages/app/component/next-soup/soup-view/sort-dropdown.tsx
+++ /dev/null
@@ -1,130 +0,0 @@
-import { type Component, createSignal, For, Show } from 'solid-js';
-import { Popover } from '@kobalte/core/popover';
-import { LabelAndHotKey, Tooltip } from '@core/component/Tooltip';
-import SortIcon from '@macro-icons/wide/sort.svg';
-import type { SystemSortOption } from '@app/component/next-soup/soup-view/sort-options';
-import { ShortcutLabel } from '@app/component/next-soup/soup-view/soup-toolbar';
-
-export interface SortOption {
- value: SystemSortOption;
- label: string;
-}
-
-export const SORT_OPTIONS: SortOption[] = [
- { value: 'viewed_at', label: 'Viewed' },
- { value: 'updated_at', label: 'Updated' },
- { value: 'created_at', label: 'Created' },
-];
-
-export interface SortDropdownProps {
- /** Current sort value */
- value: () => SystemSortOption;
- /** Handler for sort change */
- onChange: (value: SystemSortOption) => void;
- /** Available sort options (defaults to SORT_OPTIONS) */
- options?: SortOption[];
- /** Controlled open state (optional - uses internal state if not provided) */
- open?: () => boolean;
- /** Controlled open state setter (optional - uses internal state if not provided) */
- onOpenChange?: (open: boolean) => void;
-}
-
-export const SortDropdown: Component<SortDropdownProps> = (props) => {
- // Internal state for uncontrolled mode
- const [internalOpen, setInternalOpen] = createSignal(false);
- const [focusedIndex, setFocusedIndex] = createSignal(0);
-
- // Use controlled or uncontrolled state
- const open = () => props.open?.() ?? internalOpen();
- const setOpen = (isOpen: boolean) => {
- if (props.onOpenChange) {
- props.onOpenChange(isOpen);
- } else {
- setInternalOpen(isOpen);
- }
- };
-
- const options = () => props.options ?? SORT_OPTIONS;
-
- const handleKeyDown = (e: KeyboardEvent) => {
- const totalItems = options().length;
-
- if (e.key === 'ArrowDown') {
- e.preventDefault();
- setFocusedIndex((prev) => (prev + 1) % totalItems);
- } else if (e.key === 'ArrowUp') {
- e.preventDefault();
- setFocusedIndex((prev) => (prev - 1 + totalItems) % totalItems);
- } else if (e.key === 'Enter') {
- e.preventDefault();
- props.onChange(options()[focusedIndex()].value);
- setOpen(false);
- } else if (e.key === 'Escape') {
- e.preventDefault();
- setOpen(false);
- }
- };
-
- return (
- <Popover
- open={open()}
- onOpenChange={(isOpen) => {
- setOpen(isOpen);
- if (isOpen) setFocusedIndex(0);
- }}
- placement="bottom-start"
- gutter={4}
- >
- <Tooltip tooltip={<LabelAndHotKey label="Sort" shortcut="s" />}>
- <Popover.Trigger
- as="button"
- type="button"
- class="flex items-center gap-1.5 h-[22px] px-2.5 shrink-0 rounded-full active:bg-accent active:text-panel"
- classList={{
- 'bg-accent text-panel': open(),
- 'text-ink-muted hover:text-accent hover:bg-accent/20': !open(),
- }}
- >
- <SortIcon class="size-4.5" />
- <span class="leading-none">
- <ShortcutLabel label="Sort" shortcut="s" />
- </span>
- </Popover.Trigger>
- </Tooltip>
- <Popover.Portal>
- <Popover.Content
- class="z-50 bg-panel border border-edge-muted shadow-lg"
- tabIndex={0}
- ref={(el) => setTimeout(() => el?.focus(), 0)}
- onKeyDown={handleKeyDown}
- >
- <div class="flex flex-col gap-1 p-2 min-w-[140px]">
- <For each={options()}>
- {(option, index) => (
- <button
- type="button"
- class="flex items-center justify-between px-2 py-1.5 text-sm hover:bg-hover"
- classList={{
- 'bg-hover text-ink': props.value() === option.value,
- 'text-ink': props.value() !== option.value,
- 'bg-hover': focusedIndex() === index(),
- }}
- onClick={() => {
- props.onChange(option.value);
- setOpen(false);
- }}
- onMouseEnter={() => setFocusedIndex(index())}
- >
- <span>{option.label}</span>
- <Show when={props.value() === option.value}>
- <span class="text-ink">✓</span>
- </Show>
- </button>
- )}
- </For>
- </div>
- </Popover.Content>
- </Popover.Portal>
- </Popover>
- );
-};
diff --git a/js/app/packages/app/component/next-soup/soup-view/sort-options.ts b/js/app/packages/app/component/next-soup/soup-view/sort-options.ts
deleted file mode 100644
index 0f78a9913a..0000000000
--- a/js/app/packages/app/component/next-soup/soup-view/sort-options.ts
+++ /dev/null
@@ -1,63 +0,0 @@
-import type { SortConfig } from '@app/component/next-soup/create-soup-state';
-import type { SoupEntity } from '@app/component/next-soup/soup-view/soup-view-context';
-import type { EntityData, WithNotification } from '@entity';
-import { compareDateDesc } from '@core/util/date';
-
-export type SystemSortOption =
- | 'updated_at'
- | 'created_at'
- | 'viewed_at'
- | 'frecency';
-
-export function sortByNotifiedAt<T extends WithNotification<EntityData>>(
- a: T,
- b: T
-) {
- const aNotification = a.notifications?.()[0];
- const bNotification = b.notifications?.()[0];
-
- if (aNotification && bNotification) {
- return compareDateDesc(aNotification.created_at, bNotification.created_at);
- } else if (aNotification) {
- return -1;
- } else if (bNotification) {
- return 1;
- }
-
- return sortByUpdatedAt(a, b);
-}
-
-export function sortByCreatedAt<T extends EntityData>(a: T, b: T): number {
- return compareDateDesc(a.createdAt, b.createdAt);
-}
-
-export function sortByUpdatedAt<T extends EntityData>(a: T, b: T) {
- return compareDateDesc(a.updatedAt, b.updatedAt);
-}
-
-export function sortByViewedAt<T extends EntityData>(a: T, b: T) {
- return compareDateDesc(a.viewedAt, b.viewedAt);
-}
-
-export function sortByFrecencyScore<T extends EntityData>(a: T, b: T): number {
- return (b.frecencyScore ?? 0) - (a.frecencyScore ?? 0);
-}
-
-export const SORT_CONFIGS = {
- updated_at: {
- id: 'updated_at',
- fn: sortByUpdatedAt,
- },
- created_at: {
- id: 'created_at',
- fn: sortByCreatedAt,
- },
- viewed_at: {
- id: 'viewed_at',
- fn: sortByViewedAt,
- },
- frecency: {
- id: 'frecency',
- fn: sortByFrecencyScore,
- },
-} satisfies Record<string, SortConfig<SoupEntity>>;
diff --git a/js/app/packages/app/component/next-soup/soup-view/sort-options.tsx b/js/app/packages/app/component/next-soup/soup-view/sort-options.tsx
new file mode 100644
index 0000000000..5bc8658444
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/sort-options.tsx
@@ -0,0 +1,208 @@
+import type { SortConfig } from '@app/component/next-soup/create-soup-state';
+import type { SoupEntity } from '@app/component/next-soup/soup-view/soup-view-context';
+import type {
+ EntityData,
+ TaskEntityWithProperties,
+ WithNotification,
+} from '@entity';
+import {
+ getTaskPriorityOptionId,
+ getTaskStatusOptionId,
+} from '@entity/utils/task-properties';
+import { compareDateDesc } from '@core/util/date';
+import { PROPERTY_OPTION_IDS } from '@core/component/Properties/constants';
+import type { JSX } from 'solid-js';
+import ClockIcon from '@icon/regular/clock.svg';
+import ArrowClockwiseIcon from '@icon/regular/arrow-clockwise.svg';
+import EyeIcon from '@icon/regular/eye.svg';
+import ChartLineUpIcon from '@icon/regular/chart-line-up.svg';
+import FlagIcon from '@icon/regular/flag.svg';
+import ListChecksIcon from '@icon/regular/list-checks.svg';
+
+export type SystemSortOption =
+ | 'updated_at'
+ | 'created_at'
+ | 'viewed_at'
+ | 'frecency'
+ | 'priority'
+ | 'status';
+
+export interface SortOption {
+ value: SystemSortOption;
+ label: string;
+ icon?: () => JSX.Element;
+}
+
+export function sortByNotifiedAt<T extends WithNotification<EntityData>>(
+ a: T,
+ b: T
+) {
+ const aNotification = a.notifications?.()[0];
+ const bNotification = b.notifications?.()[0];
+
+ if (aNotification && bNotification) {
+ return compareDateDesc(aNotification.created_at, bNotification.created_at);
+ } else if (aNotification) {
+ return -1;
+ } else if (bNotification) {
+ return 1;
+ }
+
+ return sortByUpdatedAt(a, b);
+}
+
+export function sortByCreatedAt<T extends EntityData>(a: T, b: T): number {
+ return compareDateDesc(a.createdAt, b.createdAt);
+}
+
+export function sortByUpdatedAt<T extends EntityData>(a: T, b: T) {
+ return compareDateDesc(a.updatedAt, b.updatedAt);
+}
+
+export function sortByViewedAt<T extends EntityData>(a: T, b: T) {
+ return compareDateDesc(a.viewedAt, b.viewedAt);
+}
+
+export function sortByFrecencyScore<T extends EntityData>(a: T, b: T): number {
+ return (b.frecencyScore ?? 0) - (a.frecencyScore ?? 0);
+}
+
+/**
+ * Priority sort order: Urgent (highest) -> High -> Medium -> Low -> No priority (lowest)
+ */
+const PRIORITY_ORDER: Record<string, number> = {
+ [PROPERTY_OPTION_IDS.PRIORITY.URGENT]: 0,
+ [PROPERTY_OPTION_IDS.PRIORITY.HIGH]: 1,
+ [PROPERTY_OPTION_IDS.PRIORITY.MEDIUM]: 2,
+ [PROPERTY_OPTION_IDS.PRIORITY.LOW]: 3,
+};
+const NO_PRIORITY_ORDER = 4;
+
+const getPriorityOrder = (priority: string | undefined) => {
+ if (!priority) return NO_PRIORITY_ORDER;
+
+ return PRIORITY_ORDER[priority] ?? NO_PRIORITY_ORDER;
+};
+
+/**
+ * Status sort order: Not Started -> In Progress -> In Review -> Completed -> Canceled
+ */
+const STATUS_ORDER: Record<string, number> = {
+ [PROPERTY_OPTION_IDS.STATUS.NOT_STARTED]: 0,
+ [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS]: 1,
+ [PROPERTY_OPTION_IDS.STATUS.IN_REVIEW]: 2,
+ [PROPERTY_OPTION_IDS.STATUS.COMPLETED]: 3,
+ [PROPERTY_OPTION_IDS.STATUS.CANCELED]: 4,
+};
+
+const NO_STATUS_ORDER = 5;
+
+const getStatusOrder = (status: string | undefined) => {
+ if (!status) return NO_STATUS_ORDER;
+
+ return STATUS_ORDER[status] ?? NO_STATUS_ORDER;
+};
+
+/**
+ * Sort tasks by priority (Urgent first, no priority last).
+ * Non-task entities are sorted to the end.
+ */
+export function sortByPriority<T extends EntityData>(a: T, b: T): number {
+ // Cast to TaskEntityWithProperties - the getter safely handles missing properties
+ const aPriority = getTaskPriorityOptionId(a as TaskEntityWithProperties);
+ const bPriority = getTaskPriorityOptionId(b as TaskEntityWithProperties);
+
+ const aOrder = getPriorityOrder(aPriority);
+ const bOrder = getPriorityOrder(bPriority);
+
+ if (aOrder !== bOrder) {
+ return aOrder - bOrder;
+ }
+
+ // Fall back to updated_at for same priority
+ return sortByUpdatedAt(a, b);
+}
+
+/**
+ * Sort tasks by status (Not Started first, Canceled last).
+ * Non-task entities are sorted to the end.
+ */
+export function sortByStatus<T extends EntityData>(a: T, b: T): number {
+ // Cast to TaskEntityWithProperties - the getter safely handles missing properties
+ const aStatus = getTaskStatusOptionId(a as TaskEntityWithProperties);
+ const bStatus = getTaskStatusOptionId(b as TaskEntityWithProperties);
+
+ const aOrder = getStatusOrder(aStatus);
+ const bOrder = getStatusOrder(bStatus);
+
+ if (aOrder !== bOrder) {
+ return aOrder - bOrder;
+ }
+
+ // Fall back to updated_at for same status
+ return sortByUpdatedAt(a, b);
+}
+
+export const SORT_CONFIGS = {
+ updated_at: {
+ id: 'updated_at',
+ fn: sortByUpdatedAt,
+ },
+ created_at: {
+ id: 'created_at',
+ fn: sortByCreatedAt,
+ },
+ viewed_at: {
+ id: 'viewed_at',
+ fn: sortByViewedAt,
+ },
+ frecency: {
+ id: 'frecency',
+ fn: sortByFrecencyScore,
+ },
+ priority: {
+ id: 'priority',
+ fn: sortByPriority,
+ },
+ status: {
+ id: 'status',
+ fn: sortByStatus,
+ },
+} satisfies Record<string, SortConfig<SoupEntity>>;
+
+export const SORT_OPTIONS: SortOption[] = [
+ {
+ value: 'viewed_at',
+ label: 'Last viewed',
+ icon: () => <EyeIcon class="size-3.5" />,
+ },
+ {
+ value: 'updated_at',
+ label: 'Last updated',
+ icon: () => <ArrowClockwiseIcon class="size-3.5" />,
+ },
+ {
+ value: 'created_at',
+ label: 'Date created',
+ icon: () => <ClockIcon class="size-3.5" />,
+ },
+ {
+ value: 'frecency',
+ label: 'Frecency',
+ icon: () => <ChartLineUpIcon class="size-3.5" />,
+ },
+];
+
+export const TASK_SORT_OPTIONS: SortOption[] = [
+ ...SORT_OPTIONS,
+ {
+ value: 'priority',
+ label: 'Priority',
+ icon: () => <FlagIcon class="size-3.5" />,
+ },
+ {
+ value: 'status',
+ label: 'Status',
+ icon: () => <ListChecksIcon class="size-3.5" />,
+ },
+];
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-toolbar.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-toolbar.tsx
deleted file mode 100644
index 2c9374c0ae..0000000000
--- a/js/app/packages/app/component/next-soup/soup-view/soup-toolbar.tsx
+++ /dev/null
@@ -1,773 +0,0 @@
-import SearchIcon from '@macro-icons/macro-magnifying-glass.svg';
-import BackspaceIcon from '@icon/regular/backspace.svg?component-solid';
-import XIcon from '@icon/regular/x.svg?component-solid';
-import PreviewIcon from '@macro-icons/wide/preview.svg';
-import NoiseIcon from '@macro-icons/wide/noise.svg';
-import SignalIcon from '@macro-icons/wide/signal.svg';
-import { AnimatedNoiseIcon } from '@macro-icons/wide/animating/noise';
-import { AnimatedSignalIcon } from '@macro-icons/wide/animating/signal';
-import {
- SplitHeaderLeft,
- SplitHeaderRight,
-} from '@app/component/split-layout/components/SplitHeader';
-import { LabelAndHotKey, Tooltip } from '@core/component/Tooltip';
-
-import {
- For,
- Show,
- onCleanup,
- createSignal,
- onMount,
- createEffect,
- batch,
- type Component,
-} from 'solid-js';
-import {
- ANIMATED_ICONS,
- ENTITY_TYPE_FILTER_CONFIGS,
- EXCLUDE,
- getEntityTypeFilterIcon,
- QUERY_FILTERS,
-} from '@app/component/next-soup/filters/filters';
-import {
- applyInboxQueryFilters,
- applyOtherQueryFilters,
- removeInboxQueryFilters,
- removeOtherQueryFilters,
-} from '@app/component/next-soup/filters/inbox-query-filters';
-import { ENABLE_ANIMATED_ICONS } from '@core/constant/featureFlags';
-import { registerHotkey } from '@core/hotkey/hotkeys';
-import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
-import { useEmailLinksStatus } from '@core/email-link';
-import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
-import type { ValidHotkey } from '@core/hotkey/types';
-import { createElementSize } from '@solid-primitives/resize-observer';
-import { IS_MAC } from '@core/constant/isMac';
-import type { SystemSortOption } from '@app/component/next-soup/soup-view/sort-options';
-import { Dynamic } from 'solid-js/web';
-import { SortDropdown } from '@app/component/next-soup/soup-view/sort-dropdown';
-import { SettingsButton } from '@app/component/settings/SettingsButton';
-import {
- TaskStatusDropdown,
- TaskAssigneeDropdown,
-} from '@app/component/next-soup/soup-view/task-sub-filters';
-import type { SoupItemsQueryFilters } from '@queries/soup/items';
-import { match } from 'ts-pattern';
-
-/**
- * Keyboard shortcuts for entity type filters.
- * This object is the single source of truth for filter shortcuts,
- * used by both the filter buttons and hotkey registrations.
- */
-const ENTITY_TYPE_SHORTCUTS: Record<
- (typeof ENTITY_TYPE_FILTER_CONFIGS)[number]['id'],
- ValidHotkey
-> = {
- document: 'd',
- task: 't',
- email: 'l',
- people: 'p',
- teams: 'm',
- agent: 'a',
- file: 'f',
-};
-
-export const SoupToolbar = () => {
- const { soup, setSearchText, setQueryFilters } = useSoupView();
-
- const [scrollContainerRef, setScrollContainerRef] = createSignal<
- HTMLDivElement | undefined
- >(undefined);
-
- const handleClear = () => {
- batch(() => {
- soup.filters.clear();
- setSearchText('');
- setQueryFilters(QUERY_FILTERS.default);
- });
- };
-
- return (
- <>
- <SplitHeaderLeft>
- <div class="relative h-full w-full">
- <ScrollIndicators scrollRef={scrollContainerRef()} />
-
- <div
- ref={setScrollContainerRef}
- class="flex items-center h-full w-full overflow-x-auto scrollbar-hidden overscroll-none text-xs mobile:text-sm"
- >
- <SoupFilters />
- <SearchBar />
- </div>
- </div>
- </SplitHeaderLeft>
-
- <SplitHeaderRight>
- <Tooltip
- tooltip={<LabelAndHotKey label="Clear filters" shortcut="/" />}
- >
- <button
- type="button"
- class="flex items-center justify-center size-[22px] rounded-full text-ink-muted hover:text-accent hover:bg-accent/20 active:bg-accent active:text-panel"
- onClick={handleClear}
- >
- <BackspaceIcon class="size-4.5" />
- </button>
- </Tooltip>
- <div class="mx-0.5 w-px h-5 bg-edge-muted/50 shrink-0" />
- <SettingsButton />
- </SplitHeaderRight>
- </>
- );
-};
-
-type EntityTypeFilterId =
- | 'document'
- | 'task'
- | 'people'
- | 'teams'
- | 'agent'
- | 'file';
-
-const SoupFilters = () => {
- const { soup, setSearchText, setQueryFilters } = useSoupView();
- const panel = useSplitPanelOrThrow();
- const emailActive = useEmailLinksStatus();
-
- const [sortDropdownOpen, setSortDropdownOpen] = createSignal(false);
- const [statusDropdownOpen, setStatusDropdownOpen] = createSignal(false);
- const [assigneeDropdownOpen, setAssigneeDropdownOpen] = createSignal(false);
-
- const setQueryFiltersInboxAware = (filters: SoupItemsQueryFilters) => {
- if (soup.filters.isActive('signal')) {
- setQueryFilters(applyInboxQueryFilters(filters));
- return;
- }
- if (soup.filters.isActive('noise')) {
- setQueryFilters(applyOtherQueryFilters(removeInboxQueryFilters(filters)));
- return;
- }
- setQueryFilters(removeInboxQueryFilters(filters));
- };
-
- // Batch filter + query updates so the prefetch effect in soup-view-context
- // sees the final query filters and active filter state in a single tick,
- // avoiding intermediate re-renders with mismatched query keys.
- const toggleFocus = (id: 'signal' | 'noise') => {
- const comb = { id, isActive: soup.filters.isActive(id) };
-
- const activateFocus = () => {
- soup.filters.toggle(id);
- soup.filters.activate('not-done');
- };
-
- const deactivateFocus = () => {
- soup.filters.toggle('explicit-noise');
- soup.filters.deactivate('not-done');
- };
-
- batch(() => {
- match(comb)
- .with({ id: 'signal', isActive: false }, () => {
- setQueryFilters((prev) =>
- applyInboxQueryFilters(removeOtherQueryFilters(prev))
- );
- activateFocus();
- })
- .with({ id: 'noise', isActive: false }, () => {
- setQueryFilters((prev) =>
- applyOtherQueryFilters(removeInboxQueryFilters(prev))
- );
- activateFocus();
- })
- .with({ id: 'signal', isActive: true }, () => {
- setQueryFilters(removeInboxQueryFilters);
- deactivateFocus();
- })
- .with({ id: 'noise', isActive: true }, () => {
- setQueryFilters(removeOtherQueryFilters);
- deactivateFocus();
- })
- .exhaustive();
- });
- };
-
- const toggleUnread = () => {
- soup.filters.toggle('unread');
- };
-
- const toggleEntityType = (id: EntityTypeFilterId) => {
- const willBeActive = !soup.filters.isActive(id);
- batch(() => {
- soup.filters.toggle(id);
- setQueryFiltersInboxAware(
- willBeActive ? QUERY_FILTERS[id] : QUERY_FILTERS.default
- );
- });
- };
-
- // Email has special handling for email integration status
- const toggleEmail = () => {
- const willBeActive = !soup.filters.isActive('email');
- batch(() => {
- soup.filters.toggle('email');
- if (willBeActive) {
- const shouldIncludeEmails = emailActive();
- setQueryFiltersInboxAware({
- ...QUERY_FILTERS.email,
- email_filters: {
- recipients: shouldIncludeEmails ? [] : EXCLUDE,
- },
- });
- } else {
- setQueryFiltersInboxAware(QUERY_FILTERS.default);
- }
- });
- };
-
- const entityTypeToggleHandlers: Record<
- (typeof ENTITY_TYPE_FILTER_CONFIGS)[number]['id'],
- () => void
- > = {
- document: () => toggleEntityType('document'),
- task: () => toggleEntityType('task'),
- email: toggleEmail,
- people: () => toggleEntityType('people'),
- teams: () => toggleEntityType('teams'),
- agent: () => toggleEntityType('agent'),
- file: () => toggleEntityType('file'),
- };
-
- const togglePreview = () => {
- const currentPreview = soup.previewEntity();
- if (currentPreview) {
- soup.setPreviewEntity(undefined);
- return;
- }
-
- const focused = soup.focus.id();
-
- if (!focused) return;
-
- soup.setPreviewEntity(focused);
- };
-
- const hotkeyConfigs: {
- hotkey: ValidHotkey;
- description: string;
- handler: () => void;
- }[] = [
- {
- hotkey: 'i',
- description: 'Toggle Inbox',
- handler: () => toggleFocus('signal'),
- },
- {
- hotkey: 'o',
- description: 'Toggle Other',
- handler: () => toggleFocus('noise'),
- },
- // Entity type filter hotkeys
- {
- hotkey: ENTITY_TYPE_SHORTCUTS.document,
- description: 'Filter by Docs',
- handler: () => toggleEntityType('document'),
- },
- {
- hotkey: ENTITY_TYPE_SHORTCUTS.task,
- description: 'Filter by Tasks',
- handler: () => toggleEntityType('task'),
- },
- {
- hotkey: ENTITY_TYPE_SHORTCUTS.email,
- description: 'Filter by Mail',
- handler: toggleEmail,
- },
- {
- hotkey: ENTITY_TYPE_SHORTCUTS.people,
- description: 'Filter by People',
- handler: () => toggleEntityType('people'),
- },
- {
- hotkey: ENTITY_TYPE_SHORTCUTS.teams,
- description: 'Filter by Teams',
- handler: () => toggleEntityType('teams'),
- },
- {
- hotkey: ENTITY_TYPE_SHORTCUTS.agent,
- description: 'Filter by Agents',
- handler: () => toggleEntityType('agent'),
- },
- {
- hotkey: ENTITY_TYPE_SHORTCUTS.file,
- description: 'Filter by Files',
- handler: () => toggleEntityType('file'),
- },
- {
- hotkey: 'u',
- description: 'Filter by Unread',
- handler: toggleUnread,
- },
- {
- hotkey: 's',
- description: 'Open sort menu',
- handler: () => setSortDropdownOpen((prev) => !prev),
- },
- {
- hotkey: '/',
- description: 'Clear filters',
- handler: () => {
- batch(() => {
- soup.filters.clear();
- setQueryFilters(QUERY_FILTERS.default);
- setSearchText('');
- });
- },
- },
- {
- hotkey: 'space',
- description: 'Toggle preview',
- handler: () => {
- togglePreview();
- },
- },
- ];
-
- const hotkeyDisposers = hotkeyConfigs.map((config) =>
- registerHotkey({
- hotkey: [config.hotkey],
- scopeId: panel.splitHotkeyScope,
- description: config.description,
- keyDownHandler: () => {
- config.handler();
- return true;
- },
- })
- );
-
- onCleanup(() => {
- hotkeyDisposers.forEach((d) => d.dispose());
- });
-
- const taskSubFilterHotkeyDisposers = [
- registerHotkey({
- hotkey: ['shift+s'],
- scopeId: panel.splitHotkeyScope,
- condition: () => soup.filters.isActive('task'),
- description: 'Open status filter',
- keyDownHandler: () => {
- setStatusDropdownOpen((prev) => !prev);
- return true;
- },
- }),
- registerHotkey({
- hotkey: ['shift+a'],
- scopeId: panel.splitHotkeyScope,
- condition: () => soup.filters.isActive('task'),
- description: 'Open assignee filter',
- keyDownHandler: () => {
- setAssigneeDropdownOpen((prev) => !prev);
- return true;
- },
- }),
- ];
-
- onCleanup(() => taskSubFilterHotkeyDisposers.forEach((d) => d.dispose()));
-
- return (
- <>
- {/* Inbox toggle */}
- <FilterButton
- icon={SignalIcon}
- animatedIcon={AnimatedSignalIcon}
- label="Inbox"
- shortcut="i"
- isActive={soup.filters.isActive('signal')}
- onClick={() => toggleFocus('signal')}
- />
- {/* Other toggle */}
- <FilterButton
- icon={NoiseIcon}
- animatedIcon={AnimatedNoiseIcon}
- label="Other"
- shortcut="o"
- isActive={soup.filters.isActive('noise')}
- onClick={() => toggleFocus('noise')}
- />
- <FilterDivider />
- {/* Unread filter */}
- <div class="flex items-center mr-0.5 shrink-0">
- <Tooltip tooltip={<LabelAndHotKey label="Unread Only" shortcut="u" />}>
- <button
- type="button"
- class="flex items-center gap-1 h-[22px] mobile:h-9 pr-2.5 pl-1 active:bg-accent active:text-panel rounded-full"
- classList={{
- 'bg-accent text-panel': soup.filters.isActive('unread'),
- 'text-ink-muted hover:text-accent hover:bg-accent/20':
- !soup.filters.isActive('unread'),
- }}
- onClick={toggleUnread}
- >
- <svg
- class="size-4"
- viewBox="0 0 24 24"
- fill="currentColor"
- stroke="none"
- xmlns="http://www.w3.org/2000/svg"
- >
- <circle cx="12" cy="12" r="4" />
- </svg>
- <span class="leading-none">
- <ShortcutLabel label="Unread" shortcut="u" />
- </span>
- </button>
- </Tooltip>
- </div>
- <div class="mx-0.5 w-px h-5 bg-edge-muted/50 shrink-0" />
- {/* Entity type icons */}
- <div class="flex items-center shrink-0">
- <For each={ENTITY_TYPE_FILTER_CONFIGS}>
- {(filter) => {
- const iconConfig = () => getEntityTypeFilterIcon(filter.id);
- const shortcut = ENTITY_TYPE_SHORTCUTS[filter.id];
- const animatedIcon = ANIMATED_ICONS[filter.id];
-
- return (
- <FilterButton
- icon={iconConfig().icon}
- animatedIcon={animatedIcon}
- label={filter.label ?? ''}
- shortcut={shortcut}
- isActive={() => soup.filters.isActive(filter.id)}
- onClick={entityTypeToggleHandlers[filter.id]}
- paddingClass="px-2.5"
- />
- );
- }}
- </For>
- </div>
- <Show when={soup.filters.isActive('task')}>
- <FilterDivider />
- <div class="flex items-center gap-1 shrink-0">
- <TaskStatusDropdown
- open={statusDropdownOpen}
- onOpenChange={setStatusDropdownOpen}
- />
- <TaskAssigneeDropdown
- open={assigneeDropdownOpen}
- onOpenChange={setAssigneeDropdownOpen}
- />
- </div>
- </Show>
- <div class="mx-0.5 w-px h-5 bg-edge-muted/50 shrink-0" />
- {/* Preview toggle */}
- <Tooltip
- tooltip={<LabelAndHotKey label="Toggle Preview" shortcut="space" />}
- >
- <button
- type="button"
- class="flex items-center gap-1.5 h-[22px] mobile:h-9 px-2.5 active:bg-accent active:text-panel rounded-full"
- classList={{
- 'bg-accent text-panel': !!soup.previewEntity(),
- 'text-ink-muted hover:text-accent hover:bg-accent/20':
- !soup.previewEntity(),
- }}
- disabled={!soup.focus.id()}
- onClick={togglePreview}
- >
- <PreviewIcon class="size-4.5" />
- <span class="leading-none">
- <ShortcutLabel label="Preview" shortcut="space" />
- </span>
- </button>
- </Tooltip>
- <FilterDivider />
- {/* Sort dropdown */}
- <SortDropdown
- open={sortDropdownOpen}
- onOpenChange={setSortDropdownOpen}
- value={() => soup.sort.active()[0].id as SystemSortOption}
- onChange={(value) => {
- soup.sort.setAll([value]);
- }}
- />
- <div class="mobile:-order-1">
- <FilterDivider />
- </div>
- {/* Filter search bar */}
- </>
- );
-};
-
-const ScrollIndicators = (props: { scrollRef: HTMLElement | undefined }) => {
- const [leftOpacity, setLeftOpacity] = createSignal(0);
- const [rightOpacity, setRightOpacity] = createSignal(0);
- const SCROLL_THRESHOLD = 10;
-
- // Track size changes to update indicators
- const size = createElementSize(() => props.scrollRef);
- const containerWidth = () => size.width ?? 0;
-
- const updateClipIndicators = () => {
- const ref = props.scrollRef;
- if (!ref) return;
- const { scrollLeft, scrollWidth, clientWidth } = ref;
-
- const leftAmount = Math.min(scrollLeft, SCROLL_THRESHOLD);
- setLeftOpacity(leftAmount / SCROLL_THRESHOLD);
-
- const maxScroll = scrollWidth - clientWidth;
- const remainingScroll = maxScroll - scrollLeft;
- const rightAmount = Math.min(remainingScroll, SCROLL_THRESHOLD);
- setRightOpacity(rightAmount / SCROLL_THRESHOLD);
- };
-
- // Update indicators when size changes
- createEffect(() => {
- containerWidth(); // Track size changes
- updateClipIndicators();
- });
-
- onMount(() => {
- const ref = props.scrollRef;
- if (!ref) return;
-
- // Convert vertical scroll to horizontal scroll
- const wheelListener = (e: WheelEvent) => {
- e.preventDefault();
- const { deltaX, deltaY } = e;
- const delta = Math.abs(deltaX) > Math.abs(deltaY) ? deltaX : deltaY;
- ref.scrollLeft += delta;
- updateClipIndicators();
- };
-
- ref.addEventListener('wheel', wheelListener);
- ref.addEventListener('scroll', updateClipIndicators);
- onCleanup(() => {
- ref?.removeEventListener('wheel', wheelListener);
- ref?.removeEventListener('scroll', updateClipIndicators);
- });
- });
- return (
- <>
- {/* Left clip boundary indicator */}
- <div
- class="absolute pointer-events-none left-0 top-px bottom-px w-3 z-2 pattern-diagonal-4 pattern-edge mask-r-from-0% border-l border-edge-muted"
- style={{ opacity: leftOpacity() }}
- />
- {/* Right clip boundary indicator */}
- <div
- class="absolute pointer-events-none right-0 top-px bottom-px w-3 z-2 pattern-diagonal-4 pattern-edge mask-l-from-0% border-r border-edge-muted"
- style={{ opacity: rightOpacity() }}
- />
- </>
- );
-};
-
-const SearchBar = () => {
- const { searchText, setSearchText } = useSoupView();
- const panel = useSplitPanelOrThrow();
-
- const [ref, setRef] = createSignal<HTMLInputElement | undefined>();
- let measureSpan: HTMLSpanElement | undefined;
-
- const [searchFocused, setSearchFocused] = createSignal(false);
- const [measuredWidth, setMeasuredWidth] = createSignal(0);
-
- createEffect(() => {
- if (measureSpan) {
- measureSpan.textContent = searchText() || '';
- setMeasuredWidth(measureSpan.scrollWidth);
- }
- });
-
- const searchHotkey = registerHotkey({
- hotkey: ['cmd+f'],
- scopeId: panel.splitHotkeyScope,
- description: 'Search',
- keyDownHandler: () => {
- ref()?.focus();
- return true;
- },
- });
-
- onCleanup(searchHotkey.dispose);
-
- const MIN_INPUT_WIDTH = 48;
-
- const inputWidth = () => {
- if (!searchText() && !searchFocused()) return 0;
- return Math.max(MIN_INPUT_WIDTH, measuredWidth());
- };
-
- return (
- <div class="flex items-center shrink-0 grow min-w-0 mobile:-order-2">
- <Tooltip
- class="w-fit"
- placement="bottom-start"
- tooltip={<LabelAndHotKey label="Filter" shortcut="⌘F" />}
- >
- <div
- class="relative flex items-center gap-1.5 h-[22px] mobile:h-9 px-2.5 rounded-full mobile:min-w-35"
- classList={{
- 'bg-accent text-panel': !!searchText() && !searchFocused(),
- 'text-ink-muted hover:text-accent hover:bg-accent/20':
- !searchText() && !searchFocused(),
- 'bg-accent/15 text-ink': searchFocused(),
- }}
- onMouseDown={(e) => {
- if (e.target !== ref()) {
- e.preventDefault();
- ref()?.focus();
- }
- }}
- >
- <Show
- when={searchText()}
- fallback={<SearchIcon class="size-4.5 shrink-0" />}
- >
- <button
- type="button"
- class="size-4.5 shrink-0 hover:opacity-60"
- onMouseDown={(e) => {
- e.preventDefault();
- e.stopPropagation();
- setSearchText('');
- }}
- >
- <XIcon class="size-4.5" />
- </button>
- </Show>
- <span
- ref={(el) => {
- measureSpan = el;
- }}
- class="invisible absolute whitespace-pre"
- aria-hidden="true"
- />
- <Show when={!searchText() && !searchFocused()}>
- <span class="leading-none pointer-events-none">
- <span class="underline underline-offset-2 decoration-current/60">
- {IS_MAC ? '⌘' : '^'}F
- </span>
- <span>ilter</span>
- </span>
- </Show>
- <input
- ref={setRef}
- type="text"
- value={searchText()}
- onInput={(e) => setSearchText(e.currentTarget.value)}
- onFocus={() => setSearchFocused(true)}
- onBlur={() => setSearchFocused(false)}
- onKeyDown={(e) => {
- if (
- e.key === 'Escape' ||
- e.key === 'Enter' ||
- e.key === 'ArrowDown'
- ) {
- e.preventDefault();
- e.currentTarget.blur();
- }
- }}
- class="p-0 bg-transparent border-none outline-none ring-0 focus:outline-none focus:ring-0 cursor-default"
- style={{ width: `${inputWidth()}px` }}
- />
- </div>
- </Tooltip>
- </div>
- );
-};
-
-const SHORTCUT_SUFFIXES: Record<string, string> = { space: '␣', '/': '/' };
-
-export const ShortcutLabel: Component<{ label: string; shortcut: string }> = (
- props
-) => {
- const s = props.shortcut.trim();
- if (!s) return <>{props.label}</>;
-
- const suffix = SHORTCUT_SUFFIXES[s.toLowerCase()] ?? SHORTCUT_SUFFIXES[s];
- if (suffix) {
- return (
- <>
- {props.label}
- <span class="ml-1 font-mono opacity-70">{suffix}</span>
- </>
- );
- }
-
- const idx = props.label.toLowerCase().indexOf(s.toLowerCase());
- if (idx === -1) return <>{props.label}</>;
-
- return (
- <>
- {props.label.slice(0, idx)}
- <span class="underline underline-offset-2 decoration-current/60">
- {props.label.slice(idx, idx + s.length)}
- </span>
- {props.label.slice(idx + s.length)}
- </>
- );
-};
-
-export interface FilterButtonProps {
- icon: Component<{ class?: string }>;
- animatedIcon?: Component<{ triggerAnimation?: boolean }>;
- label: string;
- shortcut: string;
- isActive: (() => boolean) | boolean;
- onClick: () => void;
- paddingClass?: string;
-}
-
-export const FilterButton: Component<FilterButtonProps> = (props) => {
- const [isHovered, setIsHovered] = createSignal(false);
-
- const isActive = () =>
- typeof props.isActive === 'function' ? props.isActive() : props.isActive;
-
- return (
- <div class="flex items-center mr-0.5 shrink-0">
- <Tooltip
- tooltip={
- <LabelAndHotKey label={props.label} shortcut={props.shortcut} />
- }
- >
- <button
- type="button"
- class={`flex items-center gap-1 h-[22px] mobile:h-9 ${props.paddingClass ?? 'pl-2 pr-2.5'} active:bg-accent active:text-panel rounded-full`}
- classList={{
- 'bg-accent text-panel': isActive(),
- 'text-ink-muted hover:text-accent hover:bg-accent/20': !isActive(),
- }}
- onClick={props.onClick}
- onMouseEnter={() => setIsHovered(true)}
- onMouseLeave={() => setIsHovered(false)}
- >
- <Show
- when={ENABLE_ANIMATED_ICONS && props.animatedIcon}
- fallback={<Dynamic component={props.icon} class="size-3.5" />}
- >
- {(Icon) => (
- <div class="size-3.5 overflow-visible">
- <Dynamic
- component={Icon()}
- triggerAnimation={isHovered() || isActive()}
- />
- </div>
- )}
- </Show>
- <span class="leading-none">
- <ShortcutLabel label={props.label} shortcut={props.shortcut} />
- </span>
- </button>
- </Tooltip>
- </div>
- );
-};
-
-export const FilterDivider: Component = () => (
- <div class="mx-0.5 w-px h-5 bg-edge-muted/50 shrink-0" />
-);
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
index 2c66d39e66..fa91eaed01 100644
--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-context.tsx
@@ -75,10 +75,12 @@ interface SoupViewContextValues {
isLocalSearchSettling: Accessor<boolean>;
queryFilters: Accessor<SoupItemsQueryFilters>;
setQueryFilters: Setter<SoupItemsQueryFilters>;
- statusFilter: Accessor<string | undefined>;
- setStatusFilter: Setter<string | undefined>;
- assigneeFilter: Accessor<string | undefined>;
- setAssigneeFilter: Setter<string | undefined>;
+ statusFilter: Accessor<string[]>;
+ setStatusFilter: Setter<string[]>;
+ assigneeFilter: Accessor<string[]>;
+ setAssigneeFilter: Setter<string[]>;
+ activeTab: Accessor<string | undefined>;
+ setActiveTab: Setter<string | undefined>;
}
export const SoupViewContext = createContext<SoupViewContextValues>();
@@ -102,6 +104,15 @@ interface SoupViewContextProviderProps {
queryFilters?: SoupItemsQueryFilters;
}
+type ApiSortMethod = NonNullable<SoupParams['sort_method']>;
+const VALID_API_SORT_METHODS: ApiSortMethod[] = [
+ 'viewed_at',
+ 'created_at',
+ 'updated_at',
+ 'viewed_updated',
+ 'frecency',
+];
+
export const SoupViewContextProvider: FlowComponent<
SoupViewContextProviderProps
> = (props) => {
@@ -109,26 +120,32 @@ export const SoupViewContextProvider: FlowComponent<
const queryClient = useQueryClient();
- const soupParams = createMemo(
- (): SoupParams => ({
+ const soupParams = createMemo((): SoupParams => {
+ const sortId = soup.sort.active()[0]?.id ?? 'updated_at';
+
+ // Client-only sorts (priority, status) fall back to created_at for the API
+ const sortMethod = VALID_API_SORT_METHODS.includes(sortId as ApiSortMethod)
+ ? (sortId as ApiSortMethod)
+ : 'created_at';
+
+ return {
limit: 100,
- sort_method: soup.sort.active()[0]?.id ?? 'updated_at',
- })
- );
+ sort_method: sortMethod,
+ };
+ });
const [internalQueryFilters, setInternalQueryFilters] =
- createSignal<SoupItemsQueryFilters>({});
+ createSignal<SoupItemsQueryFilters>({ ...(props.queryFilters ?? {}) });
- const [statusFilter, setStatusFilter] = createSignal<string | undefined>();
- const [assigneeFilter, setAssigneeFilter] = createSignal<
- string | undefined
- >();
+ const [statusFilter, setStatusFilter] = createSignal<string[]>([]);
+ const [assigneeFilter, setAssigneeFilter] = createSignal<string[]>([]);
+ const [activeTab, setActiveTab] = createSignal<string | undefined>(undefined);
// Clear sub-filters when task filter is deactivated
createEffect(() => {
if (!soup.filters.isActive('task')) {
- setStatusFilter(undefined);
- setAssigneeFilter(undefined);
+ setStatusFilter([]);
+ setAssigneeFilter([]);
}
});
@@ -137,27 +154,6 @@ export const SoupViewContextProvider: FlowComponent<
return {
...base,
- ...props.queryFilters,
- channel_filters: {
- ...base.channel_filters,
- ...props.queryFilters?.channel_filters,
- },
- chat_filters: {
- ...base.chat_filters,
- ...props.queryFilters?.chat_filters,
- },
- document_filters: {
- ...base.document_filters,
- ...props.queryFilters?.document_filters,
- },
- email_filters: {
- ...base.email_filters,
- ...props.queryFilters?.email_filters,
- },
- project_filters: {
- ...base.project_filters,
- ...props.queryFilters?.project_filters,
- },
};
});
@@ -287,7 +283,6 @@ export const SoupViewContextProvider: FlowComponent<
);
const baseEntities = () => {
- const filters = soup.filters.active();
let transformed = items();
const next = [];
@@ -296,13 +291,13 @@ export const SoupViewContextProvider: FlowComponent<
const currentAssigneeFilter = assigneeFilter();
for (const entity of transformed) {
- if (!filters.every((f) => f.predicate(entity))) {
+ if (!soup.filters.test(entity)) {
continue;
}
// Apply task sub-filters
if (
- (currentStatusFilter || currentAssigneeFilter) &&
+ (currentStatusFilter.length > 0 || currentAssigneeFilter.length > 0) &&
isTaskEntity(entity)
) {
const taskEntity = entity as unknown as TaskEntityWithProperties;
@@ -394,6 +389,8 @@ export const SoupViewContextProvider: FlowComponent<
setStatusFilter,
assigneeFilter,
setAssigneeFilter,
+ activeTab,
+ setActiveTab,
};
return (
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx
new file mode 100644
index 0000000000..52a0b9e4e4
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx
@@ -0,0 +1,288 @@
+import {
+ VIEW_TAB_PRESETS,
+ type PresetContext,
+} from '@app/component/app-sidebar/soup-filter-presets';
+import type { FilterID } from '@app/component/next-soup/filters/filters';
+import type { SoupItemsQueryFilters } from '@queries/soup/items';
+import { useSoup } from '@app/component/next-soup/soup-context';
+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';
+import { useUserContext } from '@core/context/user';
+import {
+ batch,
+ createMemo,
+ For,
+ Match,
+ type ParentComponent,
+ Switch,
+} from 'solid-js';
+import {
+ SegmentedControl as KSegmentedControl,
+ type SegmentedControlRootProps,
+} from '@kobalte/core/segmented-control';
+
+const useApplyPreset = () => {
+ const soup = useSoup();
+ const { setQueryFilters, setActiveTab } = useSoupView();
+ const user = useUserContext();
+
+ const getPresetContext = (): PresetContext => ({
+ userId: user.userId(),
+ email: user.email(),
+ });
+
+ const applyPreset = (preset: {
+ queryFilters: SoupItemsQueryFilters;
+ clientFilters: { and?: FilterID[]; or?: FilterID[] };
+ }) => {
+ batch(() => {
+ setQueryFilters(preset.queryFilters);
+ soup.filters.set(preset.clientFilters);
+ });
+ };
+
+ const applyTabPreset = (view: ListView, tabId: string) => {
+ const config = VIEW_TAB_PRESETS[view];
+ const resolver = config.tabs[tabId];
+ if (!resolver) return;
+
+ const resolved = resolver(getPresetContext());
+ if (!resolved) return;
+
+ setActiveTab(tabId);
+ applyPreset(resolved);
+ };
+
+ return { applyTabPreset };
+};
+
+export const SoupViewTabs = () => {
+ const panel = useSplitPanelOrThrow();
+
+ const component = createMemo(() => {
+ const content = panel.handle.content();
+
+ if (content.type !== 'component') return;
+
+ return content.id;
+ });
+
+ const isComponentListView = (listView: ListView) => {
+ return component() === listView;
+ };
+
+ return (
+ <Switch>
+ <Match when={isComponentListView('inbox')}>
+ <InboxTabs />
+ </Match>
+ <Match when={isComponentListView('agents')}>
+ <AgentsTabs />
+ </Match>
+ <Match when={isComponentListView('mail')}>
+ <MailTabs />
+ </Match>
+ <Match when={isComponentListView('documents')}>
+ <DocumentsTabs />
+ </Match>
+ <Match when={isComponentListView('tasks')}>
+ <TasksTabs />
+ </Match>
+ <Match when={isComponentListView('channels')}>
+ <ChannelsTabs />
+ </Match>
+ <Match when={isComponentListView('files')}>
+ <FilesTabs />
+ </Match>
+ </Switch>
+ );
+};
+
+const InboxTabs = () => {
+ const { applyTabPreset } = useApplyPreset();
+ const { activeTab } = useSoupView();
+
+ return (
+ <div>
+ <SegmentedControl
+ list={[
+ { value: 'signal', label: 'Signal' },
+ { value: 'noise', label: 'Noise' },
+ { value: 'all', label: 'All' },
+ ]}
+ value={activeTab()}
+ defaultValue={VIEW_TAB_PRESETS.inbox.default}
+ onChange={(value) => applyTabPreset('inbox', value)}
+ />
+ </div>
+ );
+};
+
+const AgentsTabs = () => {
+ const { applyTabPreset } = useApplyPreset();
+ const { activeTab } = useSoupView();
+
+ return (
+ <div>
+ <SegmentedControl
+ list={[
+ { value: 'owned', label: 'Owned' },
+ { value: 'running', label: 'Running' },
+ { value: 'shared', label: 'Shared' },
+ ]}
+ value={activeTab()}
+ defaultValue={VIEW_TAB_PRESETS.agents.default}
+ onChange={(value) => applyTabPreset('agents', value)}
+ />
+ </div>
+ );
+};
+
+const MailTabs = () => {
+ const { applyTabPreset } = useApplyPreset();
+ const { activeTab } = useSoupView();
+
+ return (
+ <div>
+ <SegmentedControl
+ list={[
+ { value: 'important', label: 'Important' },
+ { value: 'noise', label: 'Noise' },
+ { value: 'drafts', label: 'Drafts' },
+ { value: 'sent', label: 'Sent' },
+ ]}
+ value={activeTab()}
+ defaultValue={VIEW_TAB_PRESETS.mail.default}
+ onChange={(value) => applyTabPreset('mail', value)}
+ />
+ </div>
+ );
+};
+
+const DocumentsTabs = () => {
+ const { applyTabPreset } = useApplyPreset();
+ const { activeTab } = useSoupView();
+
+ return (
+ <div>
+ <SegmentedControl
+ list={[
+ { value: 'owned', label: 'Owned' },
+ { value: 'shared', label: 'Shared' },
+ { value: 'all', label: 'All' },
+ ]}
+ value={activeTab()}
+ defaultValue={VIEW_TAB_PRESETS.documents.default}
+ onChange={(value) => applyTabPreset('documents', value)}
+ />
+ </div>
+ );
+};
+
+const TasksTabs = () => {
+ const { applyTabPreset } = useApplyPreset();
+ const { activeTab } = useSoupView();
+
+ return (
+ <div>
+ <SegmentedControl
+ list={[
+ { value: 'assigned-to-me', label: 'Assigned' },
+ { value: 'created-by-me', label: 'Created' },
+ { value: 'all', label: 'All' },
+ ]}
+ value={activeTab()}
+ defaultValue={VIEW_TAB_PRESETS.tasks.default}
+ onChange={(value) => applyTabPreset('tasks', value)}
+ />
+ </div>
+ );
+};
+
+const ChannelsTabs = () => {
+ const { applyTabPreset } = useApplyPreset();
+ const { activeTab } = useSoupView();
+
+ return (
+ <div>
+ <SegmentedControl
+ list={[
+ { value: 'recent', label: 'Recent' },
+ { value: 'people', label: 'People' },
+ { value: 'teams', label: 'Teams' },
+ ]}
+ value={activeTab()}
+ defaultValue={VIEW_TAB_PRESETS.channels.default}
+ onChange={(value) => applyTabPreset('channels', value)}
+ />
+ </div>
+ );
+};
+
+const FilesTabs = () => {
+ const { applyTabPreset } = useApplyPreset();
+ const { activeTab } = useSoupView();
+
+ return (
+ <div>
+ <SegmentedControl
+ list={[
+ { value: 'owned', label: 'Owned' },
+ { value: 'shared', label: 'Shared' },
+ { value: 'all', label: 'All' },
+ ]}
+ value={activeTab()}
+ defaultValue={VIEW_TAB_PRESETS.files.default}
+ onChange={(value) => applyTabPreset('files', value)}
+ />
+ </div>
+ );
+};
+
+export const SegmentedControl: ParentComponent<
+ {
+ list: { value: string; label: string }[];
+ value?: string;
+ defaultValue?: string;
+ } & Omit<SegmentedControlRootProps, 'defaultValue'>
+> = (props) => {
+ const onChange = (newValue: string) => {
+ props.onChange?.(newValue);
+ };
+
+ return (
+ <KSegmentedControl
+ class="size-full text-sm border border-edge rounded-md p-0.5"
+ value={props.value}
+ defaultValue={props.defaultValue ?? props.list[0]?.value}
+ onChange={onChange}
+ disabled={props.disabled}
+ >
+ <div class="relative" role="presentation">
+ <KSegmentedControl.Indicator class="absolute rounded bg-accent/15 border border-accent/30 transition-all ease-out" />
+ <div class="flex" role="presentation">
+ <For each={props.list}>
+ {(item) => {
+ const itemValue = () =>
+ typeof item === 'object' ? item.value : item;
+ const itemLabel = () =>
+ typeof item === 'object' ? item.label : item;
+ return (
+ <KSegmentedControl.Item
+ value={itemValue()}
+ disabled={props.disabled}
+ >
+ <KSegmentedControl.ItemInput class="absolute inset-0 pointer-events-none" />
+ <KSegmentedControl.ItemLabel class="relative text-ink-muted size-full px-3 py-1 text-xs font-medium data-[checked]:text-accent transition-colors block">
+ {itemLabel()}
+ </KSegmentedControl.ItemLabel>
+ </KSegmentedControl.Item>
+ );
+ }}
+ </For>
+ </div>
+ </div>
+ </KSegmentedControl>
+ );
+};
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 a045fde198..5521e23681 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
@@ -1,3 +1,4 @@
+import ChevronRightIcon from '@icon/regular/caret-right.svg';
import CheckIcon from '@icon/bold/check-bold.svg';
import Spinner from '@icon/regular/spinner.svg';
import {
@@ -56,6 +57,7 @@ import {
Match,
on,
onCleanup,
+ onMount,
Show,
Suspense,
Switch,
@@ -63,7 +65,6 @@ import {
import { createStore, reconcile } from 'solid-js/store';
import { type VirtualizerHandle, VList } from 'virtua/solid';
import { SoupEntitySelectionToolbar } from './soup-entity-selection-toolbar';
-import { SoupToolbar } from './soup-toolbar';
import { useUserId } from '@core/context/user';
import { CustomScrollbar } from '@core/component/CustomScrollbar';
import { SoupViewFileDropzone } from '@app/component/next-soup/soup-view/soup-view-file-dropzone';
@@ -78,6 +79,11 @@ import { isMobile } from '@core/mobile/isMobile';
import type { SystemSortOption } from '@app/component/next-soup/soup-view/sort-options';
import { usePropertyEditorHotkeys } from '@app/component/property-edit-modal/hooks/usePropertyEditorHotkeys';
import type { SoupItemsQueryFilters } from '@queries/soup/items';
+import type { FilterID } from '@app/component/next-soup/filters/filters';
+import { SoupViewTabs } from '@app/component/next-soup/soup-view/soup-view-tabs';
+import { SplitHeaderLeft } from '@app/component/split-layout/components/SplitHeader';
+import { SoupFiltersBar } from '@app/component/next-soup/soup-view/filters-bar/soup-filters-bar';
+import { useFilterRefinements } from '@app/component/next-soup/soup-view/filters-bar/use-filter-refinements';
import {
invalidateSoupEntity,
refetchSoupEntity,
@@ -130,22 +136,35 @@ const stateCache = new Map<
{
soup: {
focus: string | undefined;
- filters: string[];
+ filters: { and: string[]; or: string[] };
queryFilters: SoupItemsQueryFilters;
sort: SystemSortOption[];
searchText: string;
+ activeTab: string | undefined;
};
virtualCache?: CacheSnapshot;
scrollOffset?: number;
}
>();
-export const SoupView = () => {
+interface SoupViewProps {
+ viewName: string;
+ initialClientFilters?: { and?: FilterID[]; or?: FilterID[] };
+ queryFilters?: SoupItemsQueryFilters;
+}
+
+export const SoupView = (props: SoupViewProps) => {
const soup = useSoup();
const panel = useSplitPanelOrThrow();
useSoupNotificationInvalidators();
+ onMount(() => {
+ if (!props.initialClientFilters) return;
+
+ soup.filters.set(props.initialClientFilters);
+ });
+
return (
<SplitPanelContext.Provider
value={{
@@ -154,14 +173,30 @@ export const SoupView = () => {
soup.previewEntity() ? { side: 'left', percentage: 30 } : undefined,
}}
>
- <SoupViewContextProvider soup={soup}>
- <div class="relative flex-grow min-h-1 flex max-sm:flex-col flex-row size-full">
- <Suspense>
- <SoupToolbar />
- </Suspense>
- <SoupViewFileDropzone>
- <SoupViewList />
- </SoupViewFileDropzone>
+ <SoupViewContextProvider soup={soup} queryFilters={props.queryFilters}>
+ <div class="size-full flex flex-col">
+ <div class="flex flex-col w-full">
+ <SplitHeaderLeft>
+ <div class="h-full flex gap-2 items-center">
+ <Show when={!isMobile()}>
+ <h1 class="font-medium text-ink-muted select-none text-sm">
+ {props.viewName}
+ </h1>
+ <ChevronRightIcon class="size-4 text-ink-muted select-none" />
+ </Show>
+
+ <SoupViewTabs />
+ </div>
+ </SplitHeaderLeft>
+ <SoupFiltersBar />
+ </div>
+ <div class="relative flex-grow min-h-1 flex max-sm:flex-col flex-row size-full">
+ <Suspense>
+ <SoupViewFileDropzone>
+ <SoupViewList />
+ </SoupViewFileDropzone>
+ </Suspense>
+ </div>
</div>
<Suspense>
<Show when={ENABLE_UNIFIED_LIST_AI_INPUT && !isMobile()}>
@@ -191,8 +226,11 @@ export const SoupViewList = (props: SoupViewListProps) => {
featuredIds,
isSearchServiceLoading,
isLocalSearchSettling,
+ activeTab,
+ setActiveTab,
} = useSoupView();
const { getSplitCount } = useSplitLayout();
+ const { hasActiveRefinements, resetToTabDefaults } = useFilterRefinements();
const { isKeypressActive } = useIsKeyPressActive();
@@ -465,13 +503,13 @@ export const SoupViewList = (props: SoupViewListProps) => {
const isProjectList = panel.handle.content().type === 'project';
- const getCacheKey = () => {
- let key = `soup-view-${panel.handle.id}`;
+ let key = `soup-view-${panel.handle.id}-${panel.handle.content().id}`;
- if (previewPanel) {
- key += '-preview';
- }
+ if (previewPanel) {
+ key += '-preview';
+ }
+ const getCacheKey = () => {
return key;
};
@@ -483,10 +521,14 @@ export const SoupViewList = (props: SoupViewListProps) => {
stateCache.set(getCacheKey(), {
soup: {
focus: soup.focus.id(),
- filters: soup.filters.activeIds(),
+ filters: {
+ and: [...soup.filters.andFilters().map((f) => f.id)],
+ or: [...soup.filters.orFilters().map((f) => f.id)],
+ },
queryFilters: queryFilters(),
sort: soup.sort.active().map((s) => s.id),
searchText: searchText(),
+ activeTab: activeTab(),
},
virtualCache: virtualHandle?.cache,
scrollOffset: virtualHandle?.scrollOffset,
@@ -507,15 +549,16 @@ export const SoupViewList = (props: SoupViewListProps) => {
}
soup.focus.set(cached.soup.focus);
- for (const id of cached.soup.filters) {
- soup.filters.activate(id);
- }
+
+ soup.filters.set(cached.soup.filters);
setQueryFilters(cached.soup.queryFilters);
setSearchText(cached.soup.searchText);
soup.sort.setAll(cached.soup.sort);
+ setActiveTab(cached.soup.activeTab);
+
virtualizerHandle()?.scrollTo(cached.scrollOffset ?? 0);
registerFocusEffects(false);
};
@@ -568,7 +611,11 @@ export const SoupViewList = (props: SoupViewListProps) => {
</div>
</Match>
<Match when={!rows().length}>
- <EmptyState search={!!searchText()} />
+ <EmptyState
+ search={!!searchText()}
+ hasRefinementsFromBase={hasActiveRefinements()}
+ onClearFilters={resetToTabDefaults}
+ />
</Match>
<Match when={rows().length}>
<ListLayoutProvider ref={localEntityListRef}>
@@ -608,6 +655,8 @@ export const SoupViewList = (props: SoupViewListProps) => {
return row.original.createdAt;
case 'updated_at':
return row.original.updatedAt;
+ default:
+ return row.original.createdAt;
}
};
diff --git a/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.test.ts b/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.test.ts
index 827e4f4093..6c28fbee15 100644
--- a/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.test.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.test.ts
@@ -5,7 +5,7 @@ import {
} from '@core/component/Properties/constants';
import type { SoupProperty } from '@service-storage/generated/schemas';
import type { TaskEntityWithProperties } from '@entity/types/entity';
-import { matchesTaskSubFilters } from './task-sub-filter-matcher';
+import { matchesTaskSubFilters, NO_ASSIGNEE } from './task-sub-filter-matcher';
const createSoupProperty = (
definitionId: string,
@@ -37,13 +37,13 @@ describe('matchesTaskSubFilters', () => {
expect(
matchesTaskSubFilters(task, {
- statusFilter: PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS,
+ statusFilter: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],
})
).toBe(true);
expect(
matchesTaskSubFilters(task, {
- assigneeFilter: 'user-1',
+ assigneeFilter: ['user-1'],
})
).toBe(true);
});
@@ -60,7 +60,7 @@ describe('matchesTaskSubFilters', () => {
expect(
matchesTaskSubFilters(task, {
- statusFilter: PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS,
+ statusFilter: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],
})
).toBe(false);
});
@@ -77,7 +77,7 @@ describe('matchesTaskSubFilters', () => {
expect(
matchesTaskSubFilters(task, {
- assigneeFilter: 'user-1',
+ assigneeFilter: ['user-1'],
})
).toBe(false);
});
@@ -98,9 +98,184 @@ describe('matchesTaskSubFilters', () => {
expect(
matchesTaskSubFilters(task, {
- statusFilter: PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS,
- assigneeFilter: 'user-1',
+ statusFilter: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],
+ assigneeFilter: ['user-1'],
})
).toBe(true);
});
+
+ it('matches any status when multiple statuses are in filter', () => {
+ const taskInProgress = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.STATUS, {
+ type: 'SelectOption',
+ value: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],
+ }),
+ ],
+ });
+
+ const taskInReview = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.STATUS, {
+ type: 'SelectOption',
+ value: [PROPERTY_OPTION_IDS.STATUS.IN_REVIEW],
+ }),
+ ],
+ });
+
+ const taskDone = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.STATUS, {
+ type: 'SelectOption',
+ value: [PROPERTY_OPTION_IDS.STATUS.COMPLETED],
+ }),
+ ],
+ });
+
+ const multiStatusFilter = [
+ PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS,
+ PROPERTY_OPTION_IDS.STATUS.IN_REVIEW,
+ ];
+
+ expect(
+ matchesTaskSubFilters(taskInProgress, { statusFilter: multiStatusFilter })
+ ).toBe(true);
+ expect(
+ matchesTaskSubFilters(taskInReview, { statusFilter: multiStatusFilter })
+ ).toBe(true);
+ expect(
+ matchesTaskSubFilters(taskDone, { statusFilter: multiStatusFilter })
+ ).toBe(false);
+ });
+
+ it('matches any assignee when multiple assignees are in filter', () => {
+ const taskUser1 = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.ASSIGNEES, {
+ type: 'EntityReference',
+ value: [{ entity_type: 'USER', entity_id: 'user-1' }],
+ }),
+ ],
+ });
+
+ const taskUser2 = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.ASSIGNEES, {
+ type: 'EntityReference',
+ value: [{ entity_type: 'USER', entity_id: 'user-2' }],
+ }),
+ ],
+ });
+
+ const taskUser3 = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.ASSIGNEES, {
+ type: 'EntityReference',
+ value: [{ entity_type: 'USER', entity_id: 'user-3' }],
+ }),
+ ],
+ });
+
+ const multiAssigneeFilter = ['user-1', 'user-2'];
+
+ expect(
+ matchesTaskSubFilters(taskUser1, { assigneeFilter: multiAssigneeFilter })
+ ).toBe(true);
+ expect(
+ matchesTaskSubFilters(taskUser2, { assigneeFilter: multiAssigneeFilter })
+ ).toBe(true);
+ expect(
+ matchesTaskSubFilters(taskUser3, { assigneeFilter: multiAssigneeFilter })
+ ).toBe(false);
+ });
+
+ it('treats empty arrays the same as undefined filters', () => {
+ const task = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.STATUS, {
+ type: 'SelectOption',
+ value: [PROPERTY_OPTION_IDS.STATUS.IN_PROGRESS],
+ }),
+ ],
+ });
+
+ expect(
+ matchesTaskSubFilters(task, { statusFilter: [], assigneeFilter: [] })
+ ).toBe(true);
+ });
+
+ it('matches unassigned tasks when NO_ASSIGNEE filter is active', () => {
+ const taskWithNoAssignees = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.ASSIGNEES, {
+ type: 'EntityReference',
+ value: [],
+ }),
+ ],
+ });
+
+ const taskWithAssignee = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.ASSIGNEES, {
+ type: 'EntityReference',
+ value: [{ entity_type: 'USER', entity_id: 'user-1' }],
+ }),
+ ],
+ });
+
+ expect(
+ matchesTaskSubFilters(taskWithNoAssignees, {
+ assigneeFilter: [NO_ASSIGNEE],
+ })
+ ).toBe(true);
+
+ expect(
+ matchesTaskSubFilters(taskWithAssignee, { assigneeFilter: [NO_ASSIGNEE] })
+ ).toBe(false);
+ });
+
+ it('matches both unassigned and specific assignees when both filters are active', () => {
+ const taskWithNoAssignees = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.ASSIGNEES, {
+ type: 'EntityReference',
+ value: [],
+ }),
+ ],
+ });
+
+ const taskWithUser1 = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.ASSIGNEES, {
+ type: 'EntityReference',
+ value: [{ entity_type: 'USER', entity_id: 'user-1' }],
+ }),
+ ],
+ });
+
+ const taskWithUser2 = createTask({
+ properties: [
+ createSoupProperty(SYSTEM_PROPERTY_IDS.ASSIGNEES, {
+ type: 'EntityReference',
+ value: [{ entity_type: 'USER', entity_id: 'user-2' }],
+ }),
+ ],
+ });
+
+ const combinedFilter = [NO_ASSIGNEE, 'user-1'];
+
+ expect(
+ matchesTaskSubFilters(taskWithNoAssignees, {
+ assigneeFilter: combinedFilter,
+ })
+ ).toBe(true);
+
+ expect(
+ matchesTaskSubFilters(taskWithUser1, { assigneeFilter: combinedFilter })
+ ).toBe(true);
+
+ expect(
+ matchesTaskSubFilters(taskWithUser2, { assigneeFilter: combinedFilter })
+ ).toBe(false);
+ });
});
diff --git a/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.ts b/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.ts
index c158d6b7f3..5470f782f1 100644
--- a/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/task-sub-filter-matcher.ts
@@ -7,8 +7,8 @@ import type { TaskEntityWithProperties } from '@entity/types/entity';
export const NO_ASSIGNEE = 'NO_ASSIGNEE';
type TaskSubFilters = {
- statusFilter?: string;
- assigneeFilter?: string;
+ statusFilter?: string[];
+ assigneeFilter?: string[];
};
export const matchesTaskSubFilters = (
@@ -17,7 +17,10 @@ export const matchesTaskSubFilters = (
): boolean => {
const { statusFilter, assigneeFilter } = filters;
- if (!statusFilter && !assigneeFilter) {
+ const hasStatusFilter = statusFilter && statusFilter.length > 0;
+ const hasAssigneeFilter = assigneeFilter && assigneeFilter.length > 0;
+
+ if (!hasStatusFilter && !hasAssigneeFilter) {
return true;
}
@@ -27,15 +30,25 @@ export const matchesTaskSubFilters = (
return true;
}
- if (statusFilter && getTaskStatusOptionId(taskEntity) !== statusFilter) {
- return false;
+ if (hasStatusFilter) {
+ const taskStatus = getTaskStatusOptionId(taskEntity);
+ if (!taskStatus || !statusFilter.includes(taskStatus)) {
+ return false;
+ }
}
- if (assigneeFilter) {
- const assigneeIds = getTaskAssigneeIds(taskEntity);
- if (assigneeFilter === NO_ASSIGNEE) {
- if (assigneeIds.length > 0) return false;
- } else if (!assigneeIds.includes(assigneeFilter)) {
+ if (hasAssigneeFilter) {
+ const taskAssignees = getTaskAssigneeIds(taskEntity);
+ const includesNoAssignee = assigneeFilter.includes(NO_ASSIGNEE);
+ const hasNoAssignees = taskAssignees.length === 0;
+
+ // Match if task has no assignees and NO_ASSIGNEE filter is active
+ if (includesNoAssignee && hasNoAssignees) {
+ return true;
+ }
+
+ // Match if any of the task's assignees are in the filter
+ if (!taskAssignees.some((id) => assigneeFilter.includes(id))) {
return false;
}
}
diff --git a/js/app/packages/app/component/next-soup/soup-view/task-sub-filters.tsx b/js/app/packages/app/component/next-soup/soup-view/task-sub-filters.tsx
index 46069f0097..e2ad722f3f 100644
--- a/js/app/packages/app/component/next-soup/soup-view/task-sub-filters.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/task-sub-filters.tsx
@@ -14,7 +14,6 @@ import { UserIcon } from '@core/component/UserIcon';
import { useContacts } from '@queries/contacts/contacts';
import { useUserId } from '@core/context/user';
import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
-import { NO_ASSIGNEE } from '@app/component/next-soup/soup-view/task-sub-filter-matcher';
import UserCircleIcon from '@icon/regular/user-circle.svg';
import CaretDownIcon from '@icon/regular/caret-down.svg';
import XIcon from '@icon/regular/x.svg?component-solid';
@@ -30,19 +29,20 @@ const statusOptions: SelectableOption[] = TASK_STATUS_OPTIONS.map((o) => ({
label: o.label,
}));
-function FilterTrigger<T>(
+function FilterTrigger(
props: ParentProps<{
- filter: Accessor<T>;
+ filter: Accessor<string[]>;
}>
) {
+ const hasFilter = () => props.filter().length > 0;
return (
<Popover.Trigger
as="button"
type="button"
class="flex items-center gap-1 h-[22px] touch:mobile-width:h-9 px-2.5 shrink-0 rounded-full active:bg-accent/20 text-xs"
classList={{
- 'bg-accent/20 text-accent': !!props.filter(),
- 'text-ink-muted hover:text-accent hover:bg-accent/20': !props.filter(),
+ 'bg-accent/20 text-accent': hasFilter(),
+ 'text-ink-muted hover:text-accent hover:bg-accent/20': !hasFilter(),
}}
>
{props.children}
@@ -55,17 +55,27 @@ export const TaskStatusDropdown: Component<DropdownProps> = (props) => {
const open = () => props.open();
const setOpen = (v: boolean) => props.onOpenChange(v);
+ const hasFilter = () => statusFilter().length > 0;
+
const activeLabel = () => {
- if (!statusFilter()) return 'Status';
- return (
- TASK_STATUS_OPTIONS.find((o) => o.value === statusFilter())?.label ??
- 'Status'
- );
+ const filters = statusFilter();
+ if (filters.length === 0) return 'Status';
+ if (filters.length === 1) {
+ return (
+ TASK_STATUS_OPTIONS.find((o) => o.value === filters[0])?.label ??
+ 'Status'
+ );
+ }
+ return `${filters.length} statuses`;
};
- const selectOption = (id: string) => {
- setStatusFilter(statusFilter() === id ? undefined : id);
- setOpen(false);
+ const toggleOption = (id: string) => {
+ const current = statusFilter();
+ if (current.includes(id)) {
+ setStatusFilter(current.filter((s) => s !== id));
+ } else {
+ setStatusFilter([...current, id]);
+ }
};
return (
@@ -79,14 +89,16 @@ export const TaskStatusDropdown: Component<DropdownProps> = (props) => {
>
<FilterTrigger filter={statusFilter}>
<Show
- when={statusFilter()}
+ when={hasFilter() && statusFilter()[0]}
fallback={<CircleDashedIcon class="size-3.5" />}
>
- <PropertyValueIcon optionId={statusFilter()!} class="size-3.5" />
+ {(firstStatus) => (
+ <PropertyValueIcon optionId={firstStatus()} class="size-3.5" />
+ )}
</Show>
<span class="leading-none">{activeLabel()}</span>
<Show
- when={statusFilter()}
+ when={hasFilter()}
fallback={<CaretDownIcon class="size-3 opacity-60" />}
>
<span
@@ -94,7 +106,7 @@ export const TaskStatusDropdown: Component<DropdownProps> = (props) => {
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
- setStatusFilter(undefined);
+ setStatusFilter([]);
}}
>
<XIcon class="size-3" />
@@ -104,14 +116,12 @@ export const TaskStatusDropdown: Component<DropdownProps> = (props) => {
<Popover.Portal>
<Popover.Content class="z-50 bg-panel border border-edge-muted shadow-lg w-[300px]">
<PropertyOptionSelector
- config={{ isMultiSelect: false, placeholder: 'Filter status...' }}
+ config={{ isMultiSelect: true, placeholder: 'Filter status...' }}
options={statusOptions}
isLoading={false}
error={null}
- selectedOptions={() =>
- statusFilter() ? new Set([statusFilter()!]) : new Set()
- }
- onToggleOption={(id) => selectOption(id)}
+ selectedOptions={() => new Set(statusFilter())}
+ onToggleOption={toggleOption}
onClose={() => setOpen(false)}
/>
</Popover.Content>
@@ -127,13 +137,18 @@ export const TaskAssigneeDropdown: Component<DropdownProps> = (props) => {
const contacts = useContacts();
const userId = useUserId();
+ const hasFilter = () => assigneeFilter().length > 0;
+
const activeAssigneeLabel = () => {
- if (!assigneeFilter()) return 'Assignee';
- if (assigneeFilter() === NO_ASSIGNEE) return 'No assignee';
- const contact = contacts().find((c) => c.id === assigneeFilter());
- if (contact && contact.id === userId())
- return contact.name ? `${contact.name} (me)` : 'Me';
- return contact?.name || assigneeFilter()!;
+ const filters = assigneeFilter();
+ if (filters.length === 0) return 'Assignee';
+ if (filters.length === 1) {
+ const contact = contacts().find((c) => c.id === filters[0]);
+ if (contact && contact.id === userId())
+ return contact.name ? `${contact.name} (me)` : 'Me';
+ return contact?.name || filters[0];
+ }
+ return `${filters.length} assignees`;
};
return (
@@ -147,7 +162,7 @@ export const TaskAssigneeDropdown: Component<DropdownProps> = (props) => {
>
<FilterTrigger filter={assigneeFilter}>
<Show
- when={assigneeFilter() !== NO_ASSIGNEE ? assigneeFilter() : undefined}
+ when={hasFilter() && assigneeFilter()[0]}
keyed
fallback={<UserCircleIcon class="size-3.5" />}
>
@@ -157,7 +172,7 @@ export const TaskAssigneeDropdown: Component<DropdownProps> = (props) => {
</Show>
<span class="leading-none">{activeAssigneeLabel()}</span>
<Show
- when={assigneeFilter()}
+ when={hasFilter()}
fallback={<CaretDownIcon class="size-3 opacity-60" />}
>
<span
@@ -165,7 +180,7 @@ export const TaskAssigneeDropdown: Component<DropdownProps> = (props) => {
onClick={(e) => {
e.stopPropagation();
e.preventDefault();
- setAssigneeFilter(undefined);
+ setAssigneeFilter([]);
}}
>
<XIcon class="size-3" />
@@ -176,23 +191,13 @@ export const TaskAssigneeDropdown: Component<DropdownProps> = (props) => {
<Popover.Content class="z-50 bg-panel border border-edge-muted shadow-lg w-[300px]">
<PropertyEntitySelector
config={{
- isMultiSelect: false,
+ isMultiSelect: true,
placeholder: 'Filter assignee...',
specificEntityType: 'USER',
}}
- pinnedOptions={[
- {
- id: NO_ASSIGNEE,
- label: 'No assignee',
- icon: <UserCircleIcon class="size-4 text-ink-muted" />,
- },
- ]}
- selectedOptions={() =>
- assigneeFilter() ? new Set([assigneeFilter()!]) : new Set()
- }
+ selectedOptions={() => new Set(assigneeFilter())}
setSelectedOptions={(ids) => {
- const newId = [...ids][0];
- setAssigneeFilter(newId === assigneeFilter() ? undefined : newId);
+ setAssigneeFilter([...ids]);
}}
onClose={() => setOpen(false)}
/>
diff --git a/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts b/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
index a4f504c055..2c34ea88aa 100644
--- a/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/use-soup-view-hotkeys.ts
@@ -1,11 +1,13 @@
import { CommandState } from '@app/component/command/state';
import type { SplitHandle } from '@app/component/split-layout/layoutManager';
+import { GO_TO_COMMAND_SCOPE, GO_TO_LEADER_KEY } from '@app/constants/hotkeys';
import { activeScope, hotkeyScopeTree } from '@core/hotkey/state';
import { createHotkeyGroup, registerHotkey } from '@core/hotkey/hotkeys';
import { TOKENS } from '@core/hotkey/tokens';
import {
getHotkeyCommand,
getScopeElement,
+ isScopeInActiveBranch,
runCommand,
} from '@core/hotkey/utils';
import { isSearchEntity } from '@entity';
@@ -13,6 +15,7 @@ import { onCleanup, type Accessor } from 'solid-js';
import type { VirtualizerHandle } from 'virtua/solid';
import type { SoupState } from '../create-soup-state';
import { openEntityInSplitFromUnifiedList } from '@app/component/next-soup/utils';
+import { isListViewID } from '@app/constants/list-views';
type UseSoupViewHotkeysOptions = {
splitId: string;
@@ -34,7 +37,7 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
getSplitCount,
} = options;
- const splitIsUnifiedList = () => splitHandle.content().id === 'unified-list';
+ const splitIsUnifiedList = () => isListViewID(splitHandle.content().id);
// escape - Multi-purpose: Clear selection / Close spotlight / Close split / Go home
const clearMultiCondition = () =>
@@ -77,20 +80,23 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
hide: true,
}).withGroup(group);
- // g g - Jump to top of list (vim-style command scope)
- const { commandScopeId } = registerHotkey({
- hotkey: ['g'],
+ // g g - Jump to top of list (vim-style, uses global GO_TO command scope)
+ registerHotkey({
+ hotkey: GO_TO_LEADER_KEY,
scopeId,
description: 'Go to top of list',
- keyDownHandler: () => true,
- activateCommandScope: true,
+ keyDownHandler: () => false,
+ activateCommandScopeId: GO_TO_COMMAND_SCOPE,
hide: true,
}).withGroup(group);
+ // Register 'g' in the global GO_TO command scope for g+g (jump to top)
+ // Uses condition to only run for the soup-view that was focused when 'g' was pressed
registerHotkey({
- hotkey: ['g'],
- scopeId: commandScopeId!,
+ hotkey: GO_TO_LEADER_KEY,
+ scopeId: GO_TO_COMMAND_SCOPE,
description: 'Go to top of list',
+ condition: () => isScopeInActiveBranch(scopeId),
keyDownHandler: () => {
const next = soup.navigate.toFirst();
if (next) {
@@ -98,6 +104,7 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
}
return true;
},
+ registrationType: 'add',
}).withGroup(group);
// shift+g, end - Jump to bottom of list
@@ -263,10 +270,7 @@ export const useSoupViewHotkeys = (options: UseSoupViewHotkeysOptions) => {
return true;
}
if (goHomeCondition()) {
- splitHandle.replace({
- next: { type: 'component', id: 'unified-list' },
- referredFrom: 'unified-list',
- });
+ splitHandle.goBack();
return true;
}
return false;
diff --git a/js/app/packages/app/component/next-soup/utils.ts b/js/app/packages/app/component/next-soup/utils.ts
index ede13e4373..9e565dcd2b 100644
--- a/js/app/packages/app/component/next-soup/utils.ts
+++ b/js/app/packages/app/component/next-soup/utils.ts
@@ -27,6 +27,7 @@ import {
} from '@queries/soup/cache';
import { match } from 'ts-pattern';
import { isAfter } from 'date-fns';
+import { isListViewID } from '@app/constants/list-views';
const mergeSearchEntities = <T extends EntityData>(
first: WithSearch<T>,
@@ -295,10 +296,15 @@ export const openEntityInSplitFromUnifiedList = async (
}
: undefined;
+ const activeSplitContentID = splitManager.activeSplit()?.content().id;
+
splitManager.openWithSplit(
{ ...content, params },
{
- referredFrom: 'unified-list',
+ referredFrom:
+ activeSplitContentID && isListViewID(activeSplitContentID)
+ ? activeSplitContentID
+ : undefined,
activate: true,
preferNewSplit: openInNewSplit,
handle: splitHandle,
diff --git a/js/app/packages/app/component/split-layout/SplitButtons.tsx b/js/app/packages/app/component/split-layout/SplitButtons.tsx
index 9c58b43b65..a02ea8d865 100644
--- a/js/app/packages/app/component/split-layout/SplitButtons.tsx
+++ b/js/app/packages/app/component/split-layout/SplitButtons.tsx
@@ -5,6 +5,7 @@ import SplitIcon from '@icon/regular/square-half.svg';
import CloseIcon from '@icon/regular/x.svg';
import { useContext } from 'solid-js';
import { SplitLayoutContext, SplitPanelContext } from './context';
+import { LIST_VIEW_ID } from '@app/constants/list-views';
export function SplitBackButton() {
const context = useContext(SplitPanelContext);
@@ -46,7 +47,7 @@ export function SplitCreateButton() {
context.manager.createNewSplit({
content: {
type: 'component',
- id: 'unified-list',
+ id: LIST_VIEW_ID.inbox,
},
referredFrom: 'dock',
});
diff --git a/js/app/packages/app/component/split-layout/SplitLayout.tsx b/js/app/packages/app/component/split-layout/SplitLayout.tsx
index 0e725c692d..d2204da523 100644
--- a/js/app/packages/app/component/split-layout/SplitLayout.tsx
+++ b/js/app/packages/app/component/split-layout/SplitLayout.tsx
@@ -37,6 +37,7 @@ import {
} from './layoutManager';
import { decodePairs } from './layoutUtils';
import { registerSplitHotkeys } from './registerSplitHotkeys';
+import { isListViewID } from '@app/constants/list-views';
type SplitLayoutContainerProps = {
pairs: string[];
@@ -301,30 +302,33 @@ export function SplitLayoutContainer(props: SplitLayoutContainerProps) {
return (
<SplitLayoutContext.Provider value={{ manager: splitManager }}>
- <Resize.Zone
- direction="horizontal"
- gutter={4}
- captureResizeCtx={splitManager.setResizeContext}
- >
- <For each={ids()}>
- {(id, index) => (
- <Show when={splitManager.getSplit(id)}>
- {(handle) => (
- <Suspense>
- <Resize.Panel id={id} minSize={400} index={index()}>
- <SplitPanel
- split={splits()[index()]!}
- handle={handle()}
- active={activeSplitSelector(id)}
- setPanelRef={(panelRef) => panelRefs.set(id, panelRef)}
- />
- </Resize.Panel>
- </Suspense>
- )}
- </Show>
- )}
- </For>
- </Resize.Zone>
+ <div class="size-full p-2 pl-0 mobile:p-0">
+ <Resize.Zone
+ direction="horizontal"
+ gutter={0}
+ captureResizeCtx={splitManager.setResizeContext}
+ >
+ <For each={ids()}>
+ {(id, index) => (
+ <Show when={splitManager.getSplit(id)}>
+ {(handle) => (
+ <Suspense>
+ <Resize.Panel id={id} minSize={400} index={index()}>
+ <SplitPanel
+ split={splits()[index()]!}
+ handle={handle()}
+ active={activeSplitSelector(id)}
+ setPanelRef={(panelRef) => panelRefs.set(id, panelRef)}
+ index={index()}
+ />
+ </Resize.Panel>
+ </Suspense>
+ )}
+ </Show>
+ )}
+ </For>
+ </Resize.Zone>
+ </div>
<PopoverSplitRenderer
popovers={splitManager.popovers}
onClosePopover={(id) => {
@@ -342,6 +346,7 @@ type SplitPanelProps = {
handle: SplitHandle;
active: boolean;
setPanelRef: (ref: HTMLDivElement) => void;
+ index: number;
};
function SplitPanel(props: SplitPanelProps) {
@@ -370,7 +375,7 @@ function SplitPanel(props: SplitPanelProps) {
getSplitCount: () => splitLayoutHelpers.getSplitCount(),
isNotUnifiedList: () => {
const content = props.handle.content();
- return !(content.type === 'component' && content.id === 'unified-list');
+ return !isListViewID(content.id);
},
});
@@ -400,6 +405,16 @@ function SplitPanel(props: SplitPanelProps) {
props.setPanelRef(ref);
attachHotKeys(ref);
}}
+ tl={props.index === 0}
+ bl={props.index === 0}
+ tr={
+ splitLayoutHelpers.getSplitCount() > 1 &&
+ props.index === splitLayoutHelpers.getSplitCount() - 1
+ }
+ br={
+ splitLayoutHelpers.getSplitCount() > 1 &&
+ props.index === splitLayoutHelpers.getSplitCount() - 1
+ }
>
<Suspense>
<Dynamic component={props.split.mount.element} />
diff --git a/js/app/packages/app/component/split-layout/componentRegistry.tsx b/js/app/packages/app/component/split-layout/componentRegistry.tsx
index 6f69626ab3..24b80bd162 100644
--- a/js/app/packages/app/component/split-layout/componentRegistry.tsx
+++ b/js/app/packages/app/component/split-layout/componentRegistry.tsx
@@ -8,6 +8,8 @@ import { EmailCompose } from '../../../block-email/component/Compose';
import { SettingsPanelComponentWrapper } from '../settings/Settings';
import NotificationRoute from '@notifications/components/NotificationRoute';
import { SoupView } from '@app/component/next-soup/soup-view/soup-view';
+import { getDefaultListViewPreset } from '@app/component/app-sidebar/soup-filter-presets';
+import { useUserContext } from '@core/context/user';
export type ComponentFactory = (params?: Record<string, any>) => JSXElement;
@@ -55,7 +57,111 @@ export function resolveComponent(
};
}
-registerComponent('unified-list', () => <SoupView />);
+registerComponent('unified-list', () => <SoupView viewName="Unified list" />);
+
+/** BEGIN - APP ROUTES */
+registerComponent('inbox', () => {
+ const preset = getDefaultListViewPreset('inbox');
+ return (
+ <SoupView
+ viewName="Inbox"
+ queryFilters={preset.queryFilters}
+ initialClientFilters={preset.clientFilters}
+ />
+ );
+});
+registerComponent('agents', () => {
+ const user = useUserContext();
+ const preset = getDefaultListViewPreset('agents', {
+ userId: user.userId(),
+ email: user.email(),
+ });
+ return (
+ <SoupView
+ viewName="Agents"
+ queryFilters={preset.queryFilters}
+ initialClientFilters={preset.clientFilters}
+ />
+ );
+});
+registerComponent('mail', () => {
+ const preset = getDefaultListViewPreset('mail');
+ return (
+ <SoupView
+ viewName="Mail"
+ queryFilters={preset.queryFilters}
+ initialClientFilters={preset.clientFilters}
+ />
+ );
+});
+registerComponent('documents', () => {
+ const user = useUserContext();
+ const preset = getDefaultListViewPreset('documents', {
+ userId: user.userId(),
+ email: user.email(),
+ });
+ return (
+ <SoupView
+ viewName="Documents"
+ queryFilters={preset.queryFilters}
+ initialClientFilters={preset.clientFilters}
+ />
+ );
+});
+registerComponent('tasks', () => {
+ const user = useUserContext();
+ const preset = getDefaultListViewPreset('tasks', {
+ userId: user.userId(),
+ email: user.email(),
+ });
+ return (
+ <SoupView
+ viewName="Tasks"
+ queryFilters={preset.queryFilters}
+ initialClientFilters={preset.clientFilters}
+ />
+ );
+});
+registerComponent('channels', () => {
+ const preset = getDefaultListViewPreset('channels');
+ return (
+ <SoupView
+ viewName="Channels"
+ queryFilters={preset.queryFilters}
+ initialClientFilters={preset.clientFilters}
+ />
+ );
+});
+registerComponent('files', () => {
+ const user = useUserContext();
+ const preset = getDefaultListViewPreset('files', {
+ userId: user.userId(),
+ email: user.email(),
+ });
+ return (
+ <SoupView
+ viewName="Files"
+ queryFilters={preset.queryFilters}
+ initialClientFilters={preset.clientFilters}
+ />
+ );
+});
+registerComponent('search', () => {
+ const user = useUserContext();
+ const preset = getDefaultListViewPreset('search', {
+ userId: user.userId(),
+ email: user.email(),
+ });
+ return (
+ <SoupView
+ viewName="Search"
+ queryFilters={preset.queryFilters}
+ initialClientFilters={preset.clientFilters}
+ />
+ );
+});
+/** END - APP ROUTES */
+
registerComponent('loading', () => <LoadingBlock />);
registerComponent('channel-compose', () => <ChannelCompose />);
registerComponent('email-compose', (params) => (
diff --git a/js/app/packages/app/component/split-layout/components/SplitContainer.tsx b/js/app/packages/app/component/split-layout/components/SplitContainer.tsx
index 45de987ea7..d7bde4dcb8 100644
--- a/js/app/packages/app/component/split-layout/components/SplitContainer.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitContainer.tsx
@@ -1,5 +1,4 @@
import MacroJump from '@app/component/MacroJump';
-import { MobileDock } from '@app/component/mobile/MobileDock';
import { createElementSize } from '@solid-primitives/resize-observer';
import {
type Accessor,
@@ -16,10 +15,8 @@ import { SplitDrawerGroup } from './SplitDrawerContext';
import { SplitHeader } from './SplitHeader';
import { SplitModalProvider } from './SplitModalContext';
import { SplitToolbar } from './SplitToolbar';
-import { virtualKeyboardVisible } from '@core/mobile/virtualKeyboard';
import { ClippedPanel } from '@core/component/ClippedPanel';
import { globalSplitManager } from '@app/signal/splitLayout';
-import { isMobile } from '@core/mobile/isMobile';
export function SplitContainer(
props: ParentProps<{
@@ -99,6 +96,10 @@ export function SplitContainer(
multipleSplits() &&
!panel.handle.isSpotLight()
}
+ tl={props.tl}
+ bl={props.bl}
+ tr={props.tr}
+ br={props.br}
edgeColor="transparent"
>
<div class="flex flex-col min-h-0 size-full bg-panel">
@@ -110,9 +111,9 @@ export function SplitContainer(
<Show when={panel.handle.isSpotLight()}>
<MacroJump tabbableParent={ref} />
</Show>
- <Show when={isMobile() && !virtualKeyboardVisible()}>
- <MobileDock />
- </Show>
+ {/* <Show when={isMobile() && !virtualKeyboardVisible()}> */}
+ {/* <MobileDock /> */}
+ {/* </Show> */}
</div>
</ClippedPanel>
</div>
diff --git a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
index 529b8a763e..ed837f7e3b 100644
--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx
@@ -7,6 +7,7 @@ import {
import { TOKENS } from '@core/hotkey/tokens';
import { isMobile } from '@core/mobile/isMobile';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import HamburgerIcon from '@phosphor-icons/core/bold/list-bold.svg?component-solid';
import CollapseIcon from '@icon/regular/arrows-in.svg';
import ExpandIcon from '@icon/regular/arrows-out.svg';
import CaretLeft from '@icon/regular/caret-left.svg';
@@ -27,6 +28,8 @@ import { Portal } from 'solid-js/web';
import { SplitLayoutContext, SplitPanelContext } from '../context';
import { canSpotlight } from '../utils/canSpotlight';
import { cn } from '@ui/utils/classname';
+import { isListViewID } from '@app/constants/list-views';
+import { setSidebarState } from '@app/component/Layout';
function SplitBackButton() {
const context = useContext(SplitPanelContext);
@@ -105,7 +108,7 @@ function SplitCloseButton() {
const label = createMemo(() => {
const isOnlySplit = layout.manager.splits().length === 1;
- const isNotUnifiedList = context.handle.content().id !== 'unified-list';
+ const isNotUnifiedList = !isListViewID(context.handle.content().id);
return isOnlySplit && isNotUnifiedList ? 'Return to list' : 'Close';
});
@@ -184,6 +187,19 @@ export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {
>
<div class="absolute inset-0 flex justify-start items-center bg-panel">
<div class="z-2 relative flex items-center bg-panel pl-2 mobile:pl-0 h-full">
+ <div class="hidden mobile:block">
+ <button
+ type="button"
+ class="p-2"
+ onClick={() => {
+ setSidebarState((p) =>
+ p === 'expanded' ? 'hidden' : 'expanded'
+ );
+ }}
+ >
+ <HamburgerIcon class="size-6" />
+ </button>
+ </div>
<div class="mobile:hidden">
<SplitCloseButton />
</div>
diff --git a/js/app/packages/app/component/split-layout/layoutManager.ts b/js/app/packages/app/component/split-layout/layoutManager.ts
index 5f8f0f6ef3..932da6ad72 100644
--- a/js/app/packages/app/component/split-layout/layoutManager.ts
+++ b/js/app/packages/app/component/split-layout/layoutManager.ts
@@ -25,8 +25,9 @@ import {
resolveComponent,
} from './componentRegistry';
import { createHistory, type History } from './history';
+import { LIST_VIEW_ID, type ListView } from '@app/constants/list-views';
-const ENABLE_DEFAULT_ALWAYS_IN_HISTORY = true;
+const ENABLE_DEFAULT_ALWAYS_IN_HISTORY = false;
export type SplitId = string & { readonly SplitId: unique symbol };
type SplitKey = `${BlockName | BlockAlias | 'component'}:${string}`;
@@ -96,7 +97,7 @@ export type PopoverSplitHandle = {
};
export type ReferredFrom =
- | 'unified-list'
+ | ListView
| 'kommand-menu'
| 'mention'
| 'attachment'
@@ -438,7 +439,7 @@ export function createSplitLayout(
const DEFAULT_SPLIT_CONTENT = defaultSplitContent ?? {
type: 'component',
- id: 'unified-list',
+ id: LIST_VIEW_ID.inbox,
};
function dispatchEvent(
diff --git a/js/app/packages/app/component/split-layout/layoutUtils.ts b/js/app/packages/app/component/split-layout/layoutUtils.ts
index 21a4a7ce16..217b9d301b 100644
--- a/js/app/packages/app/component/split-layout/layoutUtils.ts
+++ b/js/app/packages/app/component/split-layout/layoutUtils.ts
@@ -1,7 +1,6 @@
import { globalSplitManager } from '@app/signal/splitLayout';
import type { BlockAlias, BlockName } from '@core/block';
import { isBlockAlias, resolveBlockAlias } from '@core/constant/allBlocks';
-import type { ViewId } from '@core/types/view';
import { createCallback } from '@solid-primitives/rootless';
import { type Accessor, createMemo, useContext } from 'solid-js';
import { SplitLayoutContext, SplitPanelContext } from './context';
@@ -11,6 +10,7 @@ import type {
SplitHandle,
SplitManager,
} from './layoutManager';
+import { LIST_VIEW_ID } from '@app/constants/list-views';
export function decodePairs(segments: string[]): SplitContent[] {
const pairs: SplitContent[] = [];
@@ -39,7 +39,7 @@ export function decodePairs(segments: string[]): SplitContent[] {
}
}
}
- return pairs.length ? pairs : [{ type: 'component', id: 'unified-list' }];
+ return pairs.length ? pairs : [{ type: 'component', id: LIST_VIEW_ID.inbox }];
}
export function encodePairs(splits: ReadonlyArray<SplitContent>): string[] {
@@ -130,25 +130,6 @@ export function focusAdjacentSplit(direction: 'left' | 'right') {
splitManager.returnFocus();
}
-/**
- * Check if there's a unified-list split with a particular view open. Note: not necessarily the active split.
- */
-export function isViewOpen(manager: SplitManager | undefined, viewId: ViewId) {
- if (!manager) return false;
- const split = manager.getSplitByContent('component', 'unified-list');
- return split?.meta()?.viewId === viewId;
-}
-
-/**
- * Reactive accessor indicating whether there's a unified-list split with a particular view open. Note: not necessarily the active split.
- */
-export function createIsViewOpenMemo(
- manager: SplitManager | undefined,
- viewId: ViewId
-) {
- return createMemo(() => isViewOpen(manager, viewId));
-}
-
/**
* Reactive boolean accessor indicating whether the active split is currently
* showing a specific component content id.
diff --git a/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts b/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts
index 3e0efab684..3e01c27138 100644
--- a/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts
+++ b/js/app/packages/app/component/split-layout/registerSplitHotkeys.ts
@@ -5,6 +5,7 @@ import { fireMacroJump } from '../MacroJump';
import type { ReferredFrom, SplitContent } from './layoutManager';
import { focusAdjacentSplit } from './layoutUtils';
import { canSpotlight } from './utils/canSpotlight';
+import { LIST_VIEW_ID } from '@app/constants/list-views';
export function registerSplitHotkeys(args: {
splitHotkeyScope: string;
@@ -47,7 +48,7 @@ export function registerSplitHotkeys(args: {
closeSplit();
} else {
replaceSplit({
- content: { type: 'component', id: 'unified-list' },
+ content: { type: 'component', id: LIST_VIEW_ID.inbox },
referredFrom: 'hotkey',
});
}
diff --git a/js/app/packages/app/constants/defaultRoute.ts b/js/app/packages/app/constants/defaultRoute.ts
index 3ec5254b72..ebc41cf429 100644
--- a/js/app/packages/app/constants/defaultRoute.ts
+++ b/js/app/packages/app/constants/defaultRoute.ts
@@ -1 +1 @@
-export const DEFAULT_ROUTE = '/component/unified-list';
+export const DEFAULT_ROUTE = '/component/inbox';
diff --git a/js/app/packages/app/constants/hotkeys.ts b/js/app/packages/app/constants/hotkeys.ts
new file mode 100644
index 0000000000..445368eea6
--- /dev/null
+++ b/js/app/packages/app/constants/hotkeys.ts
@@ -0,0 +1,16 @@
+import { registerScope } from '@core/hotkey/utils';
+import type { ValidHotkey } from '@core/hotkey/types';
+
+/** Leader key for vim-style "go to" commands (g + key sequences) */
+export const GO_TO_LEADER_KEY: ValidHotkey = 'g';
+
+/** Command scope for 'g' leader key (vim-style "go to" commands) */
+export const GO_TO_COMMAND_SCOPE = 'command-scope-go-to';
+
+// Register the global GO_TO command scope
+registerScope({
+ parentScopeId: 'global',
+ scopeId: GO_TO_COMMAND_SCOPE,
+ type: 'command',
+ activationKeys: [GO_TO_LEADER_KEY],
+});
diff --git a/js/app/packages/app/constants/list-views.ts b/js/app/packages/app/constants/list-views.ts
new file mode 100644
index 0000000000..97757a758e
--- /dev/null
+++ b/js/app/packages/app/constants/list-views.ts
@@ -0,0 +1,68 @@
+import type { BlockAlias, BlockName } from '@core/block';
+
+export const LIST_VIEWS = [
+ 'inbox',
+ 'agents',
+ 'mail',
+ 'documents',
+ 'tasks',
+ 'channels',
+ 'files',
+ 'search',
+] as const;
+
+export type ListView = (typeof LIST_VIEWS)[number];
+
+export const LIST_VIEW_PATHS = {
+ inbox: '/inbox',
+ agents: '/agents',
+ mail: '/mail',
+ documents: '/documents',
+ tasks: '/tasks',
+ channels: '/channels',
+ files: '/files',
+ search: '/search',
+} as const satisfies Record<ListView, string>;
+
+export const isListViewPath = (path: string) => {
+ return LIST_VIEW_PATHS[path as ListView] !== undefined;
+};
+
+export const LIST_VIEW_ID = {
+ inbox: 'inbox',
+ agents: 'agents',
+ mail: 'mail',
+ documents: 'documents',
+ tasks: 'tasks',
+ channels: 'channels',
+ files: 'files',
+ search: 'search',
+} as const satisfies Record<ListView, string>;
+
+export const isListViewID = (id: string | null | undefined): id is ListView => {
+ if (!id) return false;
+
+ return LIST_VIEWS.includes(id as 'inbox');
+};
+
+const BLOCK_LIST_VIEW_MAP = {
+ channel: 'channels',
+ canvas: 'documents',
+ chat: 'agents',
+ code: 'files',
+ contact: 'channels',
+ csv: 'files',
+ email: 'mail',
+ image: 'files',
+ md: 'documents',
+ pdf: 'files',
+ project: 'files',
+ task: 'tasks',
+ unknown: 'inbox',
+ video: 'files',
+ write: 'files',
+} as const satisfies Record<BlockName | BlockAlias, ListView>;
+
+export const getBlockListView = (block: BlockName | BlockAlias): ListView => {
+ return BLOCK_LIST_VIEW_MAP[block];
+};
diff --git a/js/app/packages/app/index.css b/js/app/packages/app/index.css
index 15406b0cc1..46575fa86d 100644
--- a/js/app/packages/app/index.css
+++ b/js/app/packages/app/index.css
@@ -588,12 +588,6 @@
--container-c: 0;
/* --shadow-*: initial; */
- --radius-sm: 6px;
- --radius-md: 6px;
- --radius-lg: 6px;
- --radius-xl: 6px;
- --radius-2xl: 6px;
- --radius-3xl: 6px;
}
@custom-variant drop-valid (&[data-drop-valid]);
diff --git a/js/app/packages/block-email/component/Compose.tsx b/js/app/packages/block-email/component/Compose.tsx
index 4c891bf2d9..9317f98fed 100644
--- a/js/app/packages/block-email/component/Compose.tsx
+++ b/js/app/packages/block-email/component/Compose.tsx
@@ -79,6 +79,7 @@ import { unwrap } from 'solid-js/store';
import { emailClient } from '@service-email/client';
import { queryClient } from '@queries/client';
import { emailKeys } from '@queries/email/keys';
+import { LIST_VIEW_ID } from '@app/constants/list-views';
const DRAFT_DEBOUNCE_MS = 1000;
@@ -544,7 +545,7 @@ export function EmailCompose(props: EmailComposeProps) {
toast.success('Email scheduled');
replaceSplit({
- content: { type: 'component', id: 'unified-list' },
+ content: { type: 'component', id: LIST_VIEW_ID.mail },
mergeHistory: true,
});
},
diff --git a/js/app/packages/core/hotkey/hotkeys.ts b/js/app/packages/core/hotkey/hotkeys.ts
index e188b66ae4..321726b9d6 100644
--- a/js/app/packages/core/hotkey/hotkeys.ts
+++ b/js/app/packages/core/hotkey/hotkeys.ts
@@ -114,6 +114,7 @@ export function registerHotkey(
keyDownHandler,
keyUpHandler,
activateCommandScope,
+ activateCommandScopeId: providedCommandScopeId,
runWithInputFocused,
hotkeyToken,
displayPriority,
@@ -179,7 +180,26 @@ export function registerHotkey(
}
let commandScopeId: string | undefined;
- if (activateCommandScope) {
+ // If a specific command scope ID is provided, use it instead of creating a new one
+ if (providedCommandScopeId) {
+ const existingScope = hotkeyScopeTree.get(providedCommandScopeId);
+ if (!existingScope) {
+ logger.error('Provided command scope ID not found.', {
+ error: new Error('Provided command scope ID not found'),
+ providedCommandScopeId,
+ });
+ return noopDisposer;
+ }
+ if (existingScope.type !== 'command') {
+ logger.error('Provided scope is not a command scope.', {
+ error: new Error('Provided scope is not a command scope'),
+ providedCommandScopeId,
+ scopeType: existingScope.type,
+ });
+ return noopDisposer;
+ }
+ commandScopeId = providedCommandScopeId;
+ } else if (activateCommandScope) {
commandScopeId = getScopeId('command-scope-' + scopeId);
// When a command scope is registered, its parent scope is set as the scopeId of the registered hotkey. It will be registered as a child of that scope. When the command scope is activated, its parent scope will get set to whatever scope is active where it was called, so that when the command scope is deactivated, it willl return to the correct scope.
registerScope({
@@ -277,8 +297,8 @@ export function registerHotkey(
});
}
- // Remove command scope if it was created
- if (commandScopeId) {
+ // Remove command scope only if we created it (not if we're using a shared one)
+ if (commandScopeId && !providedCommandScopeId) {
removeScope(commandScopeId);
}
},
diff --git a/js/app/packages/core/hotkey/types.ts b/js/app/packages/core/hotkey/types.ts
index da1f793e86..5d116d83f6 100644
--- a/js/app/packages/core/hotkey/types.ts
+++ b/js/app/packages/core/hotkey/types.ts
@@ -104,6 +104,14 @@ export interface HotkeyRegistrationOptions {
*/
activateCommandScope?: boolean;
+ /**
+ * If provided, pressing the hotkey will activate the specified command scope
+ * instead of creating a new one. Use this to share a command scope across
+ * multiple components. The specified scope must already exist (created via `registerScope`).
+ * Takes precedence over `activateCommandScope` if both are provided.
+ */
+ activateCommandScopeId?: string;
+
/**
* If true, the keyDownHandler will be run even if the input is focused.
*/
diff --git a/js/app/packages/core/util/compareUtils.ts b/js/app/packages/core/util/compareUtils.ts
index e1f1dbe529..34aeb5f8ed 100644
--- a/js/app/packages/core/util/compareUtils.ts
+++ b/js/app/packages/core/util/compareUtils.ts
@@ -62,3 +62,52 @@ export function uniqueByKeySorted<T>(
keyOf(a).localeCompare(keyOf(b))
);
}
+
+/**
+ * Deep equality check for two values.
+ * Handles primitives, arrays, objects, null, and undefined.
+ * Arrays are compared by value (order matters).
+ */
+export function deepEqual(a: unknown, b: unknown): boolean {
+ // Same reference or both primitives with same value
+ if (a === b) return true;
+
+ // Handle null/undefined
+ if (a == null || b == null) return a === b;
+
+ // Different types
+ if (typeof a !== typeof b) return false;
+
+ // Arrays
+ if (Array.isArray(a) && Array.isArray(b)) {
+ if (a.length !== b.length) return false;
+ return a.every((val, i) => deepEqual(val, b[i]));
+ }
+
+ // One is array, one is not
+ if (Array.isArray(a) !== Array.isArray(b)) return false;
+
+ // Objects
+ if (typeof a === 'object' && typeof b === 'object') {
+ const aKeys = Object.keys(a as object);
+ const bKeys = Object.keys(b as object);
+
+ // Get all unique keys from both objects
+ const allKeys = new Set([...aKeys, ...bKeys]);
+
+ for (const key of allKeys) {
+ const aVal = (a as Record<string, unknown>)[key];
+ const bVal = (b as Record<string, unknown>)[key];
+
+ // Treat undefined and missing keys as equivalent
+ if (aVal === undefined && bVal === undefined) continue;
+
+ if (!deepEqual(aVal, bVal)) return false;
+ }
+
+ return true;
+ }
+
+ // Primitives that aren't equal (already handled by ===)
+ return false;
+}
diff --git a/js/app/packages/entity/src/types/entity.ts b/js/app/packages/entity/src/types/entity.ts
index 75ac1b64e5..fb279d085c 100644
--- a/js/app/packages/entity/src/types/entity.ts
+++ b/js/app/packages/entity/src/types/entity.ts
@@ -72,6 +72,13 @@ export const getEntityProjectId = (e: EntityData): string | false => {
export type EmailThreadParticipants = Array<{ email: string; name?: string }>;
+export type EmailAttachment = {
+ id: string;
+ filename?: string | null;
+ mimeType?: string | null;
+ sizeBytes?: number | null;
+};
+
// We spread ApiThreadPreviewCursor into the email entity, should we explcitly include all those fields here, or only add them as needed?
export type EmailEntity = EntityBase & {
type: 'email';
@@ -85,6 +92,7 @@ export type EmailEntity = EntityBase & {
senderName?: string;
labels?: SoupLabel[] | ApiLabel[];
hasIcsAttachment?: boolean;
+ attachments?: EmailAttachment[];
};
export type ProjectEntity = EntityBase & {
diff --git a/js/app/packages/entity/src/utils/task-properties.ts b/js/app/packages/entity/src/utils/task-properties.ts
index 2d1856afa2..5983eed7fd 100644
--- a/js/app/packages/entity/src/utils/task-properties.ts
+++ b/js/app/packages/entity/src/utils/task-properties.ts
@@ -96,6 +96,29 @@ export const getTaskStatusOptionId = (
return value.value[0];
};
+/**
+ * Gets the priority option id from task properties.
+ */
+export const getTaskPriorityOptionId = (
+ entity: TaskEntityWithProperties
+): string | undefined => {
+ const priorityProperty = getTaskPropertyByDefinitionId(
+ entity,
+ SYSTEM_PROPERTY_IDS.PRIORITY
+ );
+
+ if (!priorityProperty?.value) {
+ return undefined;
+ }
+
+ const value = priorityProperty.value;
+ if (value.type !== 'SelectOption' || !isStringArray(value.value)) {
+ return undefined;
+ }
+
+ return value.value[0];
+};
+
/**
* Checks if a task is in a closed state.
*/
diff --git a/js/app/packages/notifications/components/NotificationRoute.tsx b/js/app/packages/notifications/components/NotificationRoute.tsx
index ca547613e2..95e87f9d03 100644
--- a/js/app/packages/notifications/components/NotificationRoute.tsx
+++ b/js/app/packages/notifications/components/NotificationRoute.tsx
@@ -1,5 +1,6 @@
import { useGlobalNotificationSource } from '@app/component/GlobalAppState';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
+import { LIST_VIEW_ID } from '@app/constants/list-views';
import { globalSplitManager } from '@app/signal/splitLayout';
import { LoadingBlock } from '@core/component/LoadingBlock';
import { toast } from '@core/component/Toast/Toast';
@@ -23,7 +24,7 @@ export default function NotificationRoute() {
logger.error('Failed to open notification.', { cause });
toast.failure('Failed to open notification.');
split.handle.replace({
- next: { type: 'component', id: 'unified-list' },
+ next: { type: 'component', id: LIST_VIEW_ID.inbox },
mergeHistory: true,
});
};
diff --git a/js/app/packages/queries/soup/transform-utils.ts b/js/app/packages/queries/soup/transform-utils.ts
index 3f28bcfdeb..361e89ba7b 100644
--- a/js/app/packages/queries/soup/transform-utils.ts
+++ b/js/app/packages/queries/soup/transform-utils.ts
@@ -380,6 +380,13 @@ export const mapSoupPageToEntityList: (
a.filename?.toLowerCase().endsWith('.ics')
);
+ const attachments = item.data.attachments?.map((a) => ({
+ id: a.id,
+ filename: a.filename,
+ mimeType: a.mimeType,
+ sizeBytes: a.sizeBytes,
+ }));
+
return {
...item.data,
createdAt: item.data.createdAt,
@@ -394,6 +401,7 @@ export const mapSoupPageToEntityList: (
viewedAt: item.data.viewedAt,
participants,
hasIcsAttachment,
+ attachments,
};
}