Skip to content

armgit / macro

Public Imported from GitHub
0

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

fix(inbox): ui and filter improvements (#4465)

dev-rbb7cb53b04a6b
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
index b448b1f5c6..8e014e3586 100644
--- a/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts
+++ b/js/app/packages/app/component/app-sidebar/soup-filter-presets.ts
@@ -84,6 +84,7 @@ const getInboxSignalFilters = () => {
emailImportance: true,
emailUpdatedAt: { gte: twoWeeksAgo },
channelDone: false,
+ channelThreadDone: false,
chatDone: false,
chatUpdatedAt: { gte: twoWeeksAgo },
folderDone: false,
@@ -110,6 +111,7 @@ const getInboxNoiseFilters = () =>
emailDone: false,
emailImportance: false,
channelDone: false,
+ channelThreadDone: false,
chatDone: false,
folderDone: false,
emailShared: 'exclude',
@@ -125,10 +127,12 @@ export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {
signal: () => ({
filters: getInboxSignalFilters(),
clientFilters: { and: ['inbox'] },
+ groupBy: 'date',
}),
noise: () => ({
filters: getInboxNoiseFilters(),
clientFilters: { and: ['noise'] },
+ groupBy: 'date',
}),
all: () => ({
filters: {
@@ -153,6 +157,7 @@ export const VIEW_TAB_PRESETS: Record<ListView, ViewTabConfig> = {
emailView: 'all',
},
clientFilters: { and: ['explicit-noise'] },
+ groupBy: 'date',
}),
},
},
diff --git a/js/app/packages/app/component/next-soup/filters/configs/general.ts b/js/app/packages/app/component/next-soup/filters/configs/general.ts
index 7fc1bdb7ee..46d3a4320a 100644
--- a/js/app/packages/app/component/next-soup/filters/configs/general.ts
+++ b/js/app/packages/app/component/next-soup/filters/configs/general.ts
@@ -24,6 +24,7 @@ export const inboxFilter = config({
emailDone: false,
emailImportance: true,
channelDone: false,
+ channelThreadDone: false,
chatDone: false,
folderDone: false,
foreignEntitySource: ['github_pull_request'],
@@ -43,6 +44,7 @@ export const noiseFilterDef = config({
emailDone: false,
emailImportance: false,
channelDone: false,
+ channelThreadDone: false,
chatDone: false,
folderDone: false,
},
@@ -75,6 +77,7 @@ export const unreadFilter = config({
documentSeen: false,
emailSeen: false,
channelSeen: false,
+ channelThreadSeen: false,
chatSeen: false,
folderSeen: false,
},
@@ -92,6 +95,7 @@ export const readFilter = config({
documentSeen: true,
emailSeen: true,
channelSeen: true,
+ channelThreadSeen: true,
chatSeen: true,
folderSeen: true,
},
@@ -109,6 +113,7 @@ export const notDoneFilter = config({
documentDone: false,
emailDone: false,
channelDone: false,
+ channelThreadDone: false,
chatDone: false,
folderDone: false,
},
@@ -126,6 +131,7 @@ export const doneFilter = config({
documentDone: true,
emailDone: true,
channelDone: true,
+ channelThreadDone: true,
chatDone: true,
folderDone: true,
},
diff --git a/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts b/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts
index 1f708668f5..18d08fbd43 100644
--- a/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts
+++ b/js/app/packages/app/component/next-soup/filters/filter-store/compile.ts
@@ -110,6 +110,9 @@ const FIELD_CONFIG: Record<
channelMessageThreadId: { target: 'chanf', field: 'ThreadId' },
channelThreadId: { target: 'cthf', field: 'ThreadId' },
channelThreadRootSenderId: { target: 'cthf', field: 'RootSender' },
+ channelThreadParticipantId: { target: 'cthf', field: 'Participant' },
+ channelThreadSeen: { target: 'cthf', field: 'NotificationSeen' },
+ channelThreadDone: { target: 'cthf', field: 'NotificationDone' },
chatId: { target: 'cf', field: 'cid' },
chatOwnerId: { target: 'cf', field: 'o' },
chatProjectId: { target: 'cf', field: 'pid' },
diff --git a/js/app/packages/app/component/next-soup/filters/filter-store/types.ts b/js/app/packages/app/component/next-soup/filters/filter-store/types.ts
index ea7f51f640..9191d0ac01 100644
--- a/js/app/packages/app/component/next-soup/filters/filter-store/types.ts
+++ b/js/app/packages/app/component/next-soup/filters/filter-store/types.ts
@@ -40,6 +40,7 @@ export type ArrayFieldFilters = {
channelMessageThreadId?: string[];
channelThreadId?: string[];
channelThreadRootSenderId?: string[];
+ channelThreadParticipantId?: string[];
chatId?: string[];
chatOwnerId?: string[];
chatProjectId?: string[];
@@ -71,6 +72,8 @@ export type ScalarFieldFilters = {
channelSeen?: boolean;
channelDone?: boolean;
channelImportance?: boolean;
+ channelThreadSeen?: boolean;
+ channelThreadDone?: boolean;
chatSeen?: boolean;
chatDone?: boolean;
folderSeen?: boolean;
diff --git a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts b/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts
index 41b200d47a..b094835215 100644
--- a/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/create-search-state.ts
@@ -119,11 +119,13 @@ function filterDataToQueryFilters(data: QueryState): EntityFilters {
// Channel thread filters
if (
include.channelThreadId?.length ||
- include.channelThreadRootSenderId?.length
+ include.channelThreadRootSenderId?.length ||
+ include.channelThreadParticipantId?.length
) {
filters.channel_thread_filters = {
thread_ids: include.channelThreadId,
root_sender_ids: include.channelThreadRootSenderId,
+ participant_ids: include.channelThreadParticipantId,
};
}
diff --git a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx
index 05617fdeae..93ae752255 100644
--- a/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/filters-bar/soup-filters-bar.tsx
@@ -39,10 +39,25 @@ export function SoupFiltersBar() {
soup.setPreviewEntity(undefined);
return;
}
- const focused = soup.focus.id();
+
+ let focused = soup.focus.id();
+
if (!focused) {
- return;
+ const allRows = soup.rows();
+
+ const firstEntityIndex = allRows.findIndex(
+ (row) => !row.getIsGrouped() && !row.getIsLoadMore()
+ );
+
+ if (firstEntityIndex === -1) return;
+
+ const result = soup.navigate.toIndex(firstEntityIndex);
+
+ if (!result) return;
+
+ focused = result.row.id;
}
+
analytics.track('preview_panel_use');
soup.setPreviewEntity(focused);
};
diff --git a/js/app/packages/app/component/next-soup/soup-view/group-by-date.ts b/js/app/packages/app/component/next-soup/soup-view/group-by-date.ts
new file mode 100644
index 0000000000..721a60663a
--- /dev/null
+++ b/js/app/packages/app/component/next-soup/soup-view/group-by-date.ts
@@ -0,0 +1,27 @@
+import { format, isSameWeek, isSameYear, isToday, isYesterday } from 'date-fns';
+
+export type DateBucket = { key: string; label: string };
+
+/**
+ * Bucket a timestamp into a relative section: Today, Yesterday, This week, then
+ * by month within the current year, and by year for anything older. The `key`
+ * is stable/collapsible; the `label` is the section header text.
+ *
+ * Generic and client-side — used to group soup rows by date without relying on
+ * backend grouping.
+ */
+export function dateBucket(value: unknown, now = new Date()): DateBucket {
+ const date =
+ value == null ? undefined : new Date(value as string | number | Date);
+
+ if (!date || Number.isNaN(date.getTime())) {
+ return { key: 'unknown', label: 'Earlier' };
+ }
+ if (isToday(date)) return { key: 'today', label: 'Today' };
+ if (isYesterday(date)) return { key: 'yesterday', label: 'Yesterday' };
+ if (isSameWeek(date, now)) return { key: 'this-week', label: 'This week' };
+ if (isSameYear(date, now)) {
+ return { key: format(date, 'yyyy-MM'), label: format(date, 'MMMM') };
+ }
+ return { key: format(date, 'yyyy'), label: format(date, 'yyyy') };
+}
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 7f98229d80..99dfc3493e 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
@@ -20,6 +20,7 @@ import {
} from '@app/component/next-soup/filters/filter-store/query-store';
import { createGroupedSoupQueries } from '@app/component/next-soup/soup-view/create-grouped-soup-queries';
import { createSearchState } from '@app/component/next-soup/soup-view/create-search-state';
+import { dateBucket } from '@app/component/next-soup/soup-view/group-by-date';
import {
INBOX_FILTER_ENTRY_KEY,
registerInboxFilterSplit,
@@ -50,10 +51,7 @@ import {
isWithNotification,
toNotificationEntity,
} from '@entity';
-import {
- useEntityTypeNotifications,
- useNotificationsForEntity,
-} from '@notifications';
+import { useNotificationsForEntity } from '@notifications';
import { useQueryClient } from '@queries/client';
import type {
GroupMeta as ApiGroupMeta,
@@ -301,10 +299,17 @@ export const SoupViewContextProvider: FlowComponent<
{ default: 'unread' }
);
+ // Date grouping is done client-side (see the date branch in `rows()`): the
+ // backend date grouping is unreliable, and we'd rather keep paginating the
+ // single flat list and regenerate buckets from whatever's loaded.
+ const isClientDateGroup = createMemo(
+ () => soup.grouping.activeGroupId() === 'date'
+ );
+
const groupByField = createMemo((): GroupByField | undefined => {
const id = soup.grouping.activeGroupId();
if (!id) return undefined;
- if (id === 'date') return { type: 'date' };
+ if (id === 'date') return undefined;
if (id === 'entity_type') return { type: 'entity_type' };
if (id === 'project') return { type: 'project' };
if (id.startsWith('property:')) {
@@ -324,6 +329,7 @@ export const SoupViewContextProvider: FlowComponent<
});
const notificationSource = useGlobalNotificationSource();
+ const userId = useUserId();
const activeListView = createMemo<ListView | undefined>(() => {
const content = panel.handle.content();
@@ -331,30 +337,13 @@ export const SoupViewContextProvider: FlowComponent<
return isListViewID(content.id) ? content.id : undefined;
});
- // The new inbox surfaces channel threads the user was mentioned in or replied
- // to (matching the experimental inbox), injected as `channelThreadId`
- // includes — soup otherwise only surfaces whole channels.
+ // The new inbox surfaces channel threads the current user participates in —
+ // the root sender, anyone who replied, or anyone @-mentioned — via the
+ // `channelThreadParticipantId` filter, since soup otherwise only surfaces
+ // whole channels.
const newInboxFlag = useFeatureFlag(ENABLE_NEW_INBOX_FLAG, {
enabledOverride: ENABLE_NEW_INBOX_OVERRIDE,
});
- const channelNotifications = useEntityTypeNotifications(
- notificationSource,
- 'channel'
- );
- const mentionedMessages = createMemo(() =>
- channelNotifications()
- .map((notification) => {
- const metadata = notification.notification_metadata;
- if (metadata.tag === 'channel_mention') {
- return metadata.content.threadId ?? metadata.content.messageId;
- }
- if (metadata.tag === 'channel_message_reply') {
- return metadata.content.threadId;
- }
- return undefined;
- })
- .filter((id): id is string => Boolean(id))
- );
const isNewInbox = () =>
activeListView() === 'inbox' && newInboxFlag().enabled;
@@ -372,13 +361,13 @@ export const SoupViewContextProvider: FlowComponent<
const applyInboxThreadFilter = (state: QueryState): QueryState => {
if (!isNewInbox()) return state;
- const threadIds = mentionedMessages();
- if (!threadIds.length) return state;
+ const id = userId();
+ if (!id) return state;
return {
...state,
include: {
...state.include,
- channelThreadId: threadIds,
+ channelThreadParticipantId: [id],
},
};
};
@@ -397,6 +386,7 @@ export const SoupViewContextProvider: FlowComponent<
documentSeen: seen,
emailSeen: seen,
channelSeen: seen,
+ channelThreadSeen: seen,
chatSeen: seen,
folderSeen: seen,
},
@@ -453,7 +443,6 @@ export const SoupViewContextProvider: FlowComponent<
});
};
- const userId = useUserId();
const showSupportedForeignEntitiesFF = useFeatureFlag(
ENABLE_SUPPORTED_SOUP_FOREIGN_ENTITIES_FLAG,
{
@@ -660,6 +649,66 @@ export const SoupViewContextProvider: FlowComponent<
const field = groupByField();
const groups = itemsQuery.data?.groups;
+ // Client-side date grouping: reuse the single flat (paginated) list and
+ // regenerate date buckets from whatever's loaded — no per-group fetching.
+ if (enabled() && isClientDateGroup() && !search.isSearching()) {
+ const all = entities();
+ const buckets = new Map<
+ string,
+ { label: string; entities: SoupEntity[] }
+ >();
+ const order: string[] = [];
+ const now = new Date();
+
+ for (const entity of all) {
+ const ts = entity.sortTs ?? entity.updatedAt ?? entity.createdAt;
+ const bucket = dateBucket(ts, now);
+ let group = buckets.get(bucket.key);
+
+ if (!group) {
+ group = { label: bucket.label, entities: [] };
+ buckets.set(bucket.key, group);
+ order.push(bucket.key);
+ }
+
+ group.entities.push(entity);
+ }
+
+ const dateRows: SoupRow[] = [];
+ let index = 0;
+ for (const key of order) {
+ const group = buckets.get(key)!;
+ const groupMeta: GroupMeta = {
+ key,
+ value: key,
+ label: group.label,
+ count: group.entities.length,
+ isExpanded: () => soup.grouping.isExpanded(key),
+ toggle: () => soup.grouping.toggle(key),
+ };
+ dateRows.push(
+ soup.buildRow({
+ id: `header:${key}`,
+ index: index++,
+ original: group.entities[0],
+ group: groupMeta,
+ isGrouped: true,
+ })
+ );
+ for (const entity of group.entities) {
+ dateRows.push(
+ soup.buildRow({
+ id: entity.id,
+ index: index++,
+ original: entity,
+ group: groupMeta,
+ })
+ );
+ }
+ }
+ return dateRows;
+ }
+
if (!enabled() || !field || !groups || search.isSearching()) {
return entities().map((entity, index) =>
soup.buildRow({ id: entity.id, index, original: entity })
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 45efb347cb..ee7551825f 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
@@ -40,7 +40,6 @@ import {
useApplyPreset,
} from '@app/component/next-soup/soup-view/soup-view-tabs';
import { InboxListEntity } from '@app/component/next-soup/soup-view/views/inbox/InboxListEntity';
-import { InboxExpansionProvider } from '@app/component/next-soup/soup-view/views/inbox/inbox-expansion';
import { TaskListEntity } from '@app/component/next-soup/soup-view/views/tasks/TaskListEntity';
import { ResponsiveTaskListHeader } from '@app/component/next-soup/soup-view/views/tasks/TaskListHeader';
import {
@@ -86,6 +85,7 @@ import { useDisplayName } from '@core/user/displayName';
import { type MacroId, tryMacroId } from '@core/user/macroId';
import { openExternalUrl } from '@core/util/url';
import { useIsKeyPressActive } from '@core/util/useIsKeyPressActive';
+import EmptyStatePreviewIcon from '@design/empty-state-doc.svg';
import {
type EntityData,
ListEntity,
@@ -112,7 +112,7 @@ import {
} from '@queries/soup/normalized-cache';
import { createElementSize } from '@solid-primitives/resize-observer';
import { debounce } from '@solid-primitives/scheduled';
-import { Button, cn, Layer, Tooltip } from '@ui';
+import { Button, cn, EmptyStatePanel, Layer, Tooltip } from '@ui';
import {
type Accessor,
batch,
@@ -136,7 +136,7 @@ import { SoupEntitySelectionToolbar } from './soup-entity-selection-toolbar';
import { useSoupNavigationHotkeys } from './use-soup-navigation-hotkeys';
import { useSoupViewHotkeys } from './use-soup-view-hotkeys';
-const WIDE_SPLIT_PANEL_BREAKPOINT = 512;
+const WIDE_SPLIT_PANEL_BREAKPOINT = window.innerWidth * 0.25;
export const SoupSectionHeader = (props: {
children: JSX.Element;
@@ -711,6 +711,25 @@ export const SoupView = (props: SoupViewProps) => {
);
};
+export const useIsNewInboxEnabled = () => {
+ const panel = useSplitPanelOrThrow();
+
+ const currentView = () => {
+ const { type, id } = panel.handle.content();
+ if (type !== 'component') return;
+ return isListViewID(id) ? id : undefined;
+ };
+
+ const newInboxFlag = useFeatureFlag(ENABLE_NEW_INBOX_FLAG, {
+ enabledOverride: ENABLE_NEW_INBOX_OVERRIDE,
+ });
+
+ const isNewInboxEnabled = () =>
+ currentView() === 'inbox' && newInboxFlag().enabled;
+
+ return isNewInboxEnabled;
+};
+
interface SoupViewListProps {
customScrollbarHidden?: boolean;
scopeId?: string;
@@ -745,14 +764,24 @@ export const SoupViewList = (props: SoupViewListProps) => {
const [soupViewRef, setSoupViewRef] = createSignal<HTMLElement | undefined>();
+ const currentView = createMemo(() => {
+ const { type, id } = panel.handle.content();
+ if (type !== 'component') return;
+ return isListViewID(id) ? id : undefined;
+ });
+
const focusFirstEntity = () => {
const allRows = rows();
const firstEntityIndex = allRows.findIndex(
(row) => !row.getIsGrouped() && !row.getIsLoadMore()
);
+
if (firstEntityIndex === -1) return;
const result = soup.navigate.toIndex(firstEntityIndex);
+
+ soup.setPreviewEntity(result?.row.id);
+
if (result) {
virtualizerHandle()?.scrollToIndex(result.index, { align: 'nearest' });
}
@@ -772,6 +801,9 @@ export const SoupViewList = (props: SoupViewListProps) => {
on([rows, focusEffectsEnabled, moveInitialFocus], () => {
if (!focusEffectsEnabled() || !moveInitialFocus()) return;
if (!initialLoad || source.isLoading()) return;
+
+ if (isNewInboxEnabled()) return;
+
focusFirstEntity();
initialLoad = false;
})
@@ -783,6 +815,9 @@ export const SoupViewList = (props: SoupViewListProps) => {
() => [soup.predicates.activeIds(), searchText(), featuredIds()] as const,
() => {
if (!focusEffectsEnabled()) return;
+
+ if (isNewInboxEnabled()) return;
+
focusFirstEntity();
},
{ defer: true }
@@ -838,18 +873,8 @@ export const SoupViewList = (props: SoupViewListProps) => {
// Register soup view hotkeys (jump navigation, enter, escape, cmd+k, etc.)
const { applyTabPreset } = useApplyPreset();
- const currentView = () => {
- const { type, id } = panel.handle.content();
- if (type !== 'component') return;
- return isListViewID(id) ? id : undefined;
- };
- // Render the inbox with the new notification card layout when the flag is on.
- const newInboxFlag = useFeatureFlag(ENABLE_NEW_INBOX_FLAG, {
- enabledOverride: ENABLE_NEW_INBOX_OVERRIDE,
- });
- const isNewInboxEnabled = () =>
- currentView() === 'inbox' && newInboxFlag().enabled;
+ const isNewInboxEnabled = useIsNewInboxEnabled();
// The per-row component depends on the active view (and the inbox flag).
const listEntityComponent = () => {
@@ -915,9 +940,14 @@ export const SoupViewList = (props: SoupViewListProps) => {
return;
}
- if (soup.previewEntity() && type === 'entity') {
+ if (
+ previewPlaceholderVisible() ||
+ (previewVisible() && soup.previewEntity() && type === 'entity')
+ ) {
if (args.rowIndex !== undefined) soup.focus.setIndex(args.rowIndex);
else soup.focus.set(entity.id);
+
+ soup.setPreviewEntity(entity.id);
return;
}
@@ -1048,20 +1078,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
);
onCleanup(previewCaptorTeardown);
- // The new inbox opens with the preview pane active by default. Wait for the
- // flag to resolve and a row to focus, then open the preview once — after that
- // the user controls it (including closing it) freely.
- if (persistedPreview === undefined) {
- let previewDefaulted = false;
- createEffect(() => {
- if (previewDefaulted || !isNewInboxEnabled()) return;
- const focused = soup.focus.id();
- if (!focused) return;
- previewDefaulted = true;
- soup.setPreviewEntity(focused);
- });
- }
-
// Which groups are collapsed is also per-entry state: captured on nav-away
// and restored on back/forward.
const collapsedCaptorTeardown = panel.handle.registerEntryStateCaptor(
@@ -1116,7 +1132,9 @@ export const SoupViewList = (props: SoupViewListProps) => {
if (force) return;
restored = true;
- registerFocusEffects();
+ // The new inbox opens with the preview pane showing a placeholder, so don't
+ // auto-focus (and thus auto-select/open) the first row on initial load.
+ registerFocusEffects(!isNewInboxEnabled());
};
const registerVirtualizerHandler = (
@@ -1129,9 +1147,27 @@ export const SoupViewList = (props: SoupViewListProps) => {
const featuredCount = createMemo(() => featuredIds().length);
+ const isWideSplitPanel = createMemo(() => {
+ return (panel.panelSize.width ?? 0) > WIDE_SPLIT_PANEL_BREAKPOINT;
+ });
+
const previewVisible = createMemo(
() =>
- (!!soup.previewEntity() || panel.previewState[0]()) && !!soup.focus.item()
+ isWideSplitPanel() &&
+ (!!soup.previewEntity() || panel.previewState[0]()) &&
+ !!soup.focus.item()
+ );
+
+ // On first load the new inbox doesn't auto-select a row, so reserve the
+ // preview pane with a placeholder until the user picks something. Only for
+ // that initial state — after the first selection, an empty selection
+ // collapses the pane as before.
+ const previewPlaceholderVisible = createMemo(() => {
+ return isWideSplitPanel() && isNewInboxEnabled() && !soup.focus.item();
+ });
+
+ const previewPaneVisible = createMemo(
+ () => previewVisible() || previewPlaceholderVisible()
);
createEffect(() => {
@@ -1147,10 +1183,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
// otherwise it stays stale-true and the entity's toolbar keeps the border.
onCleanup(() => panel.previewState[1](false));
- const isWideSplitPanel = createMemo(() => {
- return (panel.panelSize.width ?? 0) > WIDE_SPLIT_PANEL_BREAKPOINT;
- });
-
return (
<MaybeSoupEntityActionDrawerManager>
<div
@@ -1167,18 +1199,11 @@ export const SoupViewList = (props: SoupViewListProps) => {
data-soup-view
data-soup-view-id={panel.handle.id + (previewPanel ? '-preview' : '')}
>
- <Resize.Zone
- direction={
- !isNewInboxEnabled() || isWideSplitPanel()
- ? 'horizontal'
- : 'vertical'
- }
- gutter={0}
- >
+ <Resize.Zone direction="horizontal" gutter={0}>
<Resize.Panel
id="soup-list"
minSize={200}
- maxSize={previewVisible() ? 840 : undefined}
+ maxSize={previewPaneVisible() ? 840 : undefined}
>
<div
class={cn(
@@ -1229,153 +1254,127 @@ export const SoupViewList = (props: SoupViewListProps) => {
</Match>
<Match when={rows().length}>
<ListLayoutProvider ref={localEntityListRef}>
- <InboxExpansionProvider>
- <Show when={currentView() === 'tasks' && !isMobile()}>
- <ResponsiveTaskListHeader class="shrink-0" />
- </Show>
- <EntityRowProvider
- container={localEntityListRef}
- canSwipeLeft={(entityId) => {
- const entity = entityById().get(entityId);
- if (!entity) return false;
-
- const tab = activeTab();
-
- if (
- !isListViewID(contentId) ||
- (tab && !canExecuteMarkDoneOnView(contentId, tab))
- )
- return false;
-
- return markDoneAction.canExecute(entity.original);
- }}
- onSwipeLeft={(entityId) => {
- const entity = entityById().get(entityId);
- if (!entity) return;
- markDoneAction.executeWithSoup(
- [entity.original],
- soup
- );
+ <Show when={currentView() === 'tasks' && !isMobile()}>
+ <ResponsiveTaskListHeader class="shrink-0" />
+ </Show>
+ <EntityRowProvider
+ container={localEntityListRef}
+ canSwipeLeft={(entityId) => {
+ const entity = entityById().get(entityId);
+ if (!entity) return false;
+
+ const tab = activeTab();
+
+ if (
+ !isListViewID(contentId) ||
+ (tab && !canExecuteMarkDoneOnView(contentId, tab))
+ )
+ return false;
+
+ return markDoneAction.canExecute(entity.original);
+ }}
+ onSwipeLeft={(entityId) => {
+ const entity = entityById().get(entityId);
+ if (!entity) return;
+ markDoneAction.executeWithSoup(
+ [entity.original],
+ soup
+ );
+ }}
+ setCollapseEntity={soup.collapseEntity.set}
+ >
+ <SoupList
+ cache={readListEntryState()?.virtualCache}
+ ref={(el) => {
+ setLocalEntityListRef(el);
+ soupNavigationTouchHighlight(el);
}}
- setCollapseEntity={soup.collapseEntity.set}
+ virtualizerClass={'scrollbar-hidden space-y-2'}
+ class="overflow-hidden flex min-w-0"
+ virtualizerRef={registerVirtualizerHandler}
+ onScrollBottom={debouncedFetchMore}
+ scrollBottomOffset={300}
+ rows={rows()}
>
- <SoupList
- cache={readListEntryState()?.virtualCache}
- ref={(el) => {
- setLocalEntityListRef(el);
- soupNavigationTouchHighlight(el);
- }}
- virtualizerClass={cn(
- previewVisible() && 'pt-1' /* scuffed */,
- 'scrollbar-hidden'
- )}
- class="overflow-hidden flex min-w-0"
- virtualizerRef={registerVirtualizerHandler}
- onScrollBottom={debouncedFetchMore}
- scrollBottomOffset={300}
- rows={rows()}
- >
- {(row, i) => {
- const timestamp = () => {
- if (row.original.sortTs)
- return row.original.sortTs;
-
- const sort_ = soup.sort.active();
- if (!sort_.length) return;
-
- switch (sort_[0].id) {
- case 'viewed_at':
- return row.original.viewedAt;
- case 'created_at':
- return row.original.createdAt;
- case 'updated_at':
- return row.original.updatedAt;
- default:
- return row.original.createdAt;
- }
- };
-
- return (
- <>
- <Show when={i() === 0 && featuredCount() > 0}>
- <SoupSectionHeader>
- <span class="truncate">
- Featured Results
- </span>
- </SoupSectionHeader>
- </Show>
- <Show
+ {(row, i) => {
+ const timestamp = () => {
+ if (row.original.sortTs)
+ return row.original.sortTs;
+
+ const sort_ = soup.sort.active();
+ if (!sort_.length) return;
+
+ switch (sort_[0].id) {
+ case 'viewed_at':
+ return row.original.viewedAt;
+ case 'created_at':
+ return row.original.createdAt;
+ case 'updated_at':
+ return row.original.updatedAt;
+ default:
+ return row.original.createdAt;
+ }
+ };
+
+ return (
+ <>
+ <Show when={i() === 0 && featuredCount() > 0}>
+ <SoupSectionHeader>
+ <span class="truncate">
+ Featured Results
+ </span>
+ </SoupSectionHeader>
+ </Show>
+ <Show
+ when={
+ i() === featuredCount() &&
+ featuredCount() > 0
+ }
+ >
+ <SoupSectionHeader>
+ <span class="truncate">More Results</span>
+ </SoupSectionHeader>
+ </Show>
+
+ <Switch>
+ {/* Group header row */}
+ <Match when={row.getIsGrouped() && row.group}>
+ {(group) => (
+ <Dynamic
+ component={
+ group().renderHeader ??
+ DefaultGroupHeader
+ }
+ group={group()}
+ highlighted={row.isFocused()}
+ />
+ )}
+ </Match>
+
+ {/* Load more row */}
+ <Match
when={
- i() === featuredCount() &&
- featuredCount() > 0
+ row.group?.isExpanded() &&
+ row.getIsLoadMore() &&
+ row.group
}
>
- <SoupSectionHeader>
- <span class="truncate">More Results</span>
- </SoupSectionHeader>
- </Show>
-
- <Switch>
- {/* Group header row */}
- <Match
- when={row.getIsGrouped() && row.group}
- >
- {(group) => (
- <Dynamic
- component={
- group().renderHeader ??
- DefaultGroupHeader
- }
- group={group()}
- highlighted={row.isFocused()}
- />
- )}
- </Match>
-
- {/* Load more row */}
- <Match
- when={
- row.group?.isExpanded() &&
- row.getIsLoadMore() &&
- row.group
- }
- >
- {(group) => {
- const highlighted = () =>
- row.isFocused();
- return (
- <div
- class={cn(
- 'my-1 rounded min-h-9 flex items-center justify-center',
- highlighted()
- ? 'w-[calc(100%-0.5rem)] mx-1 bg-active/60'
- : 'mx-auto'
- )}
- >
- <Show
- when={
- !isFetchingGroupPage(
- group().key
- )
- }
- fallback={
- <Button
- variant="base"
- size="sm"
- depth={2}
- class={cn({
- 'bg-surface':
- !highlighted(),
- 'border-transparent':
- highlighted(),
- })}
- disabled
- >
- <Spinner class="size-3 animate-spin" />
- Loading...
- </Button>
- }
- >
+ {(group) => {
+ const highlighted = () => row.isFocused();
+ return (
+ <div
+ class={cn(
+ 'my-1 rounded min-h-9 flex items-center justify-center',
+ highlighted()
+ ? 'w-[calc(100%-0.5rem)] mx-1 bg-active/60'
+ : 'mx-auto'
+ )}
+ >
+ <Show
+ when={
+ !isFetchingGroupPage(group().key)
+ }
+ fallback={
<Button
variant="base"
size="sm"
@@ -1385,123 +1384,138 @@ export const SoupViewList = (props: SoupViewListProps) => {
'border-transparent':
highlighted(),
})}
- onClick={() => {
- fetchNextGroupPage(
- group().key
- );
- }}
+ disabled
>
- <CaretDownIcon class="size-2.5" />
- Load More
+ <Spinner class="size-3 animate-spin" />
+ Loading...
</Button>
- </Show>
- </div>
- );
- }}
- </Match>
-
- {/* Entity row */}
- <Match
- when={
- !row.group || row.group?.isExpanded()
- }
+ }
+ >
+ <Button
+ variant="base"
+ size="sm"
+ depth={2}
+ class={cn({
+ 'bg-surface': !highlighted(),
+ 'border-transparent':
+ highlighted(),
+ })}
+ onClick={() => {
+ fetchNextGroupPage(group().key);
+ }}
+ >
+ <CaretDownIcon class="size-2.5" />
+ Load More
+ </Button>
+ </Show>
+ </div>
+ );
+ }}
+ </Match>
+
+ {/* Entity row */}
+ <Match
+ when={!row.group || row.group?.isExpanded()}
+ >
+ <SoupEntityContextMenu
+ entity={row.original}
>
- <SoupEntityContextMenu
+ <Dynamic
+ component={listEntityComponent()}
entity={row.original}
- >
- <Dynamic
- component={listEntityComponent()}
- entity={row.original}
- timestamp={timestamp()}
- highlighted={row.isFocused()}
- onMouseMove={() => {
- if (isKeypressActive()) return;
- if (soup.previewEntity()) return;
- soup.focus.setIndex(row.index);
- }}
- showUnrollNotifications={
- row.original.type !== 'email' &&
- soup.predicates.isActive('inbox') &&
- !soup.predicates.isActive('noise')
- }
- checked={row.isSelected()}
- onChecked={(
- next: boolean,
- shiftKey: boolean
- ) =>
- handleMultiSelectChecked({
- entity: row.original,
- entityIndex: i(),
- next,
- shiftKey: shiftKey ?? false,
- })
- }
- onClick={(event: MouseEvent) => {
- onEntityClick({
- type: 'entity',
- entity: row.original,
- event,
- location: undefined,
- rowIndex: row.index,
- });
- }}
- onProjectClick={(
+ timestamp={timestamp()}
+ highlighted={row.isFocused()}
+ onMouseMove={() => {
+ if (isKeypressActive()) return;
+ if (
+ soup.previewEntity() ||
+ isNewInboxEnabled()
+ )
+ return;
+ soup.focus.setIndex(row.index);
+ }}
+ showUnrollNotifications={
+ row.original.type !== 'email' &&
+ soup.predicates.isActive('inbox') &&
+ !soup.predicates.isActive('noise')
+ }
+ checked={row.isSelected()}
+ onChecked={(
+ next: boolean,
+ shiftKey: boolean
+ ) =>
+ handleMultiSelectChecked({
+ entity: row.original,
+ entityIndex: i(),
+ next,
+ shiftKey: shiftKey ?? false,
+ })
+ }
+ onClick={(event: MouseEvent) => {
+ onEntityClick({
+ type: 'entity',
+ entity: row.original,
+ event,
+ location: undefined,
+ rowIndex: row.index,
+ });
+ }}
+ onProjectClick={(
+ projectEntity,
+ event
+ ) => {
+ onEntityClick({
+ type: 'project',
projectEntity,
- event
- ) => {
- onEntityClick({
- type: 'project',
- projectEntity,
- entity: row.original,
- event,
- location: undefined,
- rowIndex: row.index,
- });
- }}
- onContentHitClick={(
- e: PointerEvent | MouseEvent,
- location?: SearchLocation
- ) => {
- onEntityClick({
- type: 'entity',
- entity: row.original,
- event: e,
- location,
- rowIndex: row.index,
- });
- }}
- entityRowConfig={{
- swipeLeftColor: 'bg-success',
- swipeLeftRevealedComponent: (
- <CheckIcon class="size-8 text-panel" />
- ),
- }}
- />
- </SoupEntityContextMenu>
- </Match>
- </Switch>
- <Show
- when={
- i() === rows().length - 1 &&
- isSearchServiceLoading()
- }
- >
- <div class="flex items-center gap-2 p-3 text-xs text-text-muted">
- <Spinner class="size-3 animate-spin" />
- Searching...
- </div>
- </Show>
- <Show when={i() === rows().length - 1}>
- {/* Desktop-only: mobile clearance comes
+ entity: row.original,
+ event,
+ location: undefined,
+ rowIndex: row.index,
+ });
+ }}
+ onContentHitClick={(
+ e: PointerEvent | MouseEvent,
+ location?: SearchLocation
+ ) => {
+ onEntityClick({
+ type: 'entity',
+ entity: row.original,
+ event: e,
+ location,
+ rowIndex: row.index,
+ });
+ }}
+ entityRowConfig={{
+ swipeLeftColor: 'bg-success',
+ swipeLeftRevealedComponent: (
+ <CheckIcon class="size-8 text-panel" />
+ ),
+ }}
+ />
+ </SoupEntityContextMenu>
+ </Match>
+ </Switch>
+ <Show
+ when={
+ i() === rows().length - 1 &&
+ isSearchServiceLoading()
+ }
+ >
+ <div class="flex items-center gap-2 p-3 text-xs text-text-muted">
+ <Spinner class="size-3 animate-spin" />
+ Searching...
+ </div>
+ </Show>
+ <Show when={i() === rows().length - 1}>
+ {/* Desktop-only: mobile clearance comes
from the in-scroll trailing spacer. */}
- <div class="h-15 mobile:hidden" />
- </Show>
- </>
- );
- }}
- </SoupList>
- </EntityRowProvider>
- </InboxExpansionProvider>
+ <div class="h-15 mobile:hidden" />
+ </Show>
+ </>
+ );
+ }}
+ </SoupList>
+ </EntityRowProvider>
</ListLayoutProvider>
<Show when={!props.customScrollbarHidden}>
@@ -1522,13 +1536,13 @@ export const SoupViewList = (props: SoupViewListProps) => {
</StaticMarkdownContext>
</div>
</Resize.Panel>
- <Show when={previewVisible()}>
+ <Show when={previewPaneVisible()}>
<Resize.Panel
id="soup-preview"
- minSize={300}
+ minSize={500}
target={{
kind: 'percent',
- percent: isNewInboxEnabled() ? 80 : 70,
+ percent: isNewInboxEnabled() ? 75 : 70,
}}
>
<div
@@ -1537,14 +1551,27 @@ export const SoupViewList = (props: SoupViewListProps) => {
!isWideSplitPanel() && 'border-t border-t-edge-muted'
)}
>
- <PreviewPanel
- selectedEntity={soup.focus.item()}
- orchestrator={orchestrator}
- splitPanelContext={panel}
- onFocusOut={() => {
- soupViewRef()?.focus();
- }}
- />
+ <Show
+ when={soup.focus.item()}
+ fallback={
+ <EmptyStatePanel
+ graphic={(iconProps) => (
+ <EmptyStatePreviewIcon {...iconProps} />
+ )}
+ title="Nothing selected"
+ description="Select an item from your inbox to preview it here."
+ />
+ }
+ >
+ <PreviewPanel
+ selectedEntity={soup.focus.item()}
+ orchestrator={orchestrator}
+ splitPanelContext={panel}
+ onFocusOut={() => {
+ soupViewRef()?.focus();
+ }}
+ />
+ </Show>
</div>
</Resize.Panel>
</Show>
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxCard.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxCard.tsx
index 091695425b..1353d517c8 100644
--- a/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxCard.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxCard.tsx
@@ -1,5 +1,5 @@
import { isTouchDevice } from '@core/mobile/isTouchDevice';
-import { cn } from '@ui';
+import { cn, Layer } from '@ui';
import { For, type JSX, Show } from 'solid-js';
interface SlotProps {
@@ -38,19 +38,19 @@ function Root(props: RootProps): JSX.Element {
return (
<div
class={cn(
- 'group/inbox-item relative grid min-h-16 w-full grid-cols-[2.5rem_minmax(0,1fr)] items-center gap-x-3 rounded-lg px-2 py-1.5',
+ 'group/inbox-item relative min-h-16 grid w-full grid-cols-[2rem_minmax(0,1fr)_max-content] grid-rows-[min-content_min-content] items-start gap-x-3 rounded-lg py-2.5 px-2',
{
'bg-accent/8': props.selected,
'bg-accent/16': props.selected && props.highlighted,
- 'bg-hover/30':
+ 'bg-hover/50':
props.highlighted && !props.selected && !isTouchDevice(),
- 'hover:bg-hover/30':
+ 'hover:bg-hover/50':
!props.highlighted && !props.selected && !isTouchDevice(),
- 'opacity-75': props.dimmed,
},
props.class
)}
+ data-unread={props.dimmed ? undefined : true}
role={interactive() ? 'button' : undefined}
tabIndex={interactive() ? 0 : undefined}
onClick={props.onClick}
@@ -72,15 +72,17 @@ function Icon(props: IconProps): JSX.Element {
return (
<span
class={cn(
- 'relative grid size-10 shrink-0 place-items-center self-start overflow-visible rounded-full',
+ 'relative grid size-8 shrink-0 place-items-center self-start overflow-visible',
props.class
)}
>
- <span class="grid size-full place-items-center overflow-hidden rounded-full bg-active text-ink-muted">
- <Show when={props.src} fallback={props.fallback}>
- {(src) => <img src={src()} alt="" class="size-full object-cover" />}
- </Show>
- </span>
+ <Layer depth={3}>
+ <span class="grid size-full place-items-center overflow-hidden rounded-full bg-surface text-ink-extra-muted">
+ <Show when={props.src} fallback={props.fallback}>
+ {(src) => <img src={src()} alt="" class="size-full object-cover" />}
+ </Show>
+ </span>
+ </Layer>
{props.children}
</span>
);
@@ -88,9 +90,7 @@ function Icon(props: IconProps): JSX.Element {
function Body(props: SlotProps): JSX.Element {
return (
- <div class={cn('flex min-w-0 flex-col gap-1', props.class)}>
- {props.children}
- </div>
+ <div class={cn('flex min-w-0 flex-col', props.class)}>{props.children}</div>
);
}
@@ -104,20 +104,36 @@ function Header(props: SlotProps): JSX.Element {
function Title(props: SlotProps): JSX.Element {
return (
- <div class={cn('min-w-0 flex-1 truncate', props.class)}>
+ <div
+ class={cn(
+ 'min-w-0 flex-1 truncate text-sm font-normal text-ink-extra-muted group-data-unread/inbox-item:text-ink group-data-unread/inbox-item:font-medium',
+ props.class
+ )}
+ >
{props.children}
</div>
);
}
function Content(props: SlotProps): JSX.Element {
- return <div class={cn('min-w-0', props.class)}>{props.children}</div>;
+ return (
+ <div
+ class={cn(
+ 'min-w-0 text-ink-extra-muted/80 group-data-unread/inbox-item:text-ink-muted',
+ props.class
+ )}
+ >
+ {props.children}
+ </div>
+ );
}
function Attachments(props: {
items: InboxCardAttachment[];
max?: number;
class?: string;
+ /** When set, media tiles become clickable and call this with the item index. */
+ onOpen?: (index: number) => void;
}): JSX.Element {
const max = (): number => props.max ?? 4;
const visible = (): InboxCardAttachment[] => props.items.slice(0, max());
@@ -129,29 +145,42 @@ function Attachments(props: {
class={cn('flex max-w-full flex-wrap items-center gap-1.5', props.class)}
>
<For each={visible()}>
- {(attachment) => (
+ {(attachment, index) => (
<Show when={attachment.src} fallback={attachment.fallback?.()}>
- {(src) => (
- <Show
- when={attachment.kind === 'video'}
- fallback={
+ {(src) => {
+ const media = () =>
+ attachment.kind === 'video' ? (
+ <video
+ src={src()}
+ muted
+ playsinline
+ preload="metadata"
+ class="size-12 rounded-lg border border-edge object-cover"
+ />
+ ) : (
<img
src={attachment.thumbSrc ?? src()}
alt={attachment.alt ?? ''}
loading="lazy"
class="size-12 rounded-lg border border-edge object-cover"
/>
- }
- >
- <video
- src={src()}
- muted
- playsinline
- preload="metadata"
- class="size-12 rounded-lg border border-edge object-cover"
- />
- </Show>
- )}
+ );
+
+ return props.onOpen ? (
+ <button
+ type="button"
+ class="rounded-lg transition-opacity hover:opacity-80"
+ onClick={(e) => {
+ e.stopPropagation();
+ props.onOpen?.(index());
+ }}
+ >
+ {media()}
+ </button>
+ ) : (
+ media()
+ );
+ }}
</Show>
)}
</For>
@@ -172,7 +201,7 @@ function Meta(props: MetaProps): JSX.Element {
return (
<div
class={cn(
- 'flex min-w-0 items-center gap-1.5 text-xs text-ink-extra-muted',
+ 'flex min-w-0 items-center gap-1.5 text-xs text-ink-extra-muted mt-1',
props.class
)}
>
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxListEntity.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxListEntity.tsx
index 1d22e6d4eb..df677433bc 100644
--- a/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxListEntity.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/InboxListEntity.tsx
@@ -1,9 +1,9 @@
import { useChannelsContext } from '@core/context/channels';
-import { MaybeEntityRow } from '@entity';
+import { MaybeEntityRow, MultiSelectCheckbox } from '@entity';
import type { BaseListEntityProps } from '@entity/composed/list-entity/shared';
+import { cn } from '@ui';
import { createMemo } from 'solid-js';
import { InboxCardLayout, toInboxCardDisplayItem } from './inbox-card-layouts';
-import { useInboxExpansion } from './inbox-expansion';
import { scopeThreadNotifications } from './utils';
/**
@@ -12,12 +12,8 @@ import { scopeThreadNotifications } from './utils';
* adapter only maps the row into the card's display item and derives `selected`
* from the focused row (which is what the preview shows).
*
- * Expand/collapse of thread sub-items is read from the view-level
- * `InboxExpansionProvider` when present (so it survives the row scrolling out of
- * view); without a provider the card falls back to its own local state.
*/
export function InboxListEntity(props: BaseListEntityProps) {
- const expansion = useInboxExpansion();
const channels = useChannelsContext();
// A channel_thread soup entity comes back with a generic name ("Channel
@@ -32,21 +28,31 @@ export function InboxListEntity(props: BaseListEntityProps) {
const item = createMemo(() => toInboxCardDisplayItem(entity()));
return (
- <div class="mx-1" ref={props.ref} onMouseMove={props.onMouseMove}>
+ <div
+ class="group/inbox-item relative mx-2"
+ ref={props.ref}
+ onMouseMove={props.onMouseMove}
+ >
<MaybeEntityRow entityId={props.entity.id} config={props.entityRowConfig}>
<InboxCardLayout
item={item()}
selected={props.checked}
highlighted={props.highlighted}
onClick={props.onClick}
- expanded={
- expansion ? expansion.isExpanded(props.entity.id) : undefined
- }
- onToggleExpanded={
- expansion ? () => expansion.toggle(props.entity.id) : undefined
- }
/>
</MaybeEntityRow>
+ <div
+ class={cn(
+ 'hidden absolute right-2 bottom-2 z-10 group-hover/inbox-item:flex items-center justify-center bg-surface overflow-hidden',
+ props.checked && 'flex'
+ )}
+ >
+ <MultiSelectCheckbox
+ checked={props.checked}
+ onChecked={props.onChecked}
+ showBorder
+ />
+ </div>
</div>
);
}
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx
index 98fa417cdd..ec08082f74 100644
--- a/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx
+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-card-layouts.tsx
@@ -1,5 +1,6 @@
import { ListPropertyValue } from '@app/component/next-soup/soup-view/views/tasks/list-property-value';
-import { mapMediaItems } from '@channel/Media/media-items';
+import { MediaViewerDialog } from '@channel/Media/MediaViewerDialog';
+import { type MediaItem, mapMediaItems } from '@channel/Media/media-items';
import { BotIcon } from '@channel/Message/BotIcon';
import { MACRO_AI_BOT_ID, MACRO_AI_NAME } from '@channel/macroAi';
import { EntityIcon, getEntityIconType } from '@core/component/EntityIcon';
@@ -8,7 +9,9 @@ import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/S
import { unifiedListMarkdownTheme } from '@core/component/LexicalMarkdown/theme';
import { UserIcon } from '@core/component/UserIcon';
import { isMacroAgentId } from '@core/constant/macroAgent';
+import { useUserId } from '@core/context/user';
import { tryMacroId, useDisplayName } from '@core/user';
+import { plural } from '@core/util/string';
import {
type EntityData,
isGithubPrEntity,
@@ -19,6 +22,8 @@ import {
import MacroLogo from '@icon/macro-logo.svg';
import GithubIcon from '@icon/mcp-github.svg';
import FilesIcon from '@phosphor/files.svg';
+import GitMergeIcon from '@phosphor/git-merge.svg';
+import GitPullRequestIcon from '@phosphor/git-pull-request.svg';
import ArrowBendUpLeftIcon from '@phosphor-icons/core/regular/arrow-bend-up-left.svg?component-solid';
import AtIcon from '@phosphor-icons/core/regular/at.svg?component-solid';
import ChatCircleIcon from '@phosphor-icons/core/regular/chat-circle.svg?component-solid';
@@ -34,7 +39,7 @@ import { senderFromStorageId } from '@queries/channel/message-sender';
import { useBulkSaveEntityPropertiesMutation } from '@queries/properties/entity';
import { stringToItemType } from '@service-storage/client';
import { EntityType } from '@service-storage/generated/schemas';
-import { cn } from '@ui';
+import { Avatar, cn, Tooltip } from '@ui';
import {
createMemo,
createSignal,
@@ -44,6 +49,7 @@ import {
Show,
Switch,
} from 'solid-js';
+import { Dynamic } from 'solid-js/web';
import { match, P } from 'ts-pattern';
import { InboxCard, type InboxCardAttachment } from './InboxCard';
import {
@@ -59,9 +65,7 @@ export interface InboxCardLayoutProps {
item: InboxCardDisplayItem;
selected?: boolean;
highlighted?: boolean;
- expanded?: boolean;
onClick?: (event: MouseEvent) => void;
- onToggleExpanded?: () => void;
}
type NotificationTag = ReturnType<typeof getNotificationTag>;
@@ -70,9 +74,6 @@ type NotificationTag = ReturnType<typeof getNotificationTag>;
const getFirstNotification = (item: WithNotification<EntityData>) =>
item.notifications?.()?.[0];
-const isUnreadNotification = (notification?: Notification) =>
- notification ? !notification.viewed_at : false;
-
const getGithubSender = (entity: EntityData, notification?: Notification) => {
const meta = notification?.notification_metadata;
if (
@@ -168,10 +169,12 @@ export function SenderIcon(props: SenderIconProps) {
};
return (
- <div class={cn('shrink-0 size-(--user-icon-width)', props.class)}>
+ <div class={cn('shrink-0 size-full', props.class)}>
<Show
when={botSender()}
- fallback={<UserIcon id={props.senderId ?? ''} size="fill" />}
+ fallback={
+ <UserIcon id={props.senderId ?? ''} class="size-full" size="fill" />
+ }
>
{(bot) => (
<BotIcon name={bot().name} avatarUrl={bot().avatar_url} size="fill" />
@@ -181,7 +184,7 @@ export function SenderIcon(props: SenderIconProps) {
);
}
-function Avatar(props: {
+function InboxAvatar(props: {
senderId?: string;
fallbackName?: string;
imageUrl?: string;
@@ -196,21 +199,13 @@ function Avatar(props: {
return (
<Switch
fallback={
- <span class="text-xs text-ink-muted">
+ <Avatar.Fallback class="text-base font-semibold">
{initials(props.fallbackName ?? props.senderId ?? '')}
- </span>
+ </Avatar.Fallback>
}
>
<Match when={props.imageUrl}>
- {(url) => (
- <img
- src={url()}
- alt=""
- class="size-full object-cover"
- crossorigin="anonymous"
- referrerpolicy="no-referrer"
- />
- )}
+ {(url) => <img src={url()} alt="" class="size-full object-cover" />}
</Match>
<Match when={isMacroAgent()}>
<MacroLogo class="m-auto size-1/2 text-accent" />
@@ -225,19 +220,18 @@ function Avatar(props: {
const tagBubbleIcon = (tag: NotificationTag) =>
match(tag)
.with('new_email', () => () => (
- <span class="grid size-3 place-items-center">
- <EntityIcon targetType="email" size="fill" />
- </span>
+ <EntityIcon
+ class="size-4"
+ targetType="email"
+ theme="monochrome"
+ size="fill"
+ />
))
.with('task_assigned', () => () => (
- <span class="grid size-3 place-items-center">
- <EntityIcon targetType="task" size="fill" />
- </span>
+ <EntityIcon class="size-4" targetType="task" size="fill" />
))
.with('ai_response', () => () => (
- <span class="grid size-3 place-items-center">
- <EntityIcon targetType="chat" size="fill" />
- </span>
+ <EntityIcon class="size-4" targetType="chat" size="fill" />
))
.with('channel_mention', 'mentioned_in_document_comment', () => () => (
<AtIcon class="size-4" />
@@ -277,15 +271,38 @@ function ActionBubble(props: { tag: NotificationTag }) {
return (
<Show when={renderIcon()}>
- {(renderIcon) => (
- <span class="absolute -bottom-1 -right-1 grid size-5 place-items-center overflow-hidden rounded-full bg-surface text-ink-muted ring-2 ring-surface">
- {renderIcon()()}
- </span>
- )}
+ {(renderIcon) => <Dynamic component={renderIcon()} />}
</Show>
);
}
+function GithubStatusIcon(props: { status?: string }) {
+ const statusClass = () => {
+ if (props.status === 'merged') return 'text-note';
+ if (props.status === 'closed') return 'text-failure';
+ if (props.status === 'open') return 'text-success';
+ return undefined;
+ };
+
+ return (
+ <span class="grid size-4 place-items-center">
+ <Show
+ when={props.status === 'merged'}
+ fallback={
+ <Show
+ when={props.status === 'open' || props.status === 'closed'}
+ fallback={<GithubIcon class="size-4" />}
+ >
+ <GitPullRequestIcon class={cn('size-4', statusClass())} />
+ </Show>
+ }
+ >
+ <GitMergeIcon class="size-4 text-note" />
+ </Show>
+ </span>
+ );
+}
+
function Badge(props: { unread: boolean }) {
return (
<Show when={props.unread}>
@@ -340,8 +357,37 @@ function PropertyPills(props: { entityId: string; properties?: PropertyT[] }) {
);
}
-const relativeTime = (timestamp: string | undefined): string | undefined =>
- timestamp ? formatCompactRelativeTimestamp(timestamp) : undefined;
+const formatDetailedTimestamp = (timestamp: string | undefined) => {
+ if (!timestamp) return undefined;
+
+ const date = new Date(timestamp);
+ if (Number.isNaN(date.getTime())) return timestamp;
+
+ return date.toLocaleString(undefined, {
+ dateStyle: 'medium',
+ timeStyle: 'short',
+ });
+};
+
+function InboxTimestamp(props: { timestamp?: string; class?: string }) {
+ const short = () =>
+ props.timestamp
+ ? formatCompactRelativeTimestamp(props.timestamp)
+ : undefined;
+ const detailed = () => formatDetailedTimestamp(props.timestamp);
+
+ return (
+ <Show when={short()}>
+ {(value) => (
+ <Tooltip class={props.class} label={detailed() ?? value()}>
+ <span class={'whitespace-nowrap text-xs text-ink-extra-muted'}>
+ {value()}
+ </span>
+ </Tooltip>
+ )}
+ </Show>
+ );
+}
const createSenderDisplayName = (
senderId: () => string | undefined,
@@ -365,7 +411,9 @@ const createSenderDisplayName = (
return parsed.id === MACRO_AI_BOT_ID ? MACRO_AI_NAME : 'Bot';
};
- return () => botName() || displayName() || fallbackName?.() || senderId();
+ return () => {
+ return botName() || displayName() || fallbackName?.() || senderId();
+ };
};
const buildActionLabel = (args: {
@@ -421,9 +469,13 @@ const githubAction = (notification?: Notification): string => {
{ tag: 'github_pr_status_changed', content: { status: 'closed' } },
() => 'closed'
)
+ .with(
+ { tag: 'github_pr_status_changed', content: { status: 'open' } },
+ () => 'opened'
+ )
.with({ tag: 'github_review_requested' }, () => 'requested your review on')
.with({ tag: 'github_pr_comment' }, () => 'commented on')
- .with({ tag: 'github_pr_mention' }, () => 'mentioned you in')
+ .with({ tag: 'github_pr_mention' }, () => 'mentioned you')
.with({ tag: 'github_pr_review' }, () => 'reviewed')
.otherwise(() => 'updated');
};
@@ -440,8 +492,6 @@ function BaseCard(props: {
entityId: string;
properties?: PropertyT[];
timestamp?: string;
- /** Extra controls rendered in the meta line, after the timestamp. */
- metaActions?: JSX.Element;
}) {
return (
<InboxCard.Root
@@ -450,97 +500,47 @@ function BaseCard(props: {
highlighted={props.highlighted}
onClick={props.onClick}
>
- {props.leading}
- <InboxCard.Body>
- <InboxCard.Header>
- <InboxCard.Title class="flex items-center gap-1">
+ <div class="col-start-1 row-start-1 row-span-2">{props.leading}</div>
+ <InboxCard.Body class="contents">
+ <InboxCard.Header class="col-start-2 row-start-1 self-center">
+ <InboxCard.Title class="flex items-center gap-1 truncate">
<Badge unread={props.unread} />
{props.title}
</InboxCard.Title>
</InboxCard.Header>
- <Show when={props.preview?.trim()}>
- {(value) => (
- <InboxCard.Content class="truncate text-sm text-ink/60">
- <StaticMarkdown
- markdown={value()}
- singleLine
- theme={unifiedListMarkdownTheme}
- />
- </InboxCard.Content>
- )}
- </Show>
-
- <PropertyPills
- entityId={props.entityId}
- properties={props.properties}
- />
+ <div class="col-start-2 row-start-2 flex min-w-0 flex-col">
+ <Show when={props.preview?.trim()}>
+ {(value) => (
+ <InboxCard.Content class="truncate text-sm">
+ <StaticMarkdown
+ markdown={value()}
+ singleLine
+ theme={unifiedListMarkdownTheme}
+ />
+ </InboxCard.Content>
+ )}
+ </Show>
- <Show when={props.attachments?.length}>
- <InboxCard.Attachments items={props.attachments!} />
- </Show>
+ <PropertyPills
+ entityId={props.entityId}
+ properties={props.properties}
+ />
- <Show when={props.timestamp || props.metaActions}>
- <InboxCard.Meta timestamp={relativeTime(props.timestamp)}>
- {props.metaActions}
- </InboxCard.Meta>
- </Show>
+ <Show when={props.attachments?.length}>
+ <InboxCard.Attachments items={props.attachments!} />
+ </Show>
+ </div>
</InboxCard.Body>
+ <InboxTimestamp
+ timestamp={props.timestamp}
+ class="col-start-3 row-start-1 self-start justify-self-end"
+ />
</InboxCard.Root>
);
}
export function ChannelCardLayout(props: InboxCardLayoutProps) {
- const subItems = createMemo(() => {
- const entity = props.item.entity;
- let notifications = entity.notifications?.() ?? [];
-
- const next = [];
-
- for (const notification of notifications) {
- const meta = notification.notification_metadata;
-
- const isValid = (
- [
- 'document_mention',
- 'call_started',
- 'channel_invite',
- ] as NotificationTag[]
- ).includes(meta.tag);
-
- if (!isValid) continue;
-
- let isCurrentMessage = false;
-
- if (entity.type === 'channel') {
- if (
- meta.tag === 'document_mention' &&
- meta.content.messageId === entity.latestRootMessage?.messageId
- ) {
- isCurrentMessage = true;
- }
- }
-
- if (isCurrentMessage) continue;
-
- next.push(notification);
- }
-
- return next.toSorted((a, b) => notificationTime(b) - notificationTime(a));
- });
-
- const hasSubItems = createMemo(() => subItems().length > 0);
-
- const [localExpanded, setLocalExpanded] = createSignal(false);
- const expanded = () => props.expanded ?? localExpanded();
- const toggleExpanded = () => {
- if (props.onToggleExpanded) {
- props.onToggleExpanded();
- return;
- }
- setLocalExpanded((value) => !value);
- };
-
const entity = createMemo(() => props.item.entity);
const senderId = () => {
@@ -562,6 +562,9 @@ export function ChannelCardLayout(props: InboxCardLayoutProps) {
};
const senderName = createSenderDisplayName(senderId);
+ const currentUserId = useUserId();
+ const senderLabel = () =>
+ senderId() === currentUserId() ? 'You' : senderName();
const isDM = createMemo(() => {
const value = entity();
@@ -600,99 +603,54 @@ export function ChannelCardLayout(props: InboxCardLayoutProps) {
highlighted={props.highlighted}
onClick={props.onClick}
>
- <Show
- when={!isDM()}
- fallback={
- <InboxCard.Icon fallback={<Avatar senderId={senderId()} />}>
- <ActionBubble tag={getNotificationTag(props.item.notification)} />
- </InboxCard.Icon>
- }
- >
- <InboxCard.Icon
+ <div class="col-start-1 row-start-1 row-span-2">
+ <Show
+ when={!isDM()}
fallback={
- <EntityIcon
- class="size-5"
- targetType={getEntityIconType(entity())}
- size="fill"
- theme="monochrome"
- />
+ <InboxCard.Icon fallback={<InboxAvatar senderId={senderId()} />} />
}
- />
- </Show>
- <InboxCard.Body>
- <InboxCard.Header>
+ >
+ <InboxCard.Icon
+ fallback={
+ <EntityIcon
+ class="size-4"
+ targetType={getEntityIconType(entity())}
+ size="fill"
+ theme="monochrome"
+ />
+ }
+ ></InboxCard.Icon>
+ </Show>
+ </div>
+ <InboxCard.Body class="contents">
+ <InboxCard.Header class="col-start-2 row-start-1 self-center">
<InboxCard.Title class="flex items-center gap-1">
<Badge unread={props.item.unread} />
{text().title}
</InboxCard.Title>
</InboxCard.Header>
- <div class="flex items-center gap-1">
- <Show when={!isDM()}>
- <span class="flex gap-1 items-center text-sm whitespace-nowrap">
- <Show when={senderId()}>
- {(id) => (
- <UserIcon
- id={id()}
- size="sm"
- suppressClick
- showTooltip={false}
- />
- )}
- </Show>
- {senderName()}
- </span>
- </Show>
- <Show when={text().content?.trim()}>
- {(value) => (
- <InboxCard.Content class="truncate flex text-sm text-ink/60">
+ <div class="col-start-2 row-start-2 flex min-w-0 items-center gap-1 text-sm">
+ <InboxCard.Content class="truncate">
+ <Show when={!isDM()}>
+ <span class="whitespace-nowrap mr-1">{senderLabel()}:</span>
+ </Show>
+ <Show when={text().content?.trim()}>
+ {(value) => (
<StaticMarkdown
markdown={value()}
singleLine
theme={unifiedListMarkdownTheme}
/>
- </InboxCard.Content>
- )}
- </Show>
- </div>
-
- <Show when={props.item.timestamp || hasSubItems()}>
- <InboxCard.Meta timestamp={relativeTime(props.item.timestamp)}>
- <Show when={hasSubItems()}>
- <Show when={props.item.timestamp}>
- <span aria-hidden="true">•</span>
- </Show>
- <button
- type="button"
- class="rounded text-ink-extra-muted transition-colors hover:text-ink-muted focus-visible:outline-none focus-visible:ring focus-visible:ring-accent/40 truncate"
- onClick={(event) => {
- event.preventDefault();
- event.stopPropagation();
- toggleExpanded();
- }}
- >
- {expanded()
- ? 'Hide all notifications'
- : 'Show all notifications'}
- </button>
+ )}
</Show>
- </InboxCard.Meta>
- </Show>
- </InboxCard.Body>
- <Show when={expanded() && hasSubItems()}>
- <div class="w-full col-start-2 flex flex-col gap-1 border-l border-edge-muted">
- <For each={subItems()}>
- {(notification) => (
- <ThreadReplySubItem
- notification={notification}
- threadEntityId={props.item.entity.id}
- onClick={props.onClick}
- isDM={isDM()}
- />
- )}
- </For>
+ </InboxCard.Content>
</div>
- </Show>
+ </InboxCard.Body>
+ <InboxTimestamp
+ timestamp={props.item.timestamp}
+ class="col-start-3 row-start-1 self-start justify-self-end"
+ />
</InboxCard.Root>
);
}
@@ -707,11 +665,8 @@ export function ChannelMessageCardLayout(props: InboxCardLayoutProps) {
const text = createMemo(() => {
const location = channelLocation(props.item.entity);
- const tag = getNotificationTag(props.item.notification);
let action = 'sent a message';
- if (tag === 'channel_mention') {
- action = location ? 'mentioned you in' : 'mentioned you';
- } else if (location) {
+ if (location) {
action = 'sent a message in';
}
@@ -729,91 +684,25 @@ export function ChannelMessageCardLayout(props: InboxCardLayoutProps) {
onClick={props.onClick}
unread={props.item.unread}
timestamp={props.item.timestamp}
- leading={
- <InboxCard.Icon fallback={<Avatar senderId={senderId()} />}>
- <ActionBubble tag={getNotificationTag(props.item.notification)} />
- </InboxCard.Icon>
- }
- title={text().title}
- preview={text().content}
- />
- );
-}
-
-const notificationTime = (notification: Notification): number => {
- const raw = notification.created_at ?? notification.updated_at;
- const time = raw != null ? Date.parse(String(raw)) : 0;
- return Number.isNaN(time) ? 0 : time;
-};
-
-function ThreadReplySubItem(props: {
- isDM?: boolean;
- notification: Notification;
- threadEntityId: string;
- selected?: boolean;
- onClick?: (event: MouseEvent) => void;
-}) {
- const senderId = () => props.notification.sender_id ?? undefined;
- const senderFallbackName = () =>
- getNotificationSenderFallbackName(props.notification);
- const senderName = createSenderDisplayName(senderId, senderFallbackName);
-
- const messageContent = () => {
- const notification = props.notification;
- const meta = notification.notification_metadata;
- return match(meta)
- .with({ tag: 'channel_message_reply' }, (m) => m.content.messageContent)
- .with({ tag: 'document_mention' }, (m) => m.content.messageContent)
- .with({ tag: 'call_started' }, (m) => m.content.channel_name?.toString())
- .with({ tag: 'channel_invite' }, (m) =>
- m.content.messageContent?.toString()
- )
- .with({ tag: 'channel_mention' }, (m) => m.content.messageContent)
- .otherwise(() => undefined);
- };
-
- const action = () => {
- const tag = getNotificationTag(props.notification);
-
- if (tag === 'channel_mention') return 'mentioned you';
- if (tag === 'channel_message_reply') return 'replied';
- if (tag === 'document_mention') return 'shared a document with you';
- if (tag === 'call_started') return 'started a call';
- if (tag === 'channel_invite') return 'started a conversation';
-
- return 'sent a message';
- };
-
- const timestamp = () => {
- const raw = props.notification.created_at ?? props.notification.updated_at;
- return raw != null ? String(raw) : undefined;
- };
-
- return (
- <BaseCard
- entityId={props.threadEntityId}
- selected={props.selected}
- onClick={props.onClick}
- unread={isUnreadNotification(props.notification)}
- timestamp={timestamp()}
leading={
<InboxCard.Icon
fallback={
- <Avatar senderId={senderId()} fallbackName={senderFallbackName()} />
+ <ActionBubble tag={getNotificationTag(props.item.notification)} />
}
- >
- <ActionBubble tag={getNotificationTag(props.notification)} />
- </InboxCard.Icon>
+ ></InboxCard.Icon>
}
- title={buildActionLabel({
- sender: props.isDM ? undefined : senderName(),
- action: action(),
- })}
- preview={messageContent()}
+ title={text().title}
+ preview={text().content}
/>
);
}
+/** Fallback shown in place of message text when a message is just attachments. */
+const attachmentSummary = (count: number): string | undefined =>
+ count <= 0
+ ? undefined
+ : `sent ${count === 1 ? 'an' : count} ${plural('attachment', count)}`;
+
export function ChannelThreadCardLayout(props: InboxCardLayoutProps) {
const isLatestNotificationReply = createMemo(() => {
const notification = props.item.notification;
@@ -822,28 +711,6 @@ export function ChannelThreadCardLayout(props: InboxCardLayoutProps) {
return notificationMetadata?.tag === 'channel_message_reply';
});
- // When the latest notification is a reply, the thread's notifications become
- // expandable sub items (most recent first).
- const subItems = createMemo(() => {
- if (!isLatestNotificationReply()) return [];
- const notifications = props.item.entity.notifications?.() ?? [];
- return notifications.toSorted(
- (a, b) => notificationTime(b) - notificationTime(a)
- );
- });
-
- const hasSubItems = () => subItems().length > 0;
-
- const [localExpanded, setLocalExpanded] = createSignal(false);
- const expanded = () => props.expanded ?? localExpanded();
- const toggleExpanded = () => {
- if (props.onToggleExpanded) {
- props.onToggleExpanded();
- return;
- }
- setLocalExpanded((value) => !value);
- };
-
const senderId = createMemo(() => {
const value = props.item.entity;
@@ -870,120 +737,184 @@ export function ChannelThreadCardLayout(props: InboxCardLayoutProps) {
});
const senderName = createSenderDisplayName(senderId);
+ const currentUserId = useUserId();
+ const senderLabel = () =>
+ senderId() === currentUserId() ? 'You' : senderName();
+
+ // The root/original thread message sender (who a reply is replying to).
+ const originalSenderId = () =>
+ props.item.entity.type === 'channel_thread'
+ ? props.item.entity.senderId
+ : undefined;
+ const originalSenderName = createSenderDisplayName(originalSenderId);
+ const originalSenderLabel = () =>
+ originalSenderId() === currentUserId() ? 'You' : originalSenderName();
- const text = createMemo(() => {
- const metadata = props.item.notification?.notification_metadata;
- const location = channelLocation(props.item.entity);
+ // Media (images/videos) render in a clickable grid backed by the shared
+ // media viewer; non-media attachments keep their entity-preview tiles.
+ const mediaItems = createMemo<MediaItem[]>(() => {
+ if (
+ isLatestNotificationReply() ||
+ props.item.entity.type !== 'channel_thread'
+ )
+ return [];
+ return mapMediaItems(props.item.entity.attachments);
+ });
- const includeLocation = location && !isDM();
+ const fileAttachments = createMemo<InboxCardAttachment[]>(() => {
+ if (
+ isLatestNotificationReply() ||
+ props.item.entity.type !== 'channel_thread'
+ )
+ return [];
+ return props.item.entity.attachments
+ .filter((attachment) => mapMediaItems([attachment]).length === 0)
+ .map(
+ (attachment): InboxCardAttachment => ({
+ id: attachment.entity_id,
+ fallback: () => (
+ <ItemPreview
+ id={attachment.entity_id}
+ type={stringToItemType(attachment.entity_type)}
+ />
+ ),
+ })
+ );
+ });
- let action = includeLocation ? 'started a thread in' : 'started a thread';
+ const [viewerOpen, setViewerOpen] = createSignal(false);
+ const [viewerIndex, setViewerIndex] = createSignal(0);
- if (metadata?.tag === 'channel_mention') {
- action = includeLocation ? 'mentioned you in' : 'mentioned you';
- } else if (metadata?.tag === 'channel_message_reply') {
- action = includeLocation ? 'replied in' : 'replied';
+ const text = createMemo(() => {
+ if (props.item.entity.type !== 'channel_thread') {
+ return {
+ title: '',
+ content: '',
+ };
}
- let content = itemContent(props.item.entity, props.item.notification);
+ const metadata = props.item.notification?.notification_metadata;
+ const location = channelLocation(props.item.entity);
+
+ const rootAttachments = props.item.entity.attachments;
+
+ let content: string | undefined;
+ let context: string | undefined;
if (metadata?.tag === 'channel_message_reply') {
+ // Current message is the reply; the quoted context is the original (root).
content = metadata.content.messageContent;
+ const original = props.item.entity.content.trim();
+ context = original.length
+ ? original
+ : attachmentSummary(rootAttachments.length);
+ } else {
+ // Root message: fall back to an attachment summary when it has no text.
+ content = itemContent(props.item.entity, props.item.notification);
+ if (!content?.trim()) {
+ content = attachmentSummary(rootAttachments.length) ?? content;
+ }
}
return {
- title: buildActionLabel({
- sender: senderName(),
- action,
- location: includeLocation ? location : undefined,
- }),
+ title: location,
+ context,
content,
};
});
- const attachments = createMemo(() => {
- if (
- isLatestNotificationReply() ||
- props.item.entity.type !== 'channel_thread'
- )
- return;
-
- const itemAttachments = props.item.entity.attachments;
-
- return itemAttachments.map((attachment): InboxCardAttachment => {
- const media = mapMediaItems([attachment])[0];
- if (media) {
- return {
- id: media.id,
- src: media.src,
- kind: media.kind,
- thumbSrc: media.thumbSrc,
- };
- }
- return {
- id: attachment.entity_id,
- fallback: () => (
- <ItemPreview
- id={attachment.entity_id}
- type={stringToItemType(attachment.entity_type)}
- />
- ),
- };
- });
- });
-
return (
- <div class="flex flex-col gap-1">
- <BaseCard
- entityId={props.item.entity.id}
+ <>
+ <InboxCard.Root
+ dimmed={!props.item.unread}
selected={props.selected}
highlighted={props.highlighted}
onClick={props.onClick}
- unread={props.item.unread}
- timestamp={props.item.timestamp}
- leading={
- <InboxCard.Icon fallback={<Avatar senderId={senderId()} />}>
- <ActionBubble tag={getNotificationTag(props.item.notification)} />
- </InboxCard.Icon>
- }
- title={text().title}
- preview={text().content}
- attachments={attachments()}
- metaActions={
- hasSubItems() ? (
- <>
- <Show when={props.item.timestamp}>
- <span aria-hidden="true">•</span>
+ >
+ <div class="col-start-1 row-start-2">
+ <InboxCard.Icon
+ fallback={
+ <ActionBubble tag={getNotificationTag(props.item.notification)} />
+ }
+ ></InboxCard.Icon>
+ </div>
+ <InboxCard.Body class="contents">
+ <div class={cn('col-start-2 row-start-2')}>
+ <InboxCard.Header class="self-center">
+ <InboxCard.Title class="flex items-center gap-1">
+ <Badge unread={props.item.unread} />
+ {text().title}
+ </InboxCard.Title>
+ </InboxCard.Header>
+
+ {/* For replies, show the original message being replied to first,
+ with a left bar marking it as the quoted original. */}
+ <Show when={isLatestNotificationReply() && text().context?.trim()}>
+ {(context) => (
+ <div class="flex min-w-0 items-center gap-1 border-l-2 border-edge-muted pl-2">
+ <span class="flex gap-1 items-center text-sm whitespace-nowrap text-ink-extra-muted/80 group-data-unread/inbox-item:text-ink-muted">
+ {originalSenderLabel()}:
+ </span>
+ <InboxCard.Content class="truncate text-sm text-ink/60">
+ <StaticMarkdown
+ markdown={context()}
+ singleLine
+ theme={unifiedListMarkdownTheme}
+ />
+ </InboxCard.Content>
+ </div>
+ )}
+ </Show>
+
+ <div class="flex min-w-0 items-center gap-1">
+ <Show when={!isDM()}>
+ <span class="flex gap-1 items-center text-sm whitespace-nowrap text-ink-extra-muted/80 group-data-unread/inbox-item:text-ink-muted">
+ {senderLabel()}:
+ </span>
</Show>
- <button
- type="button"
- class="rounded text-ink-extra-muted transition-colors hover:text-ink-muted focus-visible:outline-none focus-visible:ring focus-visible:ring-accent/40 truncate"
- onClick={(event) => {
- event.preventDefault();
- event.stopPropagation();
- toggleExpanded();
- }}
- >
- {expanded() ? 'Hide thread messages' : 'Show thread messages'}
- </button>
- </>
- ) : undefined
- }
+ <Show when={text().content?.trim()}>
+ {(value) => (
+ <InboxCard.Content class="truncate text-sm text-ink/60">
+ <StaticMarkdown
+ markdown={value()}
+ singleLine
+ theme={unifiedListMarkdownTheme}
+ />
+ </InboxCard.Content>
+ )}
+ </Show>
+ </div>
+ </div>
+
+ <Show when={mediaItems().length || fileAttachments().length}>
+ <div class="col-start-2 row-start-3 flex min-w-0 flex-col gap-2">
+ <Show when={mediaItems().length}>
+ <InboxCard.Attachments
+ items={mediaItems()}
+ onOpen={(index) => {
+ setViewerIndex(index);
+ setViewerOpen(true);
+ }}
+ />
+ </Show>
+ <Show when={fileAttachments().length}>
+ <InboxCard.Attachments items={fileAttachments()} />
+ </Show>
+ </div>
+ </Show>
+ </InboxCard.Body>
+ <InboxTimestamp
+ timestamp={props.item.timestamp}
+ class="col-start-3 row-start-2 self-start justify-self-end"
+ />
+ </InboxCard.Root>
+ <MediaViewerDialog
+ items={mediaItems}
+ open={viewerOpen()}
+ onOpenChange={setViewerOpen}
+ currentIndex={viewerIndex}
+ onCurrentIndexChange={setViewerIndex}
/>
- <Show when={expanded() && hasSubItems()}>
- <div class="ml-5 flex flex-col gap-1 border-l border-edge-muted pl-4">
- <For each={subItems()}>
- {(notification) => (
- <ThreadReplySubItem
- notification={notification}
- threadEntityId={props.item.entity.id}
- onClick={props.onClick}
- isDM={isDM()}
- />
- )}
- </For>
- </div>
- </Show>
- </div>
+ </>
);
}
@@ -1061,15 +992,10 @@ export function DocumentCardLayout(props: InboxCardLayoutProps) {
<EntityIcon targetType={getEntityIconType(props.item.entity)} />
}
>
- <Avatar
- senderId={senderId()}
- fallbackName={senderFallbackName()}
- />
+ <ActionBubble tag={getNotificationTag(props.item.notification)} />
</Show>
}
- >
- <ActionBubble tag={getNotificationTag(props.item.notification)} />
- </InboxCard.Icon>
+ ></InboxCard.Icon>
}
title={text().title}
preview={text().content}
@@ -1119,21 +1045,16 @@ export function TaskCardLayout(props: InboxCardLayoutProps) {
when={props.item.notification}
fallback={
<EntityIcon
- class="size-5"
+ class="size-4"
size="fill"
targetType={getEntityIconType(props.item.entity)}
/>
}
>
- <Avatar
- senderId={senderId()}
- fallbackName={senderFallbackName()}
- />
+ <ActionBubble tag={getNotificationTag(props.item.notification)} />
</Show>
}
- >
- <ActionBubble tag={getNotificationTag(props.item.notification)} />
- </InboxCard.Icon>
+ ></InboxCard.Icon>
}
title={text().title}
preview={text().content}
@@ -1143,16 +1064,6 @@ export function TaskCardLayout(props: InboxCardLayoutProps) {
}
export function AiCardLayout(props: InboxCardLayoutProps) {
- const senderId = () => props.item.notification?.sender_id ?? undefined;
-
- const senderFallbackName = () => {
- return props.item.notification
- ? getNotificationSenderFallbackName(props.item.notification)
- : 'Ai';
- };
-
- const senderName = createSenderDisplayName(senderId, () => 'Macro');
-
const text = createMemo(() => {
const content = itemContent(props.item.entity, props.item.notification);
const location = entityLocation(props.item.entity);
@@ -1161,15 +1072,8 @@ export function AiCardLayout(props: InboxCardLayoutProps) {
return { title: props.item.entity.name, content };
}
- let action = 'responded';
- if (location) action = 'responded in';
-
return {
- title: buildActionLabel({
- sender: senderName(),
- action,
- location,
- }),
+ title: location || props.item.entity.name,
content,
};
});
@@ -1189,21 +1093,16 @@ export function AiCardLayout(props: InboxCardLayoutProps) {
when={props.item.notification}
fallback={
<EntityIcon
- class="size-5"
+ class="size-4"
targetType={getEntityIconType(props.item.entity)}
size="fill"
/>
}
>
- <Avatar
- senderId={senderId()}
- fallbackName={senderFallbackName()}
- />
+ <ActionBubble tag={getNotificationTag(props.item.notification)} />
</Show>
}
- >
- <ActionBubble tag={getNotificationTag(props.item.notification)} />
- </InboxCard.Icon>
+ ></InboxCard.Icon>
}
title={text().title}
preview={text().content}
@@ -1231,40 +1130,58 @@ export function EmailCardLayout(props: InboxCardLayoutProps) {
const text = createMemo(() => {
const subject = props.item.entity.name;
- let entitySnippet: string | undefined;
- if (props.item.entity.type === 'email') {
- entitySnippet = props.item.entity.snippet;
- }
-
return {
- title: buildActionLabel({
- sender: senderName(),
- action: `— ${subject || 'sent an email'}`,
- }),
- content: entitySnippet,
+ sender: senderName(),
+ subject,
+ content: '',
};
});
return (
- <BaseCard
- entityId={props.item.entity.id}
+ <InboxCard.Root
+ dimmed={!props.item.unread}
selected={props.selected}
highlighted={props.highlighted}
onClick={props.onClick}
- unread={props.item.unread}
- timestamp={props.item.timestamp}
- leading={
+ >
+ <div class="col-start-1 row-start-1 row-span-3">
<InboxCard.Icon
- fallback={
- <Avatar senderId={senderId()} fallbackName={senderFallbackName()} />
- }
- >
- <ActionBubble tag="new_email" />
- </InboxCard.Icon>
- }
- title={text().title}
- preview={text().content}
- />
+ fallback={<ActionBubble tag="new_email" />}
+ ></InboxCard.Icon>
+ </div>
+ <InboxCard.Body class="contents">
+ <InboxCard.Header class="col-start-2 row-start-1 self-center">
+ <InboxCard.Title class="flex items-center gap-1">
+ <Badge unread={props.item.unread} />
+ {text().sender}
+ </InboxCard.Title>
+ </InboxCard.Header>
+
+ <Show when={text().subject?.trim()}>
+ {(subject) => (
+ <InboxCard.Content class="col-start-2 row-start-2 truncate text-sm">
+ {subject()}
+ </InboxCard.Content>
+ )}
+ </Show>
+
+ <Show when={text().content?.trim()}>
+ {(value) => (
+ <InboxCard.Content class="col-start-2 row-start-3 truncate text-sm">
+ <StaticMarkdown
+ markdown={value()}
+ singleLine
+ theme={unifiedListMarkdownTheme}
+ />
+ </InboxCard.Content>
+ )}
+ </Show>
+ </InboxCard.Body>
+ <InboxTimestamp
+ timestamp={props.item.timestamp}
+ class="col-start-3 row-start-1 self-start justify-self-end"
+ />
+ </InboxCard.Root>
);
}
@@ -1276,10 +1193,22 @@ export function GithubCardLayout(props: InboxCardLayoutProps) {
const senderId = () => sender()?.id;
const senderFallbackName = () => sender()?.fallbackName;
- const avatarUrl = () => sender()?.imageUrl;
-
const senderName = createSenderDisplayName(senderId, senderFallbackName);
+ const status = createMemo(() => {
+ const metadata = props.item.notification?.notification_metadata;
+ if (
+ metadata?.tag === 'github_pr_status_changed' &&
+ typeof metadata.content.status === 'string'
+ ) {
+ return metadata.content.status;
+ }
+
+ if (!isGithubPrEntity(props.item.entity)) return;
+
+ return props.item.entity.metadata.status;
+ });
+
const text = createMemo(() => {
const entity = props.item.entity;
@@ -1289,7 +1218,7 @@ export function GithubCardLayout(props: InboxCardLayoutProps) {
)?.startsWith('github_');
let sender = entity.metadata.authorLogin;
- let action = 'opened';
+ let action = '';
if (hasGithubNotification) {
sender = senderName() ?? entity.metadata.authorLogin;
action = githubAction(props.item.notification);
@@ -1299,11 +1228,11 @@ export function GithubCardLayout(props: InboxCardLayoutProps) {
title: buildActionLabel({
sender,
action,
- location: githubLocation(entity),
}),
content:
getGithubTitle(entity, props.item.notification) ||
entity.metadata.name,
+ location: githubLocation(entity),
};
}
@@ -1311,57 +1240,75 @@ export function GithubCardLayout(props: InboxCardLayoutProps) {
title: buildActionLabel({
sender: senderName(),
action: githubAction(props.item.notification),
- location: githubLocation(entity),
}),
content: getGithubTitle(entity, props.item.notification) || entity.name,
+ location: githubLocation(entity),
};
});
return (
- <BaseCard
- entityId={props.item.entity.id}
+ <InboxCard.Root
+ dimmed={!props.item.unread}
selected={props.selected}
highlighted={props.highlighted}
onClick={props.onClick}
- unread={props.item.unread}
- timestamp={props.item.timestamp}
- leading={
- <Show
- when={avatarUrl()}
+ >
+ <div class="col-start-1 row-start-1 row-span-3">
+ <InboxCard.Icon
fallback={
- <InboxCard.Icon
+ <Show
+ when={
+ !props.item.notification ||
+ getNotificationTag(props.item.notification) ===
+ 'github_pr_status_changed'
+ }
fallback={
- <EntityIcon
- class="size-5"
- targetType="githubPullRequest"
- size="fill"
- theme="monochrome"
+ <ActionBubble
+ tag={
+ getNotificationTag(props.item.notification) ??
+ 'github_pr_status_changed'
+ }
/>
}
- />
+ >
+ <GithubStatusIcon status={status()} />
+ </Show>
}
- >
- <InboxCard.Icon
- fallback={
- <Avatar
- senderId={senderId()}
- fallbackName={senderFallbackName()}
- imageUrl={avatarUrl()}
+ ></InboxCard.Icon>
+ </div>
+ <InboxCard.Body class="contents">
+ <InboxCard.Header class="col-start-2 row-start-1 self-center">
+ <InboxCard.Title class="flex items-center gap-1">
+ <Badge unread={props.item.unread} />
+ {text().title}
+ </InboxCard.Title>
+ </InboxCard.Header>
+
+ <Show when={text().content?.trim()}>
+ {(value) => (
+ <InboxCard.Content class="col-start-2 row-start-2 truncate text-sm text-ink/60">
+ <StaticMarkdown
+ markdown={value()}
+ singleLine
+ theme={unifiedListMarkdownTheme}
/>
- }
- >
- <ActionBubble
- tag={
- getNotificationTag(props.item.notification) ??
- 'github_pr_status_changed'
- }
- />
- </InboxCard.Icon>
+ </InboxCard.Content>
+ )}
</Show>
- }
- title={text().title}
- preview={text().content}
- />
+
+ <Show when={text().location}>
+ {(location) => (
+ <InboxCard.Content class="col-start-2 row-start-3 truncate text-xs text-ink/40">
+ {location()}
+ </InboxCard.Content>
+ )}
+ </Show>
+ </InboxCard.Body>
+ <InboxTimestamp
+ timestamp={props.item.timestamp}
+ class="col-start-3 row-start-1 self-start justify-self-end"
+ />
+ </InboxCard.Root>
);
}
@@ -1421,15 +1368,16 @@ export function CallCardLayout(props: InboxCardLayoutProps) {
<InboxCard.Icon
fallback={
<EntityIcon
- class="size-5"
+ class="size-4"
targetType="call"
size="fill"
theme="monochrome"
/>
}
- />
+ ></InboxCard.Icon>
}
title={text().title}
+ preview={text().content}
/>
);
}
@@ -1454,7 +1402,7 @@ export function GenericCardLayout(props: InboxCardLayoutProps) {
<InboxCard.Icon
fallback={
<EntityIcon
- class="size-5"
+ class="size-4"
targetType={getEntityIconType(props.item.entity)}
size="fill"
theme="monochrome"
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-expansion.tsx b/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-expansion.tsx
deleted file mode 100644
index 0b6b5bdbac..0000000000
--- a/js/app/packages/app/component/next-soup/soup-view/views/inbox/inbox-expansion.tsx
+++ /dev/null
@@ -1,45 +0,0 @@
-import {
- createContext,
- createSignal,
- type FlowComponent,
- useContext,
-} from 'solid-js';
-
-type InboxExpansion = {
- isExpanded: (entityId: string) => boolean;
- toggle: (entityId: string) => void;
-};
-
-const InboxExpansionContext = createContext<InboxExpansion>();
-
-/**
- * View-level expand/collapse state for inbox rows (which thread rows have their
- * reply sub-items open). Owned above the virtualizer so it survives rows
- * unmounting as they scroll out of view — the card's own local state can't,
- * since virtua remounts offscreen rows.
- */
-export const InboxExpansionProvider: FlowComponent = (props) => {
- // Set behind a signal with `equals: false` so mutating it in place still
- // notifies the rows that read `isExpanded`.
- const [expanded, setExpanded] = createSignal(new Set<string>(), {
- equals: false,
- });
-
- const value: InboxExpansion = {
- isExpanded: (entityId) => expanded().has(entityId),
- toggle: (entityId) =>
- setExpanded((set) => {
- if (set.has(entityId)) set.delete(entityId);
- else set.add(entityId);
- return set;
- }),
- };
-
- return (
- <InboxExpansionContext.Provider value={value}>
- {props.children}
- </InboxExpansionContext.Provider>
- );
-};
-
-export const useInboxExpansion = () => useContext(InboxExpansionContext);
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/inbox/utils.ts b/js/app/packages/app/component/next-soup/soup-view/views/inbox/utils.ts
index 9483a9aa51..2b22b7cde1 100644
--- a/js/app/packages/app/component/next-soup/soup-view/views/inbox/utils.ts
+++ b/js/app/packages/app/component/next-soup/soup-view/views/inbox/utils.ts
@@ -6,7 +6,6 @@ import {
import type { SoupProperty } from '@service-storage/generated/schemas/soupProperty';
import {
differenceInDays,
- differenceInHours,
differenceInMilliseconds,
differenceInMonths,
differenceInWeeks,
@@ -177,11 +176,15 @@ export function formatCompactRelativeTimestamp(value: string) {
if (Number.isNaN(date.getTime())) return value;
const now = new Date();
- const ageMs = differenceInMilliseconds(now, date);
- if (ageMs < 12 * 60 * 60 * 1000) return format(date, 'p');
+ const ageMs = Math.max(0, differenceInMilliseconds(now, date));
+ const seconds = Math.floor(ageMs / 1000);
+ if (seconds < 60) return format(date, 'p');
- const hours = differenceInHours(now, date);
- if (hours < 24) return `${Math.max(12, hours)}h`;
+ const minutes = Math.floor(seconds / 60);
+ if (minutes < 60) return `${minutes}m`;
+
+ const hours = Math.floor(minutes / 60);
+ if (hours < 24) return `${hours}h`;
const days = differenceInDays(now, date);
if (days < 7) return `${Math.max(1, days)}d`;
diff --git a/js/app/packages/entity/src/components/MultiSelectCheckbox.tsx b/js/app/packages/entity/src/components/MultiSelectCheckbox.tsx
index 8df30c2683..14b7dc9411 100644
--- a/js/app/packages/entity/src/components/MultiSelectCheckbox.tsx
+++ b/js/app/packages/entity/src/components/MultiSelectCheckbox.tsx
@@ -4,6 +4,7 @@ import { Show } from 'solid-js';
interface MultiSelectCheckboxProps {
checked?: boolean;
+ showBorder?: boolean;
onChecked?: (checked: boolean, shiftKey: boolean) => void;
}
@@ -31,6 +32,7 @@ export function MultiSelectCheckbox(props: MultiSelectCheckboxProps) {
class={cn(
'size-4 p-0.5 flex items-center justify-center rounded-xs group-hover/button:border-accent group-hover/button:border pointer-events-none',
{
+ 'border border-edge': props.showBorder,
'bg-accent border border-accent': props.checked,
}
)}