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.

chore(agents): good mobile UI (#6229)

Wolf Mermelsteine8cabb33ca0f
diff --git a/apps/web/src/features/block-agent/component/AgentMessage.tsx b/apps/web/src/features/block-agent/component/AgentMessage.tsx
index 10a38ebe23..358fc2349c 100644
--- a/apps/web/src/features/block-agent/component/AgentMessage.tsx
+++ b/apps/web/src/features/block-agent/component/AgentMessage.tsx
@@ -61,7 +61,8 @@ function AgentMessagePart(props: {
function UserMessage(props: { message: FoldedMessage }) {
return (
<div class="flex w-full">
- <div class="relative ml-auto max-w-[calc(100%-8rem)] overflow-hidden rounded-lg border border-edge-muted bg-hover px-3 py-2 text-ink">
+ {/* Phone: a full-width card. Desktop: hugs the text, right-aligned. */}
+ <div class="relative w-full overflow-hidden rounded-lg border border-edge-muted bg-hover px-3 py-2 text-ink md:ml-auto md:w-auto md:max-w-[calc(100%-8rem)]">
<For each={props.message.parts}>
{(part, index) => (
<AgentMessagePart
diff --git a/apps/web/src/features/block-agent/component/AgentRenameModal.tsx b/apps/web/src/features/block-agent/component/AgentRenameModal.tsx
new file mode 100644
index 0000000000..1509530cc3
--- /dev/null
+++ b/apps/web/src/features/block-agent/component/AgentRenameModal.tsx
@@ -0,0 +1,116 @@
+/**
+ * Rename dialog for an agent session. Same chrome as the automation
+ * rename modal — agent sessions are not DSS entities, so they cannot use
+ * the generic bulk-edit rename view.
+ */
+
+import {
+ EntityModalActionFooter,
+ EntityModalTitle,
+} from '@app/features/entity/entity-modal/EntityModal';
+import { getSplitPanelRef } from '@components/app/split-layout/layoutUtils';
+import clickOutside from '@core/directive/clickOutside';
+import { Dialog } from '@kobalte/core/dialog';
+import {
+ type Accessor,
+ createSignal,
+ onMount,
+ type Setter,
+ Show,
+} from 'solid-js';
+import { Portal } from 'solid-js/web';
+
+false && clickOutside;
+
+export function AgentRenameModal(props: {
+ isOpen: Accessor<boolean>;
+ setIsOpen: Setter<boolean>;
+ name: string;
+ onRename: (newName: string) => void;
+}) {
+ return (
+ <Show when={props.isOpen()}>
+ <AgentRenameModalContent
+ isOpen={props.isOpen}
+ setIsOpen={props.setIsOpen}
+ name={props.name}
+ onRename={props.onRename}
+ />
+ </Show>
+ );
+}
+
+function AgentRenameModalContent(props: {
+ isOpen: Accessor<boolean>;
+ setIsOpen: Setter<boolean>;
+ name: string;
+ onRename: (newName: string) => void;
+}) {
+ let inputRef: HTMLInputElement | undefined;
+ const [editValue, setEditValue] = createSignal(props.name);
+
+ const close = () => props.setIsOpen(false);
+
+ const finishEditing = () => {
+ const newValue = editValue().trim();
+ if (newValue) {
+ props.onRename(newValue);
+ }
+ close();
+ };
+
+ const handleKeyDown = (e: KeyboardEvent) => {
+ if (e.key === 'Enter') {
+ e.preventDefault();
+ finishEditing();
+ } else if (e.key === 'Escape') {
+ e.preventDefault();
+ close();
+ }
+ };
+
+ return (
+ <Dialog open={props.isOpen()} onOpenChange={props.setIsOpen} modal={true}>
+ <Portal mount={getSplitPanelRef() ?? undefined}>
+ <Dialog.Overlay
+ as="div"
+ class="absolute z-modal inset-px bg-modal-overlay"
+ use:clickOutside={close}
+ on:click={close}
+ />
+ <div class="absolute z-modal pointer-events-none px-2 inset-px">
+ <Dialog.Content class="pointer-events-none!">
+ <div class="pointer-events-auto w-full max-w-[min(36rem,calc(100%-1rem))] mx-auto mt-16 bg-surface border border-edge h-fit p-2">
+ <div class="w-full my-1">
+ <EntityModalTitle title="Rename" />
+ <div class="w-full">
+ <input
+ ref={(el) => {
+ inputRef = el;
+ onMount(() => {
+ setTimeout(() => {
+ inputRef?.focus();
+ inputRef?.select();
+ });
+ });
+ }}
+ value={editValue()}
+ onInput={(e) => setEditValue(e.currentTarget.value)}
+ onKeyDown={handleKeyDown}
+ class="w-full p-2 text-sm border border-edge bg-surface text-ink placeholder:text-ink-placeholder focus:outline-none focus:bg-active selection:bg-ink selection:text-surface"
+ placeholder="Enter title..."
+ />
+ </div>
+ <EntityModalActionFooter
+ onCancel={close}
+ onConfirm={finishEditing}
+ confirmText="Rename"
+ />
+ </div>
+ </div>
+ </Dialog.Content>
+ </div>
+ </Portal>
+ </Dialog>
+ );
+}
diff --git a/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx b/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx
index 8149d8607f..7f69c80a27 100644
--- a/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx
+++ b/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx
@@ -11,16 +11,19 @@ import {
import { StaticSplitLabel } from '@components/app/split-layout/components/SplitLabel';
import { toast } from '@core/component/Toast/Toast';
import { useUserId } from '@core/context/user';
+import { TOKENS } from '@core/hotkey/tokens';
import { isMobile } from '@core/mobile/isMobile';
import { buildSimpleEntityUrl, openExternalUrl } from '@core/util/url';
import ArrowSquareOut from '@phosphor/arrow-square-out.svg';
import GitBranch from '@phosphor/git-branch.svg';
import LinkIcon from '@phosphor/link.svg';
+import RenameIcon from '@phosphor/pencil-line.svg';
import { handleAgentSessionRenamed } from '@queries/agent-session/session-metadata-sync';
import { agentHarnessServiceClient } from '@service-agent-harness/client';
import type { AgentSessionResponse } from '@service-agent-harness/generated/schemas';
-import { For, Show } from 'solid-js';
+import { createSignal, For, Show } from 'solid-js';
import { useAgentSession } from '../context/AgentSessionContext';
+import { AgentRenameModal } from './AgentRenameModal';
/** 'claude-code' → 'Claude Code'; the fallback when the fold has no title. */
export function harnessTitle(harness: string | undefined): string {
@@ -37,6 +40,10 @@ export function harnessTitle(harness: string | undefined): string {
* toolbar, matching the PR block's shape for non-document blocks: static
* label (names the split tab), copy-link tool, and a file menu with the
* session's repository.
+ *
+ * Rename lives on the title menu (channel / automation), not on a tap of
+ * the name — `StaticSplitLabel` without `onRename` so a touch tap opens
+ * the dropdown instead of an inline editor.
*/
export function AgentSplitHeader(props: {
session: AgentSessionResponse | undefined;
@@ -48,6 +55,7 @@ export function AgentSplitHeader(props: {
// block id is the one thing here that is not a shareable session id.
const { sessionId } = useAgentSession();
const userId = useUserId();
+ const [renameOpen, setRenameOpen] = createSignal(false);
const title = () => {
const persistedName = props.session?.name;
if (persistedName && persistedName !== 'Agent Session')
@@ -75,6 +83,17 @@ export function AgentSplitHeader(props: {
toast.success('Link copied to clipboard');
};
+ const canRename = () => props.session?.ownerId === userId();
+
+ const renameTool: BlockTool = {
+ group: 'file',
+ label: 'Rename',
+ icon: RenameIcon,
+ hotkeyToken: TOKENS.entity.action.rename,
+ action: () => setRenameOpen(true),
+ condition: canRename,
+ };
+
const tools: BlockTool[] = [
{
label: () => {
@@ -112,12 +131,7 @@ export function AgentSplitHeader(props: {
return (
<>
<SplitHeaderLeft>
- <StaticSplitLabel
- iconType="agent"
- label={title()}
- onRename={props.session?.ownerId === userId() ? rename : undefined}
- renameAriaLabel="Agent session name"
- />
+ <StaticSplitLabel iconType="agent" label={title()} />
</SplitHeaderLeft>
{/* Tools live on the header row itself — `ResponsiveBlockToolbar`
@@ -140,12 +154,18 @@ export function AgentSplitHeader(props: {
<ResponsiveBlockToolbar
tools={[]}
- menuTools={tools}
+ menuTools={[renameTool, ...tools]}
ops={ops}
id={sessionId() ?? ''}
itemType="foreign"
name={title()}
/>
+ <AgentRenameModal
+ isOpen={renameOpen}
+ setIsOpen={setRenameOpen}
+ name={title()}
+ onRename={(name) => void rename(name)}
+ />
</>
);
}
diff --git a/apps/web/src/features/block-agent/component/Block.tsx b/apps/web/src/features/block-agent/component/Block.tsx
index 100725266a..6ef680f4a3 100644
--- a/apps/web/src/features/block-agent/component/Block.tsx
+++ b/apps/web/src/features/block-agent/component/Block.tsx
@@ -1,3 +1,4 @@
+import { FloatRegionOrInline } from '@components/app/mobile/float-regions/FloatRegion';
import { SidePanel } from '@components/app/side-panel';
import { SplitPanelContext } from '@components/app/split-layout/context';
import { useBlockId } from '@core/block';
@@ -59,9 +60,17 @@ function AgentBlockContent() {
/>
<div class="size-full min-w-0 flex flex-col">
<Transcript />
- <div class="shrink-0 w-full max-w-3xl mx-auto px-4 pb-4">
- <AgentComposer />
- </div>
+ {/* Full-frame mobile: composer + queue float in the bottom
+ accessory region above the dock; desktop stays inline. */}
+ <FloatRegionOrInline region="accessory">
+ {/* Home/chat: re-enable pointer events on the accessory
+ contribution — the float host is pointer-transparent. */}
+ <div class="flex w-full justify-center shrink-0 px-4 pb-4 pointer-events-auto touch:px-(--mobile-chrome-gutter) touch:pb-0">
+ <div class="w-full md:w-1/2 mx-auto">
+ <AgentComposer />
+ </div>
+ </div>
+ </FloatRegionOrInline>
</div>
<Show when={sessionOriginThread(session())}>
{(origin) => (
diff --git a/apps/web/src/features/block-agent/component/Transcript.tsx b/apps/web/src/features/block-agent/component/Transcript.tsx
index 82a9204d12..a88365116f 100644
--- a/apps/web/src/features/block-agent/component/Transcript.tsx
+++ b/apps/web/src/features/block-agent/component/Transcript.tsx
@@ -19,6 +19,7 @@
import { ScrollToBottomOverlay } from '@channel/Channel/ScrollToBottomOverlay';
import type { ThreadListScrollState } from '@channel/Channel/ThreadList';
+import { createMobileKeyboardScrollPin } from '@core/component/AI/component/message/create-mobile-keyboard-scroll-pin';
import { Scroll } from '@ui';
import { createSignal, onCleanup } from 'solid-js';
import { Virtualizer, type VirtualizerHandle } from 'virtua/solid';
@@ -42,6 +43,7 @@ export function Transcript() {
let growthObserver: ResizeObserver | undefined;
let viewportObserver: ResizeObserver | undefined;
const [transcriptEl, setTranscriptEl] = createSignal<HTMLDivElement>();
+ const [contentEl, setContentEl] = createSignal<HTMLDivElement>();
onCleanup(() => {
cancelPin?.();
@@ -158,11 +160,21 @@ export function Transcript() {
viewportObserver.observe(el);
};
+ // Full-frame mobile: keep pinned to the bottom across virtual-keyboard
+ // show/hide when the reader was already at the bottom — same recipe as
+ // the AI chat, now that the composer lives in the accessory float.
+ createMobileKeyboardScrollPin({
+ scrollEl: () => scrollRef,
+ wrapperEl: contentEl,
+ scrollToBottom: () => pinToBottom(),
+ });
+
return (
<div class="relative flex-1 min-h-0" ref={setTranscriptEl}>
<Scroll scrollRef={attachScroller}>
<div
- class="flex flex-col [overflow-anchor:none]"
+ ref={setContentEl}
+ class="flex flex-col [overflow-anchor:none] touch:pt-[calc(var(--mobile-content-inset-top,0)+0.5rem)] touch:pb-(--mobile-content-inset-bottom)"
style={{ 'min-height': `${viewportHeight()}px` }}
>
{/* Bottom-align short transcripts, chat-style. */}
@@ -190,7 +202,9 @@ export function Transcript() {
}}
>
{(message) => (
- <div class="w-full max-w-3xl mx-auto px-4 pb-4 min-w-0">
+ // Half the pane on desktop so expanding Context grows
+ // down, not out. A phone is full-bleed.
+ <div class="w-full md:w-1/2 mx-auto px-4 pb-4 min-w-0">
<Message message={message} />
</div>
)}
@@ -201,6 +215,7 @@ export function Transcript() {
<ScrollToBottomOverlay
scrollState={scrollState}
onScrollToBottom={pinToBottom}
+ class="touch:top-[calc(var(--mobile-content-inset-top,0)+1rem)]"
/>
<ReplyToSelection container={transcriptEl()} onReply={quoteSelection} />
</div>
diff --git a/apps/web/src/features/block-agent/debug/Gallery.tsx b/apps/web/src/features/block-agent/debug/Gallery.tsx
index 7eb140edba..ef603a7dfd 100644
--- a/apps/web/src/features/block-agent/debug/Gallery.tsx
+++ b/apps/web/src/features/block-agent/debug/Gallery.tsx
@@ -7,6 +7,7 @@
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import type {
FoldedMessage,
+ ModelOption,
ToolStatus,
} from '@service-agent-fold/generated/types';
import { createSignal, type JSX, onCleanup } from 'solid-js';
@@ -15,6 +16,7 @@ import { ReplyToSelection } from '../component/ReplyToSelection';
import {
ActionLine,
AgentInput,
+ AgentModelSelector,
AnimatedNumber,
ComposerNotice,
CountSummary,
@@ -30,6 +32,87 @@ import {
ToolStatusTitle,
} from '../ui';
+/** A Cursor-shaped catalog: long enough to scroll, with one grouped tail. */
+const FIXTURE_MODELS: ModelOption[] = [
+ { id: 'auto', name: 'Auto', description: null, group: null },
+ {
+ id: 'grok-4.6-high-fast',
+ name: 'Cursor Grok 4.6 High Fast',
+ description: null,
+ group: null,
+ },
+ { id: 'composer-2.5', name: 'Composer 2.5', description: null, group: null },
+ {
+ id: 'opus-5-high',
+ name: 'Claude Opus 5 High',
+ description: null,
+ group: null,
+ },
+ {
+ id: 'opus-5-high-fast',
+ name: 'Claude Opus 5 High Fast',
+ description: null,
+ group: null,
+ },
+ { id: 'sol-high', name: 'GPT-5.6 Sol High', description: null, group: null },
+ {
+ id: 'sol-high-fast',
+ name: 'GPT-5.6 Sol High Fast',
+ description: null,
+ group: null,
+ },
+ {
+ id: 'sol-xhigh',
+ name: 'GPT-5.6 Sol Extra High',
+ description: null,
+ group: null,
+ },
+ {
+ id: 'fable-5-high',
+ name: 'Claude Fable 5 High',
+ description: null,
+ group: null,
+ },
+ {
+ id: 'gemini-3.7-flash-high',
+ name: 'Gemini 3.7 Flash High',
+ description: null,
+ group: null,
+ },
+ {
+ id: 'sonnet-5-high',
+ name: 'Claude Sonnet 5 High',
+ description: null,
+ group: null,
+ },
+ {
+ id: 'luna-high',
+ name: 'GPT-5.6 Luna High',
+ description: null,
+ group: 'Legacy',
+ },
+];
+
+/** The composer as the block mounts it, with the model control wired. */
+function ModelSelectorDemo() {
+ const [model, setModel] = createSignal<string | null>('grok-4.6-high-fast');
+ return (
+ <AgentInput
+ onSend={(content) => console.info('[gallery] send', content)}
+ modelControl={
+ <AgentModelSelector
+ model={model()}
+ options={FIXTURE_MODELS}
+ onSelect={(id) => {
+ console.info('[gallery] model', id);
+ setModel(id);
+ }}
+ />
+ }
+ />
+ );
+}
+
function Item(props: { label: string; children: JSX.Element }) {
return (
<section class="flex flex-col gap-2">
@@ -423,6 +506,10 @@ export default function AgentUiGallery() {
/>
</Item>
+ <Item label="AgentInput with model selector">
+ <ModelSelectorDemo />
+ </Item>
+
<Item label="AgentMessage (end-to-end)">
<Message message={FIXTURE_MESSAGE} />
</Item>
diff --git a/apps/web/src/features/block-agent/debug/replay/Replay.tsx b/apps/web/src/features/block-agent/debug/replay/Replay.tsx
index 549b2497ab..d409029405 100644
--- a/apps/web/src/features/block-agent/debug/replay/Replay.tsx
+++ b/apps/web/src/features/block-agent/debug/replay/Replay.tsx
@@ -260,7 +260,7 @@ export default function AgentReplay() {
<div class="flex-1 min-h-0 flex flex-col">
<SessionChrome />
<Transcript />
- <div class="shrink-0 w-full max-w-3xl mx-auto px-4 pb-4">
+ <div class="shrink-0 w-full md:w-1/2 mx-auto px-4 pb-4">
<AgentComposer />
</div>
</div>
diff --git a/apps/web/src/features/block-agent/ui/AgentInput.tsx b/apps/web/src/features/block-agent/ui/AgentInput.tsx
index 705e14ba2e..5df6ddc3c2 100644
--- a/apps/web/src/features/block-agent/ui/AgentInput.tsx
+++ b/apps/web/src/features/block-agent/ui/AgentInput.tsx
@@ -10,6 +10,9 @@
import { buildConfig } from '@core/component/LexicalMarkdown/builder/MarkdownConfigBuilder';
import { MarkdownShell } from '@core/component/LexicalMarkdown/builder/MarkdownShell';
import type { AgentCommandItem } from '@core/component/LexicalMarkdown/plugins';
+import { isMobile } from '@core/mobile/isMobile';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import { useTouchOutsideToDismissKeyboard } from '@core/mobile/useTouchOutsideToDismissKeyboard';
import { $insertReferencedPaste } from '@macro-inc/lexical-core';
import EnterIcon from '@phosphor-icons/core/regular/arrow-bend-down-left.svg?component-solid';
import { Button, SendButton, Surface } from '@ui';
@@ -37,7 +40,7 @@ export interface AgentInputProps {
/** Receives the composed markdown, including any `<m-document-mention>` tags. */
onSend: (markdown: string) => void;
onStop?: () => void;
- /** Sits as a pill above the input box, e.g. the session's model selector. */
+ /** Model control: a pill above the box on desktop, footer-left on touch. */
modelControl?: JSX.Element;
/**
* Ref-style: receives the quote-insert function once the editor mounts
@@ -57,19 +60,21 @@ export interface AgentInputProps {
registerFocus?: (focus: (() => void) | undefined) => void;
}
-/** Past this height the controls drop below the text instead of overlaying it. */
+/** Past this height a phone draft is scroll-capped so it cannot eat the dock. */
const SINGLE_LINE_HEIGHT = 40;
export function AgentInput(props: AgentInputProps) {
const [markdown, setMarkdown] = createSignal('');
+ let containerRef: HTMLDivElement | undefined;
let bodyRef: HTMLDivElement | undefined;
+ useTouchOutsideToDismissKeyboard(() => containerRef);
// Sending while busy is allowed — the service queues prompts behind the
// running turn.
const canSend = () => markdown().trim().length > 0 && !props.disabled;
- // Same content-driven switch as ChatInput: once the editor body wraps past
- // one line, the send button stops overlaying the text and sits below it.
+ // Caps tall drafts on a phone so the editor cannot eat the viewport
+ // above the dock. Controls live in a footer row, not over the text.
const isMultiline = () => {
if (markdown().trim().length === 0) return false;
if (!bodyRef) return false;
@@ -138,29 +143,47 @@ export function AgentInput(props: AgentInputProps) {
onCleanup(() => props.registerQuoteInsert?.(undefined));
});
+ // MarkdownShell only focuses on click when !isMobile(), so padding taps
+ // on a phone miss the empty contenteditable. Focus from this gesture
+ // (channel EditorShell / chat surface) so the whole box is tappable,
+ // including on touch — pointerdown stays inside the user gesture that
+ // iOS needs to raise the keyboard.
+ const focusEditor = (event: Event) => {
+ const target = event.target as HTMLElement | null;
+ if (target?.closest('button')) return;
+ editor.controls.focus();
+ };
+
return (
- <div class="flex flex-col gap-1.5">
- {/* Above the surface rather than inside it: the pill belongs to the
- composer, not to the outlined field, so it must not eat into the
- editor's frame or sit within its border. */}
- <Show when={props.modelControl}>
+ <div ref={containerRef} data-keep-keyboard class="flex flex-col gap-1.5">
+ {/* Desktop: the model pill sits above the box, as it always has. */}
+ <Show when={!isTouchDevice() && props.modelControl}>
<div class="flex items-center px-0.5">{props.modelControl}</div>
</Show>
- <Surface class="rounded-xl" depth={2} solid>
- <div class="relative px-2 py-1.5">
+ {/* h-auto beats Surface's size-full so the in-flow controls are not
+ clipped over the editor (that was Auto sitting on the placeholder). */}
+ <Surface class="rounded-xl touch:rounded-2xl h-auto" depth={2} solid>
+ {/* Desktop: one row, send right of the text. Touch: the text gets
+ the whole width and the controls drop to a footer row (model
+ left, send right) — the chat-tall / channel footer shape. */}
+ <div
+ class="flex items-end gap-1 px-2 py-1.5 touch:flex-col touch:items-stretch touch:gap-1.5 touch:px-3 touch:pt-2.5 touch:pb-2"
+ onPointerDown={focusEditor}
+ >
{/* No vertical padding of its own: the shell is min-h-8 and editor
paragraphs carry my-1.5, so the row's py-1.5 is the whole frame —
the same 44px single-line height as ChatInput. */}
<div
ref={bodyRef}
- class="pl-1 text-sm text-ink"
+ class="min-w-0 flex-1 pl-1 text-sm text-ink touch:pl-0 touch:text-base"
classList={{
- 'pr-10': !isMultiline(),
- 'pb-8': isMultiline(),
// While empty only the placeholder renders; keep it to one clipped
// line so it doesn't wrap into the single-line height.
'overflow-hidden whitespace-nowrap':
markdown().trim().length === 0,
+ // Long drafts must not eat the mobile viewport above the dock.
+ 'max-h-[calc(32*var(--dvh,1dvh))] overflow-y-auto':
+ isMultiline() && isMobile(),
}}
>
<MarkdownShell
@@ -172,41 +195,47 @@ export function AgentInput(props: AgentInputProps) {
/>
</div>
- <div class="absolute right-1.5 bottom-1.5">
- <Show
- when={props.busy && props.onStop}
- fallback={
- <SendButton
- tooltip="Send"
- disabled={!canSend()}
- onClick={send}
- />
- }
- >
+ {/* In-flow — never absolute over the text. */}
+ <div class="flex shrink-0 items-center gap-1 pb-0.5 touch:pb-0">
+ <Show when={isTouchDevice() && props.modelControl}>
+ <div class="min-w-0">{props.modelControl}</div>
+ </Show>
+ <div class="ml-auto shrink-0">
<Show
- when={canSendNext()}
+ when={props.busy && props.onStop}
fallback={
- <Button
- variant="ghost"
- size="icon-sm"
- label="Stop"
- onClick={() => props.onStop?.()}
- class="rounded-[11px] size-7.5 text-ink-extra-muted not-disabled:bg-ink/5 not-disabled:hover:bg-ink/10"
- >
- <div class="size-3.5 rounded-sm bg-current" />
- </Button>
+ <SendButton
+ tooltip="Send"
+ disabled={!canSend()}
+ onClick={send}
+ />
}
>
- <SendButton
- aria-label="Send next queued message"
- tooltip="Send next queued message"
- shortcut="Enter"
- onClick={sendNext}
+ <Show
+ when={canSendNext()}
+ fallback={
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ label="Stop"
+ onClick={() => props.onStop?.()}
+ class="rounded-[11px] size-7.5 text-ink-extra-muted not-disabled:bg-ink/5 not-disabled:hover:bg-ink/10"
+ >
+ <div class="size-3.5 rounded-sm bg-current" />
+ </Button>
+ }
>
- <EnterIcon />
- </SendButton>
+ <SendButton
+ aria-label="Send next queued message"
+ tooltip="Send next queued message"
+ shortcut="Enter"
+ onClick={sendNext}
+ >
+ <EnterIcon />
+ </SendButton>
+ </Show>
</Show>
- </Show>
+ </div>
</div>
</div>
</Surface>
diff --git a/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx b/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx
index 4d0bf65b9c..6a22d0cc1a 100644
--- a/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx
+++ b/apps/web/src/features/block-agent/ui/AgentModelSelector.tsx
@@ -6,21 +6,34 @@
* projection of them, so this component never needs a model registry of its
* own. Renders nothing until the harness has advertised its models.
*
- * Harnesses advertise as many models as they like, so the list scrolls rather
- * than growing without bound: it shows at most `MAX_VISIBLE_ROWS` (or fewer,
- * when the popper has less room than that), leaving the next row half-cut
- * under a gradient so the overflow is visible rather than merely scrollable.
+ * Touch devices get a bottom sheet (`MobileDrawer`, the same chrome as the
+ * split title menu) listing every model with a check on the current one.
+ * Desktop keeps a popover: a compact scrolling list for short catalogs, the
+ * searchable `ModelCatalogPicker` for long ones.
+ *
+ * Harnesses advertise as many models as they like, so the desktop list
+ * scrolls rather than growing without bound: it shows at most
+ * `MAX_VISIBLE_ROWS` (or fewer, when the popper has less room than that),
+ * leaving the next row half-cut under a gradient so the overflow is visible
+ * rather than merely scrollable.
*/
+import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
import { ModelCatalogPicker } from '@core/component/AI/component/input/ModelCatalogPicker';
import { isLargeModelCatalog } from '@core/component/AI/component/input/modelCatalog';
import { ScrollIndicators } from '@core/component/VerticalScrollIndicators';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
+import Check from '@phosphor/check.svg';
import CaretDown from '@phosphor-icons/core/regular/caret-down.svg?component-solid';
import type { ModelOption } from '@service-agent-fold/generated/types';
-import { cn, Dropdown } from '@ui';
-import { createSignal, For, Show } from 'solid-js';
+import { Button, cn, Dropdown } from '@ui';
+import { createMemo, createSignal, For, Show } from 'solid-js';
import { TextShimmer } from './TextShimmer';
+/** Compact ghost pill — same size as the short-list trigger and chat's selector. */
+const PILL_TRIGGER_CLASS =
+ 'h-6 w-auto max-w-[9rem] min-w-0 justify-start gap-1 rounded-full border-transparent bg-ink/5 px-2 text-left text-xs text-ink-muted hover:bg-ink/10';
+
/** Height of one model row — `h-7` on the item, so the cap is exact. */
const ROW_HEIGHT_PX = 28;
/** Rows shown in full before the list starts scrolling. */
@@ -53,8 +66,23 @@ export interface AgentModelSelectorProps {
onSelect: (model: string) => void;
}
+/** Consecutive options under one harness heading (`null` = no heading). */
+type ModelGroup = { label: string | null; options: ModelOption[] };
+
+function groupOptions(options: ModelOption[]): ModelGroup[] {
+ const groups: ModelGroup[] = [];
+ for (const option of options) {
+ const label = option.group ?? null;
+ const last = groups[groups.length - 1];
+ if (last && last.label === label) last.options.push(option);
+ else groups.push({ label, options: [option] });
+ }
+ return groups;
+}
+
export function AgentModelSelector(props: AgentModelSelectorProps) {
const [listRef, setListRef] = createSignal<HTMLElement>();
+ const [sheetOpen, setSheetOpen] = createSignal(false);
const shown = () => props.changingTo ?? props.model;
const label = () =>
props.options.find((option) => option.id === shown())?.name ??
@@ -68,77 +96,144 @@ export function AgentModelSelector(props: AgentModelSelectorProps) {
group: option.group ?? undefined,
}));
const useCatalog = () => isLargeModelCatalog(catalogOptions());
+ const groups = createMemo(() => groupOptions(props.options));
+ const disabled = () => props.disabled || props.changingTo !== undefined;
- return (
- <Show when={props.options.length > 0}>
- <Show
- when={useCatalog()}
- fallback={
- <Dropdown placement="top-start">
- <Dropdown.Trigger
- variant="ghost"
- size="sm"
- class="h-6 gap-1 rounded-full bg-ink/5 px-2 text-xs text-ink-muted hover:bg-ink/10"
- disabled={props.disabled || props.changingTo !== undefined}
- >
- <TextShimmer
- text={label()}
- active={props.changingTo !== undefined}
- />
- <CaretDown />
- </Dropdown.Trigger>
- <Dropdown.Content class="overflow-hidden">
- {/* The gradients anchor here, outside the scrolling box, and read
- the menu background through `--color-surface`. */}
- <div class="relative [--color-surface:var(--color-menu)]">
- <Dropdown.Group
- ref={setListRef}
- class="overflow-y-auto overscroll-contain p-0"
- style={{ 'max-height': LIST_MAX_HEIGHT }}
- >
- <div class="flex flex-col p-1.5">
- <For each={props.options}>
+ const pick = (id: string) => {
+ setSheetOpen(false);
+ if (id !== props.model) props.onSelect(id);
+ };
+
+ const sheet = (
+ <MobileDrawer
+ side="bottom"
+ open={sheetOpen()}
+ onOpenChange={setSheetOpen}
+ preventScroll={false}
+ preventScrollbarShift={false}
+ >
+ {/* Plain text + caret, like the reference composer — no pill. */}
+ <MobileDrawer.Trigger
+ as={Button}
+ variant="ghost"
+ size="sm"
+ aria-label="Agent model"
+ disabled={disabled()}
+ class="h-8 max-w-[60vw] min-w-0 justify-start gap-1 rounded-lg border-none bg-transparent px-1.5 text-left text-sm text-ink-muted hover:bg-hover"
+ >
+ <TextShimmer
+ text={label()}
+ active={props.changingTo !== undefined}
+ class="min-w-0 truncate"
+ />
+ <CaretDown class="size-3.5 shrink-0" />
+ </MobileDrawer.Trigger>
+ <MobileDrawer.Portal>
+ <MobileDrawer.Overlay class="fixed inset-0 z-modal-overlay bg-modal-overlay pattern-diagonal-4 pattern-edge-muted" />
+ <MobileDrawer.Content aria-label="Choose a model">
+ <MobileDrawer.Handle />
+ <MobileDrawer.ScrollBody>
+ <For each={groups()}>
+ {(group) => (
+ <>
+ <Show when={group.label}>
+ {(heading) => (
+ <MobileDrawer.Label>{heading()}</MobileDrawer.Label>
+ )}
+ </Show>
+ <MobileDrawer.Section
+ role="radiogroup"
+ aria-label={group.label ?? 'Models'}
+ class="mb-3 flex shrink-0 flex-col"
+ >
+ <For each={group.options}>
{(option) => (
- <Dropdown.Item
- class={cn(
- 'h-7 shrink-0 gap-2',
- option.id === shown() && 'text-ink font-medium'
- )}
+ <button
+ type="button"
+ role="radio"
+ aria-checked={option.id === shown()}
title={option.description ?? undefined}
- onSelect={() => {
- if (option.id !== props.model)
- props.onSelect(option.id);
- }}
+ class="flex w-full items-center gap-3 bg-surface px-4 py-3 text-left text-sm text-ink hover:bg-hover hover-transition-bg not-last:mb-px"
+ onClick={() => pick(option.id)}
>
- <span class="flex-1 truncate text-xs">
+ <span class="min-w-0 flex-1 truncate">
{option.name}
</span>
- </Dropdown.Item>
+ <Show when={option.id === shown()}>
+ <Check class="size-3.5 shrink-0 text-accent" />
+ </Show>
+ </button>
)}
</For>
- </div>
- </Dropdown.Group>
- <ScrollIndicators scrollRef={listRef} appearance="gradient" />
- </div>
- </Dropdown.Content>
- </Dropdown>
- }
+ </MobileDrawer.Section>
+ </>
+ )}
+ </For>
+ </MobileDrawer.ScrollBody>
+ </MobileDrawer.Content>
+ </MobileDrawer.Portal>
+ </MobileDrawer>
+ );
+
+ const shortList = (
+ <Dropdown placement="top-start">
+ <Dropdown.Trigger
+ variant="ghost"
+ size="sm"
+ class={PILL_TRIGGER_CLASS}
+ disabled={disabled()}
>
- <div class="min-w-44">
+ <TextShimmer text={label()} active={props.changingTo !== undefined} />
+ <CaretDown />
+ </Dropdown.Trigger>
+ <Dropdown.Content class="overflow-hidden">
+ {/* The gradients anchor here, outside the scrolling box, and read
+ the menu background through `--color-surface`. */}
+ <div class="relative [--color-surface:var(--color-menu)]">
+ <Dropdown.Group
+ ref={setListRef}
+ class="overflow-y-auto overscroll-contain p-0"
+ style={{ 'max-height': LIST_MAX_HEIGHT }}
+ >
+ <div class="flex flex-col p-1.5">
+ <For each={props.options}>
+ {(option) => (
+ <Dropdown.Item
+ class={cn(
+ 'h-7 shrink-0 gap-2',
+ option.id === shown() && 'text-ink font-medium'
+ )}
+ title={option.description ?? undefined}
+ onSelect={() => pick(option.id)}
+ >
+ <span class="flex-1 truncate text-xs">{option.name}</span>
+ </Dropdown.Item>
+ )}
+ </For>
+ </div>
+ </Dropdown.Group>
+ <ScrollIndicators scrollRef={listRef} appearance="gradient" />
+ </div>
+ </Dropdown.Content>
+ </Dropdown>
+ );
+
+ return (
+ <Show when={props.options.length > 0}>
+ <Show when={!isTouchDevice()} fallback={sheet}>
+ <Show when={useCatalog()} fallback={shortList}>
<ModelCatalogPicker
value={shown()}
options={catalogOptions()}
- onSelect={(id) => {
- if (id !== props.model) props.onSelect(id);
- }}
- disabled={props.disabled || props.changingTo !== undefined}
+ onSelect={pick}
+ disabled={disabled()}
ariaLabel="Agent model"
searchPlaceholder="Search models"
- triggerClass="h-6 rounded-full bg-ink/5 px-2 text-xs text-ink-muted hover:bg-ink/10"
+ triggerClass={PILL_TRIGGER_CLASS}
contentClass="overflow-hidden"
placement="top-start"
/>
- </div>
+ </Show>
</Show>
</Show>
);
diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.md
index 9d3ef25a72..7246c2bfa6 100644
--- a/docs/AGENT_GUIDE/ai-chat.md
+++ b/docs/AGENT_GUIDE/ai-chat.md
@@ -53,6 +53,19 @@ used in chat and channels; they serialize as `<m-document-mention>` tags in the
the agent sees. Agent replies that emit those tags render as clickable chips in the
transcript (and in the originating channel thread).
+On mobile the composer (and any queued prompts above it) floats in the bottom
+accessory region above the dock — same placement as channel and AI chat — so it
+stays tappable and clear of the home indicator. The box is full width; the text
+sits on top and a footer row holds the model name (left, e.g. `Auto ⌄`) and
+**Send** (right). Tapping the model name opens a bottom sheet listing every
+model with a check on the current one — pick a row to switch. On desktop the
+transcript and composer are half the pane wide so expanding **Context** only
+grows vertically; your messages are right-aligned bubbles and the model pill
+sits above the box. Tap the session title
+to open the title menu (caret), then **Rename** — that opens the same style of
+rename dialog automations use. Do not expect a tap on the name itself to start
+an inline edit.
+
- Sending is never blocked by a running turn. A prompt sent mid-turn is queued
**server-side** and dispatches automatically when the current turn ends, one per turn.
The queue holds at most 50 entries; past that a send is refused with an error rather