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(channels): replace the composer paperclip with a + menu (#8016)

Wolf Mermelstein62fd9e56579d
diff --git a/apps/web/src/components/ui/components/CollapsedInput.tsx b/apps/web/src/components/ui/components/CollapsedInput.tsx
index 8dd7d55299..3edfc58cbc 100644
--- a/apps/web/src/components/ui/components/CollapsedInput.tsx
+++ b/apps/web/src/components/ui/components/CollapsedInput.tsx
@@ -28,6 +28,8 @@ export type CollapsedInputProps = {
class?: string;
/** Extra composer action placed immediately before Send. */
trailingAction?: JSX.Element;
+ /** Replaces the attach button at the start of the input. */
+ leadingAction?: JSX.Element;
/**
* Target of the real input this trigger stands in for. Focused via the
* `focusInput` directive when the trigger is clicked, so the iOS virtual
@@ -60,16 +62,23 @@ export function CollapsedInput(props: CollapsedInputProps) {
props.class
)}
>
- <Button
- variant="ghost"
- size="icon-composer"
- class="not-touch:light-mode:text-composer-ink"
- aria-label="Attach files"
- label="Attach files"
- onClick={() => props.onAttach?.()}
+ <Show
+ when={props.leadingAction}
+ fallback={
+ <Button
+ variant="ghost"
+ size="icon-composer"
+ class="not-touch:light-mode:text-composer-ink"
+ aria-label="Attach files"
+ label="Attach files"
+ onClick={() => props.onAttach?.()}
+ >
+ <PaperclipIcon />
+ </Button>
+ }
>
- <PaperclipIcon />
- </Button>
+ {props.leadingAction}
+ </Show>
<button
type="button"
class={cn(
diff --git a/apps/web/src/features/channel/Call/ChannelCallButton.tsx b/apps/web/src/features/channel/Call/ChannelCallButton.tsx
index ef18e4700f..be86ea6690 100644
--- a/apps/web/src/features/channel/Call/ChannelCallButton.tsx
+++ b/apps/web/src/features/channel/Call/ChannelCallButton.tsx
@@ -1,107 +1,26 @@
-import { analytics } from '@app/lib/analytics';
-import { useChannelTab } from '@channel/Channel/ChannelTabContext';
import { HeaderActionButton } from '@components/app/HeaderActionButton';
-import { useChannelName, useChannelType } from '@core/context/channels';
-import { isMobile } from '@core/mobile/isMobile';
import PhoneIcon from '@phosphor/phone-call.svg';
-import { useActiveCallQuery } from '@queries/call/call';
-import { ChannelTypeEnum } from '@service-storage/client';
-import { cn, confirmDialog } from '@ui';
+import { cn } from '@ui';
import { tourTarget } from '@ui/components/Tour';
-import { getOwner, Show } from 'solid-js';
+import { Show } from 'solid-js';
import { CHANNEL_TOUR } from '../tour';
-import { getCallJoinTab, getCallLeaveTab } from './call-tabs';
-import { useCall } from './use-call';
+import { useStartChannelCall } from './use-start-channel-call';
export function ChannelCallButton(props: { channelId: string }) {
- const { setActiveTab } = useChannelTab();
- const call = useCall(() => props.channelId, {
- onJoin: () => setActiveTab(getCallJoinTab()),
- onLeave: () => setActiveTab(getCallLeaveTab()),
- });
+ const call = useStartChannelCall(() => props.channelId);
- const activeCallQuery = useActiveCallQuery(() => props.channelId);
- const isCallInProgress = () => !!activeCallQuery.data;
- const channelName = useChannelName(props.channelId);
- const channelType = useChannelType(props.channelId);
- const isDm = () => channelType() === ChannelTypeEnum.DirectMessage;
-
- // Captured now so the confirmation drawer opened from the click handler
- // inherits this component's lifetime (navigating away closes it).
- const owner = getOwner();
-
- const tooltip = () => (isCallInProgress() ? 'Join Call' : 'Start Call');
- const label = () => (isCallInProgress() ? 'Join' : 'Call');
-
- const confirmTitle = () => {
- const name = channelName();
- if (!name) return 'Start a call?';
- return isDm() ? `Call ${name}?` : `Start a call in ${name}?`;
- };
-
- // A DM title ("Call Jane?") already says who rings; the group-channel case
- // is the one where the blast radius needs spelling out.
- const confirmBody = () =>
- isDm() ? undefined : 'Everyone in the channel will be notified.';
-
- const joinCall = async () => {
- if (call.isJoining()) return;
- const wasExistingCall = isCallInProgress();
- analytics.track('call_action', {
- action: 'join_clicked',
- channelId: props.channelId,
- isExistingCall: wasExistingCall,
- });
- try {
- await call.joinCall();
- // A successful join with no call previously in progress means this user
- // started the call. Fires once, from the starter's client.
- if (!wasExistingCall) {
- analytics.track('call_action', {
- action: 'started',
- channelId: props.channelId,
- });
- }
- } catch (e) {
- console.error('Call action failed', e);
- }
- };
-
- const handleClick = async () => {
- if (call.isJoining()) return;
- // On mobile the header button is easy to hit by accident, and starting a
- // call rings everyone in the channel — confirm through a drawer first.
- // Joining a call that's already ringing is deliberate and disturbs no
- // one, so it goes straight through.
- if (isMobile() && !isCallInProgress()) {
- const confirmed = await confirmDialog(
- () => ({
- title: confirmTitle(),
- body: confirmBody(),
- tone: 'success' as const,
- confirmLabel: (
- <>
- <PhoneIcon class="size-5" />
- Start call
- </>
- ),
- }),
- { owner }
- );
- if (!confirmed) return;
- }
- await joinCall();
- };
+ const tooltip = () => (call.isCallInProgress() ? 'Join Call' : 'Start Call');
+ const label = () => (call.isCallInProgress() ? 'Join' : 'Call');
return (
<Show when={!call.isInThisChannel()}>
<HeaderActionButton
ref={tourTarget(CHANNEL_TOUR.call)}
- onClick={handleClick}
+ onClick={() => void call.start()}
tooltip={tooltip()}
label={label()}
icon={<PhoneIcon />}
- class={cn(isCallInProgress() && 'text-success')}
+ class={cn(call.isCallInProgress() && 'text-success')}
/>
</Show>
);
diff --git a/apps/web/src/features/channel/Call/use-start-channel-call.tsx b/apps/web/src/features/channel/Call/use-start-channel-call.tsx
new file mode 100644
index 0000000000..9674fda03f
--- /dev/null
+++ b/apps/web/src/features/channel/Call/use-start-channel-call.tsx
@@ -0,0 +1,99 @@
+import { analytics } from '@app/lib/analytics';
+import { useChannelTab } from '@channel/Channel/ChannelTabContext';
+import { useChannelName, useChannelType } from '@core/context/channels';
+import { isMobile } from '@core/mobile/isMobile';
+import PhoneIcon from '@phosphor/phone-call.svg';
+import { useActiveCallQuery } from '@queries/call/call';
+import { ChannelTypeEnum } from '@service-storage/client';
+import { confirmDialog } from '@ui';
+import { getOwner } from 'solid-js';
+import { getCallJoinTab, getCallLeaveTab } from './call-tabs';
+import { useCall } from './use-call';
+
+/**
+ * Starts or joins a channel's call, as the header's Call button and the
+ * composer's add menu both do. Must be used within `<ChannelTabProvider>`.
+ */
+export function useStartChannelCall(channelId: () => string) {
+ const { setActiveTab } = useChannelTab();
+ const call = useCall(channelId, {
+ onJoin: () => setActiveTab(getCallJoinTab()),
+ onLeave: () => setActiveTab(getCallLeaveTab()),
+ });
+
+ const activeCallQuery = useActiveCallQuery(channelId);
+ const isCallInProgress = () => !!activeCallQuery.data;
+ const channelName = useChannelName(channelId());
+ const channelType = useChannelType(channelId());
+ const isDm = () => channelType() === ChannelTypeEnum.DirectMessage;
+
+ // Captured now so the confirmation drawer opened from a click handler
+ // inherits the caller's lifetime (navigating away closes it).
+ const owner = getOwner();
+
+ const confirmTitle = () => {
+ const name = channelName();
+ if (!name) return 'Start a call?';
+ return isDm() ? `Call ${name}?` : `Start a call in ${name}?`;
+ };
+
+ // A DM title ("Call Jane?") already says who rings; the group-channel case
+ // is the one where the blast radius needs spelling out.
+ const confirmBody = () =>
+ isDm() ? undefined : 'Everyone in the channel will be notified.';
+
+ const joinCall = async () => {
+ if (call.isJoining()) return;
+ const wasExistingCall = isCallInProgress();
+ analytics.track('call_action', {
+ action: 'join_clicked',
+ channelId: channelId(),
+ isExistingCall: wasExistingCall,
+ });
+ try {
+ await call.joinCall();
+ // A successful join with no call previously in progress means this user
+ // started the call. Fires once, from the starter's client.
+ if (!wasExistingCall) {
+ analytics.track('call_action', {
+ action: 'started',
+ channelId: channelId(),
+ });
+ }
+ } catch (e) {
+ console.error('Call action failed', e);
+ }
+ };
+
+ const start = async () => {
+ if (call.isJoining()) return;
+ // On mobile a call action is easy to hit by accident, and starting a
+ // call rings everyone in the channel — confirm through a drawer first.
+ // Joining a call that's already ringing is deliberate and disturbs no
+ // one, so it goes straight through.
+ if (isMobile() && !isCallInProgress()) {
+ const confirmed = await confirmDialog(
+ () => ({
+ title: confirmTitle(),
+ body: confirmBody(),
+ tone: 'success' as const,
+ confirmLabel: (
+ <>
+ <PhoneIcon class="size-5" />
+ Start call
+ </>
+ ),
+ }),
+ { owner }
+ );
+ if (!confirmed) return;
+ }
+ await joinCall();
+ };
+
+ return {
+ start,
+ isCallInProgress,
+ isInThisChannel: call.isInThisChannel,
+ };
+}
diff --git a/apps/web/src/features/channel/Channel/Channel.tsx b/apps/web/src/features/channel/Channel/Channel.tsx
index ce8d6a16eb..2cdbfb5cb7 100644
--- a/apps/web/src/features/channel/Channel/Channel.tsx
+++ b/apps/web/src/features/channel/Channel/Channel.tsx
@@ -1,5 +1,6 @@
import { openChatWithInput } from '@app/features/chat/ChatWithAgentButton';
import { createActivityTracker } from '@channel/activity-tracker';
+import { useStartChannelCall } from '@channel/Call/use-start-channel-call';
import { DebugSuspense } from '@channel/DebugSuspense';
import {
ChannelInput,
@@ -29,6 +30,7 @@ import {
import { FindBar } from '@core/component/FindBar';
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { toast } from '@core/component/Toast/Toast';
+import { ENABLE_CALLS } from '@core/constant/featureFlags';
import {
useChannelActivity,
useChannelName,
@@ -166,6 +168,7 @@ export type ChannelHandle = {
export function Channel(props: ChannelProps) {
const userId = useUserId();
const splitPanel = useSplitPanel();
+ const channelCall = useStartChannelCall(() => props.channelId);
// Full-frame mobile/tablet: the thread list spans the whole screen and messages
// scroll behind the floating header islands (top) and the floating
@@ -1036,6 +1039,12 @@ export function Channel(props: ChannelProps) {
void setChannelInputSnapshot(snapshot)
}
onSend={onSend}
+ onStartCall={
+ ENABLE_CALLS && !channelCall.isInThisChannel()
+ ? () => void channelCall.start()
+ : undefined
+ }
+ callInProgress={channelCall.isCallInProgress()}
onStartTyping={() =>
typingMutation.mutate({
parent: {
diff --git a/apps/web/src/features/channel/Input/ChannelInput.tsx b/apps/web/src/features/channel/Input/ChannelInput.tsx
index ceff7dfebf..3c5746ded9 100644
--- a/apps/web/src/features/channel/Input/ChannelInput.tsx
+++ b/apps/web/src/features/channel/Input/ChannelInput.tsx
@@ -1,11 +1,15 @@
import { useMacroMentionLinkResolver } from '@components/app/split-layout/split-router/mention-links';
+import { EntityIcon } from '@core/component/EntityIcon';
import { ComposerEditor } from '@core/component/LexicalMarkdown/component/ComposerEditor';
import { StaticMarkdown } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { DragInsertIndicator } from '@core/component/LexicalMarkdown/component/misc/DragInsertIndicator';
import {
createDragInsertStore,
INSERT_DOCUMENT_MENTION_COMMAND,
+ TYPE_AT_SYMBOL_COMMAND,
} from '@core/component/LexicalMarkdown/plugins';
+import { ACTIONS } from '@core/component/LexicalMarkdown/plugins/actions/actions';
+import type { ActionContext } from '@core/component/LexicalMarkdown/plugins/actions/types';
import { singleLineMarkdownTheme } from '@core/component/LexicalMarkdown/theme';
import { createComposerLayout } from '@core/component/LexicalMarkdown/utils/create-composer-layout';
import {
@@ -13,6 +17,9 @@ import {
insertDocumentMentionAtDragCoordinates,
updateDragInsertPreviewFromCoordinates,
} from '@core/component/LexicalMarkdown/utils/dragInsertUtils';
+import { handleUserMention } from '@core/component/LexicalMarkdown/utils/mentionsUtils';
+import { isMacroAgentId } from '@core/constant/macroAgent';
+import { isMacroNewId } from '@core/constant/macroNew';
import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
import { createMessageComposer } from '@core/messages/create-message-composer';
import { isTouchDevice } from '@core/mobile/isTouchDevice';
@@ -24,9 +31,19 @@ import {
uploadFile,
} from '@core/util/upload';
import type { EntityData } from '@entity';
+import AtIcon from '@phosphor/at.svg';
+import ChartBarIcon from '@phosphor/chart-bar-horizontal.svg';
+import PaperclipIcon from '@phosphor/paperclip.svg';
+import PhoneIcon from '@phosphor/phone.svg';
import type { MessageParent } from '@service-storage/messages';
import { CollapsedInput, ComposerSurface, cn } from '@ui';
-import { $getRoot } from 'lexical';
+import {
+ $getRoot,
+ $getSelection,
+ $isRangeSelection,
+ $isTextNode,
+ type LexicalEditor,
+} from 'lexical';
import {
type Accessor,
createSignal,
@@ -47,7 +64,15 @@ import { useAgentMentionUsers } from '../use-agent-mention-users';
import { useMessageBotMentionUsers } from '../use-channel-bot-mention-users';
import { useMessageParticipants } from '../use-message-participants';
import { CHANNEL_FILE_PICKER_ACCEPT } from './accepted-file-types';
-import { createConfiguredChannelMarkdownEditor } from './configured-markdown-editor';
+import {
+ ComposerAddDrawer,
+ ComposerAddMenu,
+ type ComposerAddMenuGroup,
+} from './ComposerAddMenu';
+import {
+ channelComposerActions,
+ createConfiguredChannelMarkdownEditor,
+} from './configured-markdown-editor';
import { createCollapsedInputState } from './create-collapsed-input-state';
import { FormatButtons } from './FormatButtons';
import { Input } from './Input';
@@ -88,6 +113,10 @@ export type ChannelInputProps = InputCallbacks & {
/** Dismiss the host after Escape has closed inline menus or dictation. */
onEscape?: () => void;
onReady?: (handle: InputHandle) => void;
+ /** Offers "Start a call" in the add menu; omitted where a call can't start. */
+ onStartCall?: () => void;
+ /** A call is live in the channel, so the add menu offers to join it. */
+ callInProgress?: boolean;
children?: JSX.Element;
/** Whether to auto-focus the input on mount. Defaults to `!isTouchDevice()`. */
autofocus?: boolean;
@@ -108,11 +137,12 @@ export type ChannelInputProps = InputCallbacks & {
function WebDefaultActions(props: {
input: InputData;
dictation: DictationController;
+ addMenu: JSX.Element;
}) {
return (
<>
<Input.Layout.ActionsLeft>
- <Input.AttachFilesAction />
+ {props.addMenu}
<Show when={isReplyInput(props.input)}>
<Input.CloseReplyAction />
</Show>
@@ -128,11 +158,12 @@ function WebDefaultActions(props: {
function IosDefaultActions(props: {
input: InputData;
dictation: DictationController;
+ addMenu: JSX.Element;
}) {
return (
<>
<Input.Layout.ActionsLeft>
- <Input.AttachNativeMediaAction />
+ {props.addMenu}
<Show when={isReplyInput(props.input)}>
<Input.CloseReplyAction />
</Show>
@@ -148,15 +179,24 @@ function IosDefaultActions(props: {
function DefaultActions(props: {
input: InputData;
dictation: DictationController;
+ addMenu: JSX.Element;
}) {
return (
<Show
when={isPlatform('ios')}
fallback={
- <WebDefaultActions input={props.input} dictation={props.dictation} />
+ <WebDefaultActions
+ input={props.input}
+ dictation={props.dictation}
+ addMenu={props.addMenu}
+ />
}
>
- <IosDefaultActions input={props.input} dictation={props.dictation} />
+ <IosDefaultActions
+ input={props.input}
+ dictation={props.dictation}
+ addMenu={props.addMenu}
+ />
</Show>
);
}
@@ -273,8 +313,9 @@ export function ChannelInput(props: ChannelInputProps) {
...(props.bots?.() ?? parentBots()),
]);
+ const groupMentions = !props.parent || props.parent.type === 'channel';
const markdownEditor = createConfiguredChannelMarkdownEditor({
- groupMentions: !props.parent || props.parent.type === 'channel',
+ groupMentions,
namespace: props.markdownNamespace ?? 'channel-input-markdown',
resolveAppLink: useMacroMentionLinkResolver(),
enableMentions: true,
@@ -316,6 +357,170 @@ export function ChannelInput(props: ChannelInputProps) {
// Keyboard, toolbar, and external handles all share this guard.
send: async () => (dictation.active() ? false : inputState.commands.send()),
};
+ // The add menu's actions are the slash menu's, run from the + instead.
+ const actionContext: ActionContext = {
+ sourceBlockName: groupMentions ? 'channel' : undefined,
+ };
+ const sendFromAction = () => void commands.send();
+ const slashAction = (id: string) =>
+ [...ACTIONS, ...channelComposerActions(sendFromAction)].find(
+ (action) => action.id === id
+ );
+ const runInEditor = (
+ run: (editor: LexicalEditor) => void,
+ options: { focus: boolean }
+ ) => {
+ collapsedInput.expand();
+ if (options.focus) focusEditor();
+ queueMicrotask(() => run(lexicalEditor()));
+ };
+ const openMentionTypeahead = (editor: LexicalEditor) => {
+ // The typeahead opens at a word start; step past a preceding word.
+ editor.update(
+ () => {
+ if (!$isRangeSelection($getSelection())) $getRoot().selectEnd();
+ const selection = $getSelection();
+ if (!$isRangeSelection(selection)) return;
+ const { anchor } = selection;
+ const node = anchor.getNode();
+ const previous = $isTextNode(node)
+ ? node.getTextContent().slice(anchor.offset - 1, anchor.offset)
+ : '';
+ if (previous && !/\s/.test(previous)) selection.insertText(' ');
+ },
+ { discrete: true }
+ );
+ editor.dispatchCommand(TYPE_AT_SYMBOL_COMMAND, undefined);
+ };
+ // Whichever Macro the `@macro` typeahead offers: the classic chat reply or
+ // the agent-session bot, depending on rollout.
+ const macroUser = () =>
+ mentionUsers().find(
+ (user) => isMacroAgentId(user.id) || isMacroNewId(user.id)
+ );
+ const addMenuGroups = (): ComposerAddMenuGroup[] => {
+ const create = (
+ id: string,
+ label: string,
+ icon: JSX.Element
+ ): ComposerAddMenuGroup['items'] => {
+ const action = slashAction(id);
+ if (!action) return [];
+ return [
+ {
+ id,
+ label,
+ icon,
+ onSelect: () =>
+ runInEditor((editor) => action.action(editor, actionContext), {
+ focus: false,
+ }),
+ },
+ ];
+ };
+ const macro = macroUser();
+ const startCall = props.onStartCall;
+ const callInProgress = !!props.callInProgress;
+ return [
+ {
+ items: [
+ {
+ id: 'mention',
+ label: 'Mention',
+ icon: <AtIcon class="size-3.5" />,
+ hint: '@',
+ onSelect: () => runInEditor(openMentionTypeahead, { focus: true }),
+ focusesEditor: true,
+ },
+ {
+ id: 'attach',
+ label: 'Attach files',
+ icon: <PaperclipIcon class="size-3.5" />,
+ onSelect: () => collapsedInput.attach(),
+ },
+ ],
+ },
+ {
+ label: 'Create',
+ items: [
+ ...create(
+ 'task',
+ 'New task',
+ <EntityIcon targetType="task" size="xs" />
+ ),
+ ...create(
+ 'poll',
+ 'New poll',
+ <ChartBarIcon class="size-3.5 text-violet" />
+ ),
+ ...create(
+ 'form',
+ 'New form',
+ <EntityIcon targetType="form" size="xs" />
+ ),
+ ...create(
+ 'document',
+ 'New document',
+ <EntityIcon targetType="md" size="xs" />
+ ),
+ ],
+ },
+ {
+ items: [
+ ...(macro
+ ? [
+ {
+ id: 'ask-macro',
+ label: 'Ask Macro',
+ icon: <EntityIcon targetType="agent" size="xs" />,
+ hint: '@macro',
+ onSelect: () =>
+ runInEditor(
+ (editor) => {
+ void handleUserMention(macro, {
+ editor,
+ blockName: groupMentions ? 'channel' : undefined,
+ }).then(() =>
+ editor.update(() => {
+ const selection = $getSelection();
+ if ($isRangeSelection(selection))
+ selection.insertText(' ');
+ })
+ );
+ },
+ { focus: true }
+ ),
+ focusesEditor: true,
+ },
+ ]
+ : []),
+ ...(startCall
+ ? [
+ {
+ id: 'call',
+ label: callInProgress ? 'Join call' : 'Start a call',
+ icon: (
+ <PhoneIcon
+ class={cn('size-3.5', callInProgress && 'text-success')}
+ />
+ ),
+ onSelect: startCall,
+ },
+ ]
+ : []),
+ ],
+ },
+ ];
+ };
+ const [addDrawerOpen, setAddDrawerOpen] = createSignal(false);
+ const addMenu = (pill?: boolean) => (
+ <ComposerAddMenu
+ groups={addMenuGroups()}
+ onOpenDrawer={() => setAddDrawerOpen(true)}
+ class={pill ? 'not-touch:light-mode:text-composer-ink' : undefined}
+ />
+ );
+
const { isCompact: oneLineInput } = createComposerLayout(lexicalEditor(), {
container: layout,
mode: () =>
@@ -504,7 +709,13 @@ export function ChannelInput(props: ChannelInputProps) {
<Switch>
<Match when={props.children}>{props.children}</Match>
<Match when>
- <DefaultActions input={inputState.view()} dictation={dictation} />
+ <DefaultActions
+ input={inputState.view()}
+ dictation={dictation}
+ // The collapsed pill carries the + while collapsed; one + at
+ // a time, so the menu never anchors to a hidden one.
+ addMenu={<Show when={!isCollapsed()}>{addMenu()}</Show>}
+ />
</Match>
</Switch>
</Input.Layout>
@@ -520,17 +731,23 @@ export function ChannelInput(props: ChannelInputProps) {
// flat composer's host card already pads it.
class={cn(props.flat && 'mb-0')}
>
+ <ComposerAddDrawer
+ groups={addMenuGroups()}
+ getEditor={() => lexicalEditor().getRootElement()}
+ open={addDrawerOpen()}
+ onOpenChange={setAddDrawerOpen}
+ />
+ {/* File picker opened from the add menu, collapsed or not. */}
+ <input
+ ref={collapsedInput.setFilePickerRef}
+ type="file"
+ class="hidden"
+ multiple
+ accept={CHANNEL_FILE_PICKER_ACCEPT}
+ onChange={collapsedInput.onFilePickerChange}
+ data-collapsed-input-file-picker
+ />
<Show when={isCollapsed()}>
- {/* File picker opened from the CollapsedInput attach button. */}
- <input
- ref={collapsedInput.setFilePickerRef}
- type="file"
- class="hidden"
- multiple
- accept={CHANNEL_FILE_PICKER_ACCEPT}
- onChange={collapsedInput.onFilePickerChange}
- data-collapsed-input-file-picker
- />
<CollapsedInput
class="touch:rounded-full touch:island"
draft={inputState.view().value}
@@ -548,7 +765,7 @@ export function ChannelInput(props: ChannelInputProps) {
pending={inputState.view().hasPendingAttachments}
disabled={!hasSendableInputContent(inputState.view())}
getFocusTarget={() => lexicalEditor().getRootElement()}
- onAttach={collapsedInput.attach}
+ leadingAction={addMenu(true)}
onOpen={collapsedInput.expand}
trailingAction={<DictationButton dictation={dictation} />}
onSend={() => void commands.send()}
diff --git a/apps/web/src/features/channel/Input/ComposerAddMenu.tsx b/apps/web/src/features/channel/Input/ComposerAddMenu.tsx
new file mode 100644
index 0000000000..adce1370f7
--- /dev/null
+++ b/apps/web/src/features/channel/Input/ComposerAddMenu.tsx
@@ -0,0 +1,190 @@
+import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
+import { focusInput } from '@core/directive/focusInput';
+import { isMobile } from '@core/mobile/isMobile';
+import PlusIcon from '@phosphor/plus.svg';
+import { Button, cn, Dropdown } from '@ui';
+import { For, type JSX, Show } from 'solid-js';
+
+export type ComposerAddMenuItem = {
+ id: string;
+ label: string;
+ icon: JSX.Element;
+ /** A typed shortcut that does the same thing, e.g. `@`. */
+ hint?: string;
+ onSelect: () => void;
+ /**
+ * The item puts the caret in the editor (a mention, an inserted card), so
+ * the editor takes focus as the menu closes instead of the +.
+ */
+ focusesEditor?: boolean;
+};
+
+export type ComposerAddMenuGroup = {
+ /** Heads the group in the desktop menu. */
+ label?: string;
+ items: ComposerAddMenuItem[];
+};
+
+const nonEmpty = (groups: ComposerAddMenuGroup[]) =>
+ groups.filter((group) => group.items.length > 0);
+
+/**
+ * The composer's +: everything that can go into a message. A menu on desktop;
+ * on mobile it opens the composer's `ComposerAddDrawer`.
+ */
+export function ComposerAddMenu(props: {
+ groups: ComposerAddMenuGroup[];
+ onOpenDrawer: () => void;
+ class?: string;
+}) {
+ return (
+ <Show
+ when={isMobile()}
+ fallback={
+ <AddDropdown groups={nonEmpty(props.groups)} class={props.class} />
+ }
+ >
+ <Button
+ variant="ghost"
+ size="icon-composer"
+ class={cn('touch:size-6', props.class)}
+ aria-label="Add"
+ aria-haspopup="dialog"
+ // Keep compatibility mouse focus from blurring the editor before the
+ // tap's click; pointerdown stays uncancelled so WebKit emits it.
+ onMouseDown={(event: MouseEvent) => {
+ if (event.button === 0) event.preventDefault();
+ }}
+ onClick={() => props.onOpenDrawer()}
+ >
+ <PlusIcon />
+ </Button>
+ </Show>
+ );
+}
+
+function AddDropdown(props: {
+ groups: ComposerAddMenuGroup[];
+ class?: string;
+}) {
+ // An item that moves focus into the editor runs once the menu has closed,
+ // in place of the menu's return of focus to the +; otherwise that return
+ // closes the mention typeahead the item just opened.
+ let pending: (() => void) | undefined;
+ const select = (item: ComposerAddMenuItem) => {
+ if (item.focusesEditor) pending = item.onSelect;
+ else item.onSelect();
+ };
+
+ return (
+ <Dropdown placement="top-start" gutter={8}>
+ <Dropdown.Trigger
+ variant="ghost"
+ size="icon-composer"
+ class={cn('touch:size-6', props.class)}
+ aria-label="Add"
+ label="Add"
+ >
+ <PlusIcon />
+ </Dropdown.Trigger>
+ <Dropdown.Content
+ class="min-w-56"
+ onCloseAutoFocus={(event: Event) => {
+ const run = pending;
+ pending = undefined;
+ if (!run) return;
+ event.preventDefault();
+ run();
+ }}
+ >
+ <For each={props.groups}>
+ {(group) => (
+ <Dropdown.Group>
+ <Show when={group.label}>
+ <Dropdown.GroupLabel>{group.label}</Dropdown.GroupLabel>
+ </Show>
+ <For each={group.items}>
+ {(item) => (
+ <Dropdown.Item onSelect={() => select(item)}>
+ <span class="flex size-3.5 shrink-0 items-center justify-center text-ink-muted">
+ {item.icon}
+ </span>
+ <span class="flex-1 truncate">{item.label}</span>
+ <Show when={item.hint}>
+ <span class="shrink-0 pl-4 font-mono text-xs text-ink-extra-muted">
+ {item.hint}
+ </span>
+ </Show>
+ </Dropdown.Item>
+ )}
+ </For>
+ </Dropdown.Group>
+ )}
+ </For>
+ </Dropdown.Content>
+ </Dropdown>
+ );
+}
+
+/**
+ * The mobile add menu. One per composer, mounted outside its collapsing parts:
+ * opening it takes focus from the editor, which collapses the composer and
+ * unmounts the + that opened it.
+ */
+export function ComposerAddDrawer(props: {
+ groups: ComposerAddMenuGroup[];
+ /** The editor element, focused within the tap so the iOS keyboard opens. */
+ getEditor: () => HTMLElement | null | undefined;
+ open: boolean;
+ onOpenChange: (open: boolean) => void;
+}) {
+ return (
+ <MobileDrawer
+ side="bottom"
+ open={props.open}
+ onOpenChange={props.onOpenChange}
+ preventScroll={false}
+ preventScrollbarShift={false}
+ >
+ <MobileDrawer.Portal>
+ <MobileDrawer.Overlay />
+ <MobileDrawer.Content aria-label="Add to message">
+ <MobileDrawer.Handle />
+ <MobileDrawer.ScrollBody class="gap-3">
+ <For each={nonEmpty(props.groups)}>
+ {(group) => (
+ <div class="flex shrink-0 flex-col">
+ {/* Sections alone separate the groups on mobile. */}
+ <MobileDrawer.Section class="flex flex-col">
+ <For each={group.items}>
+ {(item) => (
+ <MobileDrawer.Item
+ data-composer-add-item={item.id}
+ ref={(el) => {
+ if (item.focusesEditor)
+ focusInput(el, () => ({
+ getTarget: props.getEditor,
+ }));
+ }}
+ onClick={() => {
+ props.onOpenChange(false);
+ item.onSelect();
+ }}
+ >
+ <span class="flex size-5 shrink-0 items-center justify-center text-ink-muted [&_svg]:size-5">
+ {item.icon}
+ </span>
+ <span class="flex-1">{item.label}</span>
+ </MobileDrawer.Item>
+ )}
+ </For>
+ </MobileDrawer.Section>
+ </div>
+ )}
+ </For>
+ </MobileDrawer.ScrollBody>
+ </MobileDrawer.Content>
+ </MobileDrawer.Portal>
+ </MobileDrawer>
+ );
+}
diff --git a/apps/web/src/features/channel/Input/configured-markdown-editor.ts b/apps/web/src/features/channel/Input/configured-markdown-editor.ts
index 44a6cc703b..743267ab22 100644
--- a/apps/web/src/features/channel/Input/configured-markdown-editor.ts
+++ b/apps/web/src/features/channel/Input/configured-markdown-editor.ts
@@ -2,6 +2,7 @@ import {
createPollAction,
FORM_ACTION,
} from '@app/features/block-form/composer-actions';
+import type { Action } from '@core/component/LexicalMarkdown/plugins/actions/types';
import { enableForms, isFeatureEnabled } from '@core/constant/featureFlags';
import {
createConfiguredMessageEditor,
@@ -9,22 +10,29 @@ import {
} from '@core/messages/configured-message-editor';
/**
- * Channel surfaces add group mentions, the floating format menu and, with
- * forms on, the `/form` action to common editor setup; a surface that can
- * send (`sendMessage`) also gets `/poll`, which posts the poll at once.
+ * With forms on, channel composers offer `/form`; one that can send
+ * (`sendMessage`) also offers `/poll`, which posts the poll at once.
+ */
+export function channelComposerActions(sendMessage?: () => void): Action[] {
+ if (!isFeatureEnabled(enableForms)) return [];
+ return sendMessage
+ ? [createPollAction(sendMessage), FORM_ACTION]
+ : [FORM_ACTION];
+}
+
+/**
+ * Channel surfaces add group mentions, the floating format menu and the
+ * channel's own actions (`channelComposerActions`) to common editor setup.
*/
export function createConfiguredChannelMarkdownEditor({
sendMessage,
...options
}: MessageEditorOptions & { sendMessage?: () => void }) {
+ const actions = channelComposerActions(sendMessage);
return createConfiguredMessageEditor({
groupMentions: true,
floatingFormatMenu: true,
- additionalActions: isFeatureEnabled(enableForms)
- ? sendMessage
- ? [createPollAction(sendMessage), FORM_ACTION]
- : [FORM_ACTION]
- : undefined,
+ additionalActions: actions.length ? actions : undefined,
...options,
});
}
diff --git a/apps/web/src/features/channel/Input/tests/input-slots.test.tsx b/apps/web/src/features/channel/Input/tests/input-slots.test.tsx
index 2112099ff3..8198f6662c 100644
--- a/apps/web/src/features/channel/Input/tests/input-slots.test.tsx
+++ b/apps/web/src/features/channel/Input/tests/input-slots.test.tsx
@@ -666,10 +666,21 @@ describe('Input slots', () => {
await user.click(screen.getByRole('button', { name: 'Send message' }));
const clickSpy = vi.spyOn(HTMLInputElement.prototype, 'click');
- await user.click(screen.getByRole('button', { name: 'Attach files' }));
- expect(screen.queryByRole('menu')).toBeNull();
expect(screen.queryByRole('button', { name: 'Format' })).toBeNull();
await user.click(screen.getByRole('button', { name: 'Delete reply' }));
+ // The menu is modal, so it opens last.
+ await user.click(screen.getByRole('button', { name: 'Add' }));
+ expect(
+ screen.getAllByRole('menuitem').map((item) => item.textContent)
+ ).toEqual(
+ expect.arrayContaining([
+ 'Mention@',
+ 'Attach files',
+ 'New task',
+ 'New document',
+ ])
+ );
+ await user.click(screen.getByRole('menuitem', { name: 'Attach files' }));
expect(onSend).toHaveBeenCalledOnce();
expect(clickSpy).toHaveBeenCalledOnce();
@@ -693,7 +704,7 @@ describe('Input slots', () => {
));
expect(screen.getByTestId('custom-actions')).toBeTruthy();
- expect(screen.queryByRole('button', { name: 'Attach files' })).toBeNull();
+ expect(screen.queryByRole('button', { name: 'Add' })).toBeNull();
expect(screen.queryByRole('button', { name: 'Send message' })).toBeNull();
});
diff --git a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts
index bd5e82c2a6..e84e092c4a 100644
--- a/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts
+++ b/apps/web/src/lib/core/component/LexicalMarkdown/plugins/mentions/mentionsPlugin.ts
@@ -100,7 +100,8 @@ export const CLOSE_INLINE_SEARCH_COMMAND: LexicalCommand<void> = createCommand(
'CLOSE_INLINE_SEARCH_COMMAND'
);
-const TYPE_AT_SYMBOL_COMMAND: LexicalCommand<void> = createCommand(
+/** Opens the mention typeahead at the caret, as typing `@` there does. */
+export const TYPE_AT_SYMBOL_COMMAND: LexicalCommand<void> = createCommand(
'TYPE_AT_SYMBOL_COMMAND'
);
diff --git a/docs/AGENT_GUIDE/channels.md b/docs/AGENT_GUIDE/channels.md
index ca46f85bfa..2ecdc98478 100644
--- a/docs/AGENT_GUIDE/channels.md
+++ b/docs/AGENT_GUIDE/channels.md
@@ -162,9 +162,14 @@ wrapping paragraph should stay expanded without briefly collapsing; check this
after reopening the channel with a draft already saved. Open reply composers always place the editor
above the action row, including for empty and single-line drafts, so the
attachment, delete-reply, and send controls have their own space.
-Attachment controls use a paperclip in both expanded and collapsed composers,
-including the iOS media picker. Input action and formatting buttons show the
-app tooltip without a second native browser tooltip.
+Both the expanded and collapsed composers start with a `+` button (`Add`). It
+opens a menu on desktop and a bottom drawer on mobile: `Mention` (opens the `@` typeahead), `Attach files` (the file
+picker; the iOS media picker on iOS), then under `Create` the same actions as
+`/task`, `/poll`, `/form` and `/document` (poll and form only with forms on),
+then `Ask Macro` (inserts an `@Macro` mention) and, in a channel, `Start a call`
+(`Join call` while one is live).
+Input action and formatting buttons show the app tooltip without a second
+native browser tooltip.
On desktop, select draft text to open the floating formatting toolbar. Its
compact frame uses 4px outer padding with concentric button corners, a white
light-mode background, a thin border, and a soft downward shadow. Check
diff --git a/docs/AGENT_GUIDE/documents.md b/docs/AGENT_GUIDE/documents.md
index 34fb67dd5a..ab201436eb 100644
--- a/docs/AGENT_GUIDE/documents.md
+++ b/docs/AGENT_GUIDE/documents.md
@@ -2307,7 +2307,7 @@ Document comments are messages read and written through
message components, as channels do.
Below the editor, expand `Discussion` to see comments without a text anchor.
-Its `Leave a comment...` composer is the channel composer: `Attach files`,
+Its `Leave a comment...` composer is the channel composer: the `+` (`Add`) menu,
formatting, mentions, and `Send message` (Enter also submits). Confirm
completion by the new message appearing above the composer; a failed send
retains the draft. The timeline initially loads a bounded page with up to three