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(home): add sidebar filters and stable sort for new homepage (#6467)

Jacob Beckermanfdceecad0a4f
diff --git a/apps/web/src/components/app/PreviewPanel.tsx b/apps/web/src/components/app/PreviewPanel.tsx
index 7eea191894..6a2164ab4b 100644
--- a/apps/web/src/components/app/PreviewPanel.tsx
+++ b/apps/web/src/components/app/PreviewPanel.tsx
@@ -267,7 +267,7 @@ function PreviewPanelContent(
>
<div
ref={headerCollapseController.setRow}
- class="relative flex min-h-10 w-full shrink-0 items-center justify-between bg-surface px-2"
+ class="relative flex min-h-10 w-full shrink-0 items-center justify-between bg-surface px-2 not-touch:pl-[13px]"
>
<Show when={props.headerLeading}>
<div class="flex shrink-0 items-center">{props.headerLeading}</div>
diff --git a/apps/web/src/components/app/split-layout/components/SplitHeader.tsx b/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
index ddc7be7af4..94be6fd504 100644
--- a/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
+++ b/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
@@ -563,7 +563,7 @@ export function SplitHeader(props: {
)}
</Show>
<div
- class="absolute inset-0 flex justify-start items-center touch:px-(--mobile-chrome-gutter) touch:gap-2"
+ class="absolute inset-0 flex justify-start items-center not-touch:pl-[5px] touch:px-(--mobile-chrome-gutter) touch:gap-2"
ref={props.collapseController.setRow}
>
<Show
diff --git a/apps/web/src/components/view-shell/SidebarCreateButton.tsx b/apps/web/src/components/view-shell/SidebarCreateButton.tsx
index 55ba89ee0b..bf9b444a2e 100644
--- a/apps/web/src/components/view-shell/SidebarCreateButton.tsx
+++ b/apps/web/src/components/view-shell/SidebarCreateButton.tsx
@@ -2,13 +2,14 @@ import { SplitPanel } from '@components/app/split-panel';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import PlusIcon from '@phosphor/plus.svg';
import { pressHandlers } from '@ui';
-import { Show } from 'solid-js';
+import { type JSX, Show } from 'solid-js';
import { ViewSidebar } from './ViewSidebar';
export function SidebarCreateHeader(props: {
title: string;
label: string;
onCreate: () => void;
+ actions?: JSX.Element;
}) {
return (
<header class="flex shrink-0 flex-col">
@@ -18,6 +19,7 @@ export function SidebarCreateHeader(props: {
<SplitPanel.CloseButton class="shrink-0" />
<ViewSidebar.Title>{props.title}</ViewSidebar.Title>
</div>
+ {props.actions}
</ViewSidebar.Header>
</Show>
<div class="min-w-0 px-1.5 pt-4 touch:pt-[calc(var(--safe-top,0px)+1rem)]">
diff --git a/apps/web/src/features/inbox-view/components/InboxFilters.tsx b/apps/web/src/features/inbox-view/components/InboxFilters.tsx
index 858cd9ee7c..bc616a35ad 100644
--- a/apps/web/src/features/inbox-view/components/InboxFilters.tsx
+++ b/apps/web/src/features/inbox-view/components/InboxFilters.tsx
@@ -1,26 +1,116 @@
-import {
- ListFilterDropdown,
- MobileFilterDrawer,
-} from '@app/components/view-shell';
-import { addUnique, removeValue } from '@app/lib/signals/store-array-updaters';
+import { MobileFilterDrawer } from '@app/components/view-shell';
import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
import { EntityIcon } from '@core/component/EntityIcon';
import { Accordion } from '@kobalte/core/accordion';
import BellSimpleIcon from '@phosphor/bell-simple.svg';
+import FilterIcon from '@phosphor/funnel-simple.svg';
+import { Dropdown, ToggleSwitch } from '@ui';
import { createMemo, For, type JSX, Show } from 'solid-js';
+import { selectedHomeTypes, setHomeTypeSelected } from '../core/type-selection';
import { INBOX_FILTER_GROUPS } from '../inbox-facets';
import { useInboxView } from '../inbox-view-context';
const FILTER_ICONS = new Map<string, () => JSX.Element>([
- ['documents', () => <EntityIcon targetType="md" size="xs" />],
- ['tasks', () => <EntityIcon targetType="task" size="xs" />],
- ['email', () => <EntityIcon targetType="email" size="xs" />],
- ['channels', () => <EntityIcon targetType="channel" size="xs" />],
- ['agents', () => <EntityIcon targetType="chat" size="xs" />],
- ['projects', () => <EntityIcon targetType="project" size="xs" />],
- ['github', () => <EntityIcon targetType="githubPullRequest" size="xs" />],
+ [
+ 'documents',
+ () => (
+ <EntityIcon
+ targetType="md"
+ size="xs"
+ theme="monochrome"
+ class="text-ink-muted"
+ />
+ ),
+ ],
+ [
+ 'tasks',
+ () => (
+ <EntityIcon
+ targetType="task"
+ size="xs"
+ theme="monochrome"
+ class="text-ink-muted"
+ />
+ ),
+ ],
+ [
+ 'email',
+ () => (
+ <EntityIcon
+ targetType="email"
+ size="xs"
+ theme="monochrome"
+ class="text-ink-muted"
+ />
+ ),
+ ],
+ [
+ 'channels',
+ () => (
+ <EntityIcon
+ targetType="channel"
+ size="xs"
+ theme="monochrome"
+ class="text-ink-muted"
+ />
+ ),
+ ],
+ [
+ 'chats',
+ () => (
+ <EntityIcon
+ targetType="chat"
+ size="xs"
+ theme="monochrome"
+ class="text-ink-muted"
+ />
+ ),
+ ],
+ [
+ 'agents',
+ () => (
+ <EntityIcon
+ targetType="agent"
+ size="xs"
+ theme="monochrome"
+ class="text-ink-muted"
+ />
+ ),
+ ],
+ [
+ 'projects',
+ () => (
+ <EntityIcon
+ targetType="project"
+ size="xs"
+ theme="monochrome"
+ class="text-ink-muted"
+ />
+ ),
+ ],
+ [
+ 'github',
+ () => (
+ <EntityIcon
+ targetType="githubPullRequest"
+ size="xs"
+ theme="monochrome"
+ class="text-ink-muted"
+ />
+ ),
+ ],
['reminders', () => <BellSimpleIcon class="size-3.5 text-ink-muted" />],
- ['calendar', () => <EntityIcon targetType="calendar" size="xs" />],
+ [
+ 'calendar',
+ () => (
+ <EntityIcon
+ targetType="calendar"
+ size="xs"
+ theme="monochrome"
+ class="text-ink-muted"
+ />
+ ),
+ ],
]);
const FILTER_GROUPS = INBOX_FILTER_GROUPS.map((group) => ({
@@ -30,17 +120,18 @@ const FILTER_GROUPS = INBOX_FILTER_GROUPS.map((group) => ({
icon: FILTER_ICONS.get(option.id),
})),
}));
+const TYPE_IDS = FILTER_GROUPS.flatMap((group) =>
+ group.id === 'type' ? group.options.map((option) => option.id) : []
+);
function useInboxFilters() {
const { state, setFacets } = useInboxView();
const isSelected = (groupId: string, optionId: string) => {
const selectedIds = state.facets[groupId] ?? [];
- if (groupId === 'read' && optionId === 'all') {
- return selectedIds.length === 0;
- }
-
- return selectedIds.includes(optionId);
+ return groupId === 'type'
+ ? selectedHomeTypes(selectedIds, TYPE_IDS).includes(optionId)
+ : selectedIds.includes(optionId);
};
const setSelected = (
@@ -48,30 +139,29 @@ function useInboxFilters() {
optionId: string,
selected: boolean
) => {
- if (groupId === 'read') {
- if (!selected) return;
-
- setFacets({
- ...state.facets,
- [groupId]: optionId === 'all' ? [] : [optionId],
- });
- return;
- }
-
- const update = selected ? addUnique(optionId) : removeValue(optionId);
setFacets({
...state.facets,
- [groupId]: update(state.facets[groupId]),
+ [groupId]: setHomeTypeSelected(
+ state.facets[groupId],
+ TYPE_IDS,
+ optionId,
+ selected
+ ),
});
};
+ const unreadOnly = () => state.facets.read?.includes('unread') ?? false;
+ const setUnreadOnly = (checked: boolean) =>
+ setFacets({ ...state.facets, read: checked ? ['unread'] : [] });
+
const activeCount = () =>
- Object.values(state.facets).reduce(
- (count, optionIds) => count + optionIds.length,
- 0
- );
+ TYPE_IDS.length -
+ selectedHomeTypes(state.facets.type, TYPE_IDS).length +
+ (unreadOnly() ? 1 : 0);
return {
+ unreadOnly,
+ setUnreadOnly,
activeCount,
clear: () => setFacets({}),
isSelected,
@@ -82,7 +172,7 @@ function useInboxFilters() {
function FilterCountBadge(props: { count: number }) {
return (
<Show when={props.count > 0}>
- <span class="absolute -top-0.5 right-0 flex size-4 translate-x-1/2 items-center justify-center rounded-full bg-accent text-xxs font-medium leading-none text-surface">
+ <span class="pointer-events-none absolute -top-0.5 right-0 flex size-3 translate-x-1/2 items-center justify-center rounded-full bg-panel text-[9px] font-medium leading-none text-ink-muted">
{props.count}
</span>
</Show>
@@ -94,13 +184,52 @@ export function InboxFilterDropdown() {
return (
<div class="relative ml-auto shrink-0">
- <ListFilterDropdown
- groups={FILTER_GROUPS}
- isSelected={filters.isSelected}
- onSelectionChange={filters.setSelected}
- onClear={filters.clear}
- label="Filter Home"
- />
+ <Dropdown placement="bottom-end">
+ <Dropdown.Trigger variant="ghost" size="sm" square label="Filter Home">
+ <FilterIcon />
+ </Dropdown.Trigger>
+ <Dropdown.Content class="max-h-[min(36rem,calc(100dvh-5rem))] w-56 overflow-y-auto">
+ <Dropdown.Group>
+ <Dropdown.Item
+ role="menuitemcheckbox"
+ aria-checked={filters.unreadOnly()}
+ closeOnSelect={false}
+ onSelect={() => filters.setUnreadOnly(!filters.unreadOnly())}
+ >
+ <span class="flex-1">Unread only</span>
+ <span aria-hidden="true" inert class="pointer-events-none flex">
+ <ToggleSwitch checked={filters.unreadOnly()} size="xs" />
+ </span>
+ </Dropdown.Item>
+ </Dropdown.Group>
+ <For each={FILTER_GROUPS}>
+ {(group) => (
+ <Dropdown.Group>
+ <Dropdown.GroupLabel>{group.label}</Dropdown.GroupLabel>
+ <For each={group.options}>
+ {(option) => (
+ <Dropdown.CheckboxItem
+ checked={filters.isSelected(group.id, option.id)}
+ closeOnSelect={false}
+ onChange={(selected) =>
+ filters.setSelected(group.id, option.id, selected)
+ }
+ >
+ {option.icon?.()}
+ <span>{option.label}</span>
+ </Dropdown.CheckboxItem>
+ )}
+ </For>
+ </Dropdown.Group>
+ )}
+ </For>
+ <Dropdown.Group>
+ <Dropdown.Item onSelect={filters.clear}>
+ Reset filters
+ </Dropdown.Item>
+ </Dropdown.Group>
+ </Dropdown.Content>
+ </Dropdown>
<FilterCountBadge count={filters.activeCount()} />
</div>
@@ -112,12 +241,21 @@ export function InboxFilterDrawer() {
return (
<MobileFilterDrawer
- triggerLabel="Open Inbox filters"
- label="Inbox filters"
+ triggerLabel="Filter Home"
+ label="Home filters"
activeCount={filters.activeCount()}
onClear={filters.clear}
>
- <MobileDrawer.Label class="pt-4">Filters</MobileDrawer.Label>
+ <MobileDrawer.Item
+ role="switch"
+ aria-checked={filters.unreadOnly()}
+ onClick={() => filters.setUnreadOnly(!filters.unreadOnly())}
+ >
+ <span class="flex-1">Unread only</span>
+ <span aria-hidden="true" inert class="pointer-events-none flex">
+ <ToggleSwitch checked={filters.unreadOnly()} />
+ </span>
+ </MobileDrawer.Item>
<Accordion
multiple
@@ -130,9 +268,7 @@ export function InboxFilterDrawer() {
const activeCount = createMemo(
() =>
group.options.filter(
- (option) =>
- option.id !== group.defaultOptionId &&
- filters.isSelected(group.id, option.id)
+ (option) => !filters.isSelected(group.id, option.id)
).length
);
@@ -143,16 +279,10 @@ export function InboxFilterDrawer() {
activeCount={activeCount()}
class="mb-3"
>
- <div
- role={
- group.selectionMode === 'single' ? 'radiogroup' : 'group'
- }
- aria-label={group.label}
- >
+ <div role="group" aria-label={group.label}>
<For each={group.options}>
{(option) => (
<MobileFilterDrawer.Option
- selectionMode={group.selectionMode}
checked={filters.isSelected(group.id, option.id)}
onChange={(checked) =>
filters.setSelected(group.id, option.id, checked)
diff --git a/apps/web/src/features/inbox-view/components/InboxHeader.tsx b/apps/web/src/features/inbox-view/components/InboxHeader.tsx
index ddf5b3b3ce..0925e8fc8b 100644
--- a/apps/web/src/features/inbox-view/components/InboxHeader.tsx
+++ b/apps/web/src/features/inbox-view/components/InboxHeader.tsx
@@ -2,6 +2,7 @@ import { SidebarCreateHeader } from '@app/components/view-shell/SidebarCreateBut
import { MobileTopEdgeFade } from '@components/app/mobile/MobileEdgeFade';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { type JSX, type ParentProps, Show } from 'solid-js';
+import { InboxFilterDropdown } from './InboxFilters';
function MobileInboxHeader(props: ParentProps) {
return (
@@ -31,6 +32,7 @@ export function InboxListLayout(
title="Home"
label="New chat"
onCreate={props.onNewChat}
+ actions={<InboxFilterDropdown />}
/>
}
>
diff --git a/apps/web/src/features/inbox-view/core/type-selection.test.ts b/apps/web/src/features/inbox-view/core/type-selection.test.ts
new file mode 100644
index 0000000000..8be855400d
--- /dev/null
+++ b/apps/web/src/features/inbox-view/core/type-selection.test.ts
@@ -0,0 +1,28 @@
+import { describe, expect, it } from 'vitest';
+import { selectedHomeTypes, setHomeTypeSelected } from './type-selection';
+
+const types = ['email', 'channels', 'documents'];
+
+describe('Home entity type selection', () => {
+ it('starts with every type checked and can hide one', () => {
+ expect(selectedHomeTypes(undefined, types)).toEqual(types);
+ expect(setHomeTypeSelected(undefined, types, 'email', false)).toEqual([
+ 'channels',
+ 'documents',
+ ]);
+ });
+ it('can hide every type and then re-enable one', () => {
+ let selection: string[] = [];
+ for (const type of types)
+ selection = setHomeTypeSelected(selection, types, type, false);
+ expect(selectedHomeTypes(selection, types)).toEqual([]);
+ expect(setHomeTypeSelected(selection, types, 'email', true)).toEqual([
+ 'email',
+ ]);
+ });
+ it('returns to the unrestricted default when all types are checked', () => {
+ expect(
+ setHomeTypeSelected(['channels', 'documents'], types, 'email', true)
+ ).toEqual([]);
+ });
+});
diff --git a/apps/web/src/features/inbox-view/core/type-selection.ts b/apps/web/src/features/inbox-view/core/type-selection.ts
new file mode 100644
index 0000000000..913a211de4
--- /dev/null
+++ b/apps/web/src/features/inbox-view/core/type-selection.ts
@@ -0,0 +1,22 @@
+/** Soup's empty selection means all; `none` explicitly hides every type. */
+export function selectedHomeTypes(
+ selection: readonly string[] | undefined,
+ available: readonly string[]
+): string[] {
+ return selection?.length
+ ? available.filter((id) => selection.includes(id))
+ : [...available];
+}
+
+export function setHomeTypeSelected(
+ selection: readonly string[] | undefined,
+ available: readonly string[],
+ id: string,
+ selected: boolean
+): string[] {
+ const next = new Set(selectedHomeTypes(selection, available));
+ if (selected) next.add(id);
+ else next.delete(id);
+ if (next.size === available.length) return [];
+ return next.size ? [...next] : ['none'];
+}
diff --git a/apps/web/src/features/inbox-view/inbox-facets.ts b/apps/web/src/features/inbox-view/inbox-facets.ts
index 3a03e5ae18..40013e240b 100644
--- a/apps/web/src/features/inbox-view/inbox-facets.ts
+++ b/apps/web/src/features/inbox-view/inbox-facets.ts
@@ -103,11 +103,17 @@ const typeOptions: Record<InboxTypeFilter, InboxFacetOption> = {
entity.type === 'channel_message' ||
entity.type === 'channel_thread',
},
+ chats: {
+ id: 'chats',
+ label: 'Chats',
+ clause: { cf: clause.not(clause.eq('chatId', NIL_UUID)) },
+ predicate: (entity) => entity.type === 'chat',
+ },
agents: {
id: 'agents',
label: 'Agents',
- clause: { cf: clause.not(clause.eq('chatId', NIL_UUID)) },
- predicate: (entity) => entity.type === 'chat',
+ clause: { asf: clause.not(clause.eq('agentSessionId', NIL_UUID)) },
+ predicate: (entity) => entity.type === 'agent_session',
},
projects: {
id: 'projects',
@@ -142,26 +148,13 @@ const typeOptions: Record<InboxTypeFilter, InboxFacetOption> = {
type InboxFilterGroup = {
id: string;
label: string;
- selectionMode?: 'single' | 'multiple';
- defaultOptionId?: string;
options: { id: string; label: string }[];
};
export const INBOX_FILTER_GROUPS: InboxFilterGroup[] = [
- {
- id: 'read',
- label: 'Status',
- selectionMode: 'single',
- defaultOptionId: 'all',
- options: [
- { id: 'unread', label: 'Unread' },
- { id: 'read', label: 'Read' },
- { id: 'all', label: 'All' },
- ],
- },
{
id: 'type',
- label: 'Type',
+ label: 'Entity types',
options: Object.values(typeOptions),
},
];
@@ -183,6 +176,11 @@ export const INBOX_FACETS: Facet<
id: 'type',
mode: 'or',
restrict: true,
- options: Object.values(typeOptions),
+ // Empty selections mean unrestricted in Soup. An explicit option with no
+ // allowed targets represents hiding every type, including in server queries.
+ options: [
+ ...Object.values(typeOptions),
+ { id: 'none', label: 'None', clause: {}, predicate: () => false },
+ ],
},
];
diff --git a/apps/web/src/features/inbox-view/inbox-view-context.test.tsx b/apps/web/src/features/inbox-view/inbox-view-context.test.tsx
index 546080a755..3609815d83 100644
--- a/apps/web/src/features/inbox-view/inbox-view-context.test.tsx
+++ b/apps/web/src/features/inbox-view/inbox-view-context.test.tsx
@@ -12,6 +12,8 @@ const entry = vi.hoisted(() => ({
state: {} as Record<string, unknown>,
captors: new Map<string, () => unknown>(),
}));
+const user = vi.hoisted(() => ({ id: 'alice' }));
+vi.mock('@core/context/user', () => ({ useUserId: () => () => user.id }));
vi.mock('@components/app/split-layout/layoutUtils', () => ({
useSplitPanelOrThrow: () => ({
@@ -40,6 +42,8 @@ function mountProvider(initialState?: InboxViewStateOptions) {
}
beforeEach(() => {
+ localStorage.clear();
+ user.id = 'alice';
entry.state = {};
entry.captors.clear();
});
@@ -97,7 +101,7 @@ describe('InboxViewProvider initialization', () => {
).toEqual({ tab: 'signal', search: '', groupBy: 'none', facets: {} });
});
- it('still resets restored entries to the unfiltered Signal defaults', () => {
+ it('restores filters while resetting entry navigation to Signal', () => {
entry.state = {
[INBOX_ENTRY_STATE_KEY]: {
version: 1,
@@ -112,16 +116,20 @@ describe('InboxViewProvider initialization', () => {
tab: 'signal',
search: '',
groupBy: 'date',
- facets: {},
+ facets: { read: ['unread'] },
});
});
- it('keeps the persistence reset when returning from an explicitly initialized view', () => {
+ it('restores filter changes when returning through split history', () => {
const view = mountProvider({ tab: 'noise', search: 'explicit search' });
view.context.setState('groupBy', 'type');
view.context.setFacets({ type: ['email'] });
const stored = entry.captors.get(INBOX_ENTRY_STATE_KEY)?.();
- expect(stored).toEqual({ version: 1, tab: 'signal' });
+ expect(stored).toEqual({
+ version: 1,
+ tab: 'signal',
+ facets: { type: ['email'] },
+ });
view.unmount();
entry.state = { [INBOX_ENTRY_STATE_KEY]: stored };
@@ -129,7 +137,67 @@ describe('InboxViewProvider initialization', () => {
tab: 'signal',
search: '',
groupBy: 'date',
- facets: {},
+ facets: { type: ['email'] },
+ });
+ });
+
+ it('persists type and status filters across a full reload with no entry state', () => {
+ const view = mountProvider();
+ view.context.setFacets({ type: ['none'], read: ['unread'] });
+ view.unmount();
+ entry.state = {};
+ expect(mountProvider().context.state.facets).toEqual({
+ type: ['none'],
+ read: ['unread'],
+ });
+ });
+
+ it('uses saved preferences for a fresh Home navigation, but honors explicit facets', () => {
+ const view = mountProvider();
+ view.context.setFacets({ type: ['channels'] });
+ view.unmount();
+ const next = mountProvider({ tab: 'signal' });
+ expect(next.context.state.facets).toEqual({ type: ['channels'] });
+ next.unmount();
+ expect(mountProvider({ facets: {} }).context.state.facets).toEqual({});
+ });
+
+ it('keeps filters scoped to the signed-in user', () => {
+ const view = mountProvider();
+ view.context.setFacets({ type: ['none'] });
+ view.unmount();
+ user.id = 'bob';
+ expect(mountProvider().context.state.facets).toEqual({});
+ });
+
+ it('migrates saved read-only filters to All while preserving entity types', () => {
+ localStorage.setItem(
+ 'macro:home:filters:v1:alice',
+ JSON.stringify({
+ version: 1,
+ facets: { type: ['channels'], read: ['read'] },
+ })
+ );
+ entry.state = {
+ [INBOX_ENTRY_STATE_KEY]: {
+ version: 1,
+ facets: { type: ['channels'], read: ['read'] },
+ },
+ };
+ expect(mountProvider().context.state.facets).toEqual({
+ type: ['channels'],
});
});
+
+ it('persists resetting all filters and tolerates corrupt stored preferences', () => {
+ const view = mountProvider();
+ view.context.setFacets({ type: ['none'], read: ['unread'] });
+ view.context.setFacets({});
+ view.unmount();
+ const restored = mountProvider();
+ expect(restored.context.state.facets).toEqual({});
+ restored.unmount();
+ localStorage.setItem('macro:home:filters:v1:alice', '{broken');
+ expect(mountProvider().context.state.facets).toEqual({});
+ });
});
diff --git a/apps/web/src/features/inbox-view/inbox-view-context.tsx b/apps/web/src/features/inbox-view/inbox-view-context.tsx
index d7a6a057fa..ac8209957d 100644
--- a/apps/web/src/features/inbox-view/inbox-view-context.tsx
+++ b/apps/web/src/features/inbox-view/inbox-view-context.tsx
@@ -1,8 +1,8 @@
-import { normalizeFacetSelection } from '@app/features/soup/filters/facets/selection';
import type { FacetSelection } from '@app/features/soup/filters/facets/types';
import { makePersistedState } from '@app/lib/persistence';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { createAssertedContextProvider } from '@core/context/createContext';
+import { useUserId } from '@core/context/user';
import type { ContextProviderProps } from '@solid-primitives/context';
import {
createStore,
@@ -11,7 +11,10 @@ import {
type SetStoreFunction,
type Store,
} from 'solid-js/store';
-import { createInboxViewPersistence } from './persistence';
+import {
+ createInboxViewPersistence,
+ normalizeInboxFacets,
+} from './persistence';
import type {
InboxGroupBy,
InboxTab,
@@ -39,6 +42,7 @@ export const [InboxViewProvider, useInboxView] = createAssertedContextProvider<
InboxViewProviderProps
>('InboxView', (props) => {
const panel = useSplitPanelOrThrow();
+ const userId = useUserId();
const initial = props.initialState ?? {};
const initialTab = initial.tab ?? 'signal';
const [state, setState] = makePersistedState(
@@ -46,11 +50,13 @@ export const [InboxViewProvider, useInboxView] = createAssertedContextProvider<
tab: initialTab,
search: initial.search ?? '',
groupBy: initial.groupBy ?? defaultGroupBy(initialTab),
- facets: normalizeFacetSelection(initial.facets),
+ facets: normalizeInboxFacets(initial.facets),
}),
createInboxViewPersistence({
handle: panel.handle,
+ userId,
restoreEntryState: props.initialState === undefined,
+ restorePreferences: initial.facets === undefined,
})
);
@@ -66,7 +72,7 @@ export const [InboxViewProvider, useInboxView] = createAssertedContextProvider<
};
const setFacets = (facets: FacetSelection) => {
- setState('facets', reconcile(normalizeFacetSelection(facets)));
+ setState('facets', reconcile(normalizeInboxFacets(facets)));
};
return {
diff --git a/apps/web/src/features/inbox-view/persistence.ts b/apps/web/src/features/inbox-view/persistence.ts
index 6241957951..99f54cc917 100644
--- a/apps/web/src/features/inbox-view/persistence.ts
+++ b/apps/web/src/features/inbox-view/persistence.ts
@@ -1,3 +1,4 @@
+import { normalizeFacetSelection } from '@app/features/soup/filters/facets/selection';
import type {
MakePersistedStateOptions,
PersistenceStorage,
@@ -6,15 +7,28 @@ import {
createEntryPersistenceStorage,
type EntryPersistenceHandle,
} from '@components/app/split-layout/entry-persistence';
+import { createUserScopedStorage } from '@core/util/userScopedStorage';
+import type { Accessor } from 'solid-js';
import { z } from 'zod';
import type { InboxViewState } from './types';
export const INBOX_ENTRY_STATE_KEY = 'inbox.view';
export const INBOX_LIST_ENTRY_STATE_KEY = 'inbox.listState';
+const homeFilterStorage = createUserScopedStorage('macro:home:filters:v1');
+
+/** Home now offers All or Unread; retire saved read-only selections. */
+export function normalizeInboxFacets(raw: unknown) {
+ const facets = normalizeFacetSelection(raw);
+ if (facets.read?.length !== 1 || facets.read[0] !== 'unread') {
+ delete facets.read;
+ }
+ return facets;
+}
const inboxEntryStateSchemaWithDefaults = z.object({
version: z.literal(1).default(1),
tab: z.enum(['signal', 'noise']).default('signal'),
+ facets: z.record(z.string(), z.array(z.string())).optional(),
});
type InboxEntryState = z.infer<typeof inboxEntryStateSchemaWithDefaults>;
@@ -45,10 +59,11 @@ export const DEFAULT_INBOX_LIST_STATE: InboxListStateSnapshot = {
scrollOffset: 0,
};
-function selectEntryState(_state: InboxViewState): InboxEntryState {
+function selectEntryState(state: InboxViewState): InboxEntryState {
return {
version: 1,
tab: 'signal',
+ facets: normalizeInboxFacets(state.facets),
};
}
@@ -59,12 +74,16 @@ function createInboxEntryStorage(options: {
return createEntryPersistenceStorage({
handle: options.handle,
key: INBOX_ENTRY_STATE_KEY,
- restore: (current, _stored) => {
+ restore: (current, stored) => {
if (!options.restore) return undefined;
-
+ const result = inboxEntryStateSchemaWithDefaults.safeParse(stored);
return {
...current,
tab: 'signal',
+ facets:
+ result.success && result.data.facets !== undefined
+ ? normalizeInboxFacets(result.data.facets)
+ : current.facets,
};
},
select: selectEntryState,
@@ -73,9 +92,41 @@ function createInboxEntryStorage(options: {
export type CreateInboxViewPersistenceOptions = {
handle: EntryPersistenceHandle;
+ userId: Accessor<string | undefined>;
restoreEntryState?: boolean;
+ restorePreferences?: boolean;
};
+function createHomeFilterStorage(options: {
+ userId: Accessor<string | undefined>;
+ restore: boolean;
+}): PersistenceStorage<InboxViewState> {
+ return {
+ restore: (current) => {
+ const userId = options.userId();
+ if (!options.restore || !userId) return undefined;
+ const raw = homeFilterStorage.read(userId);
+ if (raw === null) return undefined;
+ const result = inboxEntryStateSchemaWithDefaults.safeParse(
+ JSON.parse(raw)
+ );
+ if (!result.success || result.data.facets === undefined) return undefined;
+ return {
+ ...current,
+ facets: normalizeInboxFacets(result.data.facets),
+ };
+ },
+ write: (current) => {
+ const userId = options.userId();
+ if (userId)
+ homeFilterStorage.write(
+ userId,
+ JSON.stringify(selectEntryState(current))
+ );
+ },
+ };
+}
+
export function createInboxListEntryStorage(
handle: EntryPersistenceHandle
): PersistenceStorage<InboxListStateSnapshot> {
@@ -102,12 +153,16 @@ export function createInboxListEntryStorage(
});
}
-/** Persists Inbox navigation state with the owning split entry. */
+/** Shared persistence restores user filters, then the owning split entry. */
export function createInboxViewPersistence(
options: CreateInboxViewPersistenceOptions
): MakePersistedStateOptions<InboxViewState> {
return {
storages: [
+ createHomeFilterStorage({
+ userId: options.userId,
+ restore: options.restorePreferences ?? true,
+ }),
createInboxEntryStorage({
handle: options.handle,
restore: options.restoreEntryState ?? true,
diff --git a/apps/web/src/features/inbox-view/queries/home-date-buckets.test.ts b/apps/web/src/features/inbox-view/queries/home-date-buckets.test.ts
index e75eb95dbd..6829b1cb60 100644
--- a/apps/web/src/features/inbox-view/queries/home-date-buckets.test.ts
+++ b/apps/web/src/features/inbox-view/queries/home-date-buckets.test.ts
@@ -1,16 +1,18 @@
-import { describe, expect, it } from 'vitest';
-import { homeDateBucket } from './home-date-buckets';
+import { afterEach, describe, expect, it, vi } from 'vitest';
+import { homeClock, homeDateBucket } from './home-date-buckets';
const evening = new Date(2026, 8, 14, 20, 0);
const todayAt = (hour: number, minute = 0) =>
new Date(2026, 8, 14, hour, minute);
describe('Home time sections', () => {
- it('excludes future timestamps from the recent-time sections', () => {
+ afterEach(() => vi.useRealTimers());
+
+ it('keeps clock-skewed timestamps in the newest section', () => {
expect(homeDateBucket(new Date(evening.getTime() + 1), evening).key).toBe(
- 'this-evening'
+ 'last-few-minutes'
);
- expect(homeDateBucket(todayAt(21), evening).key).toBe('this-evening');
+ expect(homeDateBucket(todayAt(21), evening).key).toBe('last-few-minutes');
});
it('includes the current time in Last few minutes', () => {
expect(homeDateBucket(evening, evening).key).toBe('last-few-minutes');
@@ -31,10 +33,16 @@ describe('Home time sections', () => {
expect(homeDateBucket(item, todayAt(9, 15)).key).toBe('last-hour');
expect(homeDateBucket(item, todayAt(10)).key).toBe('this-morning');
});
- it('uses Yesterday across midnight, even if fewer than five minutes elapsed', () => {
+ it('keeps rolling sections across midnight before moving to Yesterday', () => {
expect(
homeDateBucket(todayAt(23, 59), new Date(2026, 8, 15, 0, 1)).key
- ).toBe('yesterday');
+ ).toBe('last-few-minutes');
+ expect(
+ homeDateBucket(todayAt(23, 59), new Date(2026, 8, 15, 0, 10)).key
+ ).toBe('last-hour');
+ expect(homeDateBucket(todayAt(23, 59), new Date(2026, 8, 15, 1)).key).toBe(
+ 'yesterday'
+ );
});
it('preserves older sections and handles absent or invalid timestamps', () => {
expect(homeDateBucket(new Date(2026, 8, 13, 10), evening).key).toBe(
@@ -45,5 +53,31 @@ describe('Home time sections', () => {
);
expect(homeDateBucket(undefined, evening).key).toBe('older');
expect(homeDateBucket('bad date', evening).key).toBe('older');
+ expect(homeDateBucket(null, evening).key).toBe('older');
+ expect(homeDateBucket(new Date(NaN), evening).key).toBe('older');
+ });
+
+ it('uses the same clock after a refresh within the same minute', () => {
+ vi.useFakeTimers();
+ vi.setSystemTime(new Date(2026, 8, 14, 20, 0, 1));
+ const before = homeClock();
+ vi.setSystemTime(new Date(2026, 8, 14, 20, 0, 59));
+ expect(homeClock()).toBe(before);
+ vi.setSystemTime(new Date(2026, 8, 14, 20, 1));
+ expect(homeClock()).toBe(before + 60_000);
+ });
+
+ it('keeps calendar sections stable at month and year boundaries', () => {
+ const reference = new Date(2027, 0, 2, 12);
+ expect(homeDateBucket(new Date(2027, 0, 1, 10), reference).key).toBe(
+ 'yesterday'
+ );
+ expect(homeDateBucket(new Date(2026, 11, 31, 10), reference).key).toBe(
+ 'last-7-days'
+ );
+ expect(homeDateBucket(new Date(2026, 11, 1), reference).key).toBe(
+ 'last-month'
+ );
+ expect(homeDateBucket(new Date(2026, 10, 30), reference).key).toBe('older');
});
});
diff --git a/apps/web/src/features/inbox-view/queries/home-date-buckets.ts b/apps/web/src/features/inbox-view/queries/home-date-buckets.ts
index 590cf64714..f1f1089707 100644
--- a/apps/web/src/features/inbox-view/queries/home-date-buckets.ts
+++ b/apps/web/src/features/inbox-view/queries/home-date-buckets.ts
@@ -1,22 +1,52 @@
-import {
- type DateBucket,
- dateBucket,
-} from '@app/features/soup/collection/date-buckets';
+import { dateBucket } from '@app/features/soup/collection/date-buckets';
-/** Fine-grained local-time sections for the live Home feed. */
-export function homeDateBucket(value: unknown, now = new Date()): DateBucket {
- const day = dateBucket(value, now);
+/** Section order is independent of which source/page supplied the first row. */
+const HOME_DATE_BUCKETS = [
+ { key: 'last-few-minutes', label: 'Last few minutes' },
+ { key: 'last-hour', label: 'Last hour' },
+ { key: 'this-evening', label: 'This evening' },
+ { key: 'this-afternoon', label: 'This afternoon' },
+ { key: 'this-morning', label: 'This morning' },
+ { key: 'earlier-today', label: 'Earlier today' },
+ { key: 'yesterday', label: 'Yesterday' },
+ { key: 'last-7-days', label: 'Last 7 days' },
+ { key: 'earlier-this-month', label: 'Earlier this month' },
+ { key: 'last-month', label: 'Last month' },
+ { key: 'older', label: 'Older' },
+] as const;
+
+export function homeTimestamp(value: unknown): number | undefined {
+ const timestamp =
+ value instanceof Date
+ ? value.getTime()
+ : typeof value === 'string' || typeof value === 'number'
+ ? new Date(value).getTime()
+ : NaN;
+ return Number.isFinite(timestamp) ? timestamp : undefined;
+}
+
+/** Quantize the reference clock so a reload within a minute keeps its sections. */
+export const homeClock = () => Math.floor(Date.now() / 60_000) * 60_000;
+
+export const homeDateBucketRank = (key: string): number =>
+ HOME_DATE_BUCKETS.findIndex((bucket) => bucket.key === key);
+
+/** Rolling intervals precede calendar sections, including across midnight.
+ * Future timestamps (clock skew) belong to the newest section, never an older
+ * time of day. Invalid timestamps always sort into the final section. */
+export function homeDateBucket(value: unknown, now = new Date()) {
+ const timestamp = homeTimestamp(value);
+ if (timestamp === undefined) return HOME_DATE_BUCKETS[10];
+ const age = Math.max(0, now.getTime() - timestamp);
+ if (age < 5 * 60_000) return HOME_DATE_BUCKETS[0];
+ if (age < 60 * 60_000) return HOME_DATE_BUCKETS[1];
+
+ const date = new Date(timestamp);
+ const day = dateBucket(date, now);
if (day.key !== 'today') return day;
- const date =
- value instanceof Date ? value : new Date(value as string | number);
- const minutesAgo = (now.getTime() - date.getTime()) / 60_000;
- if (minutesAgo >= 0 && minutesAgo < 5)
- return { key: 'last-few-minutes', label: 'Last few minutes' };
- if (minutesAgo >= 0 && minutesAgo < 60)
- return { key: 'last-hour', label: 'Last hour' };
const hour = date.getHours();
- if (hour >= 18) return { key: 'this-evening', label: 'This evening' };
- if (hour >= 12) return { key: 'this-afternoon', label: 'This afternoon' };
- if (hour >= 6) return { key: 'this-morning', label: 'This morning' };
- return { key: 'earlier-today', label: 'Earlier today' };
+ if (hour >= 18) return HOME_DATE_BUCKETS[2];
+ if (hour >= 12) return HOME_DATE_BUCKETS[3];
+ if (hour >= 6) return HOME_DATE_BUCKETS[4];
+ return HOME_DATE_BUCKETS[5];
}
diff --git a/apps/web/src/features/inbox-view/queries/inbox-results.test.ts b/apps/web/src/features/inbox-view/queries/inbox-results.test.ts
index e2305976fa..9474d5bf81 100644
--- a/apps/web/src/features/inbox-view/queries/inbox-results.test.ts
+++ b/apps/web/src/features/inbox-view/queries/inbox-results.test.ts
@@ -4,6 +4,7 @@ import { describe, expect, it, vi } from 'vitest';
import { getHomePagination } from './home-pagination';
import { buildInboxQuery } from './inbox-query';
import {
+ groupHomeEntitiesByDate,
groupInboxEntitiesByDate,
inboxGroupTimestamp,
mergeHomeEntities,
@@ -324,6 +325,58 @@ describe('Home activity and notifications', () => {
'b',
]);
});
+
+ it('sorts sections and rows independently of arrival order, including clock skew and invalid dates', () => {
+ const reference = new Date(2026, 8, 14, 10);
+ const row = (id: string, sortTs: Date | string | undefined) => ({
+ ...staleTaskFreshComment,
+ id,
+ sortTs,
+ });
+ const entities = [
+ row('morning', new Date(2026, 8, 14, 8)),
+ row('invalid', 'bad date'),
+ row('hour-b', new Date(2026, 8, 14, 9, 30)),
+ row('skew', new Date(2026, 8, 14, 10, 0, 1)),
+ row('hour-a', new Date(2026, 8, 14, 9, 30)),
+ row('recent', new Date(2026, 8, 14, 9, 59)),
+ row('yesterday', new Date(2026, 8, 13, 20)),
+ row('missing', undefined),
+ ];
+ const expected = [
+ ['last-few-minutes', ['skew', 'recent']],
+ ['last-hour', ['hour-a', 'hour-b']],
+ ['this-morning', ['morning']],
+ ['yesterday', ['yesterday']],
+ ['older', ['invalid', 'missing']],
+ ];
+ for (let offset = 0; offset < entities.length; offset++) {
+ const shuffled = [
+ ...entities.slice(offset),
+ ...entities.slice(0, offset),
+ ];
+ expect(
+ groupHomeEntitiesByDate(shuffled, reference).map((group) => [
+ group.id,
+ group.entities.map((entity) => entity.id),
+ ])
+ ).toEqual(expected);
+ }
+ expect(entities[0].id).toBe('morning');
+ });
+
+ it('does not let an invalid duplicate timestamp discard valid sort evidence', () => {
+ const valid = recent('task', '2026-09-02T18:00:00Z');
+ const invalid = { ...staleTaskFreshComment, notifiedAt: 'bad date' };
+ for (const notifications of [
+ [invalid, staleTaskFreshComment],
+ [staleTaskFreshComment, invalid],
+ ]) {
+ const [row] = mergeHomeEntities(notifications, [valid], signal);
+ expect(row.sortTs).toBe(valid.touchedAt);
+ expect(row.notifiedAt).toBe(staleTaskFreshComment.notifiedAt);
+ }
+ });
});
describe('Home pagination', () => {
diff --git a/apps/web/src/features/inbox-view/queries/inbox-results.ts b/apps/web/src/features/inbox-view/queries/inbox-results.ts
index 8df1465524..90c0886b5b 100644
--- a/apps/web/src/features/inbox-view/queries/inbox-results.ts
+++ b/apps/web/src/features/inbox-view/queries/inbox-results.ts
@@ -5,9 +5,13 @@ import {
} from '@app/features/soup/collection/transforms';
import type { SoupGroup } from '@app/features/soup/collection/types';
import type { EntityWithRawNotifications } from '@app/features/soup/entity-notifications';
-import { compareDateDesc, type DateValue } from '@core/util/date';
+import type { DateValue } from '@core/util/date';
import type { EntityData } from '@entity';
-import { homeDateBucket } from './home-date-buckets';
+import {
+ homeDateBucket,
+ homeDateBucketRank,
+ homeTimestamp,
+} from './home-date-buckets';
import {
type InboxViewContext,
inboxTabOrdersByNotification,
@@ -46,10 +50,24 @@ export function groupInboxEntitiesByDate<T extends EntityData>(
});
}
+const compareHomeDates = (first: unknown, second: unknown) => {
+ const a = homeTimestamp(first) ?? -Infinity;
+ const b = homeTimestamp(second) ?? -Infinity;
+ return a === b ? 0 : a > b ? -1 : 1;
+};
+
+const compareIdentity = (a: string, b: string) =>
+ a === b ? 0 : a < b ? -1 : 1;
+
+const compareHomeEntities = (a: EntityData, b: EntityData) =>
+ compareHomeDates(a.sortTs, b.sortTs) ||
+ compareIdentity(a.type, b.type) ||
+ compareIdentity(a.id, b.id);
+
const latestTimestamp = (
first: DateValue | null | undefined,
second: DateValue | null | undefined
-) => (compareDateDesc(first, second) <= 0 ? first : second);
+) => (compareHomeDates(first, second) <= 0 ? first : second);
/** Content freshness and Home ordering are independent: keep the newest
* payload, both source stamps, and the notification source's metadata. */
@@ -66,7 +84,7 @@ export function mergeHomeEntities(
})),
// Cache inserts from other users are not the viewer's own activity.
...recents
- .filter((entity) => entity.touchedAt)
+ .filter((entity) => homeTimestamp(entity.touchedAt) !== undefined)
.map((entity) => ({
...entity,
sortTs: entity.touchedAt,
@@ -75,7 +93,7 @@ export function mergeHomeEntities(
{
getKey: (entity) => `${entity.type}:${entity.id}`,
resolveConflict: (existing, incoming) => ({
- ...(compareDateDesc(
+ ...(compareHomeDates(
incoming.updatedAt ?? incoming.createdAt,
existing.updatedAt ?? existing.createdAt
) < 0
@@ -87,12 +105,7 @@ export function mergeHomeEntities(
sortTs: latestTimestamp(existing.sortTs, incoming.sortTs),
}),
}
- ).sort(
- (a, b) =>
- compareDateDesc(a.sortTs, b.sortTs) ||
- a.type.localeCompare(b.type) ||
- a.id.localeCompare(b.id)
- );
+ ).sort(compareHomeEntities);
}
/** Home uses its merged timestamp and finer intraday sections. */
@@ -100,9 +113,11 @@ export function groupHomeEntitiesByDate<T extends EntityData>(
entities: T[],
now: Date
): SoupGroup<T>[] {
- return groupSoupEntities(entities, {
+ return groupSoupEntities([...entities].sort(compareHomeEntities), {
getGroupId: (entity) => homeDateBucket(entity.sortTs, now).key,
getGroupLabel: (_groupId, firstEntity) =>
homeDateBucket(firstEntity.sortTs, now).label,
+ compareGroups: (a, b) =>
+ homeDateBucketRank(a.id) - homeDateBucketRank(b.id),
});
}
diff --git a/apps/web/src/features/inbox-view/queries/inbox-search.ts b/apps/web/src/features/inbox-view/queries/inbox-search.ts
index 63e0c3ffa4..25fb8f5ddf 100644
--- a/apps/web/src/features/inbox-view/queries/inbox-search.ts
+++ b/apps/web/src/features/inbox-view/queries/inbox-search.ts
@@ -17,6 +17,7 @@ const tabTypes: Record<InboxTab, ReadonlySet<InboxTypeFilter>> = {
'tasks',
'email',
'channels',
+ 'chats',
'agents',
'projects',
'github',
@@ -89,6 +90,7 @@ export function buildInboxSearchRequest(
filtersIncompleteEntities || notification !== undefined;
const filters: EntityFilters = {
+ agent_session_filters: { ids: [NIL_UUID] },
calendar_event_filters: { calendar_event_ids: [NIL_UUID] },
call_filters: { call_ids: [NIL_UUID] },
channel_filters: { channel_ids: [NIL_UUID] },
@@ -106,6 +108,10 @@ export function buildInboxSearchRequest(
filters.calendar_event_filters = {};
}
+ if (types.has('agents')) {
+ filters.agent_session_filters = { include: true };
+ }
+
if (types.has('channels')) {
const channelFilters: NonNullable<EntityFilters['channel_filters']> = {};
@@ -126,7 +132,7 @@ export function buildInboxSearchRequest(
};
}
- if (types.has('agents')) {
+ if (types.has('chats')) {
const chatFilters: NonNullable<EntityFilters['chat_filters']> = {};
if (hasNotificationFilter) {
diff --git a/apps/web/src/features/inbox-view/queries/use-inbox-query.test.ts b/apps/web/src/features/inbox-view/queries/use-inbox-query.test.ts
index bf80e0979e..51c781dcdb 100644
--- a/apps/web/src/features/inbox-view/queries/use-inbox-query.test.ts
+++ b/apps/web/src/features/inbox-view/queries/use-inbox-query.test.ts
@@ -268,4 +268,95 @@ describe('Home data source', () => {
expect(notifications.fetchNextPage).toHaveBeenCalledOnce();
expect(activity.fetchNextPage).not.toHaveBeenCalled();
});
+
+ it('applies type visibility to both sources and hides channels together with replies', () => {
+ const channel: EntityData = {
+ type: 'channel',
+ id: 'channel',
+ name: 'Channel',
+ ownerId: 'alice',
+ channelType: 'public',
+ touchedAt: new Date(2026, 8, 9),
+ };
+ const thread: EntityData = {
+ type: 'channel_thread',
+ id: 'reply',
+ name: 'Reply',
+ ownerId: 'alice',
+ channelId: channel.id,
+ messageId: 'root',
+ threadId: 'root',
+ senderId: 'alice',
+ sender: { id: 'alice', type: 'user' },
+ content: '',
+ attachments: [],
+ reactions: [],
+ thread: { replyCount: 1, preview: [] },
+ touchedAt: new Date(2026, 8, 8),
+ };
+ const notifications = makeQuery([email('received', 9)], false);
+ const activity = makeQuery([email('sent', 10), channel, thread], false);
+ const { source, setState } = mount(notifications, activity);
+ expect(ids(source)).toEqual(['sent', 'channel', 'received', 'reply']);
+ setState('facets', { type: ['channels'] });
+ expect(ids(source)).toEqual(['channel', 'reply']);
+ setState('facets', { type: ['email'] });
+ expect(ids(source)).toEqual(['sent', 'received']);
+ setState('facets', { type: ['none'] });
+ expect(ids(source)).toEqual([]);
+ });
+
+ it('selects read and unread rows consistently across notification and activity sources', () => {
+ const notifications = makeQuery([email('unread', 9)], false);
+ const activity = makeQuery([{ ...email('read', 10), isRead: true }], false);
+ const { source, setState } = mount(notifications, activity);
+ setState('facets', { read: ['read'] });
+ expect(ids(source)).toEqual(['read']);
+ setState('facets', { read: ['unread'] });
+ expect(ids(source)).toEqual(['unread']);
+ setState('facets', { read: [] });
+ expect(ids(source)).toEqual(['read', 'unread']);
+ });
+
+ it('does not drain paginated history when every entity type is hidden', async () => {
+ const notifications = makeQuery([email('notification', 9)]);
+ const activity = makeQuery([email('activity', 10)]);
+ const { source, setState } = mount(notifications, activity);
+ setState('facets', { type: ['none'] });
+ expect(ids(source)).toEqual([]);
+ expect(source.hasMore()).toBe(false);
+ expect(source.isLoading()).toBe(false);
+ await source.loadMore();
+ expect(notifications.fetchNextPage).not.toHaveBeenCalled();
+ expect(activity.fetchNextPage).not.toHaveBeenCalled();
+ });
+
+ it('can select chats and agent sessions independently', () => {
+ const activity = makeQuery(
+ [
+ {
+ type: 'chat',
+ id: 'chat',
+ name: 'Chat',
+ ownerId: 'alice',
+ touchedAt: new Date(2026, 8, 9),
+ },
+ {
+ type: 'agent_session',
+ id: 'agent',
+ name: 'Agent',
+ ownerId: 'alice',
+ botId: 'bot',
+ status: 'idle',
+ touchedAt: new Date(2026, 8, 10),
+ },
+ ],
+ false
+ );
+ const { source, setState } = mount(makeQuery([], false), activity);
+ setState('facets', { type: ['chats'] });
+ expect(ids(source)).toEqual(['chat']);
+ setState('facets', { type: ['agents'] });
+ expect(ids(source)).toEqual(['agent']);
+ });
});
diff --git a/apps/web/src/features/inbox-view/queries/use-inbox-query.ts b/apps/web/src/features/inbox-view/queries/use-inbox-query.ts
index dd64e621b9..80511c9f43 100644
--- a/apps/web/src/features/inbox-view/queries/use-inbox-query.ts
+++ b/apps/web/src/features/inbox-view/queries/use-inbox-query.ts
@@ -39,6 +39,7 @@ import {
import { scheduledRemindersFilter } from '../../next-soup/filters/predicates';
import { INBOX_FACETS, type InboxFacetContext } from '../inbox-facets';
import type { InboxTab, InboxViewState } from '../types';
+import { homeClock, homeTimestamp } from './home-date-buckets';
import { getHomePagination } from './home-pagination';
import { soupItemMatchesInboxTab } from './inbox-item-filter';
import {
@@ -192,9 +193,9 @@ export function useInboxDataSource(
transformEntities,
} = useInboxEntitiesQuery(state);
- const [now, setNow] = createSignal(new Date());
+ const [now, setNow] = createSignal(homeClock());
onMount(() => {
- const timer = setInterval(() => setNow(new Date()), 30_000);
+ const timer = setInterval(() => setNow(homeClock()), 30_000);
onCleanup(() => clearInterval(timer));
});
@@ -295,11 +296,13 @@ export function useInboxDataSource(
const transformed = transformHomeEntities(
rawEntities(),
search.isSearching() ? rawEntities() : recentEntities()
- ).filter(
- (entity) =>
- new Date(entity.sortTs ?? 0).getTime() >
- (homePagination()?.cutoff ?? -Infinity)
- );
+ ).filter((entity) => {
+ const cutoff = homePagination()?.cutoff ?? -Infinity;
+ return (
+ cutoff === -Infinity ||
+ (homeTimestamp(entity.sortTs) ?? -Infinity) > cutoff
+ );
+ });
const activeReadFacets = context.facets.read ?? [];
const readScope = `${context.tab}:${activeReadFacets.join(',')}`;
const admittedIds =
@@ -340,8 +343,11 @@ export function useInboxDataSource(
);
const usesServiceSearch = search.usesServiceSearch;
+ const hasNoTypes = () =>
+ state.facets.type?.length === 1 && state.facets.type[0] === 'none';
const hasMore = () => {
+ if (hasNoTypes()) return false;
if (usesServiceSearch()) return search.hasNextPage();
return (
(query.hasNextPage && !query.error) ||
@@ -362,7 +368,7 @@ export function useInboxDataSource(
if (state.groupBy === 'date' && !search.isSearching()) {
result = buildGroupedSoupRows(
state.tab === 'signal'
- ? groupHomeEntitiesByDate(entities().items, now())
+ ? groupHomeEntitiesByDate(entities().items, new Date(now()))
: groupInboxEntitiesByDate(entities().items, viewContext())
);
} else {
@@ -373,6 +379,7 @@ export function useInboxDataSource(
});
const isLoading = () => {
+ if (hasNoTypes()) return false;
if (!search.isSearching()) {
return (
(query.isLoading ||
@@ -396,6 +403,7 @@ export function useInboxDataSource(
(state.tab === 'signal' && recentQuery.isFetching);
},
error: () => {
+ if (hasNoTypes()) return undefined;
if (!usesServiceSearch())
return entities().items.length === 0 && !hasMore()
? (query.error ??
@@ -415,6 +423,7 @@ export function useInboxDataSource(
hasMore,
isLoadingMore,
loadMore: async () => {
+ if (hasNoTypes()) return;
if (usesServiceSearch()) {
await search.fetchNextPage();
return;
diff --git a/apps/web/src/features/inbox-view/types.ts b/apps/web/src/features/inbox-view/types.ts
index 2f4f86ff72..88ff7deba6 100644
--- a/apps/web/src/features/inbox-view/types.ts
+++ b/apps/web/src/features/inbox-view/types.ts
@@ -18,6 +18,7 @@ export type InboxTypeFilter =
| 'tasks'
| 'email'
| 'channels'
+ | 'chats'
| 'agents'
| 'projects'
| 'github'
diff --git a/docs/AGENT_GUIDE/surfaces.md b/docs/AGENT_GUIDE/surfaces.md
index 2653d3a274..31a37e0165 100644
--- a/docs/AGENT_GUIDE/surfaces.md
+++ b/docs/AGENT_GUIDE/surfaces.md
@@ -61,18 +61,27 @@ it does not imply deletion. Only explicit `GraphqlCacheDeletion` events remove r
## Home — `/app/component/inbox`
-With the new app views enabled, Home defaults to an unfiltered Signal feed merging
+With the new app views enabled, Home defaults to a Signal feed merging
notifications with Activity's `touched_by_me` recents, including sent emails and
AI chats. Each entity appears once, ordered by its latest notification or own
-action. On desktop, there are no Signal/Noise tabs or filter menu. A **Home** heading
+action. On desktop, the funnel button to the right of **Home** opens **Filter Home**.
+The first menu row is an **Unread only** toggle: on shows unread items; off shows
+all items. Entity type checkboxes start checked. Unchecking **Email** hides received
+and sent mail. **Channels** controls
+both channels and reply threads; **Chats** and **Agents** have separate toggles.
+Unchecking every type shows an empty feed. **Reset filters** shows every type and
+both read states again. A badge counts hidden types plus an active status filter.
+Older saved read-only selections restore as All. The mobile drawer uses the same toggle.
+There are no desktop Signal/Noise tabs. A **Home** heading
labels the top left of the block, matching the **Email**, **Tasks**, **Chat**, and
**Agents** sidebar headings. The full-width **New chat** plus pill below the heading clears the preview and returns to the Home
starting pane; it does not create a chat. Email and Tasks have matching top pills
for **New email** and **New task**.
The Inbox provider honors an explicit initial tab, search, grouping, and facet
-selection. Returning through split history still resets the view to the unfiltered
-Signal defaults.
+selection. Filters persist per user across reloads and fresh Home navigation;
+split history restores that entry's filter selection. An explicit facet selection
+overrides saved filters. Returning through split history resets navigation to Signal.
Channel thread replies remain separate Home entries from their parent channel,
using single-line rows and a reply arrow icon on desktop and touch devices, labeled
@@ -128,8 +137,13 @@ draft. Mobile composer styling and send behavior are unchanged.
Sections are Last few minutes (under five minutes), Last hour, This evening
(6pm onward), This afternoon (noon–6pm), This morning (6am–noon), Earlier today,
-Yesterday, and the existing older-date groups. These use local time and refresh
-every 30 seconds without a new action. Scrolling near the bottom automatically
+Yesterday, and the existing older-date groups. Sections always follow this order,
+with newest rows first and entity identity breaking equal-timestamp ties.
+The reference clock uses whole minutes, so refreshing within the same minute
+preserves grouping. Rolling five-minute/hour windows continue across midnight;
+future timestamps caused by clock skew stay in the newest section, and invalid
+dates go last. Calendar sections use local time. The clock is checked every 30
+seconds without a new action. Scrolling near the bottom automatically
loads older items. Home buffers older rows until both notification and own-activity
pages have loaded through their timestamp, then advances the shallower feed first.
Fetched rows still advance this boundary when display filters hide them;