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.

Revert "Calls tab: gallery view by default with a gallery/list toggle" (#4555) (#4575)

teo8d3371a83f35
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 314f144467..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
@@ -78,15 +78,6 @@ export function SoupFiltersBar() {
return content.type === 'component' && content.id === 'search';
});
- // The calls view has no sort/group/filter chips, so its toolbar would hold
- // only the preview button — skip both toolbar portals there so the empty
- // bar collapses entirely (SplitPanel hides a toolbar with no content).
- // Space still toggles the preview via the hotkey above.
- const isCallsView = createMemo(() => {
- const content = panel.handle.content();
- return content.type === 'component' && content.id === 'calls';
- });
-
// The new inbox hides sort (it's fixed to updated_at for this view).
const newInboxFlag = useFeatureFlag(ENABLE_NEW_INBOX_FLAG, {
enabledOverride: ENABLE_NEW_INBOX_OVERRIDE,
@@ -102,36 +93,34 @@ export function SoupFiltersBar() {
return (
<Show when={!isMobile()}>
- <Show when={!isCallsView()}>
- <SplitToolbarLeft>
- <div class="flex items-start gap-1 min-w-0 flex-1">
- <Show when={!isSearchView()} fallback={<SearchFiltersRow />}>
- <Show when={!isNewInbox()}>
- <SoupViewContextSort />
- </Show>
- <SoupViewContextGroup />
- <UnifiedFilterDropdown
- open={filterDropdownOpen}
- onOpenChange={setFilterDropdownOpen}
- />
+ <SplitToolbarLeft>
+ <div class="flex items-start gap-1 min-w-0 flex-1">
+ <Show when={!isSearchView()} fallback={<SearchFiltersRow />}>
+ <Show when={!isNewInbox()}>
+ <SoupViewContextSort />
</Show>
- </div>
- </SplitToolbarLeft>
- <SplitToolbarRight>
- <Tooltip hotkey={TOKENS.unifiedList.togglePreview} label="Preview">
- <Button
- onClick={togglePreview}
- variant="base"
- size="sm"
- depth={2}
- class="bg-surface"
- >
- {soup.previewEntity() ? <EyeSlashIcon /> : <EyeIcon />}
- <span>Preview</span>
- </Button>
- </Tooltip>
- </SplitToolbarRight>
- </Show>
+ <SoupViewContextGroup />
+ <UnifiedFilterDropdown
+ open={filterDropdownOpen}
+ onOpenChange={setFilterDropdownOpen}
+ />
+ </Show>
+ </div>
+ </SplitToolbarLeft>
+ <SplitToolbarRight>
+ <Tooltip hotkey={TOKENS.unifiedList.togglePreview} label="Preview">
+ <Button
+ onClick={togglePreview}
+ variant="base"
+ size="sm"
+ depth={2}
+ class="bg-surface"
+ >
+ {soup.previewEntity() ? <EyeSlashIcon /> : <EyeIcon />}
+ <span>Preview</span>
+ </Button>
+ </Tooltip>
+ </SplitToolbarRight>
{/* Active filters bar - shown below the toolbar when there are filters */}
<Show when={!isSearchView()}>
<SoupActiveFiltersBar
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 547f01e87c..73a63818da 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
@@ -39,12 +39,6 @@ import {
SoupViewTabs,
useApplyPreset,
} from '@app/component/next-soup/soup-view/soup-view-tabs';
-import {
- CallsGalleryRow,
- CallsLayoutToggle,
- callsLayoutMode,
- getCallsGalleryColumns,
-} from '@app/component/next-soup/soup-view/views/calls/CallsGallery';
import { CompanyKanban } from '@app/component/next-soup/soup-view/views/companies/CompanyKanban';
import { CompanyListEntity } from '@app/component/next-soup/soup-view/views/companies/CompanyListEntity';
import { ResponsiveCompanyListHeader } from '@app/component/next-soup/soup-view/views/companies/CompanyListHeader';
@@ -372,14 +366,6 @@ const useSoupNotificationInvalidators = () => {
const SOUP_LIST_STATE_ENTRY_KEY = 'soup.listState';
-/**
- * One virtualizer item: a normal soup row, or (calls gallery mode) a chunk of
- * consecutive call rows rendered as one row of cards.
- */
-type DisplayRow =
- | { kind: 'single'; row: SoupRow }
- | { kind: 'cards'; rows: SoupRow[] };
-
type SoupListEntryState = {
focus: string | undefined;
virtualCache?: CacheSnapshot;
@@ -682,9 +668,6 @@ export const SoupView = (props: SoupViewProps) => {
collapsed={() => <CollapsedSoupViewTabs />}
containerClass="h-full"
/>
- <Show when={isComponentListView('calls')}>
- <CallsLayoutToggle />
- </Show>
</Show>
</Show>
<Show
@@ -899,100 +882,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
const { paneVisible, placeholderVisible, previewVisible } =
usePreviewPaneVisiblity();
- // On desktop the calls view defaults to a gallery of call cards instead of
- // list rows (toggleable from the header). The gallery only renders while
- // the list column is wide enough for at least two card columns and while
- // no search is active (hit snippets belong in the list) — otherwise the
- // rows fall back to the normal list.
- const [listColumnRef, setListColumnRef] = createSignal<HTMLElement>();
- const listColumnSize = createElementSize(listColumnRef);
-
- const galleryColumns = createMemo(() => {
- if (isMobile() || currentView() !== 'calls') return 0;
- if (callsLayoutMode() !== 'gallery') return 0;
- if (searchText()) return 0;
- return getCallsGalleryColumns(listColumnSize.width ?? 0);
- });
-
- // What the virtualizer actually renders: plain rows in list mode; in
- // gallery mode consecutive call rows are chunked into card rows of
- // `galleryColumns` while group headers and load-more rows stay full-width.
- const displayRows = createMemo<DisplayRow[]>(() => {
- const columns = galleryColumns();
- const allRows = rows();
-
- if (columns === 0) {
- return allRows.map((row): DisplayRow => ({ kind: 'single', row }));
- }
-
- const out: DisplayRow[] = [];
- let chunk: SoupRow[] = [];
- const flush = () => {
- if (chunk.length) {
- out.push({ kind: 'cards', rows: chunk });
- chunk = [];
- }
- };
-
- for (const row of allRows) {
- if (row.getIsGrouped() || row.getIsLoadMore()) {
- flush();
- out.push({ kind: 'single', row });
- continue;
- }
- // Rows of collapsed groups render as empty items in list mode; skip
- // them here so they don't leave blank cells in a card row.
- if (row.group && !row.group.isExpanded()) continue;
- if (row.original.type !== 'call') {
- flush();
- out.push({ kind: 'single', row });
- continue;
- }
- chunk.push(row);
- if (chunk.length === columns) flush();
- }
- flush();
- return out;
- });
-
- const displayIndexByRowIndex = createMemo(() => {
- const map = new Map<number, number>();
- displayRows().forEach((displayRow, displayIndex) => {
- if (displayRow.kind === 'single') {
- map.set(displayRow.row.index, displayIndex);
- } else {
- for (const row of displayRow.rows) map.set(row.index, displayIndex);
- }
- });
- return map;
- });
-
- // Navigation code scrolls by index into the full rows() array, but the
- // virtualizer holds display rows (in gallery mode several calls share one
- // card row) — remap so scroll targets stay aligned.
- const adjustedVirtualizerHandle = createMemo<VirtualizerHandle | undefined>(
- () => {
- const handle = virtualizerHandle();
- if (!handle) return handle;
-
- return new Proxy(handle, {
- get(target, prop) {
- if (prop === 'scrollToIndex') {
- return (
- index: number,
- opts?: Parameters<VirtualizerHandle['scrollToIndex']>[1]
- ) =>
- target.scrollToIndex(
- displayIndexByRowIndex().get(index) ?? index,
- opts
- );
- }
- const value = Reflect.get(target, prop);
- return typeof value === 'function' ? value.bind(target) : value;
- },
- });
- }
- );
const focusFirstEntity = () => {
const allRows = rows();
@@ -1004,16 +893,12 @@ export const SoupViewList = (props: SoupViewListProps) => {
const result = soup.navigate.toIndex(firstEntityIndex);
- // The calls view has no preview button in its chrome, so never auto-open
- // the pane there — only keep an already-open pane (Space) in sync.
- if (paneVisible() && (currentView() !== 'calls' || soup.previewEntity())) {
+ if (paneVisible()) {
soup.setPreviewEntity(result?.row.id);
}
if (result) {
- adjustedVirtualizerHandle()?.scrollToIndex(result.index, {
- align: 'nearest',
- });
+ virtualizerHandle()?.scrollToIndex(result.index, { align: 'nearest' });
}
};
@@ -1086,7 +971,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
scopeId: scopeId(),
soup,
splitHandle: panel.handle,
- virtualizerHandle: adjustedVirtualizerHandle,
+ virtualizerHandle,
hasNextPage: source.hasNextPage,
isFetching: source.isFetching,
isFetchingNextPage: source.isFetchingNextPage,
@@ -1119,7 +1004,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
scopeId: scopeId(),
soup,
splitHandle: panel.handle,
- virtualizerHandle: adjustedVirtualizerHandle,
+ virtualizerHandle,
previewState: () => !!soup.previewEntity(),
currentView,
activeTab,
@@ -1418,7 +1303,6 @@ export const SoupViewList = (props: SoupViewListProps) => {
maxSize={paneVisible() ? 840 : undefined}
>
<div
- ref={setListColumnRef}
class={cn(
'@container/u-list size-full unified-list-root flex flex-col relative',
paneVisible() && 'border-r border-edge-muted'
@@ -1509,42 +1393,9 @@ export const SoupViewList = (props: SoupViewListProps) => {
virtualizerRef={registerVirtualizerHandler}
onScrollBottom={debouncedFetchMore}
scrollBottomOffset={300}
- rows={displayRows()}
+ rows={rows()}
>
- {(displayRow, i) => {
- if (displayRow.kind === 'cards') {
- return (
- <>
- <CallsGalleryRow
- rows={displayRow.rows}
- columns={galleryColumns()}
- onEntityClick={(row, event) => {
- onEntityClick({
- type: 'entity',
- entity: row.original,
- event,
- location: undefined,
- rowIndex: row.index,
- });
- }}
- onEntityMouseMove={(row) => {
- if (isKeypressActive()) return;
- if (
- soup.previewEntity() ||
- isNewInboxEnabled()
- )
- return;
- soup.focus.setIndex(row.index);
- }}
- />
- <Show when={i() === displayRows().length - 1}>
- <div class="h-15 mobile:hidden" />
- </Show>
- </>
- );
- }
-
- const row = displayRow.row;
+ {(row, i) => {
const timestamp = () => {
if (row.original.sortTs)
return row.original.sortTs;
@@ -1694,7 +1545,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
) =>
handleMultiSelectChecked({
entity: row.original,
- entityIndex: row.index,
+ entityIndex: i(),
next,
shiftKey: shiftKey ?? false,
})
@@ -1745,7 +1596,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
</Switch>
<Show
when={
- i() === displayRows().length - 1 &&
+ i() === rows().length - 1 &&
isSearchServiceLoading()
}
>
@@ -1754,7 +1605,7 @@ export const SoupViewList = (props: SoupViewListProps) => {
Searching...
</div>
</Show>
- <Show when={i() === displayRows().length - 1}>
+ <Show when={i() === rows().length - 1}>
{/* Desktop-only: mobile clearance comes
from the in-scroll trailing spacer. */}
<div class="h-15 mobile:hidden" />
@@ -1845,11 +1696,11 @@ interface SoupListProps {
virtualizerClass?: string;
itemSize?: number;
overscan?: number;
- children: (row: DisplayRow, index: Accessor<number>) => JSX.Element;
+ children: (row: SoupRow, index: Accessor<number>) => JSX.Element;
onScrollOffsetChange?: (offset: number) => void;
onScrollBottom?: VoidFunction;
scrollBottomOffset?: number;
- rows: DisplayRow[];
+ rows: SoupRow[];
cache?: CacheSnapshot;
}
diff --git a/js/app/packages/app/component/next-soup/soup-view/views/calls/CallsGallery.tsx b/js/app/packages/app/component/next-soup/soup-view/views/calls/CallsGallery.tsx
deleted file mode 100644
index df45f6db88..0000000000
--- a/js/app/packages/app/component/next-soup/soup-view/views/calls/CallsGallery.tsx
+++ /dev/null
@@ -1,256 +0,0 @@
-import type { SoupRow } from '@app/component/next-soup/create-soup-state';
-import { SoupEntityContextMenu } from '@app/component/next-soup/soup-view/soup-entity-context-menu';
-import { usePreference } from '@app/preferences/use-preference';
-import { formatCallDuration } from '@block-call/utils';
-import { EntityIcon } from '@core/component/EntityIcon';
-import { TabsInset } from '@core/component/TabsInset';
-import { UserIcon } from '@core/component/UserIcon';
-import { CallRecordName } from '@entity/components/CallRecordName';
-import { Entity } from '@entity/entity';
-import type { CallEntity } from '@entity/types/entity';
-import ListIcon from '@phosphor/list.svg';
-import SquaresFourIcon from '@phosphor/squares-four.svg';
-import { usePropertyEntityDisplay } from '@property/hooks';
-import { useCallRecordQuery } from '@queries/call/call';
-import { EntityType } from '@service-properties/generated/schemas/entityType';
-import { cn, Tooltip } from '@ui';
-import { createSignal, For, onCleanup, Show } from 'solid-js';
-
-export type CallsLayoutMode = 'gallery' | 'list';
-
-/**
- * Module-scope so the header toggle and the list body read the same reactive
- * source (usePreference creates an independent signal per call, so two
- * component-level calls with the same key would not stay in sync live).
- */
-const [callsLayoutMode, setCallsLayoutMode] = usePreference<CallsLayoutMode>(
- 'macro:pref:soup:calls:layout',
- { default: 'gallery' }
-);
-
-export { callsLayoutMode };
-
-/**
- * Narrowest list-column width (px) the gallery renders at. Below this the
- * two-column grid would collapse to a single column, so the gallery falls
- * back to normal list rows regardless of the toggle.
- */
-const CALLS_GALLERY_MIN_WIDTH = 520;
-const CALLS_GALLERY_FOUR_COLUMN_WIDTH = 896;
-
-/** Card columns for a given list-column width; 0 disables the gallery. */
-export function getCallsGalleryColumns(width: number): number {
- if (width < CALLS_GALLERY_MIN_WIDTH) return 0;
- return width < CALLS_GALLERY_FOUR_COLUMN_WIDTH ? 2 : 4;
-}
-
-/** Finder-style gallery/list switch shown in the calls view header. */
-export function CallsLayoutToggle() {
- return (
- <TabsInset
- list={[
- {
- value: 'gallery',
- label: (
- <Tooltip label="Gallery view" as="span">
- <span class="flex items-center" aria-label="Gallery view">
- <SquaresFourIcon class="size-3.5" />
- </span>
- </Tooltip>
- ),
- },
- {
- value: 'list',
- label: (
- <Tooltip label="List view" as="span">
- <span class="flex items-center" aria-label="List view">
- <ListIcon class="size-3.5" />
- </span>
- </Tooltip>
- ),
- },
- ]}
- value={callsLayoutMode()}
- onChange={(value) => setCallsLayoutMode(value as CallsLayoutMode)}
- />
- );
-}
-
-const MAX_ATTENDEE_PILLS = 3;
-
-function AttendeePill(props: { userId: string }) {
- const { name } = usePropertyEntityDisplay(
- () => props.userId,
- () => EntityType.USER,
- { fallbackIcon: null }
- );
- return (
- <span class="inline-flex min-w-0 items-center gap-1.5 rounded-full border border-edge-muted bg-surface py-0.5 pl-0.5 pr-2 text-xs leading-none text-ink-muted">
- <span class="size-4 shrink-0 overflow-hidden rounded-full">
- <UserIcon id={props.userId} isDeleted={false} size="fill" />
- </span>
- <span class="ph-no-capture max-w-24 truncate">{name()}</span>
- </span>
- );
-}
-
-/**
- * Don't fetch a card's record until it has stayed mounted this long —
- * flinging the scrollbar through a large calls list mounts and unmounts
- * hundreds of cards, and those fetches are heavy (full transcript) and
- * uncancellable. Cards scrolled past never fetch.
- */
-const CARD_FETCH_SETTLE_MS = 150;
-
-/**
- * Treat a fetched record as fresh for this long so scrolling a card back
- * into view reuses the cache instead of refetching. The preview image is a
- * presigned URL with a 1h TTL, so a 10-minute window is comfortably safe;
- * the opened call entity uses its own observer with the default staleTime
- * and still refetches fresh data.
- */
-const CARD_RECORD_STALE_MS = 10 * 60 * 1000;
-const CARD_RECORD_GC_MS = 30 * 60 * 1000;
-
-/**
- * The recording preview only exists on the full call record — the soup list
- * payload doesn't carry it — so each card fetches its record (shared with the
- * cache the opened call entity uses) and renders the presigned poster image.
- */
-function CallCardPreview(props: { entity: CallEntity }) {
- const [settled, setSettled] = createSignal(false);
- const settleTimer = setTimeout(() => setSettled(true), CARD_FETCH_SETTLE_MS);
- onCleanup(() => clearTimeout(settleTimer));
-
- const record = useCallRecordQuery(() => props.entity.id, {
- enabled: settled,
- staleTime: CARD_RECORD_STALE_MS,
- gcTime: CARD_RECORD_GC_MS,
- });
- const [failed, setFailed] = createSignal(false);
- const previewUrl = () =>
- failed() ? undefined : record.data?.recordingPreviewUrl;
-
- return (
- <div class="relative aspect-video w-full shrink-0 overflow-hidden bg-ink/5">
- <Show
- when={previewUrl()}
- fallback={
- <div class="grid size-full place-items-center">
- <span class="size-7 text-ink-extra-muted">
- <EntityIcon targetType="call" size="fill" theme="monochrome" />
- </span>
- </div>
- }
- >
- {(url) => (
- <img
- src={url()}
- alt=""
- draggable={false}
- loading="lazy"
- onError={() => setFailed(true)}
- class="size-full object-cover"
- />
- )}
- </Show>
- <Show when={props.entity.durationMs}>
- {(ms) => (
- <span class="absolute bottom-1.5 right-1.5 rounded bg-black/60 px-1.5 py-0.5 text-[10px] font-medium tabular-nums text-white">
- {formatCallDuration(ms())}
- </span>
- )}
- </Show>
- </div>
- );
-}
-
-function CallCard(props: {
- entity: CallEntity;
- highlighted: boolean;
- onClick: (event: MouseEvent) => void;
- onMouseMove?: () => void;
-}) {
- const overflowCount = () =>
- props.entity.participantIds.length - MAX_ATTENDEE_PILLS;
-
- return (
- <div
- role="button"
- data-highlighted={props.highlighted || undefined}
- onClick={props.onClick}
- onMouseMove={props.onMouseMove}
- class={cn(
- 'flex size-full min-w-0 cursor-pointer flex-col overflow-hidden rounded-xl border border-edge-muted bg-surface text-left',
- 'hover:bg-hover/30 data-highlighted:border-accent/40 data-highlighted:bg-hover/30'
- )}
- >
- <CallCardPreview entity={props.entity} />
- <div class="flex min-h-0 flex-1 flex-col gap-1.5 p-3">
- <div class="flex items-baseline gap-2">
- <span class="ph-no-capture min-w-0 flex-1 truncate text-sm font-semibold">
- <CallRecordName entity={props.entity} />
- </span>
- <span class="shrink-0 text-xs font-medium text-ink-extra-muted">
- <Entity.Timestamp entity={props.entity} />
- </span>
- </div>
- <Show when={props.entity.summary}>
- {(summary) => (
- <p class="ph-no-capture line-clamp-3 text-xs leading-relaxed text-ink/60">
- {summary()}
- </p>
- )}
- </Show>
- <Show when={props.entity.participantIds.length > 0}>
- <div class="mt-auto flex min-w-0 flex-wrap items-center gap-1 pt-1">
- <For
- each={props.entity.participantIds.slice(0, MAX_ATTENDEE_PILLS)}
- >
- {(userId) => <AttendeePill userId={userId} />}
- </For>
- <Show when={overflowCount() > 0}>
- <span class="rounded-full bg-ink/10 px-1.5 py-1 text-xs leading-none text-ink-extra-muted tabular-nums">
- +{overflowCount()}
- </span>
- </Show>
- </div>
- </Show>
- </div>
- </div>
- );
-}
-
-/**
- * One virtualized row of the calls gallery: up to `columns` call cards laid
- * out on a fixed grid. Cards keep click/focus/context-menu parity with list
- * rows.
- */
-export function CallsGalleryRow(props: {
- rows: SoupRow[];
- columns: number;
- onEntityClick: (row: SoupRow, event: MouseEvent) => void;
- onEntityMouseMove?: (row: SoupRow) => void;
-}) {
- return (
- <div
- class="grid items-stretch gap-2 px-2 py-1"
- style={{
- 'grid-template-columns': `repeat(${props.columns}, minmax(0, 1fr))`,
- }}
- >
- <For each={props.rows}>
- {(row) => (
- <SoupEntityContextMenu entity={row.original}>
- <CallCard
- entity={row.original as CallEntity}
- highlighted={row.isFocused()}
- onClick={(event) => props.onEntityClick(row, event)}
- onMouseMove={() => props.onEntityMouseMove?.(row)}
- />
- </SoupEntityContextMenu>
- )}
- </For>
- </div>
- );
-}
diff --git a/js/app/packages/queries/call/call.ts b/js/app/packages/queries/call/call.ts
index 661a106993..47bc269fc7 100644
--- a/js/app/packages/queries/call/call.ts
+++ b/js/app/packages/queries/call/call.ts
@@ -145,24 +145,11 @@ export function useLeaveCallMutation() {
}));
}
-export function useCallRecordQuery(
- callId: Accessor<string>,
- options?: {
- /** Gate the fetch (e.g. until a virtualized card settles in view). */
- enabled?: Accessor<boolean>;
- /** How long cached data counts as fresh for this observer (ms). */
- staleTime?: number;
- /** How long unobserved data stays cached (ms). */
- gcTime?: number;
- }
-) {
+export function useCallRecordQuery(callId: Accessor<string>) {
return useQuery(() => ({
queryKey: callKeys.record(callId()).queryKey,
queryFn: async () =>
await throwOnErr(() => callServiceClient.getCallRecord(callId())),
- enabled: options?.enabled ? options.enabled() : true,
- staleTime: options?.staleTime,
- gcTime: options?.gcTime,
}));
}