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
Jbecke/split changes (#145)
Jacob Beckermana874662c522e
diff --git a/js/app/packages/app/component/Soup.tsx b/js/app/packages/app/component/Soup.tsxindex 656a460f3d..8d72e38743 100644--- a/js/app/packages/app/component/Soup.tsx+++ b/js/app/packages/app/component/Soup.tsx@@ -225,7 +225,20 @@ export function Soup() {},} = splitPanelContext;const view = createMemo(() => viewsData[selectedView()]);- const preview = () => view().display.preview;+ // Use preview state from SplitPanelContext (created in SplitLayout for unified-list)+ const previewState = () => splitPanelContext.previewState;+ const preview = () => previewState()?.[0]?.() ?? false;+ const setPreview = (value: boolean | ((prev: boolean) => boolean)) => {+ const state = previewState();+ if (state) {+ const [, setState] = state;+ if (typeof value === 'function') {+ setState((prev) => value(prev));+ } else {+ setState(value);+ }+ }+ };const selectedEntity = () => view().selectedEntity;const orchestrator = useGlobalBlockOrchestrator();@@ -248,6 +261,18 @@ export function Soup() {},});+ registerHotkey({+ hotkey: ['p'],+ scopeId: splitHotkeyScope,+ description: 'Toggle Preview',+ hotkeyToken: TOKENS.unifiedList.togglePreview,+ keyDownHandler: () => {+ setPreview((prev) => !prev);+ return true;+ },+ hide: true,+ });+const [isDragging, setIsDragging] = createSignal(false);const [isValidDrag, setIsValidDrag] = createSignal(true);diff --git a/js/app/packages/app/component/SoupContext.tsx b/js/app/packages/app/component/SoupContext.tsxindex f68218125d..a89280ab4b 100644--- a/js/app/packages/app/component/SoupContext.tsx+++ b/js/app/packages/app/component/SoupContext.tsx@@ -138,7 +138,6 @@ function createViewData(unrollNotifications:viewProps?.display?.unrollNotifications ??VIEWCONFIG_BASE.display.unrollNotifications,- preview: viewProps?.display?.preview ?? VIEWCONFIG_BASE.display.preview,limit: viewProps?.display?.limit,},sort: {@@ -507,19 +506,6 @@ export function createNavigationEntityListShortcut({return true;},});- registerHotkey({- hotkey: ['p'],- scopeId: splitHotkeyScope,- description: 'Toggle Preview',- hotkeyToken: TOKENS.unifiedList.togglePreview,- keyDownHandler: () => {- if (!entityListRef()) return false;-- setViewDataStore(selectedView(), 'display', 'preview', (prev) => !prev);- return true;- },- hide: true,- });const navigateThroughViews = ({axis,diff --git a/js/app/packages/app/component/UnifiedListView.tsx b/js/app/packages/app/component/UnifiedListView.tsxindex 0e7078c9ce..4e220e7d87 100644--- a/js/app/packages/app/component/UnifiedListView.tsx+++ b/js/app/packages/app/component/UnifiedListView.tsx@@ -23,10 +23,7 @@ import {blockAcceptsFileExtension,fileTypeToBlockName,} from '@core/constant/allBlocks';-import {- ENABLE_PREVIEW,- ENABLE_SOUP_FROM_FILTER,-} from '@core/constant/featureFlags';+import { ENABLE_SOUP_FROM_FILTER } from '@core/constant/featureFlags';import { registerHotkey } from '@core/hotkey/hotkeys';import { TOKENS } from '@core/hotkey/tokens';import { isTouchDevice } from '@core/mobile/isTouchDevice';@@ -210,7 +207,9 @@ export function UnifiedListView(props: UnifiedListViewProps) {);const splitContext = useSplitPanelOrThrow();- const { isPanelActive, unifiedListContext, panelRef } = splitContext;+ const { isPanelActive, unifiedListContext, panelRef, previewState } =+ splitContext;+ const preview = () => previewState?.[0]?.() ?? false;const {viewsDataStore: viewsData,setViewDataStore,@@ -392,13 +391,6 @@ export function UnifiedListView(props: UnifiedListViewProps) {);};- const preview = createMemo(- () => view()?.display.preview ?? defaultDisplayOptions.preview- );- const setPreview = (preview: DisplayOptions['preview']) => {- setViewDataStore(selectedView(), 'display', 'preview', preview);- };-const rawSearchText = createMemo<string>(() => view()?.searchText ?? '');const searchText = createMemo(() => rawSearchText()?.trim() ?? '');const [isSearchLoading, setIsSearchLoading] = createSignal(false);@@ -962,7 +954,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {<SplitToolbarRight order={5}><div class="flex flex-row items-center gap-1 p-1 h-full select-none"><Show when={isViewConfigChanged()}>- <Show when={view().display.preview}>+ <Show when={preview()}><DropdownMenusize="SM"theme="secondary"@@ -990,7 +982,7 @@ export function UnifiedListView(props: UnifiedListViewProps) {</div></DropdownMenu></Show>- <Show when={!view().display.preview}>+ <Show when={!preview()}><Buttonsize="SM"classList={{@@ -1162,13 +1154,6 @@ export function UnifiedListView(props: UnifiedListViewProps) {checked={showUnreadIndicator()}onChange={setShowUnreadIndicator}/>- <ToggleSwitch- size="SM"- label="Preview"- disabled={!ENABLE_PREVIEW}- checked={preview()}- onChange={setPreview}- /></section></div></div>diff --git a/js/app/packages/app/component/ViewConfig.tsx b/js/app/packages/app/component/ViewConfig.tsxindex 229be93da2..9a419ffb2c 100644--- a/js/app/packages/app/component/ViewConfig.tsx+++ b/js/app/packages/app/component/ViewConfig.tsx@@ -67,7 +67,6 @@ export type DisplayOptions = {layout: 'compact' | 'expanded' | 'visual';unrollNotifications: boolean;showUnreadIndicator: boolean;- preview: boolean;limit?: number;};@@ -114,7 +113,6 @@ export const VIEWCONFIG_BASE: ViewConfigBase = {layout: 'compact',unrollNotifications: false,showUnreadIndicator: false,- preview: false,limit: 100,},};@@ -137,7 +135,6 @@ export const PROJECT_VIEWCONFIG_BASE: ViewConfigBase = {layout: 'compact',unrollNotifications: false,showUnreadIndicator: true,- preview: false,limit: 100,},};@@ -223,9 +220,6 @@ const ALL_VIEWCONFIG_DEFAULTS = {filters: {typeFilter: ['chat'],},- display: {- preview: true,- },},folders: {view: 'folders',diff --git a/js/app/packages/app/component/dock/Dock.tsx b/js/app/packages/app/component/dock/Dock.tsxindex 4609ea966e..53a1736e42 100644--- a/js/app/packages/app/component/dock/Dock.tsx+++ b/js/app/packages/app/component/dock/Dock.tsx@@ -22,6 +22,7 @@ import { TOKENS } from '@core/hotkey/tokens';import { isMobileWidth } from '@core/mobile/mobileWidth';import { isRightPanelOpen, useToggleRightPanel } from '@core/signal/layout';import IconQuestion from '@icon/regular/question.svg';+import SplitIcon from '@icon/regular/square-split-horizontal.svg';import IconAtom from '@macro-icons/macro-atom.svg';import IconGear from '@macro-icons/macro-gear.svg';import { createMemo, createSignal, Show } from 'solid-js';@@ -164,6 +165,25 @@ export function Dock() {/></Show>+ <IconButton+ icon={SplitIcon}+ theme="clear"+ tooltip={{+ label: 'Create New Split',+ hotkeyToken: TOKENS.global.createNewSplit,+ }}+ class="h-full aspect-square"+ onClick={() => {+ const manager = globalSplitManager();+ if (manager) {+ manager.createNewSplit({+ type: 'component',+ id: 'unified-list',+ });+ }+ }}+ />+<IconButtonicon={IconGear}theme={settingsOpen() ? 'accent' : 'clear'}diff --git a/js/app/packages/app/component/split-layout/SplitLayout.tsx b/js/app/packages/app/component/split-layout/SplitLayout.tsxindex 666581210a..0451f6d2fb 100644--- a/js/app/packages/app/component/split-layout/SplitLayout.tsx+++ b/js/app/packages/app/component/split-layout/SplitLayout.tsx@@ -423,6 +423,14 @@ function SplitPanel(props: SplitPanelProps) {unifiedListContext,});+ // Create ephemeral preview state for unified-list component+ const isUnifiedList = createMemo(() => splitName() === 'unified-list');+ const [previewState, setPreviewState] = createSignal(false);+ const previewStateSignal: [typeof previewState, typeof setPreviewState] = [+ previewState,+ setPreviewState,+ ];+return (<SplitPanelContext.Providervalue={{@@ -435,6 +443,7 @@ function SplitPanel(props: SplitPanelProps) {layoutRefs: {},contentOffsetTop,setContentOffsetTop,+ previewState: isUnifiedList() ? previewStateSignal : undefined,}}><SplitContainerdiff --git a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx b/js/app/packages/app/component/split-layout/components/SplitHeader.tsxindex bf40a25e3e..8d38a76200 100644--- a/js/app/packages/app/component/split-layout/components/SplitHeader.tsx+++ b/js/app/packages/app/component/split-layout/components/SplitHeader.tsx@@ -1,6 +1,6 @@import EntityNavigationIndicator from '@app/component/EntityNavigationIndicator';import { IconButton } from '@core/component/IconButton';-import { ResizeZoneContext } from '@core/component/Resize/Resize';+import { ENABLE_PREVIEW } from '@core/constant/featureFlags';import { TOKENS } from '@core/hotkey/tokens';import { cornerClip } from '@core/util/clipPath';import CollapseIcon from '@icon/regular/arrows-in.svg';@@ -50,42 +50,6 @@ function SplitForwardButton() {);}-// TODO: Move to Dock-// (would likely require global split context, or at least a bit higher in the tree)-function SplitCreateButton() {- const context = useContext(SplitLayoutContext);- const zoneContext = useContext(ResizeZoneContext);- if (!context || !zoneContext) return '';-- // TODO (seamus) : What should the behavior be for not enough space for split?- // Block, replace, toast? This should be consistent everywhere:- // 1) keyboard shortcut- // 2) here- // 3) opt-click and open-in-split button- const canAdd = () => zoneContext.canFit({ minSize: 400 });-- return (- <IconButton- size="sm"- icon={SplitIcon}- theme="current"- disabled={!canAdd()}- tooltip={{- hotkeyToken: canAdd() ? TOKENS.global.createNewSplit : undefined,- label: canAdd()- ? 'Create New Split'- : 'Not Enough Space for a New Split',- }}- onClick={() => {- context.manager.createNewSplit({- type: 'component',- id: 'unified-list',- });- }}- />- );-}-function SplitSpotlightButton() {const context = useContext(SplitPanelContext);const layout = useContext(SplitLayoutContext);@@ -126,6 +90,32 @@ function SplitCloseButton() {);}+function SplitPreviewToggle() {+ const context = useContext(SplitPanelContext);+ if (!context || !context.previewState || !ENABLE_PREVIEW) return '';++ // Only show toggle for unified-list component, not for blocks+ const content = () => context.handle.content();+ const isUnifiedList = () =>+ content().type === 'component' && content().id === 'unified-list';+ if (!isUnifiedList()) return '';++ const [preview, setPreview] = context.previewState;++ return (+ <IconButton+ size="sm"+ icon={SplitIcon}+ theme={preview() ? 'accent' : 'current'}+ tooltip={{+ label: preview() ? 'Split View' : 'Full View',+ hotkeyToken: TOKENS.unifiedList.togglePreview,+ }}+ onClick={() => setPreview((prev) => !prev)}+ />+ );+}+function SplitControlButtons() {return (<div class="flex flex-row items-center px-2 border-t border-t-edge-muted border-b border-b-edge-muted h-full shrink-0">@@ -172,8 +162,8 @@ export function SplitHeader(props: { ref: Setter<HTMLDivElement | null> }) {/><div class="z-2 relative flex items-center bg-panel pr-2 border-t border-t-edge-muted border-b border-b-edge-muted h-full"><EntityNavigationIndicator />+ <SplitPreviewToggle /><SplitSpotlightButton />- <SplitCreateButton /></div></div></div>diff --git a/js/app/packages/app/component/split-layout/context.ts b/js/app/packages/app/component/split-layout/context.tsindex 7033da7521..e6305663d5 100644--- a/js/app/packages/app/component/split-layout/context.ts+++ b/js/app/packages/app/component/split-layout/context.ts@@ -1,5 +1,10 @@import type { NullableSize } from '@solid-primitives/resize-observer';-import { type Accessor, createContext, type Setter } from 'solid-js';+import {+ type Accessor,+ createContext,+ type Setter,+ type Signal,+} from 'solid-js';import type { UnifiedListContext } from '../SoupContext';import type { SplitHandle, SplitManager } from './layoutManager';@@ -22,6 +27,7 @@ export type SplitPanelContextType = {contentOffsetTop: Accessor<number>;setContentOffsetTop: Setter<number>;halfSplitState?: Accessor<HalfSplitState | undefined>;+ previewState?: Signal<boolean>;layoutRefs: {headerLeft?: HTMLDivElement;headerRight?: HTMLDivElement;diff --git a/js/app/packages/core/component/FormControls/ToggleSwitch.tsx b/js/app/packages/core/component/FormControls/ToggleSwitch.tsxindex 388ad6482f..6c7492c0d0 100644--- a/js/app/packages/core/component/FormControls/ToggleSwitch.tsx+++ b/js/app/packages/core/component/FormControls/ToggleSwitch.tsx@@ -27,6 +27,8 @@ export const ToggleSwitch: Component<animateFlickerOnDeactivate?: boolean;size?: 'SM' | 'Base';disabled?: boolean;+ trueLabel?: string;+ falseLabel?: string;} & SwitchRootOptions> = (props) => {const [checked, setChecked] = createSignal(props.checked);@@ -64,8 +66,9 @@ export const ToggleSwitch: Component<return (<KSwitch- class="flex justify-between items-center text-xs font-medium gap-1"+ class="flex justify-between items-center font-medium gap-1"classList={{+ [`${sizeClass[props.size || 'Base']}`]: true,[`${props.switchRootClass}`]: !!props.switchRootClass,'flex-row-reverse': props.labelPlacement === 'right','opacity-50 cursor-not-allowed': props.disabled,@@ -135,28 +138,44 @@ export const ToggleSwitch: Component<</div></div><div- class="absolute inset-0 border border-ink uppercase"+ class="absolute inset-0 uppercase"classList={{[`${sizeClass[props.size || 'Base']}`]: true,+ 'border border-ink/30':+ props.switchRootClass?.includes('subtle'),+ 'border border-ink':+ !props.switchRootClass?.includes('subtle'),}}aria-hidden><div class="absolute inset-0"><div- class="font-bold absolute inset-0 flex justify-center items-center mr-[100cqh] bg-ink text-panel transition-[clip-path] duration-100"+ class="absolute inset-0 flex justify-center items-center mr-[100cqh] transition-[clip-path] duration-100"+ classList={{+ 'font-bold bg-ink text-panel':+ !props.switchRootClass?.includes('subtle'),+ 'font-medium bg-ink/20 text-ink/80':+ props.switchRootClass?.includes('subtle'),+ }}style={{'clip-path': `polygon(0% 0%, ${!checked() ? 0 : 100}% 0%, ${!checked() ? 0 : 100}% 100%, 0% 100%)`,}}>- True+ {props.trueLabel ?? 'True'}</div><div- class="font-bold absolute inset-0 flex justify-center items-center ml-[100cqh] text-ink transition-[clip-path] duration-100"+ class="absolute inset-0 flex justify-center items-center ml-[100cqh] transition-[clip-path] duration-100"+ classList={{+ 'font-bold text-ink':+ !props.switchRootClass?.includes('subtle'),+ 'font-medium text-ink/60':+ props.switchRootClass?.includes('subtle'),+ }}style={{'clip-path': `polygon(${!checked() ? 0 : 100}% 0%, 100% 0%, 100% 100%, ${!checked() ? 0 : 100}% 100%)`,}}>- False+ {props.falseLabel ?? 'False'}</div></div></div>