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(agents): bring the new agents experience to mobile (#7134)

Wolf Mermelsteind24151138a7a
diff --git a/apps/web/src/components/app/split-layout/componentRegistry.tsx b/apps/web/src/components/app/split-layout/componentRegistry.tsx
index 35875568cb..eb82d042ef 100644
--- a/apps/web/src/components/app/split-layout/componentRegistry.tsx
+++ b/apps/web/src/components/app/split-layout/componentRegistry.tsx
@@ -227,7 +227,7 @@ registerComponent(
'agents',
() => <AgentsRouteView />,
() =>
- isFeatureEnabled(enableChatV3Agents) && !isTouchDevice()
+ isFeatureEnabled(enableChatV3Agents)
? { splitPanelLayout: 'composable' }
: undefined
);
diff --git a/apps/web/src/components/app/split-layout/components/SplitHeader.tsx b/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
index fa1a07f2fe..dcd68ed6d4 100644
--- a/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
+++ b/apps/web/src/components/app/split-layout/components/SplitHeader.tsx
@@ -122,6 +122,12 @@ function getEntitySplitContent(data: EntityDragEvent['draggable']['data']):
);
}
+function hasAgentsBackFallback(content: SplitContent) {
+ return (
+ content.type === 'agent' || (isTouchDevice() && content.type === 'chat')
+ );
+}
+
function SplitBackButton() {
const context = useContext(SplitPanelContext);
if (!context) return null;
@@ -132,10 +138,21 @@ function SplitBackButton() {
class="p-1 touch:active:bg-transparent"
label="Go Back"
hotkey={TOKENS.split.go.back}
- disabled={!context.handle.canGoBack()}
+ disabled={
+ !context.handle.canGoBack() &&
+ !hasAgentsBackFallback(context.handle.content())
+ }
onClick={() => {
if (splitBackInterceptor()?.()) return;
- context.handle.goBack();
+ if (
+ !context.handle.canGoBack() &&
+ hasAgentsBackFallback(context.handle.content())
+ ) {
+ context.handle.replace({
+ next: { type: 'component', id: 'agents' },
+ mergeHistory: true,
+ });
+ } else context.handle.goBack();
}}
>
<CaretLeft />
@@ -602,7 +619,8 @@ export function SplitHeader(props: {
<HeaderIsland
class={cn(
'relative gap-0 px-1',
- (!panel.handle.canGoBack() ||
+ ((!panel.handle.canGoBack() &&
+ !hasAgentsBackFallback(panel.handle.content())) ||
isListViewID(panel.handle.content().id)) &&
'hidden'
)}
diff --git a/apps/web/src/components/app/split-layout/split-router/app-route-shell.tsx b/apps/web/src/components/app/split-layout/split-router/app-route-shell.tsx
index c03cfafefc..b00bc27bc8 100644
--- a/apps/web/src/components/app/split-layout/split-router/app-route-shell.tsx
+++ b/apps/web/src/components/app/split-layout/split-router/app-route-shell.tsx
@@ -28,7 +28,10 @@ export function withAuth<P extends object>(View: Component<P>): Component<P> {
};
}
-export function RedirectSplit(props: { to: SplitContent }) {
+export function RedirectSplit(props: {
+ to: SplitContent;
+ mergeHistory?: boolean;
+}) {
const panel = useSplitPanelOrThrow();
const router = useSplitRouter<SplitId>();
onMount(() => {
@@ -36,6 +39,7 @@ export function RedirectSplit(props: { to: SplitContent }) {
? props.to.entryMetadata
: {};
panel.handle.replace({
+ mergeHistory: props.mergeHistory,
next: {
...props.to,
entryMetadata: {
diff --git a/apps/web/src/features/agent-changes/components/ChangesHeader.tsx b/apps/web/src/features/agent-changes/components/ChangesHeader.tsx
index ff41df28bd..0482a7cbaf 100644
--- a/apps/web/src/features/agent-changes/components/ChangesHeader.tsx
+++ b/apps/web/src/features/agent-changes/components/ChangesHeader.tsx
@@ -1,3 +1,4 @@
+import ArrowLeftIcon from '@phosphor/arrow-left.svg';
import ArrowsInSimpleIcon from '@phosphor/arrows-in-simple.svg';
import ArrowsOutSimpleIcon from '@phosphor/arrows-out-simple.svg';
import GitBranchIcon from '@phosphor/git-branch.svg';
@@ -13,6 +14,7 @@ import { pullRequestNumber } from '../core/pull-request';
* diffs themselves live in the toolbar below.
*/
export function ChangesHeader(props: {
+ mobile?: boolean;
/** The pane fills the width; the session is off screen. */
spotlit: boolean;
/** `head → base`, when known. */
@@ -29,6 +31,16 @@ export function ChangesHeader(props: {
};
return (
<>
+ <Show when={props.mobile}>
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ label="Back to conversation"
+ onClick={props.onClose}
+ >
+ <ArrowLeftIcon />
+ </Button>
+ </Show>
<h2 class="shrink-0 px-1 text-sm font-semibold text-ink">Changes</h2>
<Show when={props.pullRequestUrl}>
<Button
@@ -56,27 +68,29 @@ export function ChangesHeader(props: {
)}
</Show>
<span class="flex-1" />
- <Button
- variant="ghost"
- size="icon-sm"
- aria-pressed={props.spotlit}
- label={
- props.spotlit
- ? 'Back to the split'
- : 'Expand changes to the full width'
- }
- onClick={() => props.onSpotlight()}
- >
- {props.spotlit ? <ArrowsInSimpleIcon /> : <ArrowsOutSimpleIcon />}
- </Button>
- <Button
- variant="ghost"
- size="icon-sm"
- label="Close the changes pane"
- onClick={() => props.onClose()}
- >
- <XIcon />
- </Button>
+ <Show when={!props.mobile}>
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ aria-pressed={props.spotlit}
+ label={
+ props.spotlit
+ ? 'Back to the split'
+ : 'Expand changes to the full width'
+ }
+ onClick={() => props.onSpotlight()}
+ >
+ {props.spotlit ? <ArrowsInSimpleIcon /> : <ArrowsOutSimpleIcon />}
+ </Button>
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ label="Close the changes pane"
+ onClick={() => props.onClose()}
+ >
+ <XIcon />
+ </Button>
+ </Show>
</>
);
}
diff --git a/apps/web/src/features/agent-changes/views/AgentChangesSplit.tsx b/apps/web/src/features/agent-changes/views/AgentChangesSplit.tsx
index 4290b47f8e..11cbb1e131 100644
--- a/apps/web/src/features/agent-changes/views/AgentChangesSplit.tsx
+++ b/apps/web/src/features/agent-changes/views/AgentChangesSplit.tsx
@@ -4,8 +4,11 @@
* takes the session's width away.
*/
+import { FloatRegion } from '@components/app/mobile/float-regions/FloatRegion';
+import { FloatRegions } from '@components/app/mobile/float-regions/float-region-state';
import { Resize } from '@core/component/Resize';
import type { ResizeZoneCtx } from '@core/component/Resize/types';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { type ParentProps, Show } from 'solid-js';
import { useAgentChanges } from '../context/agent-changes-controller';
import { ChangesPane } from './ChangesPane';
@@ -22,39 +25,65 @@ export function AgentChangesSplit(props: ParentProps) {
const changesVisible = () => available() && layout.changesVisible();
return (
- <Resize.Zone
- direction="horizontal"
- gutter={1}
- resizable
- captureResizeCtx={(ctx) => {
- zone = ctx;
- }}
- >
- {/* Panels mount and unmount with the layout: an unregistered panel
- would still paint its content at the zone's left edge. */}
- <Show when={sessionVisible()}>
- <Resize.Panel id="agent-session" minSize={SESSION_MIN_PX} index={0}>
- <div class="flex h-full min-w-0 flex-col overflow-hidden">
- {props.children}
- </div>
- </Resize.Panel>
- </Show>
- <Show when={changesVisible()}>
- <Resize.Panel
- id="agent-changes"
- minSize={CHANGES_MIN_PX}
- index={1}
- target={layout.changesShare()}
- onSizeChangeEnd={(size) => {
- const total = zone?.size() ?? 0;
- if (total > 0) layout.setChangesShare((size / total) * 100);
+ <Show
+ when={isTouchDevice()}
+ fallback={
+ <Resize.Zone
+ direction="horizontal"
+ gutter={1}
+ resizable
+ captureResizeCtx={(ctx) => {
+ zone = ctx;
}}
>
- <div class="h-full min-w-0 overflow-hidden">
+ {/* Panels mount and unmount with the layout: an unregistered panel
+ would still paint its content at the zone's left edge. */}
+ <Show when={sessionVisible()}>
+ <Resize.Panel id="agent-session" minSize={SESSION_MIN_PX} index={0}>
+ <div class="flex h-full min-w-0 flex-col overflow-hidden">
+ {props.children}
+ </div>
+ </Resize.Panel>
+ </Show>
+ <Show when={changesVisible()}>
+ <Resize.Panel
+ id="agent-changes"
+ minSize={CHANGES_MIN_PX}
+ index={1}
+ target={layout.changesShare()}
+ onSizeChangeEnd={(size) => {
+ const total = zone?.size() ?? 0;
+ if (total > 0) layout.setChangesShare((size / total) * 100);
+ }}
+ >
+ <div class="h-full min-w-0 overflow-hidden">
+ <ChangesPane />
+ </div>
+ </Resize.Panel>
+ </Show>
+ </Resize.Zone>
+ }
+ >
+ <div class="relative flex size-full min-w-0 flex-col">
+ <div
+ class="flex size-full min-w-0 flex-col"
+ classList={{ hidden: changesVisible() }}
+ inert={changesVisible()}
+ >
+ {props.children}
+ </div>
+ <Show when={changesVisible()}>
+ <FloatRegion region="accessory" priority={1}>
+ <span />
+ </FloatRegion>
+ <div
+ class="absolute inset-0 min-w-0 pt-(--mobile-content-inset-top)"
+ style={{ 'padding-bottom': `${FloatRegions.hostHeight()}px` }}
+ >
<ChangesPane />
</div>
- </Resize.Panel>
- </Show>
- </Resize.Zone>
+ </Show>
+ </div>
+ </Show>
);
}
diff --git a/apps/web/src/features/agent-changes/views/ChangesPane.tsx b/apps/web/src/features/agent-changes/views/ChangesPane.tsx
index c47feb3790..4bcf81cbac 100644
--- a/apps/web/src/features/agent-changes/views/ChangesPane.tsx
+++ b/apps/web/src/features/agent-changes/views/ChangesPane.tsx
@@ -1,3 +1,4 @@
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
/**
* The Changes pane: a title row with the pane's own controls, a toolbar for
* the diffs, the capture notices, and the file tree beside the diff stack
@@ -104,29 +105,33 @@ function ChangesBody() {
<DiffView.Root
files={model.files()}
patch={model.patch() ?? ''}
- diffStyle={diffStyle()}
+ diffStyle={isTouchDevice() ? 'unified' : diffStyle()}
collapse={collapse}
active={review.active()}
>
<Panel.Toolbar class="gap-1">
- <Button
- variant="ghost"
- size="icon-sm"
- label={layout.treeOpen() ? 'Hide file tree' : 'Show file tree'}
- aria-expanded={layout.treeOpen()}
- onClick={layout.toggleTree}
- >
- <SidebarIcon />
- </Button>
+ <Show when={!isTouchDevice()}>
+ <Button
+ variant="ghost"
+ size="icon-sm"
+ label={layout.treeOpen() ? 'Hide file tree' : 'Show file tree'}
+ aria-expanded={layout.treeOpen()}
+ onClick={layout.toggleTree}
+ >
+ <SidebarIcon />
+ </Button>
+ </Show>
<span class="truncate px-1 text-xs text-ink-subtle">
{describeFileCount(model.files().length)}
</span>
<span class="flex-1" />
- <DiffView.StyleToggle
- value={diffStyle()}
- onChange={setDiffStyle}
- class="max-md:hidden"
- />
+ <Show when={!isTouchDevice()}>
+ <DiffView.StyleToggle
+ value={diffStyle()}
+ onChange={setDiffStyle}
+ class="max-md:hidden"
+ />
+ </Show>
<DiffView.CollapseAll />
<Button
variant="ghost"
@@ -147,7 +152,10 @@ function ChangesBody() {
/>
</Show>
<div class="flex min-h-0 flex-1">
- <CollapseTransition open={layout.treeOpen()} axis="width">
+ <CollapseTransition
+ open={!isTouchDevice() && layout.treeOpen()}
+ axis="width"
+ >
<div class="flex w-64 shrink-0 flex-col overflow-y-auto border-r border-edge-muted p-2 max-md:w-48">
<FileTree.Root
aria-label="Changed files"
@@ -316,6 +324,7 @@ export function ChangesPane() {
<Panel class="rounded-none" role="region" aria-label="Changes">
<Panel.Header class="gap-1.5">
<ChangesHeader
+ mobile={isTouchDevice()}
spotlit={layout.layout() === 'full'}
range={range()}
pullRequestUrl={context.host.pullRequestUrl()}
diff --git a/apps/web/src/features/agent-changes/views/changes-pane.test.tsx b/apps/web/src/features/agent-changes/views/changes-pane.test.tsx
index 6d32efc25f..2000f03c8e 100644
--- a/apps/web/src/features/agent-changes/views/changes-pane.test.tsx
+++ b/apps/web/src/features/agent-changes/views/changes-pane.test.tsx
@@ -1,6 +1,6 @@
import { fireEvent, render, screen, waitFor } from '@solidjs/testing-library';
import { createSignal } from 'solid-js';
-import { describe, expect, it, vi } from 'vitest';
+import { afterEach, describe, expect, it, vi } from 'vitest';
import type { AgentChangesContext } from '../context/agent-changes-context';
import { AgentChangesControllerProvider } from '../context/agent-changes-controller';
import { createLocalPaneViewState } from '../pane-view-state';
@@ -21,11 +21,23 @@ import {
ReviewNotesDock,
} from './SessionChangesControls';
+const device = vi.hoisted(() => ({ touch: false }));
+vi.mock('@core/mobile/isTouchDevice', () => ({
+ isTouchDevice: () => device.touch,
+}));
+afterEach(() => {
+ device.touch = false;
+});
+
// Pierre mounts a custom element and highlights with shiki; the pane test
// covers everything around it and leaves the diff body to the browser.
vi.mock('@app/components/diff-view/pierre/PierreFileDiff', () => ({
- PierreFileDiff: (props: { path: string }) => (
- <div data-testid="diff" data-path={props.path} />
+ PierreFileDiff: (props: { path: string; diffStyle: string }) => (
+ <div
+ data-testid="diff"
+ data-path={props.path}
+ data-style={props.diffStyle}
+ />
),
}));
@@ -88,6 +100,27 @@ function readyContext() {
}
describe('ChangesPane', () => {
+ it('returns to the touch conversation and uses unified diffs without a side tree', async () => {
+ device.touch = true;
+ const { controller } = mount(readyContext(), () => <ChangesPane />);
+ controller().layout.open();
+ controller().setDiffStyle('split');
+ await waitFor(() => expect(screen.getAllByTestId('diff')).toHaveLength(2));
+ expect(
+ screen
+ .getAllByTestId('diff')
+ .every((diff) => diff.dataset.style === 'unified')
+ ).toBe(true);
+ expect(
+ screen.queryByRole('button', { name: 'Expand changes to the full width' })
+ ).toBeNull();
+ expect(screen.queryByRole('button', { name: /file tree/ })).toBeNull();
+ expect(screen.queryByLabelText('Diff layout')).toBeNull();
+ fireEvent.click(
+ screen.getByRole('button', { name: 'Back to conversation' })
+ );
+ expect(controller().layout.changesVisible()).toBe(false);
+ });
it('lists files and collapses individual or all diffs without viewed controls', async () => {
const context = readyContext();
const { controller } = mount(context, () => <ChangesPane />);
diff --git a/apps/web/src/features/agents-view/components/AgentsSidebar.tsx b/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
index 2767f2e17b..41689e8397 100644
--- a/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
+++ b/apps/web/src/features/agents-view/components/AgentsSidebar.tsx
@@ -19,6 +19,7 @@ import {
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { MenuItem } from '@core/component/ContextMenu';
import { useUserId } from '@core/context/user';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { unreadFilterFn } from '@entity/utils/filter';
import ChatIcon from '@phosphor/chat-circle.svg';
import MagnifyingGlassIcon from '@phosphor/magnifying-glass.svg';
@@ -218,43 +219,49 @@ export function AgentsSidebar(props: AgentsSidebarProps) {
return (
<MaybeSoupEntityActionDrawerManager>
<ViewSidebar.Root aria-label="Agents navigation">
- <ViewSidebar.Header>
- <div class="flex min-w-0 items-center gap-1">
- <ViewSidebar.CloseButton />
- <ViewSidebar.Title>Agents</ViewSidebar.Title>
- </div>
- </ViewSidebar.Header>
+ <Show when={!isTouchDevice()}>
+ <ViewSidebar.Header>
+ <div class="flex min-w-0 items-center gap-1">
+ <ViewSidebar.CloseButton />
+ <ViewSidebar.Title>Agents</ViewSidebar.Title>
+ </div>
+ </ViewSidebar.Header>
+ </Show>
- <ViewSidebar.Primary>
- <SidebarCreateButton
- label="New conversation"
- onCreate={props.onNewConversation}
- ref={tourTarget(AGENTS_TOUR.newChat)}
- />
- </ViewSidebar.Primary>
+ <Show when={!isTouchDevice()}>
+ <div class="px-(--sidebar-gutter) pt-2">
+ <SidebarCreateButton
+ label="New conversation"
+ onCreate={props.onNewConversation}
+ ref={tourTarget(AGENTS_TOUR.newChat)}
+ />
+ </div>
+ </Show>
<ViewSidebar.Content class="gap-2 overflow-hidden pt-2">
- <ViewSidebar.Nav aria-label="Agent tools">
- <ViewSidebar.Item
- active={props.activePage === 'agents'}
- onClick={() => props.onOpenPage('agents')}
- ref={tourTarget(AGENTS_TOUR.rosterNav)}
- >
- <ViewSidebar.Icon>
- <AgentIcon />
- </ViewSidebar.Icon>
- <span>Agents</span>
- </ViewSidebar.Item>
- <ViewSidebar.Item
- active={props.activePage === 'connections'}
- onClick={() => props.onOpenPage('connections')}
- >
- <ViewSidebar.Icon>
- <PlugIcon />
- </ViewSidebar.Icon>
- <span>Connections</span>
- </ViewSidebar.Item>
- </ViewSidebar.Nav>
+ <Show when={!isTouchDevice()}>
+ <ViewSidebar.Nav aria-label="Agent tools">
+ <ViewSidebar.Item
+ active={props.activePage === 'agents'}
+ onClick={() => props.onOpenPage('agents')}
+ ref={tourTarget(AGENTS_TOUR.rosterNav)}
+ >
+ <ViewSidebar.Icon>
+ <AgentIcon />
+ </ViewSidebar.Icon>
+ <span>Agents</span>
+ </ViewSidebar.Item>
+ <ViewSidebar.Item
+ active={props.activePage === 'connections'}
+ onClick={() => props.onOpenPage('connections')}
+ >
+ <ViewSidebar.Icon>
+ <PlugIcon />
+ </ViewSidebar.Icon>
+ <span>Connections</span>
+ </ViewSidebar.Item>
+ </ViewSidebar.Nav>
+ </Show>
<CollapsibleSection.Root
open={conversationsOpen()}
onOpenChange={setConversationsOpen}
diff --git a/apps/web/src/features/agents-view/components/ChatComposer.test.tsx b/apps/web/src/features/agents-view/components/ChatComposer.test.tsx
index 94f2801568..a0c685e31f 100644
--- a/apps/web/src/features/agents-view/components/ChatComposer.test.tsx
+++ b/apps/web/src/features/agents-view/components/ChatComposer.test.tsx
@@ -11,6 +11,7 @@ import {
} from 'lexical';
import { createSignal } from 'solid-js';
import { beforeEach, describe, expect, it, vi } from 'vitest';
+import { RepositoryPicker } from '../views/RepositoryPicker';
import { ChatComposer, ChatSessionInput } from './ChatComposer';
vi.mock('@core/mobile/isTouchDevice', () => ({
@@ -450,3 +451,146 @@ it('keeps the paperclip visible while the session is unavailable', () => {
.hasAttribute('disabled')
).toBe(true);
});
+
+it.each([undefined, 'Describe what you want to build'])(
+ 'leaves the mobile editor blank instead of showing placeholder %s',
+ (placeholder) => {
+ vi.mocked(isTouchDevice).mockReturnValue(true);
+ render(() => (
+ <ChatComposer
+ draft=""
+ placeholder={placeholder}
+ onDraftChange={() => {}}
+ onSend={() => {}}
+ selector={<button>Model</button>}
+ />
+ ));
+ expect(screen.getByTestId('editor').textContent).toBe('');
+ }
+);
+
+it('expands Home controls on focus without replacing the editor or model picker', () => {
+ vi.mocked(isTouchDevice).mockReturnValue(true);
+ const { container } = render(() => (
+ <ChatComposer
+ collapseOnBlur
+ draft=""
+ onDraftChange={() => {}}
+ onSend={() => {}}
+ onAttachFiles={() => {}}
+ selector={<button>Model</button>}
+ drawer={<button>Repository</button>}
+ drawerOpen
+ />
+ ));
+ const input = screen.getByTestId('editor');
+ const model = screen.getByRole('button', { name: 'Model' });
+ const attach = screen.getByRole('button', { name: 'Attach files' });
+ const repository = container.querySelector('.composer-drawer');
+ const compact = () => input.closest('[data-composer-compact]');
+
+ expect(compact()?.getAttribute('data-composer-compact')).toBe('true');
+ expect(model.parentElement?.classList.contains('hidden')).toBe(false);
+ expect(attach.parentElement?.classList.contains('hidden')).toBe(true);
+ expect(repository?.getAttribute('aria-hidden')).toBe('true');
+
+ fireEvent.focusIn(input);
+ expect(compact()?.getAttribute('data-composer-compact')).toBe('false');
+ expect(model.parentElement?.classList.contains('hidden')).toBe(false);
+ expect(attach.parentElement?.classList.contains('hidden')).toBe(false);
+ expect(repository?.getAttribute('aria-hidden')).toBe('false');
+
+ fireEvent.pointerDown(document.body);
+ expect(compact()?.getAttribute('data-composer-compact')).toBe('true');
+ expect(repository?.getAttribute('aria-hidden')).toBe('true');
+ expect(screen.getByTestId('editor')).toBe(input);
+ expect(screen.getByRole('button', { name: 'Model' })).toBe(model);
+});
+
+it.each(['Send', 'Attach files', 'Model'])(
+ 'keeps the expanded Home composer stable through an iOS %s tap',
+ (control) => {
+ vi.mocked(isTouchDevice).mockReturnValue(true);
+ const send = vi.fn();
+ render(() => (
+ <ChatComposer
+ collapseOnBlur
+ draft={'First line\nSecond line'}
+ onDraftChange={() => {}}
+ onSend={send}
+ onAttachFiles={() => {}}
+ selector={<button>Model</button>}
+ />
+ ));
+ editor.text = 'First line\nSecond line';
+ const input = screen.getByTestId('editor');
+ const clipped = () => input.parentElement?.classList.contains('max-h-6');
+ fireEvent.focusIn(input);
+ expect(clipped()).toBe(false);
+ const button = screen.getByRole('button', { name: control });
+ fireEvent.pointerDown(button);
+ fireEvent.focusOut(input, { relatedTarget: null });
+ expect(clipped()).toBe(false);
+ fireEvent.click(button);
+ if (control === 'Send')
+ expect(send).toHaveBeenCalledWith('First line\nSecond line', []);
+ fireEvent.pointerDown(document.body);
+ expect(clipped()).toBe(true);
+ }
+);
+
+it.each(['Repository', 'Branch'])(
+ 'keeps the mobile composer expanded while the portaled %s picker has focus',
+ (control) => {
+ vi.mocked(isTouchDevice).mockReturnValue(true);
+ const [controlsOpen, setControlsOpen] = createSignal(false);
+ const { container } = render(() => (
+ <ChatComposer
+ collapseOnBlur
+ controlsOpen={controlsOpen()}
+ draft="Keep this draft"
+ onDraftChange={() => {}}
+ onSend={() => {}}
+ selector={<button>Model</button>}
+ drawerOpen
+ drawer={
+ <RepositoryPicker
+ onOpenChange={setControlsOpen}
+ repoUrl="https://github.com/macro-inc/macro"
+ branch="main"
+ repositories={[]}
+ repositoriesLoading={false}
+ repositoriesError={false}
+ recentRepositories={[]}
+ branches={['main']}
+ branchesLoading={false}
+ branchesError={false}
+ onRetryRepositories={() => {}}
+ onRetryBranches={() => {}}
+ onSelectRepository={() => {}}
+ onSelectBranch={() => {}}
+ />
+ }
+ />
+ ));
+ const input = screen.getByTestId('editor');
+ fireEvent.focusIn(input);
+ fireEvent.click(screen.getByRole('button', { name: control }));
+ const search = screen.getByRole('combobox');
+ expect(container.contains(search)).toBe(false);
+ fireEvent.focusOut(input, { relatedTarget: search });
+ fireEvent.pointerDown(search);
+ expect(controlsOpen()).toBe(true);
+ expect(
+ container.querySelector('.composer-drawer')?.getAttribute('aria-hidden')
+ ).toBe('false');
+ expect(
+ input
+ .closest('[data-composer-compact]')
+ ?.getAttribute('data-composer-compact')
+ ).toBe('false');
+ fireEvent.click(screen.getAllByRole('option')[0]);
+ expect(controlsOpen()).toBe(false);
+ expect(screen.getByTestId('editor')).toBe(input);
+ }
+);
diff --git a/apps/web/src/features/agents-view/components/ChatComposer.tsx b/apps/web/src/features/agents-view/components/ChatComposer.tsx
index 54ad088648..09f2bad987 100644
--- a/apps/web/src/features/agents-view/components/ChatComposer.tsx
+++ b/apps/web/src/features/agents-view/components/ChatComposer.tsx
@@ -17,6 +17,7 @@ import { useTouchOutsideToDismissKeyboard } from '@core/mobile/useTouchOutsideTo
import { handleFileFolderDrop } from '@core/util/upload';
import { $insertReferencedPaste } from '@macro-inc/lexical-core';
import PlusIcon from '@phosphor/plus.svg';
+import { makeEventListener } from '@solid-primitives/event-listener';
import { createResizeObserver } from '@solid-primitives/resize-observer';
import { Button, ComposerSurface, SendButton } from '@ui';
import {
@@ -32,6 +33,9 @@ import { createChatComposerTip } from '../primitives/chat-composer-tip';
/** Shared input that starts on one line and grows with the draft. */
export function ChatComposer(props: {
autoFocus?: boolean;
+ collapseOnBlur?: boolean;
+ /** Portaled controls retain their anchor when focus leaves the composer. */
+ controlsOpen?: boolean;
registerFocus?: (focus: () => void) => void;
draft: string;
onDraftChange: (draft: string) => void;
@@ -76,6 +80,13 @@ export function ChatComposer(props: {
setHeight(element.getBoundingClientRect().height);
});
let container: HTMLDivElement | undefined;
+ const [focused, setFocused] = createSignal(false);
+ const collapsed = () =>
+ isTouchDevice() &&
+ props.collapseOnBlur &&
+ !focused() &&
+ !props.controlsOpen;
+ const drawerOpen = () => props.drawerOpen && !collapsed();
useTouchOutsideToDismissKeyboard(() => container);
const disabled = () => !!props.blockedReason || props.session?.disabled;
const canSendNext = () =>
@@ -130,6 +141,12 @@ export function ChatComposer(props: {
const { isCompact } = createComposerLayout(editor.buildHandle().lexical, {
container: layout,
+ mode: () =>
+ collapsed()
+ ? 'collapsed'
+ : isTouchDevice() && props.collapseOnBlur
+ ? 'expanded'
+ : 'auto',
});
// Apply host-supplied drafts (Home suggestions) to the existing editor.
@@ -139,6 +156,12 @@ export function ChatComposer(props: {
});
onMount(() => {
+ if (props.collapseOnBlur) {
+ makeEventListener(document, 'pointerdown', (event) => {
+ if (event.target instanceof Node && !container?.contains(event.target))
+ setFocused(false);
+ });
+ }
props.registerFocus?.(() => editor.controls.focus());
props.session?.registerFocus?.(() => editor.controls.focus());
props.session?.registerQuoteInsert?.((text) => {
@@ -196,11 +219,25 @@ export function ChatComposer(props: {
commands: inputCommands,
}}
>
- <div ref={container} data-keep-keyboard class="min-w-0">
+ <div
+ ref={container}
+ data-keep-keyboard
+ class="min-w-0"
+ onFocusIn={() => setFocused(true)}
+ onFocusOut={(event) => {
+ // iOS control taps can blur with no relatedTarget before click.
+ // Collapse only for a known outside focus or pointer interaction.
+ if (
+ event.relatedTarget instanceof Node &&
+ !event.currentTarget.contains(event.relatedTarget)
+ )
+ setFocused(false);
+ }}
+ >
<ComposerSurface
as="div"
data-agent-composer="chat"
- class="relative z-10 min-w-0 rounded-[32px] transition-[height] duration-200 ease-[cubic-bezier(0.77,0,0.175,1)] motion-reduce:transition-none"
+ class="relative z-10 min-w-0 rounded-[32px] touch:island touch:bg-chrome transition-[height] duration-200 ease-[cubic-bezier(0.77,0,0.175,1)] motion-reduce:transition-none"
style={{
height: height() === undefined ? undefined : `${height()}px`,
}}
@@ -229,13 +266,15 @@ export function ChatComposer(props: {
7.5px padding + half the button/line-height difference. */}
<div
ref={setLayout}
- data-composer-compact={!props.drawerOpen && isCompact()}
- data-composer-coding={props.drawerOpen || undefined}
- class="group/composer flex min-w-0 data-[composer-compact=false]:flex-wrap items-end gap-2 p-[7.5px] pl-3 data-[composer-compact=false]:pb-2.5 data-[composer-compact=false]:px-3 data-[composer-compact=false]:pt-[calc(7.5px_+_(33.75px_-_1.5rem)/2)]"
+ data-composer-compact={!drawerOpen() && isCompact()}
+ data-composer-coding={drawerOpen() || undefined}
+ data-composer-collapsed={collapsed() || undefined}
+ class="group/composer flex min-w-0 data-[composer-compact=false]:flex-wrap items-end gap-2 p-[7.5px] pl-3 data-[composer-compact=false]:pb-2.5 data-[composer-compact=false]:px-3 data-[composer-compact=false]:pt-[calc(7.5px_+_(33.75px_-_1.5rem)/2)] data-[composer-collapsed=true]:h-(--mobile-chrome-button-size) data-[composer-collapsed=true]:items-center data-[composer-collapsed=true]:py-0 data-[composer-collapsed=true]:pl-3.5 data-[composer-collapsed=true]:pr-[9.5px]"
>
<Show when={props.onAttachFiles}>
<div
data-composer-controls
+ classList={{ hidden: !!collapsed() }}
class="shrink-0 group-data-[composer-compact=false]/composer:order-1"
>
<Input.AttachFilesAction
@@ -246,12 +285,20 @@ export function ChatComposer(props: {
</Input.AttachFilesAction>
</div>
</Show>
- <div class="max-h-60 min-w-0 flex-1 self-center group-data-[composer-compact=false]/composer:flex-none group-data-[composer-compact=false]/composer:basis-full overflow-y-auto px-[9.375px] group-data-[composer-compact=true]/composer:px-0 group-data-[composer-coding=true]/composer:min-h-[58px]">
+ <div
+ classList={{
+ 'max-h-6 overflow-hidden': !!collapsed(),
+ 'max-h-[min(15rem,30dvh)]': !collapsed(),
+ }}
+ class="min-w-0 flex-1 self-center group-data-[composer-compact=false]/composer:flex-none group-data-[composer-compact=false]/composer:basis-full overflow-y-auto px-[9.375px] group-data-[composer-compact=true]/composer:px-0 group-data-[composer-coding=true]/composer:min-h-[58px]"
+ >
<MarkdownShell
class="h-auto min-h-6 text-base leading-6 [&_[data-markdown-editable]]:min-h-6 [&_[data-markdown-editable]]:outline-none [&_[data-markdown-editable]>.md-p]:my-0 [&_[data-markdown-placeholder]]:max-w-full [&_[data-markdown-placeholder]>p]:m-0 [&_[data-markdown-placeholder]>p]:truncate"
config={editor}
initialValue={props.draft}
- placeholder={props.placeholder ?? tip()}
+ placeholder={
+ isTouchDevice() ? '' : (props.placeholder ?? tip())
+ }
refFn={(element) =>
element.setAttribute('aria-label', 'Message the agent')
}
@@ -268,11 +315,15 @@ export function ChatComposer(props: {
aria-label="Composer settings"
>
<div class="ml-auto flex min-w-0 max-w-full items-center gap-2 [&_.menu]:right-0 [&_.menu]:left-auto [&_.menu-anchor]:min-w-0 [&_.pill]:max-w-full">
- {props.selector}
- <DictationButton
- dictation={dictation}
- disabled={disabled()}
- />
+ <div class="flex min-w-0 items-center gap-2">
+ {props.selector}
+ <div class={collapsed() ? 'hidden' : 'contents'}>
+ <DictationButton
+ dictation={dictation}
+ disabled={disabled()}
+ />
+ </div>
+ </div>
<Show
when={
(props.session?.busy || canSendNext()) &&
@@ -327,9 +378,9 @@ export function ChatComposer(props: {
<Show when={props.drawer}>
<div
class="composer-drawer"
- data-open={props.drawerOpen ? '' : undefined}
- aria-hidden={!props.drawerOpen}
- inert={!props.drawerOpen}
+ data-open={drawerOpen() ? '' : undefined}
+ aria-hidden={!drawerOpen()}
+ inert={!drawerOpen()}
>
<div class="composer-drawer-inner">
<div
diff --git a/apps/web/src/features/agents-view/components/Topbar.tsx b/apps/web/src/features/agents-view/components/Topbar.tsx
index 9f247ecd02..933a7845d1 100644
--- a/apps/web/src/features/agents-view/components/Topbar.tsx
+++ b/apps/web/src/features/agents-view/components/Topbar.tsx
@@ -1,16 +1,33 @@
import { ViewShell } from '@app/components/view-shell/ViewShell';
import { SplitPanel } from '@components/app/split-panel';
-import type { JSX } from 'solid-js';
+import ArrowLeft from '@phosphor/arrow-left.svg';
+import { Button } from '@ui';
+import { type JSX, Show } from 'solid-js';
/** Shared workspace chrome for conversation and new-session pages. */
export function Topbar(props: {
title: string;
+ onBack?: () => void;
titleContent?: JSX.Element;
children?: JSX.Element;
}) {
return (
<ViewShell.TopBar class="touch:flex">
- <SplitPanel.CloseButton class="hidden shrink-0 @max-[720px]/view-shell:flex" />
+ <Show
+ when={props.onBack}
+ fallback={
+ <SplitPanel.CloseButton class="hidden shrink-0 @max-[720px]/view-shell:flex" />
+ }
+ >
+ <Button
+ variant="ghost"
+ size="icon-md"
+ label="Back to conversations"
+ onClick={props.onBack}
+ >
+ <ArrowLeft />
+ </Button>
+ </Show>
<div class="flex min-w-0 items-center gap-1">
{props.titleContent ?? (
<h1 class="min-w-0 truncate text-sm font-semibold tracking-[-0.03em] text-ink">
diff --git a/apps/web/src/features/agents-view/mobile-agent-composer.tsx b/apps/web/src/features/agents-view/mobile-agent-composer.tsx
new file mode 100644
index 0000000000..88b8764bcb
--- /dev/null
+++ b/apps/web/src/features/agents-view/mobile-agent-composer.tsx
@@ -0,0 +1,42 @@
+import { useSplitLayout } from '@components/app/split-layout/layout';
+import { useUserId } from '@core/context/user';
+import { Suspense } from 'solid-js';
+import { startPendingSession } from '../block-agent/context/pending-session';
+import { openAgentsPage } from './primitives/open-page';
+import { createAgentRosterSource } from './queries/agent-roster-source';
+import { NewChatPage, type StartConversation } from './views/NewChatPage';
+import './agents-view.css';
+
+/** The mobile accessory uses the same agent choices and send contract as Home. */
+function Composer() {
+ const roster = createAgentRosterSource();
+ const layout = useSplitLayout();
+ const userId = useUserId();
+ const start = (conversation: StartConversation) => {
+ const id = startPendingSession({ ...conversation, userId: userId() });
+ layout.openWithSplit({ type: 'agent', id }, { referredFrom: 'agents' });
+ };
+ return (
+ <div class="agents-view-portal min-w-0">
+ <NewChatPage
+ compact
+ autoFocus={false}
+ roster={roster.roster()}
+ rosterLoading={roster.loading()}
+ availabilityLoading={roster.availabilityLoading()}
+ onStart={start}
+ onOpenRoster={() => openAgentsPage(layout, 'agents')}
+ />
+ </div>
+ );
+}
+
+export function MobileAgentComposer() {
+ return (
+ <Suspense
+ fallback={<div class="h-12" aria-label="Loading agent composer" />}
+ >
+ <Composer />
+ </Suspense>
+ );
+}
diff --git a/apps/web/src/features/agents-view/primitives/open-composer.ts b/apps/web/src/features/agents-view/primitives/open-composer.ts
index 9d14061a76..b1d61b1e0e 100644
--- a/apps/web/src/features/agents-view/primitives/open-composer.ts
+++ b/apps/web/src/features/agents-view/primitives/open-composer.ts
@@ -28,11 +28,17 @@ export function openAgentComposer(
}
// Scope focus to this split and the new-chat input, never an existing session
// or Home's shared composer. Wait for asynchronous route/query mounting.
- triggerFocusInput(() =>
- Array.from(
- document.querySelectorAll<HTMLElement>('[data-agents-workspace]')
- )
- .find((element) => element.dataset.agentsWorkspace === split.id)
- ?.querySelector<HTMLElement>('.newchat [contenteditable="true"]')
+ triggerFocusInput(
+ () =>
+ Array.from(
+ document.querySelectorAll<HTMLElement>('[data-agent-new-composer]')
+ )
+ .find((element) => element.dataset.agentNewComposer === split.id)
+ ?.querySelector<HTMLElement>('[contenteditable="true"]') ??
+ Array.from(
+ document.querySelectorAll<HTMLElement>('[data-agents-workspace]')
+ )
+ .find((element) => element.dataset.agentsWorkspace === split.id)
+ ?.querySelector<HTMLElement>('.newchat [contenteditable="true"]')
);
}
diff --git a/apps/web/src/features/agents-view/route.test.tsx b/apps/web/src/features/agents-view/route.test.tsx
index 9f5b3a4e4e..26f06f0ee7 100644
--- a/apps/web/src/features/agents-view/route.test.tsx
+++ b/apps/web/src/features/agents-view/route.test.tsx
@@ -8,6 +8,8 @@ const state = vi.hoisted(() => ({
enabled: false,
loading: true,
}),
+ routeId: 'agents',
+ redirect: vi.fn(),
updateMeta: vi.fn(),
touch: false,
}));
@@ -24,7 +26,7 @@ vi.mock('@components/app/split-layout/layoutUtils', () => ({
handle: {
content: () => ({
type: 'component',
- id: 'agents',
+ id: state.routeId,
params: { agentPage: 'connections' },
}),
updateMeta: state.updateMeta,
@@ -34,7 +36,10 @@ vi.mock('@components/app/split-layout/layoutUtils', () => ({
vi.mock('@components/app/split-layout/split-router/app-route-shell', () => ({
withAuth: (view: unknown) => view,
usePageViewTracking: () => {},
- RedirectSplit: () => null,
+ RedirectSplit: (props: { to: unknown; mergeHistory?: boolean }) => {
+ state.redirect(props.to, props.mergeHistory);
+ return null;
+ },
}));
vi.mock('@core/component/LoadingBlock', () => ({ LoadingBlock: () => null }));
vi.mock('@core/constant/featureFlags', () => ({
@@ -52,6 +57,7 @@ vi.mock('../settings/McpConnections', () => ({ McpConnections: () => null }));
beforeEach(() => {
vi.clearAllMocks();
state.touch = false;
+ state.routeId = 'agents';
});
afterEach(cleanup);
@@ -77,7 +83,7 @@ it('updates Agents layout metadata after the remote flag loads and changes', ()
});
});
-it('keeps the legacy layout on touch devices when Agents is enabled', () => {
+it('uses the new Agents layout on touch devices when enabled', () => {
state.touch = true;
state.flag = () => ({ enabled: true, loading: false });
render(() => (
@@ -87,6 +93,21 @@ it('keeps the legacy layout on touch devices when Agents is enabled', () => {
));
expect(state.updateMeta).toHaveBeenCalledWith({
- splitPanelLayout: 'legacy',
+ splitPanelLayout: 'composable',
});
});
+
+it('replaces the mobile conversation alias instead of trapping Back in a redirect', () => {
+ state.touch = true;
+ state.routeId = 'agents-session~agents~session-id';
+ state.flag = () => ({ enabled: true, loading: false });
+ render(() => (
+ <Suspense fallback={null}>
+ <AgentsRouteView />
+ </Suspense>
+ ));
+ expect(state.redirect).toHaveBeenCalledWith(
+ { type: 'agent', id: 'session-id' },
+ true
+ );
+});
diff --git a/apps/web/src/features/agents-view/route.tsx b/apps/web/src/features/agents-view/route.tsx
index 859a27d01a..ef8c252b5b 100644
--- a/apps/web/src/features/agents-view/route.tsx
+++ b/apps/web/src/features/agents-view/route.tsx
@@ -60,7 +60,7 @@ export const AgentsRouteView = withAuth(() => {
};
usePageViewTracking('agents');
const flag = useFeatureFlag(enableChatV3Agents);
- const enabled = () => flag().enabled && !isTouchDevice();
+ const enabled = () => flag().enabled;
createRenderEffect(() => {
if (flag().loading) return;
panel.handle.updateMeta?.({
@@ -101,7 +101,23 @@ export const AgentsRouteView = withAuth(() => {
</Show>
}
>
- <AgentsView initialRoute={route()} />
+ <Show
+ when={isTouchDevice() && route()}
+ fallback={<AgentsView initialRoute={route()} />}
+ >
+ {(current) => (
+ <RedirectSplit
+ mergeHistory
+ to={{
+ type:
+ current().conversation.type === 'agent_session'
+ ? 'agent'
+ : 'chat',
+ id: current().conversation.id,
+ }}
+ />
+ )}
+ </Show>
</Show>
</Show>
);
diff --git a/apps/web/src/features/agents-view/views/AgentPicker.tsx b/apps/web/src/features/agents-view/views/AgentPicker.tsx
index 55ce0f6710..aa3ebe2bb2 100644
--- a/apps/web/src/features/agents-view/views/AgentPicker.tsx
+++ b/apps/web/src/features/agents-view/views/AgentPicker.tsx
@@ -23,9 +23,10 @@ import {
} from '../core/roster';
import { createComposerModels } from '../queries/composer-models';
import { AGENTS_TOUR } from '../tour';
+import { MobileAgentPicker } from './MobileAgentPicker';
/** Agent selection with a per-message model catalog in each submenu. */
-export function AgentPicker(props: {
+export type AgentPickerProps = {
agents: RosterAgent[];
selected?: RosterAgent;
modelOverride?: string;
@@ -41,7 +42,17 @@ export function AgentPicker(props: {
) => void;
onConnect: (agent: RosterAgent) => void;
onCreate: () => void;
-}) {
+};
+
+export function AgentPicker(props: AgentPickerProps) {
+ return (
+ <Show when={isTouchDevice()} fallback={<DesktopAgentPicker {...props} />}>
+ <MobileAgentPicker {...props} />
+ </Show>
+ );
+}
+
+function DesktopAgentPicker(props: AgentPickerProps) {
const [open, setOpen] = createSignal(false);
const catalog = createComposerModels(() => props.selected);
const macro = () =>
diff --git a/apps/web/src/features/agents-view/views/AgentsView.tsx b/apps/web/src/features/agents-view/views/AgentsView.tsx
index de6f15b286..423749028a 100644
--- a/apps/web/src/features/agents-view/views/AgentsView.tsx
+++ b/apps/web/src/features/agents-view/views/AgentsView.tsx
@@ -9,6 +9,7 @@ import {
useGlobalBlockOrchestrator,
useGlobalNotificationSource,
} from '@components/app/GlobalAppState';
+import { FloatRegions } from '@components/app/mobile/float-regions/float-region-state';
import { PreviewPanel } from '@components/app/PreviewPanel';
import { previewBlockTarget } from '@components/app/previewTarget';
import { useSplitLayout } from '@components/app/split-layout/layout';
@@ -18,6 +19,7 @@ import { ChatEmptyStateContext } from '@core/component/AI/component/message/Empt
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
import { toast } from '@core/component/Toast/Toast';
import { useUserId } from '@core/context/user';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { ListEntityMetadataQueryProvider } from '@entity';
import SpinnerIcon from '@phosphor/spinner.svg';
import { useSoupItemsQuery } from '@queries/soup/items';
@@ -88,6 +90,8 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
}
: undefined
);
+ const [mobileList, setMobileList] = createSignal(true);
+ const [draft, setDraft] = createSignal('');
const [search, setSearch] = createSignal('');
const rosterSource = createAgentRosterSource();
const query = useSoupItemsQuery(
@@ -128,18 +132,15 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
let composerFocus: (() => void) | undefined;
const showComposer = () => {
+ setMobileList(false);
if (panel.handle.content().id !== 'agents') {
panel.handle.replace({ next: { type: 'component', id: 'agents' } });
return;
}
- // Already showing the composer: nothing remounts to retrigger autofocus,
- // so focus it imperatively instead.
- if (!selected() && page() === 'new') {
- composerFocus?.();
- return;
- }
setSelected(undefined);
setPage('new');
+ // The preflight page stays mounted when navigating through management.
+ composerFocus?.();
};
// A launcher navigation can target this already-mounted workspace.
createEffect(
@@ -151,11 +152,19 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
: undefined;
},
(request) => {
- if (request) showComposer();
+ if (!request) return;
+ const content = panel.handle.content();
+ if (
+ content.type === 'component' &&
+ typeof content.params?.draft === 'string'
+ )
+ setDraft(content.params.draft);
+ showComposer();
}
)
);
const openPage = (next: AgentsPage) => {
+ setMobileList(false);
setSelected(undefined);
setPage(next);
};
@@ -178,6 +187,7 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
)
);
const openRoster = (_kind: AgentKind) => {
+ setMobileList(false);
setSelected(undefined);
setPage('agents');
};
@@ -186,6 +196,16 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
event?: MouseEvent,
targetMode: AgentsMode = mode()
) => {
+ if (isTouchDevice()) {
+ layout.openWithSplit(
+ {
+ type: conversation.type === 'agent_session' ? 'agent' : 'chat',
+ id: conversation.id,
+ },
+ { referredFrom: 'agents' }
+ );
+ return;
+ }
const next = {
type: 'component' as const,
id: agentsRouteId({ mode: targetMode, conversation }),
@@ -243,6 +263,31 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
return 'New conversation';
};
+ const sidebar = () => (
+ <AgentsSidebar
+ activePage={selected() ? undefined : page()}
+ onOpenPage={(next) =>
+ next === 'agents' ? openRoster('agent') : openPage(next)
+ }
+ modeForConversation={modeForConversation}
+ activeConversationId={selected()?.activeConversationId}
+ search={search()}
+ conversations={partitioned().conversations}
+ archived={partitioned().archived}
+ loading={query.isPending}
+ error={query.isLoadingError}
+ hasNextPage={Boolean(query.hasNextPage)}
+ loadingNextPage={query.isFetchingNextPage}
+ onNewConversation={showComposer}
+ onSearchChange={setSearch}
+ onOpenConversation={(conversation, event) =>
+ openConversation(conversation, event, modeForConversation(conversation))
+ }
+ onRetry={() => void query.refetch()}
+ onLoadMore={() => void query.fetchNextPage()}
+ />
+ );
+
return (
<SplitPanel.Root>
<SplitPanel.Body>
@@ -264,44 +309,29 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
}}
main={{ min: 280, preferredWidth: 640 }}
>
- <ViewShell.Aside>
- <AgentsSidebar
- activePage={selected() ? undefined : page()}
- onOpenPage={(next) =>
- next === 'agents' ? openRoster('agent') : openPage(next)
- }
- modeForConversation={modeForConversation}
- activeConversationId={selected()?.activeConversationId}
- search={search()}
- conversations={partitioned().conversations}
- archived={partitioned().archived}
- loading={query.isPending}
- error={query.isLoadingError}
- hasNextPage={Boolean(query.hasNextPage)}
- loadingNextPage={query.isFetchingNextPage}
- onNewConversation={showComposer}
- onSearchChange={setSearch}
- onOpenConversation={(conversation, event) =>
- openConversation(
- conversation,
- event,
- modeForConversation(conversation)
- )
- }
- onRetry={() => void query.refetch()}
- onLoadMore={() => void query.fetchNextPage()}
- />
- </ViewShell.Aside>
+ <Show when={!isTouchDevice()}>
+ <ViewShell.Aside>{sidebar()}</ViewShell.Aside>
+ </Show>
<ViewShell.Main class="overflow-hidden">
<ViewTour tour={agentsTour} />
- <main class="main">
+ <main
+ class="main touch:pt-[calc(var(--safe-top,0px)+0.5rem)]"
+ classList={{ hidden: isTouchDevice() && mobileList() }}
+ >
<Show
when={selected()?.conversation}
keyed
fallback={
<>
- <Topbar title={pageTitle()} />
+ <Topbar
+ title={pageTitle()}
+ onBack={
+ isTouchDevice()
+ ? () => setMobileList(true)
+ : undefined
+ }
+ />
<div class="body">
<Suspense fallback={<LoadingComposer />}>
<Switch>
@@ -311,19 +341,29 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
<Match when={page() === 'agents'}>
<AgentSettings />
</Match>
- <Match when={true}>
- <NewChatPage
- roster={rosterSource.roster()}
- rosterLoading={rosterSource.loading()}
- availabilityLoading={rosterSource.availabilityLoading()}
- registerFocus={(focus) => {
- composerFocus = focus;
- }}
- onStart={startConversation}
- onOpenRoster={openRoster}
- />
- </Match>
</Switch>
+ <div
+ class="contents"
+ classList={{ hidden: page() !== 'new' }}
+ >
+ <NewChatPage
+ active={
+ !isTouchDevice() ||
+ (!mobileList() && page() === 'new')
+ }
+ registerFocus={(focus) => {
+ composerFocus = focus;
+ }}
+ workspaceId={panel.handle.id}
+ draft={draft()}
+ onDraftChange={setDraft}
+ roster={rosterSource.roster()}
+ rosterLoading={rosterSource.loading()}
+ availabilityLoading={rosterSource.availabilityLoading()}
+ onStart={startConversation}
+ onOpenRoster={openRoster}
+ />
+ </div>
</Suspense>
</div>
</>
@@ -371,6 +411,16 @@ function AgentsWorkspace(props: { initialRoute?: AgentsRoute }) {
)}
</Show>
</main>
+ <Show when={isTouchDevice() && mobileList()}>
+ <div
+ class="size-full min-h-0 pt-[calc(var(--safe-top,0px)+0.5rem)]"
+ style={{
+ 'padding-bottom': `${FloatRegions.hostHeight()}px`,
+ }}
+ >
+ {sidebar()}
+ </div>
+ </Show>
</ViewShell.Main>
</ViewShell.Root>
</div>
diff --git a/apps/web/src/features/agents-view/views/MobileAgentPicker.tsx b/apps/web/src/features/agents-view/views/MobileAgentPicker.tsx
new file mode 100644
index 0000000000..62a29ccd49
--- /dev/null
+++ b/apps/web/src/features/agents-view/views/MobileAgentPicker.tsx
@@ -0,0 +1,211 @@
+import { MobileDrawer } from '@components/app/mobile/MobileDrawer';
+import { ModelIcon } from '@core/component/AI/component/ProviderIcon';
+import { modelLabel } from '@core/component/AI/constant/model-label';
+import ArrowLeft from '@phosphor/arrow-left.svg';
+import CaretDown from '@phosphor/caret-down.svg';
+import CaretRight from '@phosphor/caret-right.svg';
+import Check from '@phosphor/check.svg';
+import Plus from '@phosphor/plus.svg';
+import { Button } from '@ui';
+import { createSignal, For, Show } from 'solid-js';
+import { AgentIcon } from '../components/AgentGlyph';
+import {
+ MACRO_PERSONA_ID,
+ type RosterAgent,
+ rosterForAgentPicker,
+} from '../core/roster';
+import { createComposerModels } from '../queries/composer-models';
+import type { AgentPickerProps } from './AgentPicker';
+
+/** A single sheet drills into models without hover menus or offscreen submenus. */
+export function MobileAgentPicker(props: AgentPickerProps) {
+ const [open, setOpen] = createSignal(false);
+ const [query, setQuery] = createSignal('');
+ const [browsing, setBrowsing] = createSignal<RosterAgent>();
+ const macro = () =>
+ props.agents.find((agent) => agent.id === MACRO_PERSONA_ID);
+ const catalog = createComposerModels(() => browsing() ?? macro());
+ const model = () => props.modelOverride ?? props.selected?.defaultModel;
+ const label = () =>
+ props.selected?.id === MACRO_PERSONA_ID
+ ? modelLabel(model())
+ : (props.selected?.name ?? 'Choose agent');
+ const matches = (text: string) =>
+ text.toLocaleLowerCase().includes(query().trim().toLocaleLowerCase());
+ const models = () =>
+ catalog
+ .models()
+ .filter((option) => matches(modelLabel(option.id, option.name)));
+ const agents = () =>
+ rosterForAgentPicker(props.agents).filter((agent) => matches(agent.name));
+ const changeOpen = (next: boolean) => {
+ setOpen(next);
+ if (!next) {
+ setQuery('');
+ setBrowsing(undefined);
+ }
+ };
+ const choose = (agent: RosterAgent, model?: string) => {
+ props.onSelect(agent, model);
+ changeOpen(false);
+ };
+ const browse = (agent?: RosterAgent) => {
+ setQuery('');
+ setBrowsing(agent);
+ };
+ return (
+ <MobileDrawer side="bottom" open={open()} onOpenChange={changeOpen}>
+ <MobileDrawer.Trigger
+ as={Button}
+ variant="ghost"
+ size="sm"
+ aria-label="Agent"
+ title={label()}
+ class="h-[30px] min-w-0 max-w-full gap-1 rounded-full border border-edge-muted bg-ink/5 px-2 text-[12px] font-medium leading-none text-ink-muted"
+ >
+ <Show when={props.selected?.id !== MACRO_PERSONA_ID && props.selected}>
+ {(agent) => (
+ <AgentIcon agent={agent()} class="size-[12px] shrink-0" />
+ )}
+ </Show>
+ <span class="truncate">{label()}</span>
+ <CaretDown class="size-[10px] shrink-0" />
+ </MobileDrawer.Trigger>
+ <MobileDrawer.Portal>
+ <MobileDrawer.Overlay />
+ <MobileDrawer.Content aria-label="Choose an agent or model">
+ <MobileDrawer.Handle />
+ <div class="flex items-center gap-2 px-4 pb-3">
+ <Show when={browsing()}>
+ <Button
+ variant="ghost"
+ size="icon-md"
+ label="Back to agents"
+ onClick={() => browse()}
+ >
+ <ArrowLeft />
+ </Button>
+ </Show>
+ <h2 class="min-w-0 flex-1 truncate font-medium">
+ {browsing()?.name ?? 'Agents and models'}
+ </h2>
+ </div>
+ <input
+ aria-label="Search agents and models"
+ placeholder="Search"
+ value={query()}
+ onInput={(event) => setQuery(event.currentTarget.value)}
+ class="mx-4 mb-3 rounded-xl border border-edge-muted bg-input px-3 py-2 text-base outline-none"
+ />
+ <MobileDrawer.ScrollBody>
+ <Show when={browsing()}>
+ {(agent) => (
+ <MobileDrawer.Item onClick={() => choose(agent())}>
+ Use {agent().name} default
+ </MobileDrawer.Item>
+ )}
+ </Show>
+ <MobileDrawer.Label>Models</MobileDrawer.Label>
+ <For each={models()}>
+ {(option) => (
+ <MobileDrawer.Item
+ onClick={() => {
+ const agent = browsing() ?? macro();
+ if (agent) choose(agent, option.id);
+ }}
+ >
+ <ModelIcon model={option.id} />
+ <span class="min-w-0 flex-1 truncate">
+ {modelLabel(option.id, option.name)}
+ </span>
+ <Show
+ when={
+ props.selected?.id === (browsing() ?? macro())?.id &&
+ model() === option.id
+ }
+ >
+ <Check class="size-4 text-accent" />
+ </Show>
+ </MobileDrawer.Item>
+ )}
+ </For>
+ <Show when={models().length === 0}>
+ <p role="status" class="px-4 py-3 text-sm text-ink-muted">
+ {query() ? 'No matching models' : catalog.message()}
+ </p>
+ </Show>
+ <Show when={!browsing()}>
+ <For each={['agent', 'coder'] as const}>
+ {(kind) => (
+ <Show when={agents().some((agent) => agent.kind === kind)}>
+ <MobileDrawer.Label>
+ {kind === 'coder' ? 'Coding agents' : 'Agents'}
+ </MobileDrawer.Label>
+ <For each={agents().filter((agent) => agent.kind === kind)}>
+ {(agent) => (
+ <div class="flex items-center">
+ <MobileDrawer.Item
+ class="min-w-0 flex-1"
+ disabled={Boolean(
+ agent.unavailableReason && !agent.connectLabel
+ )}
+ onClick={() => {
+ if (agent.unavailableReason) {
+ changeOpen(false);
+ props.onConnect(agent);
+ } else choose(agent);
+ }}
+ >
+ <AgentIcon agent={agent} class="size-5 shrink-0" />
+ <span class="min-w-0 flex-1 text-left">
+ <span class="block truncate">{agent.name}</span>
+ <Show when={agent.unavailableReason}>
+ <span class="block text-xs text-ink-muted">
+ {agent.connectLabel ??
+ agent.unavailableReason}
+ </span>
+ </Show>
+ </span>
+ <Show when={props.selected?.id === agent.id}>
+ <Check class="size-4 text-accent" />
+ </Show>
+ </MobileDrawer.Item>
+ <Show when={!agent.unavailableReason}>
+ <Button
+ variant="ghost"
+ size="icon-md"
+ class="mr-3 size-11"
+ label={`Models for ${agent.name}`}
+ onClick={() => browse(agent)}
+ >
+ <CaretRight />
+ </Button>
+ </Show>
+ </div>
+ )}
+ </For>
+ </Show>
+ )}
+ </For>
+ <Show when={props.loading}>
+ <p role="status" class="px-4 py-3 text-sm text-ink-muted">
+ Loading agents…
+ </p>
+ </Show>
+ </Show>
+ </MobileDrawer.ScrollBody>
+ <MobileDrawer.Item
+ class="shrink-0 border-t border-edge-muted"
+ onClick={() => {
+ changeOpen(false);
+ props.onCreate();
+ }}
+ >
+ <Plus class="size-5" />
+ Create agent
+ </MobileDrawer.Item>
+ </MobileDrawer.Content>
+ </MobileDrawer.Portal>
+ </MobileDrawer>
+ );
+}
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
index 9ee364aee5..6be316cfc9 100644
--- a/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
+++ b/apps/web/src/features/agents-view/views/NewChatPage.test.tsx
@@ -16,6 +16,7 @@ import { AgentPicker } from './AgentPicker';
import { NewChatPage } from './NewChatPage';
const mocks = vi.hoisted(() => ({
+ touch: false,
openSettings: vi.fn(),
capabilitiesPending: false,
attachments: [] as InputAttachmentData[],
@@ -27,6 +28,9 @@ const mocks = vi.hoisted(() => ({
}),
repositories: [] as { url: string; defaultBranch?: string }[],
}));
+vi.mock('@core/mobile/isTouchDevice', () => ({
+ isTouchDevice: () => mocks.touch,
+}));
vi.mock('@core/util/upload', () => ({ uploadFile: vi.fn() }));
vi.mock('@channel/Input', async () => ({
...(await import('../../channel/Input/attachment-tracker')),
@@ -203,6 +207,7 @@ function page(
const onStart = vi.fn();
render(() => (
<NewChatPage
+ compact={mocks.touch}
roster={buildAgentRoster({
agents,
runtimes: [],
@@ -256,6 +261,7 @@ describe('agent-led new conversation', () => {
let motionStyles: HTMLStyleElement;
beforeEach(() => {
mocks.capabilitiesPending = false;
+ mocks.touch = false;
mocks.attachments = [];
mocks.recentIds = [MACRO_CODER_BOT_ID];
mocks.recentUrls = [];
@@ -269,15 +275,66 @@ describe('agent-led new conversation', () => {
});
motionStyles = document.createElement('style');
motionStyles.textContent =
- '[role="menu"] { animation-name: none; transition-duration: 0s; }';
+ '[role="menu"], [data-corvu-drawer-content], [data-corvu-drawer-overlay] { animation-name: none; transition-duration: 0s; }';
document.head.append(motionStyles);
vi.stubGlobal('scrollTo', vi.fn());
+ vi.stubGlobal(
+ 'ResizeObserver',
+ class {
+ observe() {}
+ unobserve() {}
+ disconnect() {}
+ }
+ );
+ Element.prototype.scrollTo = vi.fn();
});
afterEach(() => {
cleanup();
+ mocks.touch = false;
motionStyles.remove();
vi.unstubAllGlobals();
});
+ it('selects a coding model from the phone sheet without hover and preserves the draft', async () => {
+ mocks.touch = true;
+ const send = page();
+ fireEvent.input(screen.getByRole('textbox', { name: 'Draft' }), {
+ target: { value: 'Phone draft' },
+ });
+ fireEvent.click(screen.getByRole('button', { name: 'Agent' }));
+ fireEvent.click(
+ await screen.findByRole('button', { name: 'Models for Cursor' })
+ );
+ fireEvent.click(await screen.findByRole('button', { name: 'GPT-5' }));
+ await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenCalledWith(
+ expect.objectContaining({
+ prompt: 'Phone draft',
+ botId: CURSOR_BOT_ID,
+ modelOverride: 'gpt-5',
+ })
+ );
+ });
+ it('filters models in the phone sheet and selects an in-memory model', async () => {
+ mocks.touch = true;
+ const send = page();
+ fireEvent.click(screen.getByRole('button', { name: 'Agent' }));
+ fireEvent.input(
+ await screen.findByRole('textbox', { name: 'Search agents and models' }),
+ {
+ target: { value: 'Sonnet 5' },
+ }
+ );
+ expect(screen.queryByRole('button', { name: 'Chat default' })).toBeNull();
+ fireEvent.click(screen.getByRole('button', { name: 'Sonnet 5' }));
+ await waitFor(() => expect(screen.queryByRole('dialog')).toBeNull());
+ fireEvent.click(screen.getByRole('button', { name: 'Send' }));
+ expect(send).toHaveBeenCalledWith(
+ expect.objectContaining({
+ modelOverride: 'anthropic/claude-sonnet-5',
+ })
+ );
+ });
it('offers both kinds without a mode or model control and starts with the agent default', async () => {
const send = page();
expect(
diff --git a/apps/web/src/features/agents-view/views/NewChatPage.tsx b/apps/web/src/features/agents-view/views/NewChatPage.tsx
index 87040c4af9..f19738fb2d 100644
--- a/apps/web/src/features/agents-view/views/NewChatPage.tsx
+++ b/apps/web/src/features/agents-view/views/NewChatPage.tsx
@@ -5,13 +5,14 @@ import {
type InputAttachmentData,
uploadInputAttachments,
} from '@channel/Input';
+import { FloatRegionOrInline } from '@components/app/mobile/float-regions/FloatRegion';
import { useSettingsState } from '@core/constant/SettingsState';
import { useUserId } from '@core/context/user';
import { uploadFile } from '@core/util/upload';
import { useAgentCapabilitiesQuery } from '@queries/agents/capabilities';
import type { PromptAttachment } from '@service-agent-harness/generated/schemas';
import { tourTarget } from '@ui/components/Tour';
-import { createMemo, createSignal } from 'solid-js';
+import { createMemo, createSignal, Show } from 'solid-js';
import {
type EffortChoice,
effortConfigOption,
@@ -48,6 +49,9 @@ export type StartConversation = {
/** One agent choice determines the session kind, default model, and repository context. */
export function NewChatPage(props: {
+ compact?: boolean;
+ active?: boolean;
+ workspaceId?: string;
draft?: string;
onDraftChange?: (draft: string) => void;
autoFocus?: boolean;
@@ -69,6 +73,7 @@ export function NewChatPage(props: {
const [agentId, setAgentId] = createSignal<string>();
/** One-shot model from a coding agent's submenu; Macro uses {@link preferredInmem}. */
const [modelOverride, setModelOverride] = createSignal<string>();
+ const [repositoryPickerOpen, setRepositoryPickerOpen] = createSignal(false);
// A new conversation starts on Automatic until the caller picks a repository.
const [repoUrl, setRepoUrl] = createSignal<string | undefined>();
const persistedDraft = createPersistedComposerDraft();
@@ -255,49 +260,68 @@ export function NewChatPage(props: {
/>
);
+ const composer = () => (
+ <ChatComposer
+ autoFocus={props.autoFocus}
+ collapseOnBlur={props.compact}
+ controlsOpen={repositoryPickerOpen()}
+ registerFocus={props.registerFocus}
+ draft={draft()}
+ onDraftChange={setDraft}
+ blockedReason={blocked()}
+ selector={agentSelector()}
+ drawer={
+ <RepositoryPicker
+ onOpenChange={setRepositoryPickerOpen}
+ repoUrl={repoUrl()}
+ branch={repoBranch()}
+ repositories={reachable.repositories()}
+ repositoriesLoading={reachable.loading()}
+ repositoriesError={reachable.error()}
+ recentRepositories={repositories.urls()}
+ onRetryRepositories={reachable.retry}
+ branches={reachableBranches.branches()}
+ branchesLoading={reachableBranches.loading()}
+ branchesError={reachableBranches.error()}
+ onRetryBranches={reachableBranches.retry}
+ onConnectGitHub={() => openSettings('Connected')}
+ onSelectRepository={selectRepository}
+ onSelectBranch={setBranchOverride}
+ />
+ }
+ drawerOpen={coding()}
+ placeholder={coding() ? 'Describe what you want to build' : undefined}
+ onSend={send}
+ attachments={attachmentTracker.attachments()}
+ onAttachFiles={attachFiles}
+ onRemoveAttachment={(attachment) =>
+ attachmentTracker.removeAttachment(attachment.id)
+ }
+ />
+ );
+
return (
- <section class="page newchat" data-active aria-label="New conversation">
- <div ref={tourTarget(AGENTS_TOUR.composer)} class="col">
- <div class="greeting">
- <h2>
- {coding() ? 'What should we build?' : 'What should we work on?'}
- </h2>
+ <Show when={!props.compact} fallback={composer()}>
+ <section class="page newchat" data-active aria-label="New conversation">
+ <div ref={tourTarget(AGENTS_TOUR.composer)} class="col">
+ <div class="greeting">
+ <h2>
+ {coding() ? 'What should we build?' : 'What should we work on?'}
+ </h2>
+ </div>
+ <FloatRegionOrInline
+ region="accessory"
+ active={() => props.active !== false}
+ >
+ <div
+ data-agent-new-composer={props.workspaceId}
+ class="agents-view-portal touch:px-(--mobile-chrome-gutter) pointer-events-auto min-w-0"
+ >
+ {composer()}
+ </div>
+ </FloatRegionOrInline>
</div>
- <ChatComposer
- autoFocus={props.autoFocus}
- registerFocus={props.registerFocus}
- draft={draft()}
- onDraftChange={setDraft}
- blockedReason={blocked()}
- selector={agentSelector()}
- drawer={
- <RepositoryPicker
- repoUrl={repoUrl()}
- branch={repoBranch()}
- repositories={reachable.repositories()}
- repositoriesLoading={reachable.loading()}
- repositoriesError={reachable.error()}
- recentRepositories={repositories.urls()}
- onRetryRepositories={reachable.retry}
- branches={reachableBranches.branches()}
- branchesLoading={reachableBranches.loading()}
- branchesError={reachableBranches.error()}
- onRetryBranches={reachableBranches.retry}
- onConnectGitHub={() => openSettings('Connected')}
- onSelectRepository={selectRepository}
- onSelectBranch={setBranchOverride}
- />
- }
- drawerOpen={coding()}
- placeholder={coding() ? 'Describe what you want to build' : undefined}
- onSend={send}
- attachments={attachmentTracker.attachments()}
- onAttachFiles={attachFiles}
- onRemoveAttachment={(attachment) =>
- attachmentTracker.removeAttachment(attachment.id)
- }
- />
- </div>
- </section>
+ </section>
+ </Show>
);
}
diff --git a/apps/web/src/features/agents-view/views/RepositoryPicker.tsx b/apps/web/src/features/agents-view/views/RepositoryPicker.tsx
index 0eb9e73877..c251cf72e3 100644
--- a/apps/web/src/features/agents-view/views/RepositoryPicker.tsx
+++ b/apps/web/src/features/agents-view/views/RepositoryPicker.tsx
@@ -38,6 +38,7 @@ type BranchChoice =
/** Explicit, portaled repository/branch controls shared by Home and Agents. */
export function RepositoryPicker(props: {
repoUrl?: string;
+ onOpenChange?: (open: boolean) => void;
branch: string;
/** Repositories the signed-in user can hand a coder through Macro's GitHub App. */
repositories: ReachableRepository[];
@@ -58,8 +59,16 @@ export function RepositoryPicker(props: {
onSelectBranch: (branch: string) => void;
}) {
const listId = createUniqueId();
- const [repoOpen, setRepoOpen] = createSignal(false);
- const [branchOpen, setBranchOpen] = createSignal(false);
+ const [repoOpen, updateRepoOpen] = createSignal(false);
+ const [branchOpen, updateBranchOpen] = createSignal(false);
+ const setRepoOpen = (open: boolean) => {
+ updateRepoOpen(open);
+ props.onOpenChange?.(open || branchOpen());
+ };
+ const setBranchOpen = (open: boolean) => {
+ updateBranchOpen(open);
+ props.onOpenChange?.(open || repoOpen());
+ };
const [search, setSearch] = createSignal('');
const [branchSearch, setBranchSearch] = createSignal('');
const [error, setError] = createSignal('');
diff --git a/apps/web/src/features/block-agent/component/AgentComposer.test.tsx b/apps/web/src/features/block-agent/component/AgentComposer.test.tsx
index c3b7d1da88..f7e220bf92 100644
--- a/apps/web/src/features/block-agent/component/AgentComposer.test.tsx
+++ b/apps/web/src/features/block-agent/component/AgentComposer.test.tsx
@@ -1,4 +1,4 @@
-import { cleanup, render } from '@solidjs/testing-library';
+import { cleanup, fireEvent, render, screen } from '@solidjs/testing-library';
import { createSignal } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
import type { AgentInputProps } from '../ui/AgentInput';
@@ -8,6 +8,7 @@ import { AgentComposer } from './AgentComposer';
const mocks = vi.hoisted(() => ({
session: () => ({ canEdit: false as boolean | undefined }),
+ turn: () => 'idle' as 'idle' | 'working' | 'starting' | 'stopping',
issue: vi.fn(),
selectModel: vi.fn(),
sendNext: vi.fn(),
@@ -54,7 +55,7 @@ vi.mock('../context/AgentSessionContext', () => ({
remove: mocks.removeQueued,
},
sendNext: mocks.sendNext,
- turn: () => 'idle',
+ turn: () => mocks.turn(),
registerQuoteInsert: vi.fn(),
}),
}));
@@ -77,6 +78,7 @@ vi.mock('./PermissionRequest', () => ({ PermissionRequest: () => null }));
beforeEach(() => {
vi.resetAllMocks();
+ mocks.turn = () => 'idle';
mocks.session = () => ({ canEdit: false });
mocks.issue.mockResolvedValue({ isErr: () => false });
});
@@ -151,3 +153,23 @@ describe('view-only session controls', () => {
}
);
});
+
+it('explicitly sends the queue head and disables it while the turn transitions', () => {
+ const [turn, setTurn] = createSignal<'working' | 'stopping' | 'starting'>(
+ 'working'
+ );
+ mocks.turn = turn;
+ mocks.session = () => ({ canEdit: true });
+ render(() => <AgentComposer />);
+ const sendNext = screen.getByRole('button', {
+ name: 'Send next queued message now',
+ });
+ fireEvent.click(sendNext);
+ expect(mocks.sendNext).toHaveBeenCalledTimes(1);
+ for (const next of ['stopping', 'starting'] as const) {
+ setTurn(next);
+ expect(sendNext.hasAttribute('disabled')).toBe(true);
+ fireEvent.click(sendNext);
+ }
+ expect(mocks.sendNext).toHaveBeenCalledTimes(1);
+});
diff --git a/apps/web/src/features/block-agent/component/AgentComposer.tsx b/apps/web/src/features/block-agent/component/AgentComposer.tsx
index cb0a67a555..b20b35fed2 100644
--- a/apps/web/src/features/block-agent/component/AgentComposer.tsx
+++ b/apps/web/src/features/block-agent/component/AgentComposer.tsx
@@ -1,3 +1,5 @@
+import ArrowUp from '@phosphor/arrow-up.svg';
+import { Button } from '@ui';
/**
* The block's composer container: reads the session from context and drives
* the dumb `AgentInput` with derived props. Every in-flight state it shows
@@ -189,20 +191,46 @@ export function AgentComposer(props: {
<>
<Show when={queuedItems().length > 0}>
<div class="pb-1.5">
- <QueuedPrompts
- items={queuedItems()}
- disabled={readOnly()}
- onEdit={(actionId, prompt) => {
- if (!readOnly()) void queue.edit(actionId, prompt);
- }}
- onRemove={(actionId) => {
- if (!readOnly()) void queue.remove(actionId);
- }}
- onNavigateBelow={() => focusInput?.()}
- registerFocusFromBelow={(focus) => {
- focusQueueBottom = focus;
- }}
- />
+ <div class="mb-1 flex items-center justify-between gap-2 px-1">
+ <span class="text-xs text-ink-muted">
+ {queuedItems().length} queued
+ </span>
+ <Button
+ variant="outline"
+ size="sm"
+ class="touch:min-h-11"
+ aria-label="Send next queued message now"
+ disabled={
+ readOnly() ||
+ loadFailed() ||
+ pending() ||
+ turn() === 'stopping' ||
+ turn() === 'starting'
+ }
+ onClick={() => {
+ if (!readOnly()) sendNext();
+ }}
+ >
+ <ArrowUp class="size-4" />
+ Send next
+ </Button>
+ </div>
+ <div class="max-h-[25dvh] overflow-y-auto overscroll-contain">
+ <QueuedPrompts
+ items={queuedItems()}
+ disabled={readOnly()}
+ onEdit={(actionId, prompt) => {
+ if (!readOnly()) void queue.edit(actionId, prompt);
+ }}
+ onRemove={(actionId) => {
+ if (!readOnly()) void queue.remove(actionId);
+ }}
+ onNavigateBelow={() => focusInput?.()}
+ registerFocusFromBelow={(focus) => {
+ focusQueueBottom = focus;
+ }}
+ />
+ </div>
</div>
</Show>
<Show when={resuming()}>
diff --git a/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx b/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx
index a842e2ec00..f6b22b6b62 100644
--- a/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx
+++ b/apps/web/src/features/block-agent/component/AgentSplitHeader.tsx
@@ -15,7 +15,7 @@ import { ProviderIcon } from '@core/component/AI/component/ProviderIcon';
import { Permissions } from '@core/component/SharePermissions';
import { ShareTrigger } from '@core/component/TopBar/ShareButton';
import { useShareModal } from '@core/component/TopBar/shareModal';
-import { isMobile } from '@core/mobile/isMobile';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { openExternalUrl } from '@core/util/url';
import type { AgentSessionEntity } from '@entity';
import ShareIcon from '@icon/share.svg';
@@ -192,7 +192,7 @@ export function AgentSplitHeader(props: {
<Show when={props.session?.pullRequestUrl}>
{(url) => <AgentPullRequestChip url={url()} />}
</Show>
- <Show when={!isMobile()}>
+ <Show when={!isTouchDevice()}>
<ChangesToggle />
<For each={tools}>
{(tool) => (
diff --git a/apps/web/src/features/block-agent/component/Block.tsx b/apps/web/src/features/block-agent/component/Block.tsx
index cd0e161092..2b16d30ead 100644
--- a/apps/web/src/features/block-agent/component/Block.tsx
+++ b/apps/web/src/features/block-agent/component/Block.tsx
@@ -13,13 +13,22 @@ import { useNavigatedFromJK } from '@components/app/useNavigatedFromJK';
import { useBlockId } from '@core/block';
import { LoadErrorPanel } from '@core/component/EntityLoadGate';
import { StaticMarkdownContext } from '@core/component/LexicalMarkdown/component/core/StaticMarkdown';
+import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { nativeNetworkStatus } from '@core/mobile/native-network-status';
import { createMethodRegistration } from '@core/orchestrator';
import { blockHandleSignal } from '@core/signal/load';
import type { NotificationSource } from '@notifications/notification-source';
import { useSearchParams } from '@solidjs/router';
import { EmptyStatePanel } from '@ui';
-import { createEffect, createSignal, on, Show, useContext } from 'solid-js';
+import {
+ children,
+ createEffect,
+ createSignal,
+ on,
+ type ParentProps,
+ Show,
+ useContext,
+} from 'solid-js';
import { AgentSessionProvider } from '../agent-session-provider';
import { useAgentSession } from '../context/AgentSessionContext';
import { forgetPendingSession } from '../context/pending-session';
@@ -33,6 +42,30 @@ import { ArchivedSessionFooter } from './ArchivedSessionFooter';
import { AgentSidePanelSections } from './sidepanel/AgentSidePanelSections';
import { Transcript } from './Transcript';
+// Keep the editor mounted while another mobile accessory (Changes) is active.
+function AgentComposerRegion(props: ParentProps) {
+ const content = children(() => props.children);
+ return (
+ <FloatRegionOrInline region="accessory">{content()}</FloatRegionOrInline>
+ );
+}
+
+function AgentContentLayout(props: ParentProps) {
+ return (
+ <Show
+ when={isTouchDevice()}
+ fallback={
+ <SidePanel.Layout defaultOpen={false}>
+ <AgentSidePanelSections />
+ {props.children}
+ </SidePanel.Layout>
+ }
+ >
+ <div class="flex size-full min-w-0 flex-col">{props.children}</div>
+ </Show>
+ );
+}
+
function AgentBlockContent(props: {
active: boolean;
notificationSource: NotificationSource;
@@ -133,8 +166,7 @@ function AgentBlockContent(props: {
<div class="size-full overflow-hidden flex">
{/* Collapsed by default, like the other conversation-shaped blocks —
the transcript wants the width; `]` or the header button opens it. */}
- <SidePanel.Layout defaultOpen={false}>
- <AgentSidePanelSections />
+ <AgentContentLayout>
<AgentSplitHeader
session={session()}
title={metadata()?.title ?? undefined}
@@ -146,7 +178,7 @@ function AgentBlockContent(props: {
<Transcript searchTarget={searchTarget()} />
{/* Full-frame mobile: composer + queue float in the bottom
accessory region above the dock; desktop stays inline. */}
- <FloatRegionOrInline region="accessory">
+ <AgentComposerRegion>
{/* Home/chat: re-enable pointer events on the accessory
contribution — the float host is pointer-transparent. */}
{/* pb matches ChannelInputContainer so the composer sits at
@@ -173,9 +205,9 @@ function AgentBlockContent(props: {
</Show>
</div>
</div>
- </FloatRegionOrInline>
+ </AgentComposerRegion>
</AgentChangesSplit>
- </SidePanel.Layout>
+ </AgentContentLayout>
</div>
</StaticMarkdownContext>
</Show>
diff --git a/apps/web/src/features/block-agent/context/pending-session.ts b/apps/web/src/features/block-agent/context/pending-session.ts
index 2c5b23d0bf..8e65a6c692 100644
--- a/apps/web/src/features/block-agent/context/pending-session.ts
+++ b/apps/web/src/features/block-agent/context/pending-session.ts
@@ -168,7 +168,7 @@ export function startPendingSession(
? { attachments: options.attachments }
: {}),
},
- { userId: options.userId }
+ { userId: options.userId ?? result.value.session.ownerId }
);
if (delivered.isErr()) {
setError(
diff --git a/apps/web/src/features/block-agent/context/resolve-session-id.test.ts b/apps/web/src/features/block-agent/context/resolve-session-id.test.ts
index e6eb40fd5b..a8bb30fa77 100644
--- a/apps/web/src/features/block-agent/context/resolve-session-id.test.ts
+++ b/apps/web/src/features/block-agent/context/resolve-session-id.test.ts
@@ -21,6 +21,7 @@ const create = vi.hoisted(() => ({
autoConfirm: true,
confirm: undefined as ((error?: string) => void) | undefined,
release: vi.fn(),
+ attribution: vi.fn(),
}));
vi.mock('@service-agent-harness/client', () => ({
@@ -29,7 +30,10 @@ vi.mock('@service-agent-harness/client', () => ({
(request: { id: string }) =>
new Promise((resolve) => {
create.resolve = (id: string = request.id) =>
- resolve({ isErr: () => false, value: { session: { id } } });
+ resolve({
+ isErr: () => false,
+ value: { session: { id, ownerId: 'session-owner' } },
+ });
create.reject = () =>
resolve({
isErr: () => true,
@@ -60,7 +64,8 @@ vi.mock('@core/agent-session/AgentSession', () => ({
};
return {
load: async () => {},
- issue: async (action: AgentAction) => {
+ issue: async (action: AgentAction, options: unknown) => {
+ create.attribution(options);
const result = await create.control(id, action);
if (!result.isErr()) {
requestId = result.value.actionId;
@@ -411,3 +416,20 @@ it.each(['Describe this', ''])(
});
}
);
+
+it.each([undefined, 'explicit-user'])(
+ 'attributes the first prompt when userId is %s',
+ async (userId) => {
+ create.attribution.mockClear();
+ create.control.mockResolvedValue({
+ isErr: () => false,
+ value: { actionId: 'prompt-id' },
+ });
+ startPendingSession({ prompt: 'Hello', userId });
+ create.resolve?.();
+ await flush();
+ expect(create.attribution).toHaveBeenCalledWith({
+ userId: userId ?? 'session-owner',
+ });
+ }
+);
diff --git a/apps/web/src/features/block-agent/ui/AgentInput.test.tsx b/apps/web/src/features/block-agent/ui/AgentInput.test.tsx
index 774a2aeec1..c52564562b 100644
--- a/apps/web/src/features/block-agent/ui/AgentInput.test.tsx
+++ b/apps/web/src/features/block-agent/ui/AgentInput.test.tsx
@@ -189,7 +189,7 @@ describe('queued message advancement', () => {
screen.getByTestId('agent-input-editor').getAttribute('data-disabled')
).toBe('true');
const stop = screen.getByRole('button', {
- name: 'Stop',
+ name: 'Send next queued message',
}) as HTMLButtonElement;
expect(stop.disabled).toBe(true);
fireEvent.click(stop);
@@ -202,7 +202,7 @@ describe('queued message advancement', () => {
expect(onSendNext).not.toHaveBeenCalled();
});
- it('shows a pressable Enter action that advances the next queued message', () => {
+ it('shows a send action that advances the next queued message', () => {
const onStop = vi.fn();
render(() => (
@@ -212,7 +212,7 @@ describe('queued message advancement', () => {
const sendNext = screen.getByRole('button', {
name: 'Send next queued message',
});
- expect(screen.getByTestId('enter-icon')).toBeTruthy();
+ expect(sendNext.hasAttribute('disabled')).toBe(false);
fireEvent.click(sendNext);
expect(onStop).toHaveBeenCalledTimes(1);
@@ -259,13 +259,12 @@ describe('queued message advancement', () => {
/>
));
- // Attached files are a draft, so this is the typed-text case: Enter sends
- // them, and the control is Stop rather than the send-next Enter action,
- // which would have stopped the agent and left the files behind.
+ // Attached files are a draft: both tapping Send and Enter send them.
expect(
screen.queryByRole('button', { name: 'Send next queued message' })
).toBeNull();
- expect(screen.getByRole('button', { name: 'Stop' })).toBeTruthy();
+ expect(screen.getByRole('button', { name: 'Send' })).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Stop' })).toBeNull();
editor.enter?.();
expect(onSend).toHaveBeenCalledWith('', [uploaded]);
diff --git a/apps/web/src/features/block-agent/ui/AgentInput.tsx b/apps/web/src/features/block-agent/ui/AgentInput.tsx
index 2808195e94..434420ed1d 100644
--- a/apps/web/src/features/block-agent/ui/AgentInput.tsx
+++ b/apps/web/src/features/block-agent/ui/AgentInput.tsx
@@ -29,7 +29,7 @@ import { isTouchDevice } from '@core/mobile/isTouchDevice';
import { useTouchOutsideToDismissKeyboard } from '@core/mobile/useTouchOutsideToDismissKeyboard';
import { handleFileFolderDrop } from '@core/util/upload';
import { $insertReferencedPaste } from '@macro-inc/lexical-core';
-import EnterIcon from '@phosphor-icons/core/regular/arrow-bend-down-left.svg?component-solid';
+import ArrowUp from '@phosphor/arrow-up.svg';
import { Button, ComposerSurface, SendButton } from '@ui';
import { createSignal, type JSX, onCleanup, onMount, Show } from 'solid-js';
@@ -394,10 +394,14 @@ export function AgentInput(props: AgentInputProps) {
disabled={props.disabled || props.readOnly}
/>
<Show
- when={canSendNext()}
+ when={
+ props.hasQueuedMessages &&
+ markdown().trim().length === 0 &&
+ attachments().length === 0
+ }
fallback={
<Show
- when={props.busy && props.onStop}
+ when={props.busy && props.onStop && !canSend()}
fallback={
<SendButton
appearance="composer"
@@ -430,8 +434,9 @@ export function AgentInput(props: AgentInputProps) {
tooltip="Send next queued message"
shortcut="Enter"
onClick={sendNext}
+ disabled={!canSendNext()}
>
- <EnterIcon />
+ <ArrowUp />
</SendButton>
</Show>
</div>
diff --git a/apps/web/src/features/block-project/component/ProjectCreateMenu.tsx b/apps/web/src/features/block-project/component/ProjectCreateMenu.tsx
index 8f211eb4b1..d1b653dbc6 100644
--- a/apps/web/src/features/block-project/component/ProjectCreateMenu.tsx
+++ b/apps/web/src/features/block-project/component/ProjectCreateMenu.tsx
@@ -1,9 +1,14 @@
import { useSpreadsheetAccess } from '@app/features/block-spreadsheet/primitives/use-spreadsheet-access';
+import { openChatWithAgent } from '@app/features/chat/ChatWithAgentButton';
import type { BlockTool } from '@components/app/ResponsiveBlockToolbar';
import { useSplitLayout } from '@components/app/split-layout/layout';
import type { BlockAlias, BlockName } from '@core/block';
import { EntityIcon } from '@core/component/EntityIcon';
import { toast } from '@core/component/Toast/Toast';
+import {
+ enableChatV3Agents,
+ isFeatureEnabled,
+} from '@core/constant/featureFlags';
import { pressedKeys } from '@core/hotkey/state';
import { type HotkeyToken, TOKENS } from '@core/hotkey/tokens';
import {
@@ -258,6 +263,17 @@ function ProjectCreateDialog(props: {
class="flex items-center gap-2 py-1 text-sm hover:bg-hover w-full text-left min-h-11"
onClick={() => {
props.onClose();
+ if (
+ spec.blockName === 'chat' &&
+ isFeatureEnabled(enableChatV3Agents)
+ ) {
+ void openChatWithAgent({
+ type: 'project',
+ id: props.projectId,
+ name: props.name,
+ });
+ return;
+ }
createBlock({
blockName: spec.blockName,
loading: spec.loading,
@@ -291,7 +307,7 @@ function MenuItem(props: MenuItemProps) {
);
}
-function MenuContent(props: { projectId: string }) {
+function MenuContent(props: { projectId: string; name: string }) {
const { replaceSplit, insertSplit } = useSplitLayout();
const createBlock = makeCreateBlock({ replaceSplit, insertSplit });
const spreadsheetAccess = useSpreadsheetAccess();
@@ -302,13 +318,22 @@ function MenuContent(props: { projectId: string }) {
).map((spec) => ({
label: spec.label,
Icon: spec.icon,
- action: () =>
- createBlock({
+ action: () => {
+ if (spec.blockName === 'chat' && isFeatureEnabled(enableChatV3Agents)) {
+ void openChatWithAgent({
+ type: 'project',
+ id: props.projectId,
+ name: props.name,
+ });
+ return;
+ }
+ return createBlock({
blockName: spec.blockName,
loading: spec.loading,
createFn: () => spec.createFn(props.projectId),
params: spec.params,
- }),
+ });
+ },
}));
return (
@@ -349,7 +374,7 @@ export function useProjectCreateTools(
return { tools, CreateDialog };
}
-export function ProjectCreateMenu(props: { id: string }) {
+export function ProjectCreateMenu(props: { id: string; name: string }) {
const [open, setOpen] = createSignal(false);
return (
<Dropdown open={open()} onOpenChange={setOpen}>
@@ -365,7 +390,7 @@ export function ProjectCreateMenu(props: { id: string }) {
<CaretDown />
</Dropdown.Trigger>
</div>
- <MenuContent projectId={props.id} />
+ <MenuContent projectId={props.id} name={props.name} />
</Dropdown>
);
}
diff --git a/apps/web/src/features/block-project/component/TopBar.tsx b/apps/web/src/features/block-project/component/TopBar.tsx
index c83cfa8972..2d651a3fe8 100644
--- a/apps/web/src/features/block-project/component/TopBar.tsx
+++ b/apps/web/src/features/block-project/component/TopBar.tsx
@@ -138,7 +138,7 @@ export function TopBar() {
<div class="flex gap-2 p-1">
<Show when={ops().length > 0}>
<Show when={canEdit()}>
- <ProjectCreateMenu id={id} />
+ <ProjectCreateMenu id={id} name={name()} />
</Show>
</Show>
</div>
diff --git a/apps/web/src/features/chat/SoupChatInput.test.tsx b/apps/web/src/features/chat/SoupChatInput.test.tsx
index 1d854cae96..89f7fb5c36 100644
--- a/apps/web/src/features/chat/SoupChatInput.test.tsx
+++ b/apps/web/src/features/chat/SoupChatInput.test.tsx
@@ -6,6 +6,7 @@ import {
screen,
waitFor,
} from '@solidjs/testing-library';
+import { createSignal } from 'solid-js';
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
const mocks = vi.hoisted(() => ({
@@ -16,6 +17,18 @@ const mocks = vi.hoisted(() => ({
storeModel: vi.fn(),
sendBackground: vi.fn(),
background: false,
+ agentsEnabled: false,
+ agentsLoading: (): boolean => false,
+}));
+
+vi.mock('@app/lib/analytics/posthog', () => ({
+ useFeatureFlag: () => () => ({
+ enabled: mocks.agentsEnabled,
+ loading: mocks.agentsLoading(),
+ }),
+}));
+vi.mock('../agents-view/mobile-agent-composer', () => ({
+ MobileAgentComposer: () => <div data-testid="agent-composer" />,
}));
vi.mock('@components/app/split-layout/layoutUtils', () => ({
@@ -100,10 +113,34 @@ import { SoupChatInput } from './SoupChatInput';
beforeEach(() => {
vi.clearAllMocks();
mocks.background = false;
+ mocks.agentsEnabled = false;
+ mocks.agentsLoading = () => false;
});
afterEach(cleanup);
describe('SoupChatInput', () => {
+ it.each([true, false])(
+ 'waits for flags before mounting the composer (agents enabled: %s)',
+ (enabled) => {
+ const [loading, setLoading] = createSignal(true);
+ mocks.agentsLoading = loading;
+ render(() => <SoupChatInput />);
+ expect(screen.queryByRole('button', { name: 'Send' })).toBeNull();
+ expect(screen.queryByTestId('agent-composer')).toBeNull();
+ expect(mocks.createChat).not.toHaveBeenCalled();
+ mocks.agentsEnabled = enabled;
+ setLoading(false);
+ expect(!!screen.queryByTestId('agent-composer')).toBe(enabled);
+ expect(!!screen.queryByRole('button', { name: 'Send' })).toBe(!enabled);
+ }
+ );
+ it('uses the new composer when agents are enabled', () => {
+ mocks.agentsEnabled = true;
+ render(() => <SoupChatInput />);
+ expect(screen.getByTestId('agent-composer')).toBeTruthy();
+ expect(screen.queryByRole('button', { name: 'Send' })).toBeNull();
+ expect(mocks.createChat).not.toHaveBeenCalled();
+ });
it('renders the compact chat input inline without page actions', () => {
const { container } = render(() => <SoupChatInput />);
const send = screen.getByRole('button', { name: 'Send' });
diff --git a/apps/web/src/features/chat/SoupChatInput.tsx b/apps/web/src/features/chat/SoupChatInput.tsx
index f65d799c10..a6950f8ab1 100644
--- a/apps/web/src/features/chat/SoupChatInput.tsx
+++ b/apps/web/src/features/chat/SoupChatInput.tsx
@@ -1,3 +1,4 @@
+import { useFeatureFlag } from '@app/lib/analytics/posthog';
import { useSplitPanelOrThrow } from '@components/app/split-layout/layoutUtils';
import { useMacroMentionLinkResolver } from '@components/app/split-layout/split-router/mention-links';
import { buildChatEditor } from '@core/component/AI/component/input/buildChatEditor';
@@ -16,6 +17,7 @@ import {
storeChatStateImmediate,
storeSoupInputModel,
} from '@core/component/AI/util/storage';
+import { enableChatV3Agents } from '@core/constant/featureFlags';
import { PaywallKey, usePaywallState } from '@core/constant/PaywallState';
import { registerHotkey, useHotkeyDOMScope } from '@core/hotkey/hotkeys';
import { TOKENS } from '@core/hotkey/tokens';
@@ -23,7 +25,8 @@ import { isPaymentError } from '@core/util/handlePaymentError';
import { createRenameDssEntityMutation } from '@entity';
import { invalidateAllSoup } from '@queries/soup/cache';
import { cognitionApiServiceClient } from '@service-cognition/client';
-import { createEffect } from 'solid-js';
+import { createEffect, Show } from 'solid-js';
+import { MobileAgentComposer } from '../agents-view/mobile-agent-composer';
function SoupChatInputInner() {
const splitPanelContext = useSplitPanelOrThrow();
@@ -137,6 +140,17 @@ function SoupChatInputInner() {
}
export function SoupChatInput() {
+ const agents = useFeatureFlag(enableChatV3Agents);
+ return (
+ <Show when={!agents().loading}>
+ <Show when={agents().enabled} fallback={<LegacySoupChatInput />}>
+ <MobileAgentComposer />
+ </Show>
+ </Show>
+ );
+}
+
+function LegacySoupChatInput() {
// Seed the selector from the persisted soup draft model so the user's last
// choice in the new-chat composer is restored. ChatInputProvider falls back
// to DEFAULT_MODEL when this is undefined.
diff --git a/apps/web/src/features/command/Launcher.tsx b/apps/web/src/features/command/Launcher.tsx
index ab77722d13..e7e49f6098 100644
--- a/apps/web/src/features/command/Launcher.tsx
+++ b/apps/web/src/features/command/Launcher.tsx
@@ -368,6 +368,11 @@ export function runCreateAction(
});
return;
case 'chat':
+ if (isFeatureEnabled(enableChatV3Agents)) {
+ setCreateMenuOpen(false, false);
+ openAgentComposer(useSplitLayout(), shouldInsert);
+ return;
+ }
// On mobile the chat input doesn't autofocus on mount, so arm focus
// within this gesture (iOS only raises the keyboard for a synchronous
// focus). The chat mounts asynchronously, so this waits for the input.
diff --git a/apps/web/src/features/getting-started/getting-started.tsx b/apps/web/src/features/getting-started/getting-started.tsx
index cc7141652e..8d2e779bde 100644
--- a/apps/web/src/features/getting-started/getting-started.tsx
+++ b/apps/web/src/features/getting-started/getting-started.tsx
@@ -9,6 +9,10 @@ import { defaultModelForPlan } from '@core/component/AI/constant';
import { setPendingSendData } from '@core/component/AI/signal/pendingSend';
import { deriveChatName } from '@core/component/AI/util/deriveName';
import { toast } from '@core/component/Toast/Toast';
+import {
+ enableChatV3Agents,
+ isFeatureEnabled,
+} from '@core/constant/featureFlags';
import {
type SettingsTab,
useSettingsState,
@@ -35,6 +39,7 @@ import {
themeMode,
} from '@theme/signals/themeSignals';
import { createEffect, createSignal, For, on, onMount, Show } from 'solid-js';
+import { startPendingSession } from '../block-agent/context/pending-session';
import { AGENT_EXAMPLES } from './agent-examples';
import { createGettingStartedChatOpener } from './getting-started-chat';
import { ActionRow, SectionHeader } from './getting-started-rows';
@@ -107,6 +112,8 @@ function GettingStartedContent() {
};
const startChat = async (prompt: string): Promise<string | undefined> => {
+ if (isFeatureEnabled(enableChatV3Agents))
+ return startPendingSession({ prompt });
const result = await createChat(
{ name: deriveChatName(prompt) },
{ source: 'getting-started' }
@@ -129,9 +136,23 @@ function GettingStartedContent() {
};
const openChatPrompt = createGettingStartedChatOpener({
- state,
+ state: {
+ chatIdForAction: (actionId) =>
+ state.chatIdForAction(
+ isFeatureEnabled(enableChatV3Agents) ? `agent:${actionId}` : actionId
+ ),
+ rememberChat: (actionId, id) =>
+ state.rememberChat(
+ isFeatureEnabled(enableChatV3Agents) ? `agent:${actionId}` : actionId,
+ id
+ ),
+ },
startChat,
- openChat: (id) => openContent({ type: 'chat', id }),
+ openChat: (id) =>
+ openContent({
+ type: isFeatureEnabled(enableChatV3Agents) ? 'agent' : 'chat',
+ id,
+ }),
});
/**
diff --git a/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsx b/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsx
index a4c4dc1a26..923f667f3d 100644
--- a/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsx
+++ b/apps/web/src/lib/core/component/AI/component/input/ChatInput.model.test.tsx
@@ -33,6 +33,14 @@ const mocks = vi.hoisted(() => ({
send: vi.fn(),
}));
+// This suite exercises legacy chat model persistence, including the flag-off Soup input.
+vi.mock('@app/lib/analytics/posthog', () => ({
+ useFeatureFlag: () => () => ({ enabled: false }),
+}));
+vi.mock('@app/features/agents-view/mobile-agent-composer', () => ({
+ MobileAgentComposer: () => null,
+}));
+
vi.mock('@components/app/split-layout/layoutUtils', () => ({
useSplitPanelOrThrow: () => ({ handle: { replace: mocks.replace } }),
useCanAutofocusSplitContent: () => false,
diff --git a/docs/AGENT_GUIDE/ai-chat.md b/docs/AGENT_GUIDE/ai-chat.md
index f7412b85e3..fd488c8167 100644
--- a/docs/AGENT_GUIDE/ai-chat.md
+++ b/docs/AGENT_GUIDE/ai-chat.md
@@ -19,6 +19,51 @@ Deleting a project shows its result without a link to the deleted project.
Failed project deletions show `Not deleted`. Clearing projects from several tasks
reports each task's outcome, including partial failures.
+## Phones with new agents enabled
+
+With `enable-chat-v3-agents`, **Agents** opens the new conversation list on phones,
+including GitHub PR state and links. Tap a row to open a full-screen conversation;
+the header back button returns to the previous screen, or Agents for a direct link.
+Portrait and landscape touch layouts have no conversation side panel. **Changes** opens a full-width,
+unified diff with **Back to conversation**; returning preserves the unsent draft.
+
+The mobile conversation list omits the desktop **New conversation**, **Agents**,
+and **Connections** controls. Use the Home composer or global create menu to start
+a conversation. Returning to the list and reopening the composer preserves the
+draft, attachments, agent, model, repository, and branch. Tap the
+agent/model control to open a searchable bottom sheet. Tap an agent to use its
+default model, or its model arrow to choose a model; **Create agent** opens the
+roster. Desktop navigation remains unchanged.
+
+The mobile Home composer is a filled, rounded input with no placeholder or
+rotating tips. Its collapsed height matches the New button, with the model
+selector and Send always visible. Tap the input to reveal attachment, microphone
+(when enabled), and repository controls; they collapse again when tapping outside.
+The editor and model picker stay mounted so collapsing preserves the draft.
+Repository and branch pickers keep the composer expanded while their search
+fields are focused, so their anchor stays in place.
+
+With the flag enabled, Home/list composers, search, the create menu, folder AI
+creation, contextual **Chat with AI**, and onboarding prompts all start new agent
+sessions. Existing legacy chat rows still open their original chats. Contextual
+chat actions use agent sessions regardless of the flag; without the flag, the
+legacy list and flag-gated composer flows remain available.
+
+While an agent works, a draft can be sent to its queue. Above the queue,
+**Send next** explicitly interrupts the current turn and sends the oldest queued
+message. The empty composer offers the same action when messages are queued;
+with a draft it offers **Send**. With no draft or queue, the busy composer offers
+**Stop**. Send-next actions disable during stopping/starting and for read-only
+sessions.
+
+Phone verification: check portrait and landscape with touch emulation. In the
+Home composer, enter multiple lines and tap Send, attach, or the model control;
+blurring the editor during the tap must not collapse or move the controls. Then exercise
+list → new conversation → back → new conversation, a row and direct session link,
+the model sheet and repository controls, queued sends, and Changes → back. Check
+that composers remain above the keyboard and neither Changes nor headers cause
+horizontal overflow.
+
## Uploading files with AI
`UploadFile` accepts a filename and standard padded base64 contents, up to 25 MiB
@@ -269,10 +314,11 @@ the shimmer.
Archived sessions are read-only: Rename and all message controls are unavailable,
and an **Unarchive** action replaces the composer at the bottom. Archive /
Unarchive is also available from the title dropdown.
-- Touch devices and users outside the flag retain the Owned / Running / Shared /
- Automations / Skills list. On touch devices, conversation links open standalone
- agent sessions or legacy chats instead of the desktop Agents workspace. A standalone legacy chat is `/app/chat/<uuid>`; doc-scoped chat
- is `/app/md/<doc>/chat/<chat>` (split view).
+- Users without `enable-chat-v3-agents` retain the Owned / Running / Shared /
+ Automations / Skills list. With the flag enabled, touch devices use the new
+ conversation list described above. Touch conversation links open standalone
+ agent sessions or legacy chats. A standalone legacy chat is `/app/chat/<uuid>`;
+ doc-scoped chat is `/app/md/<doc>/chat/<chat>` (split view).
## Routine run history