Skip to content

armgit / macro

Public Imported from GitHub
0

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

feat(tutorial): sidebar stuff, new buttons, new split button, per user feedback via linkedin (#1998)

Jacob Beckerman4bc532550cd4
diff --git a/js/app/bun.lock b/js/app/bun.lock
index 7e2f396114..abcbc46fe3 100644
--- a/js/app/bun.lock
+++ b/js/app/bun.lock
@@ -1,6 +1,5 @@
{
"lockfileVersion": 1,
- "configVersion": 0,
"workspaces": {
"": {
"name": "@coparse/monorepo",
@@ -374,12 +373,11 @@
},
"overrides": {
- "ajv": ">=6.14.0",
- "cross-spawn": "7.0.6",
"flatted": ">=3.4.0",
- "minimatch": ">=3.1.4",
+ "cross-spawn": "7.0.6",
"rollup": ">=4.59.0",
- "undici": ">=6.24.0",
+ "minimatch": ">=3.1.4",
+ "ajv": ">=6.14.0",
},
"packages": {
"@adobe/css-tools": ["@adobe/[email protected]", "", {}, "sha512-Elp+iwUx5rN5+Y8xLt5/GRoG20WGoDCQ/1Fb+1LiGtvwbDavuSk0jhD/eZdckHAuzcDzccnkv+rEjyWfRx18gg=="],
diff --git a/js/app/packages/app/component/Launcher.tsx b/js/app/packages/app/component/Launcher.tsx
index d03f6d7781..c4860cd060 100644
--- a/js/app/packages/app/component/Launcher.tsx
+++ b/js/app/packages/app/component/Launcher.tsx
@@ -53,6 +53,7 @@ import { Dynamic } from 'solid-js/web';
import { type FocusableElement, tabbable } from 'tabbable';
import { useSplitLayout } from './split-layout/layout';
import { cn } from '@ui/utils/classname';
+import type { ListViewCreateActionId } from './list-view-create';
const createBlock = async (spec: {
blockName: BlockName | BlockAlias;
@@ -127,6 +128,83 @@ const createComponent = async (spec: {
);
};
+export function runCreateAction(
+ actionId: ListViewCreateActionId,
+ options: { shouldInsert?: boolean } = {}
+) {
+ const shouldInsert = options.shouldInsert ?? false;
+
+ switch (actionId) {
+ case 'doc':
+ createBlock({
+ blockName: 'md',
+ loading: true,
+ createFn: () =>
+ createMarkdownFile({
+ title: '',
+ content: '',
+ projectId: undefined,
+ }),
+ shouldInsert,
+ });
+ return;
+ case 'canvas':
+ createBlock({
+ blockName: 'canvas',
+ loading: true,
+ createFn: async () => {
+ const result = await createCanvasFileFromJsonString({
+ json: JSON.stringify({ nodes: [], edges: [] }),
+ title: 'New Canvas',
+ });
+ if ('error' in result) return;
+ const [_, id] = ok(result.documentId);
+ return id;
+ },
+ shouldInsert,
+ });
+ return;
+ case 'task':
+ createComponent({
+ componentId: 'task-compose',
+ asPopover: true,
+ });
+ return;
+ case 'email':
+ createComponent({
+ componentId: 'email-compose',
+ shouldInsert,
+ });
+ return;
+ case 'message':
+ createComponent({
+ componentId: 'channel-compose',
+ shouldInsert,
+ });
+ return;
+ case 'agent':
+ createBlock({
+ blockName: 'chat',
+ createFn: async () => {
+ const result = await createChat();
+ if ('error' in result) {
+ return;
+ }
+ return result.chatId;
+ },
+ shouldInsert,
+ });
+ return;
+ case 'folder':
+ createBlock({
+ blockName: 'project',
+ createFn: () => createProject({ name: 'New Folder' }),
+ shouldInsert,
+ });
+ return;
+ }
+}
+
type CreatableBlock = Omit<HotkeyRegistrationOptions, 'scopeId'> & {
label: string;
blockName: BlockName;
@@ -145,17 +223,7 @@ export const CREATABLE_BLOCKS: CreatableBlock[] = [
altHotkeyToken: TOKENS.create.noteNewSplit,
hotkey: 'd',
keyDownHandler: () => {
- createBlock({
- blockName: 'md',
- loading: true,
- createFn: () =>
- createMarkdownFile({
- title: '',
- content: '',
- projectId: undefined,
- }),
- shouldInsert: pressedKeys().has('shift'),
- });
+ runCreateAction('doc', { shouldInsert: pressedKeys().has('shift') });
return true;
},
},
@@ -171,10 +239,7 @@ export const CREATABLE_BLOCKS: CreatableBlock[] = [
altHotkeyToken: TOKENS.create.taskNewSplit,
hotkey: 't' as const,
keyDownHandler: () => {
- createComponent({
- componentId: 'task-compose',
- asPopover: true,
- });
+ runCreateAction('task');
return true;
},
},
@@ -190,10 +255,7 @@ export const CREATABLE_BLOCKS: CreatableBlock[] = [
altHotkeyToken: TOKENS.create.emailNewSplit,
hotkey: 'e',
keyDownHandler: () => {
- createComponent({
- componentId: 'email-compose',
- shouldInsert: pressedKeys().has('shift'),
- });
+ runCreateAction('email', { shouldInsert: pressedKeys().has('shift') });
return true;
},
},
@@ -207,10 +269,7 @@ export const CREATABLE_BLOCKS: CreatableBlock[] = [
altHotkeyToken: TOKENS.create.messageNewSplit,
hotkey: 'm',
keyDownHandler: () => {
- createComponent({
- componentId: 'channel-compose',
- shouldInsert: pressedKeys().has('shift'),
- });
+ runCreateAction('message', { shouldInsert: pressedKeys().has('shift') });
return true;
},
},
@@ -224,17 +283,7 @@ export const CREATABLE_BLOCKS: CreatableBlock[] = [
altHotkeyToken: TOKENS.create.chatNewSplit,
hotkey: 'a',
keyDownHandler: () => {
- createBlock({
- blockName: 'chat',
- createFn: async () => {
- const result = await createChat();
- if ('error' in result) {
- return;
- }
- return result.chatId;
- },
- shouldInsert: pressedKeys().has('shift'),
- });
+ runCreateAction('agent', { shouldInsert: pressedKeys().has('shift') });
return true;
},
},
@@ -248,18 +297,7 @@ export const CREATABLE_BLOCKS: CreatableBlock[] = [
altHotkeyToken: TOKENS.create.canvasNewSplit,
hotkey: 'n',
keyDownHandler: () => {
- createBlock({
- blockName: 'canvas',
- loading: true,
- createFn: async () => {
- const result = await createCanvasFileFromJsonString({
- json: JSON.stringify({ nodes: [], edges: [] }),
- title: 'New Canvas',
- });
- if ('error' in result) return;
- const [_, id] = ok(result.documentId);
- return id;
- },
+ runCreateAction('canvas', {
shouldInsert: pressedKeys().has('shift'),
});
return true;
@@ -275,11 +313,7 @@ export const CREATABLE_BLOCKS: CreatableBlock[] = [
altHotkeyToken: TOKENS.create.projectNewSplit,
hotkey: 'f',
keyDownHandler: () => {
- createBlock({
- blockName: 'project',
- createFn: () => createProject({ name: 'New Folder' }),
- shouldInsert: pressedKeys().has('shift'),
- });
+ runCreateAction('folder', { shouldInsert: pressedKeys().has('shift') });
return true;
},
},
diff --git a/js/app/packages/app/component/app-sidebar/sidebar.tsx b/js/app/packages/app/component/app-sidebar/sidebar.tsx
index 6abc9a9c34..bc8f0b9750 100644
--- a/js/app/packages/app/component/app-sidebar/sidebar.tsx
+++ b/js/app/packages/app/component/app-sidebar/sidebar.tsx
@@ -11,10 +11,15 @@ import { AnimatedInboxIcon } from '@macro-icons/wide/animating/inbox';
import { AnimatedSearchIcon } from '@macro-icons/wide/animating/search';
import { AnimatedSidebarIcon } from '@macro-icons/wide/animating/sidebar';
import { AnimatedPlusIcon } from '@macro-icons/wide/animating/plus';
+import SplitIcon from '@macro-icons/new-split.svg';
import { AnimatedCommandIcon } from '@macro-icons/wide/animating/command';
import { useLocation } from '@solidjs/router';
import LogoIcon from '@macro-icons/macro-logo.svg';
-import { LIST_VIEW_PATHS, type ListView } from '@app/constants/list-views';
+import {
+ LIST_VIEW_ID,
+ LIST_VIEW_PATHS,
+ type ListView,
+} from '@app/constants/list-views';
import { LabelAndHotKey } from '@core/component/Tooltip';
import { setCreateMenuOpen } from '@app/component/Launcher';
import { CommandState } from '@app/component/command';
@@ -27,6 +32,8 @@ import { useSettingsState } from '@core/constant/SettingsState';
import type { ValidHotkey } from '@core/hotkey/types';
import { registerHotkey } from '@core/hotkey/hotkeys';
import { GO_TO_COMMAND_SCOPE, GO_TO_LEADER_KEY } from '@app/constants/hotkeys';
+import { ContextMenuContent, MenuItem } from '@core/component/Menu';
+import { ContextMenu } from '@kobalte/core/context-menu';
import { TOKENS } from '@core/hotkey/tokens';
import { Hotkey } from '@core/component/Hotkey';
@@ -181,6 +188,24 @@ export const AppSidebar = (props: AppSidebarProps) => {
setCreateMenuOpen((p) => !p);
};
+ const canCreateNewSplit = () =>
+ globalSplitManager()?.canAppendSplit() ?? true;
+
+ const handleNewSplitClick = () => {
+ const manager = globalSplitManager();
+ if (!manager || !manager.canAppendSplit()) return;
+
+ manager.createNewSplit({
+ content: {
+ type: 'component',
+ id: LIST_VIEW_ID.inbox,
+ },
+ activate: true,
+ allowDuplicate: true,
+ referredFrom: 'sidebar',
+ });
+ };
+
const registerHotkeys = () =>
registerSidebarHotkeys({
isSlim,
@@ -299,6 +324,28 @@ export const AppSidebar = (props: AppSidebarProps) => {
</div>
</Button>
+ <Button
+ class="flex items-center justify-start text-sm gap-2 cursor-default w-full rounded-xs py-1"
+ variant="ghost"
+ tooltipPlacement="right"
+ tooltip={
+ <LabelAndHotKey
+ label="Create new split"
+ hotkeyToken={TOKENS.global.createNewSplit}
+ />
+ }
+ onClick={handleNewSplitClick}
+ disabled={!canCreateNewSplit()}
+ >
+ <SplitIcon class="size-4 shrink-0" />
+ <span class="whitespace-nowrap group-data-[slim=true]/sidebar:invisible">
+ New Split
+ </span>
+ <div class="text-[0.625rem] text-ink-extra-muted/50 rounded-sm ml-auto border border-edge-muted px-1.5 py-0.25 -my-1 group-data-[slim=true]/sidebar:invisible">
+ <Hotkey token={TOKENS.global.createNewSplit} class="flex gap-1" />
+ </div>
+ </Button>
+
<Button
class="flex items-center justify-start text-sm gap-2 cursor-default w-full rounded-xs py-1"
variant="ghost"
@@ -382,66 +429,110 @@ const SidebarLink = (props: SidebarLinkProps) => {
return activeContent?.id === props.id;
};
+ const content = () =>
+ ({
+ type: 'component',
+ id: props.id,
+ }) as const;
+
+ const canOpenInNewSplit = () =>
+ globalSplitManager()?.canAppendSplit() ?? true;
+
+ const openInCurrentSplit = () =>
+ layout.openWithSplit(content(), {
+ allowDuplicate: true,
+ mergeHistory: false,
+ referredFrom: 'sidebar',
+ });
+
+ const openInNewSplit = () => {
+ const manager = globalSplitManager();
+ if (!manager || !manager.canAppendSplit()) return;
+
+ manager.createNewSplit({
+ content: content(),
+ activate: true,
+ allowDuplicate: true,
+ referredFrom: 'sidebar',
+ });
+ };
+
+ const openFullscreen = () => {
+ const split = openInCurrentSplit();
+ split?.toggleSpotlight(true);
+ };
+
return (
- <Button
- as="button"
- draggable={false}
- variant="ghost"
- class={cn(
- 'flex items-center justify-start text-sm gap-2 cursor-default w-full rounded-xs py-1',
- isActive() && 'bg-ink/7 not-disabled:hover:bg-ink/15 text-ink'
- )}
- tooltipPlacement="right"
- tooltip={
- <LabelAndHotKey
- label={`Go to ${props.label}`}
- hotkeySequence={
- props.standaloneHotkey
- ? [{ shortcut: props.hotkey }]
- : [{ shortcut: GO_TO_LEADER_KEY }, { shortcut: props.hotkey }]
- }
- />
- }
- onMouseEnter={() => setIsHovering(true)}
- onMouseLeave={() => setIsHovering(false)}
- onClick={(e) => {
- // Middle mouse handling
- if (e.button === 1) return;
-
- e.preventDefault();
- layout.openWithSplit(
- {
- type: 'component',
- id: props.id,
- },
- {
- preferNewSplit: e.shiftKey,
- mergeHistory: false,
- allowDuplicate: true,
+ <ContextMenu>
+ <ContextMenu.Trigger class="w-full">
+ <Button
+ as="button"
+ draggable={false}
+ variant="ghost"
+ class={cn(
+ 'flex items-center justify-start text-sm gap-2 cursor-default w-full rounded-xs py-1',
+ isActive() && 'bg-ink/7 not-disabled:hover:bg-ink/15 text-ink'
+ )}
+ tooltipPlacement="right"
+ tooltip={
+ <LabelAndHotKey
+ label={`Go to ${props.label}`}
+ hotkeySequence={
+ props.standaloneHotkey
+ ? [{ shortcut: props.hotkey }]
+ : [{ shortcut: GO_TO_LEADER_KEY }, { shortcut: props.hotkey }]
+ }
+ />
}
- );
- }}
- >
- <Show when={props.icon}>
- <div class="shrink-0 [&_svg]:size-4">
- <Dynamic component={props.icon} triggerAnimation={isHovering()} />
- </div>
- </Show>
- <span class="whitespace-nowrap group-data-[slim=true]/sidebar:invisible">
- {props.label}
- </span>
-
- <div class="text-[0.625rem] text-ink-extra-muted/50 rounded-sm ml-auto border border-edge-muted px-2 py-0.5 -my-1 group-data-[slim=true]/sidebar:invisible">
- <div class="flex gap-1">
- <Show when={!props.standaloneHotkey}>
- <Hotkey shortcut={GO_TO_LEADER_KEY} />
- <Hotkey shortcut={props.hotkey} />
- </Show>
- <Show when={props.standaloneHotkey}>
- <Hotkey shortcut={props.hotkey} />
+ onMouseEnter={() => setIsHovering(true)}
+ onMouseLeave={() => setIsHovering(false)}
+ onClick={(e) => {
+ // Middle mouse handling
+ if (e.button === 1) return;
+
+ e.preventDefault();
+ layout.openWithSplit(content(), {
+ preferNewSplit: e.shiftKey,
+ mergeHistory: false,
+ allowDuplicate: true,
+ referredFrom: 'sidebar',
+ });
+ }}
+ >
+ <Show when={props.icon}>
+ <div class="shrink-0 [&_svg]:size-4">
+ <Dynamic component={props.icon} triggerAnimation={isHovering()} />
+ </div>
</Show>
- </div>
- </div>
- </Button>
+ <span class="whitespace-nowrap group-data-[slim=true]/sidebar:invisible">
+ {props.label}
+ </span>
+
+ <div class="text-[0.625rem] text-ink-extra-muted/50 rounded-sm ml-auto border border-edge-muted px-1.5 py-0.25 -my-1 group-data-[slim=true]/sidebar:invisible">
+ <div class="flex gap-1">
+ <Show when={!props.standaloneHotkey}>
+ <Hotkey shortcut={GO_TO_LEADER_KEY} lowercase />
+ <Hotkey shortcut={props.hotkey} lowercase />
+ </Show>
+ <Show when={props.standaloneHotkey}>
+ <Hotkey shortcut={props.hotkey} lowercase />
+ </Show>
+ </div>
+ </div>
+ </Button>
+ </ContextMenu.Trigger>
+
+ <ContextMenu.Portal>
+ <ContextMenuContent class="text-xs text-ink-muted">
+ <MenuItem
+ text="Open in new split"
+ onClick={openInNewSplit}
+ disabled={!canOpenInNewSplit()}
+ />
+ <MenuItem text="Open fullscreen" onClick={openFullscreen} />
+ <MenuItem text="Open in current split" onClick={openInCurrentSplit} />
+ </ContextMenuContent>
+ </ContextMenu.Portal>
+ </ContextMenu>
);
};
diff --git a/js/app/packages/app/component/list-view-create.test.ts b/js/app/packages/app/component/list-view-create.test.ts
new file mode 100644
index 0000000000..2f81b83919
--- /dev/null
+++ b/js/app/packages/app/component/list-view-create.test.ts
@@ -0,0 +1,65 @@
+import { describe, expect, test } from 'vitest';
+import {
+ getCreateActionLabel,
+ getCreateOptionLabel,
+ getListViewCreateActionId,
+ getListViewCreateButtonLabel,
+ getListViewCreateOptions,
+} from './list-view-create';
+
+describe('getListViewCreateActionId', () => {
+ test.each([
+ ['agents', 'agent'],
+ ['mail', 'email'],
+ ['documents', 'doc'],
+ ['tasks', 'task'],
+ ['channels', 'message'],
+ ['files', 'folder'],
+ ] as const)('maps %s to %s', (view, actionId) => {
+ expect(getListViewCreateActionId(view)).toBe(actionId);
+ });
+
+ test('does not expose create actions for aggregate views', () => {
+ expect(getListViewCreateActionId('inbox')).toBeUndefined();
+ expect(getListViewCreateActionId('search')).toBeUndefined();
+ });
+
+ test.each([
+ ['agents', 'New agent'],
+ ['mail', 'New email'],
+ ['documents', 'New doc'],
+ ['tasks', 'New task'],
+ ['channels', 'New message'],
+ ['files', 'New folder'],
+ ] as const)('builds the correct button label for %s', (view, label) => {
+ expect(getListViewCreateButtonLabel(view)).toBe(label);
+ });
+
+ test('returns the action label for each create action', () => {
+ expect(getCreateActionLabel('doc')).toBe('doc');
+ expect(getCreateActionLabel('canvas')).toBe('canvas');
+ expect(getCreateActionLabel('task')).toBe('task');
+ expect(getCreateActionLabel('email')).toBe('email');
+ expect(getCreateActionLabel('folder')).toBe('folder');
+ expect(getCreateActionLabel('message')).toBe('message');
+ expect(getCreateActionLabel('agent')).toBe('agent');
+ });
+
+ test('returns the option label for import', () => {
+ expect(getCreateOptionLabel('import')).toBe('Import');
+ });
+
+ test('returns the full documents create menu', () => {
+ expect(getListViewCreateOptions('documents')).toEqual([
+ { id: 'doc', label: 'New doc' },
+ { id: 'canvas', label: 'New canvas' },
+ { id: 'import', label: 'Import' },
+ ]);
+ });
+
+ test('returns a single create option for non-document views', () => {
+ expect(getListViewCreateOptions('tasks')).toEqual([
+ { id: 'task', label: 'New task' },
+ ]);
+ });
+});
diff --git a/js/app/packages/app/component/list-view-create.ts b/js/app/packages/app/component/list-view-create.ts
new file mode 100644
index 0000000000..8dad4952a2
--- /dev/null
+++ b/js/app/packages/app/component/list-view-create.ts
@@ -0,0 +1,78 @@
+import type { ListView } from '@app/constants/list-views';
+
+export const LIST_VIEW_CREATE_ACTIONS: Partial<
+ Record<ListView, ListViewCreateActionId>
+> = {
+ agents: 'agent',
+ mail: 'email',
+ documents: 'doc',
+ tasks: 'task',
+ channels: 'message',
+ files: 'folder',
+};
+
+export type ListViewCreateActionId =
+ | 'agent'
+ | 'canvas'
+ | 'doc'
+ | 'email'
+ | 'folder'
+ | 'message'
+ | 'task';
+
+export type ListViewCreateOptionId = ListViewCreateActionId | 'import';
+
+const CREATE_OPTION_LABELS: Record<ListViewCreateOptionId, string> = {
+ agent: 'agent',
+ canvas: 'canvas',
+ doc: 'doc',
+ email: 'email',
+ folder: 'folder',
+ import: 'Import',
+ message: 'message',
+ task: 'task',
+};
+
+export type ListViewCreateOption = {
+ id: ListViewCreateOptionId;
+ label: string;
+};
+
+export function getListViewCreateActionId(
+ view: ListView
+): ListViewCreateActionId | undefined {
+ return LIST_VIEW_CREATE_ACTIONS[view];
+}
+
+export function getCreateActionLabel(actionId: ListViewCreateActionId): string {
+ return CREATE_OPTION_LABELS[actionId];
+}
+
+export function getListViewCreateButtonLabel(
+ view: ListView
+): string | undefined {
+ const actionId = getListViewCreateActionId(view);
+ if (!actionId) return;
+ return `New ${getCreateActionLabel(actionId)}`;
+}
+
+export function getCreateOptionLabel(optionId: ListViewCreateOptionId): string {
+ return CREATE_OPTION_LABELS[optionId];
+}
+
+export function getListViewCreateOptions(
+ view: ListView
+): ListViewCreateOption[] {
+ if (view === 'documents') {
+ return [
+ { id: 'doc', label: 'New doc' },
+ { id: 'canvas', label: 'New canvas' },
+ { id: 'import', label: 'Import' },
+ ];
+ }
+
+ const actionId = getListViewCreateActionId(view);
+ if (!actionId) return [];
+
+ return [{ id: actionId, label: `New ${getCreateOptionLabel(actionId)}` }];
+}
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.tsx
index fe5dd34513..40b1608f3d 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
@@ -2,25 +2,50 @@ import {
VIEW_TAB_PRESETS,
type PresetContext,
} from '@app/component/app-sidebar/soup-filter-presets';
+import { runCreateAction } from '@app/component/Launcher';
import type { FilterID } from '@app/component/next-soup/filters/configs';
import type { SoupItemsQueryFilters } from '@queries/soup/items';
import { useSoup } from '@app/component/next-soup/soup-context';
import { useSoupView } from '@app/component/next-soup/soup-view/soup-view-context';
import { useSplitPanelOrThrow } from '@app/component/split-layout/layoutUtils';
-import type { ListView } from '@app/constants/list-views';
+import { isListViewID, type ListView } from '@app/constants/list-views';
+import {
+ type ListViewCreateActionId,
+ type ListViewCreateOptionId,
+ getListViewCreateOptions,
+} from '@app/component/list-view-create';
+import { useHandleFileUpload } from '@app/util/handleFileUpload';
+import { DropdownMenuContent, MenuItem } from '@core/component/Menu';
import { useUserContext } from '@core/context/user';
+import { openFilePicker } from '@core/util/upload';
+import ChevronDownIcon from '@icon/regular/caret-down.svg';
import {
batch,
createMemo,
For,
Match,
type ParentComponent,
+ Show,
Switch,
} from 'solid-js';
+import { DropdownMenu } from '@kobalte/core/dropdown-menu';
import {
SegmentedControl as KSegmentedControl,
type SegmentedControlRootProps,
} from '@kobalte/core/segmented-control';
+import { Button } from '@ui/components/Button';
+
+const useCurrentListView = () => {
+ const panel = useSplitPanelOrThrow();
+
+ return createMemo<ListView | undefined>(() => {
+ const content = panel.handle.content();
+
+ if (content.type !== 'component') return;
+
+ return isListViewID(content.id) ? content.id : undefined;
+ });
+};
export const useApplyPreset = () => {
const soup = useSoup();
@@ -58,18 +83,10 @@ export const useApplyPreset = () => {
};
export const SoupViewTabs = () => {
- const panel = useSplitPanelOrThrow();
+ const listView = useCurrentListView();
- const component = createMemo(() => {
- const content = panel.handle.content();
-
- if (content.type !== 'component') return;
-
- return content.id;
- });
-
- const isComponentListView = (listView: ListView) => {
- return component() === listView;
+ const isComponentListView = (view: ListView) => {
+ return listView() === view;
};
return (
@@ -99,6 +116,73 @@ export const SoupViewTabs = () => {
);
};
+export const SoupViewCreateButton = () => {
+ const listView = useCurrentListView();
+ const handleFileUpload = useHandleFileUpload();
+ const options = createMemo(() => {
+ const view = listView();
+ if (!view) return [];
+ return getListViewCreateOptions(view);
+ });
+
+ const primaryOption = createMemo(() => options()[0]);
+
+ const handleSelect = (optionId: ListViewCreateOptionId) => {
+ if (optionId === 'import') {
+ openFilePicker({ multiple: true }, async (files) => {
+ await handleFileUpload(files, false);
+ });
+ return;
+ }
+
+ runCreateAction(optionId as ListViewCreateActionId);
+ };
+
+ return (
+ <Show when={primaryOption()}>
+ {(option) => (
+ <Show
+ when={options().length > 1}
+ fallback={
+ <Button
+ variant="secondary"
+ size="sm"
+ class="rounded-xs whitespace-nowrap px-3"
+ onClick={() => handleSelect(option().id)}
+ >
+ {option().label}
+ </Button>
+ }
+ >
+ <DropdownMenu placement="bottom-start" gutter={4}>
+ <DropdownMenu.Trigger
+ as={Button}
+ variant="secondary"
+ size="sm"
+ class="rounded-xs whitespace-nowrap px-3"
+ >
+ <span>{option().label}</span>
+ <ChevronDownIcon class="size-3" />
+ </DropdownMenu.Trigger>
+ <DropdownMenu.Portal>
+ <DropdownMenuContent class="z-action-menu min-w-[160px]">
+ <For each={options()}>
+ {(item) => (
+ <MenuItem
+ text={item.label}
+ onClick={() => handleSelect(item.id)}
+ />
+ )}
+ </For>
+ </DropdownMenuContent>
+ </DropdownMenu.Portal>
+ </DropdownMenu>
+ </Show>
+ )}
+ </Show>
+ );
+};
+
const InboxTabs = () => {
const { applyTabPreset } = useApplyPreset();
const { activeTab } = useSoupView();
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 a04623292c..5f580cadc5 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
@@ -80,6 +80,7 @@ import type { SystemSortOption } from '@app/component/next-soup/soup-view/sort-o
import type { SoupItemsQueryFilters } from '@queries/soup/items';
import type { FilterID } from '@app/component/next-soup/filters';
import {
+ SoupViewCreateButton,
SoupViewTabs,
useApplyPreset,
} from '@app/component/next-soup/soup-view/soup-view-tabs';
@@ -218,6 +219,7 @@ export const SoupView = (props: SoupViewProps) => {
</Show>
<SoupViewTabs />
+ <SoupViewCreateButton />
</div>
</SplitHeaderLeft>
<SplitHeaderRight>
diff --git a/js/app/packages/app/component/split-layout/layoutManager.ts b/js/app/packages/app/component/split-layout/layoutManager.ts
index dea0d232d6..c2130ac169 100644
--- a/js/app/packages/app/component/split-layout/layoutManager.ts
+++ b/js/app/packages/app/component/split-layout/layoutManager.ts
@@ -102,6 +102,7 @@ export type ReferredFrom =
| 'mention'
| 'attachment'
| 'launcher'
+ | 'sidebar'
| 'dock'
| 'entity-actions-menu'
| 'hotkey'
diff --git a/js/app/packages/core/component/AI/component/input/sendMode.test.ts b/js/app/packages/core/component/AI/component/input/sendMode.test.ts
new file mode 100644
index 0000000000..0dabeac309
--- /dev/null
+++ b/js/app/packages/core/component/AI/component/input/sendMode.test.ts
@@ -0,0 +1,50 @@
+import { describe, expect, test } from 'vitest';
+import { getSendModeFromEnterKeyEvent, shouldOpenChatSplit } from './sendMode';
+
+describe('chat send mode', () => {
+ test('uses foreground mode for plain enter', () => {
+ expect(
+ getSendModeFromEnterKeyEvent({
+ metaKey: false,
+ ctrlKey: false,
+ shiftKey: false,
+ })
+ ).toBe('foreground');
+ });
+
+ test('uses foreground mode for shift+enter newline flow', () => {
+ expect(
+ getSendModeFromEnterKeyEvent({
+ metaKey: false,
+ ctrlKey: false,
+ shiftKey: true,
+ })
+ ).toBe('foreground');
+ });
+
+ test('uses background mode for cmd+shift+enter', () => {
+ expect(
+ getSendModeFromEnterKeyEvent({
+ metaKey: true,
+ ctrlKey: false,
+ shiftKey: true,
+ })
+ ).toBe('background');
+ });
+
+ test('uses background mode for ctrl+shift+enter', () => {
+ expect(
+ getSendModeFromEnterKeyEvent({
+ metaKey: false,
+ ctrlKey: true,
+ shiftKey: true,
+ })
+ ).toBe('background');
+ });
+
+ test('only opens chat split for foreground send', () => {
+ expect(shouldOpenChatSplit('foreground')).toBe(true);
+ expect(shouldOpenChatSplit(undefined)).toBe(true);
+ expect(shouldOpenChatSplit('background')).toBe(false);
+ });
+});
diff --git a/js/app/packages/core/component/AI/component/input/sendMode.ts b/js/app/packages/core/component/AI/component/input/sendMode.ts
new file mode 100644
index 0000000000..0e2732ca28
--- /dev/null
+++ b/js/app/packages/core/component/AI/component/input/sendMode.ts
@@ -0,0 +1,15 @@
+export type ChatSendMode = 'foreground' | 'background';
+
+export function getSendModeFromEnterKeyEvent(event: {
+ shiftKey: boolean;
+ metaKey: boolean;
+ ctrlKey: boolean;
+}): ChatSendMode {
+ return event.shiftKey && (event.metaKey || event.ctrlKey)
+ ? 'background'
+ : 'foreground';
+}
+
+export function shouldOpenChatSplit(sendMode?: ChatSendMode): boolean {
+ return sendMode !== 'background';
+}
diff --git a/js/app/packages/core/component/LexicalMarkdown/builder/enterKeyUtils.test.ts b/js/app/packages/core/component/LexicalMarkdown/builder/enterKeyUtils.test.ts
new file mode 100644
index 0000000000..bfd3277cd1
--- /dev/null
+++ b/js/app/packages/core/component/LexicalMarkdown/builder/enterKeyUtils.test.ts
@@ -0,0 +1,34 @@
+import { describe, expect, test } from 'vitest';
+import { shouldInsertNewlineOnEnter } from './enterKeyUtils';
+
+describe('shouldInsertNewlineOnEnter', () => {
+ test('returns true for shift+enter', () => {
+ expect(
+ shouldInsertNewlineOnEnter({
+ shiftKey: true,
+ metaKey: false,
+ ctrlKey: false,
+ })
+ ).toBe(true);
+ });
+
+ test('returns false for enter', () => {
+ expect(
+ shouldInsertNewlineOnEnter({
+ shiftKey: false,
+ metaKey: false,
+ ctrlKey: false,
+ })
+ ).toBe(false);
+ });
+
+ test('returns false for cmd+shift+enter', () => {
+ expect(
+ shouldInsertNewlineOnEnter({
+ shiftKey: true,
+ metaKey: true,
+ ctrlKey: false,
+ })
+ ).toBe(false);
+ });
+});
diff --git a/js/app/packages/core/component/LexicalMarkdown/builder/enterKeyUtils.ts b/js/app/packages/core/component/LexicalMarkdown/builder/enterKeyUtils.ts
new file mode 100644
index 0000000000..9ba3c7583c
--- /dev/null
+++ b/js/app/packages/core/component/LexicalMarkdown/builder/enterKeyUtils.ts
@@ -0,0 +1,7 @@
+export function shouldInsertNewlineOnEnter(event: {
+ shiftKey: boolean;
+ metaKey: boolean;
+ ctrlKey: boolean;
+}): boolean {
+ return event.shiftKey && !event.metaKey && !event.ctrlKey;
+}