Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix(agents): make mobile builder panes usable (ZIC-385, MUL-8415) (#9764)

ZIcea71532df3f4f
diff --git a/packages/views/agents/create/ai-builder-session-page.tsx b/packages/views/agents/create/ai-builder-session-page.tsx
index 1bc06c0345..6a33ffe142 100644
--- a/packages/views/agents/create/ai-builder-session-page.tsx
+++ b/packages/views/agents/create/ai-builder-session-page.tsx
@@ -49,6 +49,7 @@ export function AiBuilderSessionPage({ sessionId }: { sessionId: string }) {
return (
<AgentCreateShell
+ fitVisualViewport
title={
squadId
? t(($) => $.creation_studio.squad_title)
diff --git a/packages/views/agents/create/builder-workspace-layout.test.tsx b/packages/views/agents/create/builder-workspace-layout.test.tsx
new file mode 100644
index 0000000000..8bc2c07bcd
--- /dev/null
+++ b/packages/views/agents/create/builder-workspace-layout.test.tsx
@@ -0,0 +1,50 @@
+// @vitest-environment jsdom
+
+import { useState } from "react";
+import { cleanup, fireEvent, screen } from "@testing-library/react";
+import { afterEach, describe, expect, it } from "vitest";
+import { renderWithI18n } from "../../test/i18n";
+import { BuilderWorkspaceLayout } from "./builder-workspace-layout";
+
+function Editor({ label }: { label: string }) {
+ const [value, setValue] = useState("");
+ return <textarea aria-label={label} value={value} onChange={(e) => setValue(e.target.value)} />;
+}
+function mount(width: number) {
+ Object.defineProperty(window, "innerWidth", { configurable: true, value: width });
+ return renderWithI18n(<BuilderWorkspaceLayout
+ conversation={<Editor label="Message" />}
+ configuration={<Editor label="Name" />}
+ footer={<button>Create agent</button>}
+ />);
+}
+
+afterEach(cleanup);
+
+describe("responsive builder workspace", () => {
+ it.each([320, 390, 767])("shows one pane at %ipx and retains both editors across switches", (width) => {
+ mount(width);
+ expect(screen.getByRole("tab", { name: "Conversation" })).toHaveAttribute("aria-selected", "true");
+ expect(screen.getAllByRole("tabpanel")).toHaveLength(1);
+ const message = screen.getByRole("textbox", { name: "Message" });
+ fireEvent.change(message, { target: { value: "Unsent message" } });
+ fireEvent.click(screen.getByRole("tab", { name: "Agent configuration" }));
+ expect(screen.getAllByRole("tabpanel")).toHaveLength(1);
+ const name = screen.getByRole("textbox", { name: "Name" });
+ fireEvent.change(name, { target: { value: "My agent" } });
+ expect(screen.getByRole("button", { name: "Create agent" })).toBeVisible();
+ fireEvent.click(screen.getByRole("tab", { name: "Conversation" }));
+ expect(screen.getByRole("textbox", { name: "Message" })).toBe(message);
+ expect(message).toHaveValue("Unsent message");
+ fireEvent.click(screen.getByRole("tab", { name: "Agent configuration" }));
+ expect(screen.getByRole("textbox", { name: "Name" })).toBe(name);
+ expect(name).toHaveValue("My agent");
+ });
+
+ it.each([768, 1280])("retains both desktop panels and the resize handle at %ipx", (width) => {
+ const { container } = mount(width);
+ expect(screen.queryByRole("tab")).toBeNull();
+ expect(screen.getAllByRole("textbox")).toHaveLength(2);
+ expect(container.querySelector('[data-slot="resizable-handle"]')).not.toBeNull();
+ });
+});
diff --git a/packages/views/agents/create/builder-workspace-layout.tsx b/packages/views/agents/create/builder-workspace-layout.tsx
new file mode 100644
index 0000000000..90a0051b5f
--- /dev/null
+++ b/packages/views/agents/create/builder-workspace-layout.tsx
@@ -0,0 +1,68 @@
+"use client";
+
+import { useEffect, useState, type ReactNode } from "react";
+import { useDefaultLayout } from "react-resizable-panels";
+import { useIsMobile } from "@multica/ui/hooks/use-mobile";
+import { Tabs, TabsContent, TabsList, TabsTrigger } from "@multica/ui/components/ui/tabs";
+import { ResizableHandle, ResizablePanel, ResizablePanelGroup } from "@multica/ui/components/ui/resizable";
+import { useT } from "../../i18n";
+
+export function BuilderWorkspaceLayout({ conversation, configuration, footer }: {
+ conversation: ReactNode;
+ configuration: ReactNode;
+ footer: ReactNode;
+}) {
+ const { t } = useT("agents");
+ const isMobile = useIsMobile();
+ const [mounted, setMounted] = useState(false);
+ useEffect(() => setMounted(true), []);
+ const { defaultLayout, onLayoutChanged } = useDefaultLayout({
+ id: "multica_agent_builder_layout",
+ });
+
+ // The breakpoint resolves after hydration. Do not briefly mount a desktop
+ // group on phones and persist its constrained sizes over the desktop layout.
+ if (!mounted) return null;
+
+ if (isMobile) {
+ return (
+ <div
+ data-testid="agent-builder-workspace"
+ className="flex min-h-0 min-w-0 flex-1 flex-col bg-background"
+ >
+ <Tabs defaultValue="conversation" className="min-h-0 flex-1 gap-0">
+ <TabsList className="mx-4 my-2 w-auto shrink-0">
+ <TabsTrigger value="conversation">{t(($) => $.creation_studio.builder.conversation_tab)}</TabsTrigger>
+ <TabsTrigger value="configuration">{t(($) => $.creation_studio.live_draft)}</TabsTrigger>
+ </TabsList>
+ {/* Keep editors and their unsent input alive while switching panes. */}
+ <TabsContent value="conversation" keepMounted className="min-h-0 data-[hidden]:hidden">
+ {conversation}
+ </TabsContent>
+ <TabsContent value="configuration" keepMounted className="min-h-0 data-[hidden]:hidden">
+ {configuration}
+ </TabsContent>
+ </Tabs>
+ {footer}
+ </div>
+ );
+ }
+
+ return (
+ <ResizablePanelGroup
+ orientation="horizontal"
+ className="min-h-0 flex-1"
+ defaultLayout={defaultLayout}
+ onLayoutChanged={onLayoutChanged}
+ >
+ <ResizablePanel id="conversation" minSize="30%">{conversation}</ResizablePanel>
+ <ResizableHandle />
+ <ResizablePanel id="config" defaultSize={420} minSize={340} groupResizeBehavior="preserve-pixel-size">
+ <div className="flex h-full min-h-0 flex-col border-l">
+ <div className="min-h-0 flex-1">{configuration}</div>
+ {footer}
+ </div>
+ </ResizablePanel>
+ </ResizablePanelGroup>
+ );
+}
diff --git a/packages/views/agents/create/builder-workspace.tsx b/packages/views/agents/create/builder-workspace.tsx
index e516aeb1d1..70e8b1dd6c 100644
--- a/packages/views/agents/create/builder-workspace.tsx
+++ b/packages/views/agents/create/builder-workspace.tsx
@@ -2,7 +2,6 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { useQuery } from "@tanstack/react-query";
-import { useDefaultLayout } from "react-resizable-panels";
import {
AlertDialog,
AlertDialogAction,
@@ -13,11 +12,7 @@ import {
AlertDialogHeader,
AlertDialogTitle,
} from "@multica/ui/components/ui/alert-dialog";
-import {
- ResizableHandle,
- ResizablePanel,
- ResizablePanelGroup,
-} from "@multica/ui/components/ui/resizable";
+import { BuilderWorkspaceLayout } from "./builder-workspace-layout";
import {
applyDraftRuntimeChange,
decodeBuilderInput,
@@ -76,9 +71,6 @@ export function BuilderWorkspace({
onRuntimeLabel: (label: string | null) => void;
}) {
const { t } = useT("agents");
- const { defaultLayout, onLayoutChanged } = useDefaultLayout({
- id: "multica_agent_builder_layout",
- });
// Resuming: the conversation already runs somewhere, and only the server
// knows where. Until it answers, the form seeds no runtime at all — falling
@@ -322,18 +314,8 @@ export function BuilderWorkspace({
return (
<>
- {/* The group lives here, not on the route, so its two panels are its
- only children — the same shape the chat page uses. A group whose
- children alternate between one and two panels (setup vs conversation)
- cannot keep a single persisted layout straight, and a panel arriving
- through a child component's fragment is not a child it can measure. */}
- <ResizablePanelGroup
- orientation="horizontal"
- className="min-h-0 flex-1"
- defaultLayout={defaultLayout}
- onLayoutChanged={onLayoutChanged}
- >
- <ResizablePanel id="conversation" minSize="30%">
+ <BuilderWorkspaceLayout
+ conversation={
<BuilderConversation
sessionId={sessionId}
messages={displayMessages}
@@ -356,15 +338,9 @@ export function BuilderWorkspace({
: undefined
}
/>
- </ResizablePanel>
- <ResizableHandle />
- <ResizablePanel
- id="config"
- defaultSize={420}
- minSize={340}
- groupResizeBehavior="preserve-pixel-size"
- >
- <div className="flex h-full min-h-0 flex-col border-l bg-muted/10">
+ }
+ configuration={
+ <div className="flex h-full min-h-0 flex-col bg-muted/10">
<div className="min-h-0 flex-1 overflow-y-auto">
<div className="mx-auto max-w-2xl px-5 py-6">
<div className="mb-6">
@@ -404,18 +380,20 @@ export function BuilderWorkspace({
/>
</div>
</div>
- <CreateAgentFooter
- canCreate={canCreate}
- creating={submit.creating}
- squad={!!squadId}
- error={submit.formError}
- onCreate={() => void submit.create()}
- onDiscard={() => setConfirmingDiscard(true)}
- discarding={builder.closing}
- />
</div>
- </ResizablePanel>
- </ResizablePanelGroup>
+ }
+ footer={
+ <CreateAgentFooter
+ canCreate={canCreate}
+ creating={submit.creating}
+ squad={!!squadId}
+ error={submit.formError}
+ onCreate={() => void submit.create()}
+ onDiscard={() => setConfirmingDiscard(true)}
+ discarding={builder.closing}
+ />
+ }
+ />
<AlertDialog
open={confirmingDiscard}
diff --git a/packages/views/agents/create/create-flow-chrome.test.tsx b/packages/views/agents/create/create-flow-chrome.test.tsx
index a3b179442e..fe4ac1c214 100644
--- a/packages/views/agents/create/create-flow-chrome.test.tsx
+++ b/packages/views/agents/create/create-flow-chrome.test.tsx
@@ -6,8 +6,19 @@ import { Button } from "@multica/ui/components/ui/button";
import { renderWithI18n } from "../../test/i18n";
import { AgentCreateShell } from "./create-shell";
import { CreateAgentFooter, CreateFlowFooter } from "./create-agent-footer";
+import { BuilderWorkspaceLayout } from "./builder-workspace-layout";
-afterEach(cleanup);
+const h = vi.hoisted(() => ({
+ keyboard: null as null | { occludedBottom: number; viewportHeight: number },
+}));
+vi.mock("../../chat/components/use-visual-viewport-keyboard", () => ({
+ useVisualViewportKeyboard: () => h.keyboard,
+}));
+
+afterEach(() => {
+ cleanup();
+ h.keyboard = null;
+});
describe("AgentCreateShell", () => {
it("puts close, the title and the step indicator in one header", () => {
@@ -51,6 +62,68 @@ describe("AgentCreateShell", () => {
expect(within(header).queryByRole("list")).not.toBeInTheDocument();
expect(within(header).getByRole("button", { name: "Close" })).toBeInTheDocument();
});
+
+ it("keeps the close header and workspace together inside the mobile keyboard viewport", () => {
+ Object.defineProperty(window, "innerWidth", { configurable: true, value: 390 });
+ h.keyboard = { occludedBottom: 300, viewportHeight: 420 };
+ const onClose = vi.fn();
+ const onCreate = vi.fn();
+ const shell = () => (
+ <AgentCreateShell
+ title="Create an agent"
+ step="Build through conversation"
+ onClose={onClose}
+ fitVisualViewport
+ >
+ <BuilderWorkspaceLayout
+ conversation={<textarea aria-label="Message" />}
+ configuration={<input aria-label="Name" />}
+ footer={<button onClick={onCreate}>Create agent</button>}
+ />
+ </AgentCreateShell>
+ );
+ const view = renderWithI18n(shell());
+ const layout = screen.getByTestId("agent-create-shell");
+ expect(layout).toHaveStyle({ position: "fixed", height: "420px", bottom: "300px" });
+ const header = within(layout).getByRole("banner");
+ const workspace = within(layout).getByTestId("agent-builder-workspace");
+ expect(workspace.style.position).toBe("");
+ fireEvent.click(within(workspace).getByRole("tab", { name: "Agent configuration" }));
+ expect(within(workspace).getByRole("textbox", { name: "Name" })).toBeVisible();
+ fireEvent.click(within(workspace).getByRole("button", { name: "Create agent" }));
+ expect(onCreate).toHaveBeenCalledTimes(1);
+ fireEvent.click(within(header).getByRole("button", { name: "Close" }));
+ expect(onClose).toHaveBeenCalledTimes(1);
+
+ h.keyboard = { occludedBottom: 250, viewportHeight: 380 };
+ view.rerender(shell());
+ expect(layout).toHaveStyle({ height: "380px", bottom: "250px" });
+
+ h.keyboard = null;
+ view.rerender(shell());
+ expect(layout.style.position).toBe("");
+ expect(layout.style.height).toBe("");
+ expect(layout.style.bottom).toBe("");
+ });
+
+ it.each([
+ { width: 390, fitVisualViewport: false },
+ { width: 1280, fitVisualViewport: true },
+ ])("keeps normal positioning at $width px with fitVisualViewport=$fitVisualViewport", ({ width, fitVisualViewport }) => {
+ Object.defineProperty(window, "innerWidth", { configurable: true, value: width });
+ h.keyboard = { occludedBottom: 300, viewportHeight: 420 };
+ renderWithI18n(
+ <AgentCreateShell
+ title="Create an agent"
+ step="Configure"
+ onClose={vi.fn()}
+ fitVisualViewport={fitVisualViewport}
+ >
+ <main />
+ </AgentCreateShell>,
+ );
+ expect(screen.getByTestId("agent-create-shell").style.position).toBe("");
+ });
});
describe("create flow footer", () => {
diff --git a/packages/views/agents/create/create-shell.tsx b/packages/views/agents/create/create-shell.tsx
index 23c44f04da..5b33de5d98 100644
--- a/packages/views/agents/create/create-shell.tsx
+++ b/packages/views/agents/create/create-shell.tsx
@@ -5,6 +5,8 @@ import { Check, X } from "@multica/ui/icons";
import { IconButton } from "@multica/ui/components/common/icon-button";
import { Separator } from "@multica/ui/components/ui/separator";
import { cn } from "@multica/ui/lib/utils";
+import { useIsMobile } from "@multica/ui/hooks/use-mobile";
+import { useVisualViewportKeyboard } from "../../chat/components/use-visual-viewport-keyboard";
import { PageHeader } from "../../layout/page-header";
import { useT } from "../../i18n";
@@ -25,6 +27,7 @@ export function AgentCreateShell({
onClose,
chips,
children,
+ fitVisualViewport = false,
}: {
title: string;
/** Names the screen where there is no step position to show. */
@@ -35,10 +38,22 @@ export function AgentCreateShell({
/** Right-aligned context badges (method, runtime). Hidden on small screens. */
chips?: ReactNode;
children: ReactNode;
+ /** Keep the conversation, page header and actions above the mobile keyboard. */
+ fitVisualViewport?: boolean;
}) {
const { t } = useT("agents");
+ const isMobile = useIsMobile();
+ const keyboard = useVisualViewportKeyboard();
return (
- <div className="flex min-h-0 flex-1 flex-col bg-background">
+ <div
+ data-testid="agent-create-shell"
+ className="flex min-h-0 min-w-0 flex-1 flex-col bg-background"
+ // Fit the whole page so the workspace cannot cover its close/step header.
+ style={fitVisualViewport && isMobile && keyboard ? {
+ position: "fixed", left: 0, right: 0, zIndex: 20,
+ bottom: keyboard.occludedBottom, height: keyboard.viewportHeight,
+ } : undefined}
+ >
<PageHeader
leading={
<IconButton
diff --git a/packages/views/locales/en/agents.json b/packages/views/locales/en/agents.json
index 26b84fecab..0e577ac231 100644
--- a/packages/views/locales/en/agents.json
+++ b/packages/views/locales/en/agents.json
@@ -349,6 +349,7 @@
"switch_runtime_failed": "Could not switch runtime. The conversation is still running on the previous one.",
"switch_runtime_pending": "Stop the current reply to switch runtime.",
"switch_runtime_success": "Runtime switched. Your draft is kept and the conversation continues on the new runtime with a fresh model session.",
+ "conversation_tab": "Conversation",
"chat_title": "Agent Builder",
"runtime_online": "Runtime online",
"runtime_offline": "Runtime offline",
diff --git a/packages/views/locales/fr/agents.json b/packages/views/locales/fr/agents.json
index fc56abe4a3..ef9bdd996e 100644
--- a/packages/views/locales/fr/agents.json
+++ b/packages/views/locales/fr/agents.json
@@ -349,6 +349,7 @@
"switch_runtime_failed": "Impossible de changer de runtime. La conversation se poursuit sur le précédent.",
"switch_runtime_pending": "Arrêtez la réponse en cours pour changer de runtime.",
"switch_runtime_success": "Runtime changé. Votre brouillon est conservé et la conversation se poursuit sur le nouveau runtime avec une session de modèle neuve.",
+ "conversation_tab": "Conversation",
"chat_title": "Agent Builder",
"runtime_online": "Runtime en ligne",
"runtime_offline": "Runtime hors ligne",
diff --git a/packages/views/locales/ja/agents.json b/packages/views/locales/ja/agents.json
index 1d0ef5d297..28992f7b8b 100644
--- a/packages/views/locales/ja/agents.json
+++ b/packages/views/locales/ja/agents.json
@@ -928,6 +928,7 @@
"switch_runtime_failed": "ランタイムを切り替えられませんでした。会話は引き続き元のランタイムで実行されています。",
"switch_runtime_pending": "現在の返信を停止するとランタイムを切り替えられます。",
"switch_runtime_success": "ランタイムを切り替えました。下書き設定はそのまま残り、以降の会話は新しいランタイムで新しいモデルセッションとして続きます。",
+ "conversation_tab": "会話",
"chat_title": "Agent Builder",
"runtime_online": "ランタイムはオンライン",
"runtime_offline": "ランタイムはオフライン",
diff --git a/packages/views/locales/ko/agents.json b/packages/views/locales/ko/agents.json
index dc8c48fb64..91efbb3acb 100644
--- a/packages/views/locales/ko/agents.json
+++ b/packages/views/locales/ko/agents.json
@@ -928,6 +928,7 @@
"switch_runtime_failed": "런타임을 전환하지 못했습니다. 대화는 이전 런타임에서 계속 실행됩니다.",
"switch_runtime_pending": "현재 답변을 중지하면 런타임을 전환할 수 있습니다.",
"switch_runtime_success": "런타임을 전환했습니다. 설정 초안은 유지되며, 이후 대화는 새 런타임에서 새로운 모델 세션으로 이어집니다.",
+ "conversation_tab": "대화",
"chat_title": "Agent Builder",
"runtime_online": "런타임 온라인",
"runtime_offline": "런타임 오프라인",
diff --git a/packages/views/locales/zh-Hans/agents.json b/packages/views/locales/zh-Hans/agents.json
index e2c13add53..96a86f0759 100644
--- a/packages/views/locales/zh-Hans/agents.json
+++ b/packages/views/locales/zh-Hans/agents.json
@@ -337,6 +337,7 @@
"switch_runtime_failed": "切换运行时失败,对话仍在原来的运行时上执行。",
"switch_runtime_pending": "停止当前回复后即可切换运行时。",
"switch_runtime_success": "已切换运行时。配置草稿保留,后续对话将在新运行时上重新开始一段模型会话。",
+ "conversation_tab": "对话",
"chat_title": "智能体构建器",
"runtime_online": "运行时在线",
"runtime_offline": "运行时离线",
diff --git a/packages/views/locales/zh-Hant/agents.json b/packages/views/locales/zh-Hant/agents.json
index b13f6b6f36..63094f4def 100644
--- a/packages/views/locales/zh-Hant/agents.json
+++ b/packages/views/locales/zh-Hant/agents.json
@@ -337,6 +337,7 @@
"switch_runtime_failed": "切換執行時失敗,對話仍在原來的執行時上執行。",
"switch_runtime_pending": "停止當前回覆後即可切換執行時。",
"switch_runtime_success": "已切換執行時。配置草稿保留,後續對話將在新執行時上重新開始一段模型會話。",
+ "conversation_tab": "對話",
"chat_title": "AI 代理構建器",
"runtime_online": "執行時線上",
"runtime_offline": "執行時離線",