Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
feat(soup): collapsible view tabs with dropdown fallback (#2133)
Evan Hutnikb9ccc26f4fb2
diff --git a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsxindex 505ea1ab16..6d1389fbfe 100644--- a/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx+++ b/js/app/packages/app/component/next-soup/soup-view/soup-view-tabs.tsx@@ -21,6 +21,57 @@ import {SegmentedControl as KSegmentedControl,type SegmentedControlRootProps,} from '@kobalte/core/segmented-control';+import { DropdownMenu } from '@kobalte/core/dropdown-menu';+import ChevronDownIcon from '@icon/regular/caret-down.svg';++type TabItem = { value: string; label: string };++/** Views that have tab definitions. Shared between VIEW_TAB_LISTS and VIEW_TAB_PRESETS. */+type TabbedListView = Extract<+ ListView,+ 'inbox' | 'agents' | 'mail' | 'documents' | 'tasks' | 'channels' | 'folders'+>;++/** Tab definitions for each list view. */+export const VIEW_TAB_LISTS: Record<TabbedListView, TabItem[]> = {+ inbox: [+ { value: 'signal', label: 'Signal' },+ { value: 'noise', label: 'Noise' },+ { value: 'all', label: 'All' },+ ],+ agents: [+ { value: 'owned', label: 'Owned' },+ { value: 'running', label: 'Running' },+ { value: 'shared', label: 'Shared' },+ ],+ mail: [+ { value: 'important', label: 'Important' },+ { value: 'noise', label: 'Noise' },+ { value: 'drafts', label: 'Drafts' },+ { value: 'sent', label: 'Sent' },+ { value: 'shared', label: 'Shared' },+ ],+ documents: [+ { value: 'owned', label: 'Owned' },+ { value: 'shared', label: 'Shared' },+ { value: 'attachments', label: 'Attachments' },+ { value: 'all', label: 'All' },+ ],+ tasks: [+ { value: 'assigned-to-me', label: 'Assigned' },+ { value: 'created-by-me', label: 'Created' },+ { value: 'all', label: 'All' },+ ],+ channels: [+ { value: 'recent', label: 'Recent' },+ { value: 'people', label: 'People' },+ { value: 'teams', label: 'Teams' },+ ],+ folders: [+ { value: 'owned', label: 'Owned' },+ { value: 'all', label: 'All' },+ ],+};const useCurrentListView = () => {const panel = useSplitPanelOrThrow();@@ -72,176 +123,80 @@ export const useApplyPreset = () => {export const SoupViewTabs = () => {const listView = useCurrentListView();- const isComponentListView = (view: ListView) => {- return listView() === view;- };-return (<Switch>- <Match when={isComponentListView('inbox')}>- <InboxTabs />- </Match>- <Match when={isComponentListView('agents')}>- <AgentsTabs />- </Match>- <Match when={isComponentListView('mail')}>- <MailTabs />- </Match>- <Match when={isComponentListView('documents')}>- <DocumentsTabs />- </Match>- <Match when={isComponentListView('tasks')}>- <TasksTabs />- </Match>- <Match when={isComponentListView('channels')}>- <ChannelsTabs />- </Match>- <Match when={isComponentListView('folders')}>- <FilesTabs />- </Match>+ <For each={Object.keys(VIEW_TAB_LISTS) as TabbedListView[]}>+ {(v) => (+ <Match when={listView() === v}>+ <ViewTabs view={v} />+ </Match>+ )}+ </For></Switch>);};-const InboxTabs = () => {- const { applyTabPreset } = useApplyPreset();- const { activeTab } = useSoupView();-- return (- <div>- <SegmentedControl- list={[- { value: 'signal', label: 'Signal' },- { value: 'noise', label: 'Noise' },- { value: 'all', label: 'All' },- ]}- value={activeTab()}- defaultValue={VIEW_TAB_PRESETS.inbox.default}- onChange={(value) => applyTabPreset('inbox', value)}- />- </div>- );-};--const AgentsTabs = () => {- const { applyTabPreset } = useApplyPreset();- const { activeTab } = useSoupView();-- return (- <div>- <SegmentedControl- list={[- { value: 'owned', label: 'Owned' },- { value: 'running', label: 'Running' },- { value: 'shared', label: 'Shared' },- ]}- value={activeTab()}- defaultValue={VIEW_TAB_PRESETS.agents.default}- onChange={(value) => applyTabPreset('agents', value)}- />- </div>- );-};--const MailTabs = () => {- const { applyTabPreset } = useApplyPreset();- const { activeTab } = useSoupView();-- return (- <div>- <SegmentedControl- list={[- { value: 'important', label: 'Important' },- { value: 'noise', label: 'Noise' },- { value: 'drafts', label: 'Drafts' },- { value: 'sent', label: 'Sent' },- { value: 'shared', label: 'Shared' },- ]}- value={activeTab()}- defaultValue={VIEW_TAB_PRESETS.mail.default}- onChange={(value) => applyTabPreset('mail', value)}- />- </div>- );-};--const DocumentsTabs = () => {- const { applyTabPreset } = useApplyPreset();- const { activeTab } = useSoupView();-- return (- <div>- <SegmentedControl- list={[- { value: 'owned', label: 'Owned' },- { value: 'shared', label: 'Shared' },- { value: 'attachments', label: 'Attachments' },- { value: 'all', label: 'All' },- ]}- value={activeTab()}- defaultValue={VIEW_TAB_PRESETS.documents.default}- onChange={(value) => applyTabPreset('documents', value)}- />- </div>- );-};--const TasksTabs = () => {+const ViewTabs = (props: { view: TabbedListView }) => {const { applyTabPreset } = useApplyPreset();const { activeTab } = useSoupView();+ const list = () => VIEW_TAB_LISTS[props.view];return (<div><SegmentedControl- list={[- { value: 'assigned-to-me', label: 'Assigned' },- { value: 'created-by-me', label: 'Created' },- { value: 'all', label: 'All' },- ]}+ list={list()}value={activeTab()}- defaultValue={VIEW_TAB_PRESETS.tasks.default}- onChange={(value) => applyTabPreset('tasks', value)}+ defaultValue={VIEW_TAB_PRESETS[props.view].default}+ onChange={(value) => applyTabPreset(props.view, value)}/></div>);};-const ChannelsTabs = () => {+/** Compact dropdown variant of tabs, used when the header is too narrow for the full segmented control. */+export const CollapsedSoupViewTabs = () => {+ const listView = useCurrentListView();const { applyTabPreset } = useApplyPreset();const { activeTab } = useSoupView();- return (- <div>- <SegmentedControl- list={[- { value: 'recent', label: 'Recent' },- { value: 'people', label: 'People' },- { value: 'teams', label: 'Teams' },- ]}- value={activeTab()}- defaultValue={VIEW_TAB_PRESETS.channels.default}- onChange={(value) => applyTabPreset('channels', value)}- />- </div>- );-};+ const list = createMemo(() => {+ const view = listView();+ if (!view || !(view in VIEW_TAB_LISTS)) return [];+ return VIEW_TAB_LISTS[view as TabbedListView];+ });-const FilesTabs = () => {- const { applyTabPreset } = useApplyPreset();- const { activeTab } = useSoupView();+ const activeLabel = createMemo(() => {+ const tab = activeTab();+ return list().find((item) => item.value === tab)?.label ?? list()[0]?.label;+ });return (- <div>- <SegmentedControl- list={[- { value: 'owned', label: 'Owned' },- { value: 'all', label: 'All' },- ]}- value={activeTab()}- defaultValue={VIEW_TAB_PRESETS.folders.default}- onChange={(value) => applyTabPreset('folders', value)}- />- </div>+ <DropdownMenu placement="bottom-start" gutter={4}>+ <DropdownMenu.Trigger class="flex items-center gap-1 px-2 py-1 text-xs font-medium rounded-xs border border-edge-muted hover:bg-ink/6 transition-colors">+ <span class="truncate">{activeLabel()}</span>+ <ChevronDownIcon class="size-3 shrink-0" />+ </DropdownMenu.Trigger>+ <DropdownMenu.Portal>+ <DropdownMenu.Content class="z-action-menu bg-surface-0 border border-edge-muted rounded-sm shadow-sm p-1">+ <For each={list()}>+ {(item) => (+ <DropdownMenu.Item+ class="w-full px-2 py-1.5 text-left text-xs transition-colors hover:bg-ink/5 focus:bg-ink/5 outline-none cursor-default rounded-md"+ classList={{+ 'font-semibold': activeTab() === item.value,+ }}+ onSelect={() => {+ const view = listView();+ if (view) applyTabPreset(view, item.value);+ }}+ >+ {item.label}+ </DropdownMenu.Item>+ )}+ </For>+ </DropdownMenu.Content>+ </DropdownMenu.Portal>+ </DropdownMenu>);};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.tsxindex ac08ffecc8..392c674755 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@@ -83,6 +83,7 @@ import type { SoupItemsQueryFilters } from '@queries/soup/items';import type { FilterID } from '@app/component/next-soup/filters';import {SoupViewTabs,+ CollapsedSoupViewTabs,useApplyPreset,} from '@app/component/next-soup/soup-view/soup-view-tabs';import { SoupViewCreateButton } from '@app/component/next-soup/soup-view/soup-view-create-button';@@ -229,7 +230,16 @@ export const SoupView = (props: SoupViewProps) => {</h1></Show><Show when={!narrowSearchExpanded()}>- <SoupViewTabs />+ <CollapsibleHeaderItem+ id="tabs"+ priority={1}+ expanded={+ <div classList={{ 'pr-1': isMobile() }}>+ <SoupViewTabs />+ </div>+ }+ collapsed={<CollapsedSoupViewTabs />}+ /><SoupViewCreateButton /></Show><Show when={narrowSearchExpanded()}>