Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(mobile): steer running chat replies and keep an explicit queue (MUL-9404) (#10735)
Multica Eveba201d48ca79
diff --git a/apps/docs/content/docs/chat.fr.mdx b/apps/docs/content/docs/chat.fr.mdxindex fd331208c6..645911974a 100644--- a/apps/docs/content/docs/chat.fr.mdx+++ b/apps/docs/content/docs/chat.fr.mdx@@ -102,7 +102,7 @@ Pour attendre le prochain tour, utilisez **Mettre le message en file d’attenteLa file apparaît au-dessus du champ de saisie et suit l’ordre des messages. Vous pouvez supprimer un message, le modifier via **⋯**, ou vider la file. **Envoyer maintenant (arrête la réponse)** place le message en tête et arrête la réponse en cours. Cette action nécessite une réponse démarrée et le droit d’exécuter l’agent.-Cette fonction concerne les conversations Chat directes sur les clients web et de bureau à jour. Le mobile, les anciens clients et les conversations Slack et Lark conservent leur file habituelle.+Cette fonction concerne les conversations Chat directes sur les clients web, de bureau et mobile à jour. Sur mobile, les messages en file apparaissent à la fin de la conversation ; supprimez-les ou modifiez-les depuis le web ou le bureau. Les anciens clients et les conversations Slack et Lark conservent leur file habituelle.## Organiser la liste des conversationsdiff --git a/apps/docs/content/docs/chat.ja.mdx b/apps/docs/content/docs/chat.ja.mdxindex fb6060a0be..79a27c79e2 100644--- a/apps/docs/content/docs/chat.ja.mdx+++ b/apps/docs/content/docs/chat.ja.mdx@@ -102,7 +102,7 @@ Multica で作成したダイレクトチャットを読めるのは作成者だキューは入力欄の上に表示され、順番に処理されます。削除、**⋯** からの編集や全消去も可能です。**今すぐ送信(現在の返信を停止)** はキュー内のメッセージを先頭に移し、現在の返信を停止します。返信が開始済みで、実行権限が必要です。-対象は更新済みのウェブ版とデスクトップ版の通常の Chat です。モバイル、旧クライアント、Slack や Lark の会話は従来のキュー動作を維持します。+対象は更新済みのウェブ版、デスクトップ版、モバイル版の通常の Chat です。モバイル版ではキュー内のメッセージが会話の末尾に表示され、削除や編集はウェブ版またはデスクトップ版で行います。旧クライアント、Slack や Lark の会話は従来のキュー動作を維持します。## チャット一覧の整理diff --git a/apps/docs/content/docs/chat.ko.mdx b/apps/docs/content/docs/chat.ko.mdxindex 6ce2f3236e..3004a70989 100644--- a/apps/docs/content/docs/chat.ko.mdx+++ b/apps/docs/content/docs/chat.ko.mdx@@ -102,7 +102,7 @@ Multica에서 만든 직접 대화는 만든 사람만 읽을 수 있고, 다른대기열은 입력창 위에 표시되며 순서대로 처리됩니다. 삭제하거나 **⋯** 에서 편집 또는 전체 삭제할 수 있습니다. **지금 보내기 (현재 응답 중지)** 는 메시지를 맨 앞으로 옮기고 현재 응답을 중지합니다. 응답이 시작된 상태이고 에이전트 실행 권한이 있어야 합니다.-업데이트된 웹 및 데스크톱 클라이언트의 일반 Chat에 적용됩니다. 모바일, 이전 클라이언트, Slack과 Lark 채널 대화는 기존 대기열 동작을 유지합니다.+업데이트된 웹, 데스크톱, 모바일 클라이언트의 일반 Chat에 적용됩니다. 모바일에서는 대기열의 메시지가 대화 끝에 표시되며, 삭제나 편집은 웹 또는 데스크톱에서 할 수 있습니다. 이전 클라이언트, Slack과 Lark 채널 대화는 기존 대기열 동작을 유지합니다.## 대화 목록 정리diff --git a/apps/docs/content/docs/chat.mdx b/apps/docs/content/docs/chat.mdxindex a555840e22..b69f5858fe 100644--- a/apps/docs/content/docs/chat.mdx+++ b/apps/docs/content/docs/chat.mdx@@ -102,7 +102,7 @@ Use **Queue message** beside Send to save a message for the next turn instead. MQueued messages appear above the input and run in order. You can remove them, use **⋯ → Edit queued message** to restore them to the input, or **⋯ → Clear all** to withdraw them. **Send now (stops current reply)** moves a queued message to the front and stops the current reply. It requires an active reply and permission to run the agent.-Steering applies to direct Chat sessions on updated web and desktop clients. Mobile, older clients, and Slack and Lark channel conversations keep their existing queue behavior.+Steering applies to direct Chat sessions on updated web, desktop, and mobile clients. On mobile, queued messages appear at the end of the conversation; remove or edit them on web or desktop. Older clients and Slack and Lark channel conversations keep their existing queue behavior.## Organize the conversation listdiff --git a/apps/docs/content/docs/chat.zh-Hant.mdx b/apps/docs/content/docs/chat.zh-Hant.mdxindex 494cecdf20..367d8dfa51 100644--- a/apps/docs/content/docs/chat.zh-Hant.mdx+++ b/apps/docs/content/docs/chat.zh-Hant.mdx@@ -102,7 +102,7 @@ AI 代理執行時,介面會顯示當前階段和工具活動。展開**檢視佇列顯示在輸入框上方,依序處理。可以移除、透過 **⋯ → 編輯排隊訊息** 放回輸入框,或用 **⋯ → 全部清空** 撤回。**立即傳送(停止目前回覆)** 會將訊息移到最前並停止目前回覆;需要回覆已開始,且你有執行該智能體的權限。-插話適用於新版網頁和桌面用戶端的一般 Chat;行動版、舊版用戶端和 Slack、Lark 等渠道會話維持原有佇列行為。+插話適用於新版網頁、桌面和行動版用戶端的一般 Chat。行動版的排隊訊息顯示在對話末尾,移除或編輯請在網頁或桌面用戶端操作。舊版用戶端和 Slack、Lark 等渠道會話維持原有佇列行為。## 整理對話列表diff --git a/apps/docs/content/docs/chat.zh.mdx b/apps/docs/content/docs/chat.zh.mdxindex d4ebe32a4a..88fac7f7c1 100644--- a/apps/docs/content/docs/chat.zh.mdx+++ b/apps/docs/content/docs/chat.zh.mdx@@ -102,7 +102,7 @@ import { ChatDemo } from "@/components/demos/chat-demo";排队消息显示在输入框上方,按顺序处理。可以删除,通过 **⋯ → 编辑排队消息** 放回输入框,或用 **⋯ → 全部清空** 撤回。**立即发送(停止当前回复)** 会把排队消息提到队首,并停止当前回复;需要当前回复已开始,且你有运行该智能体的权限。-插话适用于新版网页和桌面客户端的普通 Chat;移动端、旧版客户端和 Slack、Lark 等渠道会话保持原有排队行为。+插话适用于新版网页端、桌面端和移动端的普通 Chat。移动端的排队消息显示在对话末尾,删除或编辑请在网页端或桌面端操作。旧版客户端和 Slack、Lark 等渠道会话保持原有排队行为。## 整理对话列表diff --git a/apps/mobile/app/(app)/[workspace]/(tabs)/chat.tsx b/apps/mobile/app/(app)/[workspace]/(tabs)/chat.tsxindex 1e19ba3684..be20778762 100644--- a/apps/mobile/app/(app)/[workspace]/(tabs)/chat.tsx+++ b/apps/mobile/app/(app)/[workspace]/(tabs)/chat.tsx@@ -29,6 +29,11 @@* (packages/views/chat/components/chat-window.tsx ~262-345):* seed messages → seed pendingTask → flip activeSessionId → POST →* patch pendingTask with server task_id + created_at.+ *+ * During a reply on a queue-capable server, Send asks to add the message to+ * that reply (`steer`) and the composer's Queue action keeps it for the next+ * turn. The server decides whether steering applies; an accepted steer keeps+ * the running head instead of seeding a new turn.*/import { useCallback, useEffect, useMemo, useRef, useState } from "react";import {@@ -76,9 +81,10 @@ import { useChatSessionPickerStore } from "@/data/stores/chat-session-picker-stoimport { useChatSessionRealtime } from "@/data/realtime/use-chat-session-realtime";import {invalidatePendingTask,- seedAcceptedPendingTask,+ reconcileAcceptedChatSend,} from "@/data/realtime/chat-ws-updaters";import { useWorkspaceAgentAvailability } from "@/lib/workspace-agent-availability";+import { queuedChatMessages } from "@/lib/chat-queued-messages";import {dispatchReasonCode,} from "@/lib/dispatch-reason";@@ -156,6 +162,7 @@ export default function ChatTab() {pendingChatTaskOptions(activeSessionId),);const visibleMessages = hideQueuedChatMessages(messages, pendingTask);+ const queuedMessages = queuedChatMessages(pendingTask, messages);// Live execution trace for the in-flight task. `task:message` WS events// append rows to this same cache key via `appendTaskMessage`, so the// list/pill stay in sync without a polling fetch. `enabled` is gated by@@ -292,7 +299,7 @@ export default function ChatTab() {async (content: string,attachmentIds: string[] = [],- options: { clearDraft?: boolean } = {},+ options: { clearDraft?: boolean; queue?: boolean } = {},) => {if (!currentAgent) return;// Invoke permission was revoked while this session was open — the server@@ -360,35 +367,22 @@ export default function ChatTab() {}try {+ // One request per tap, never replayed: a send whose outcome is unknown+ // fails visibly and keeps the draft, so a retry is the user's choice.const result = await api.sendChatMessage(sessionId, content, {attachmentIds: attachmentIds.length > 0 ? attachmentIds : undefined,+ queue: options.queue,});// Replace the local bubble before reconciling pending state. When the// server says this is a follow-up, its real message id lets the shared// queue filter hide it immediately instead of waiting for the refetch.- qc.setQueryData<ChatMessage[]>(chatKeys.messages(sessionId), (old) =>- old?.map((message) =>- message.id === optimistic.id- ? {- ...message,- id: result.message_id,- task_id: result.task_id,- created_at: result.created_at,- }- : message,- ),- );- seedAcceptedPendingTask(qc, {+ reconcileAcceptedChatSend(qc, {chat_session_id: sessionId,- task_id: result.task_id,- created_at: result.created_at,- message_id: result.message_id,- content,+ optimistic_message_id: optimistic.id,optimistic_task_id: optimisticTaskId,- supports_queue: result.supports_queue,- queued: result.queued,+ content,+ result,});- qc.invalidateQueries({ queryKey: chatKeys.messages(sessionId) });// This send just committed the new session's server-derived title.if (isNewSession) {void refetchChatSessionsAfterCommit(qc, chatKeys.sessions(wsId));@@ -550,6 +544,7 @@ export default function ChatTab() {quickActionsDisabled={sending || disabled}pendingTask={pendingTask}liveTaskMessages={liveTaskMessages}+ queuedMessages={queuedMessages}availability={presenceAvailability}/>{runtimeBound ? (@@ -567,6 +562,7 @@ export default function ChatTab() {onStop={handleStop}sending={sending}allowStop={pendingTask?.status !== "queued"}+ allowSendWhileSending={pendingTask?.supports_queue === true}disabled={disabled}disabledReason={disabledReason}/>diff --git a/apps/mobile/components/chat/chat-composer.tsx b/apps/mobile/components/chat/chat-composer.tsxindex d3ddd5b80f..ebc4d9b831 100644--- a/apps/mobile/components/chat/chat-composer.tsx+++ b/apps/mobile/components/chat/chat-composer.tsx@@ -9,6 +9,10 @@* session, `sending` flips true and we replace the Send button slot* with a Stop affordance (filled foreground bg + stop glyph). Tap →* `onStop()` cancels the in-flight task.+ * - **Send during a reply**: when the server accepts follow-ups+ * (`allowSendWhileSending`), typed content swaps Stop for Send, which+ * asks to add the message to the running reply, plus a Queue action+ * for the next turn. Mirrors web's ChatInput action slot.* - **Mention picker mode=chat**: chat is user ↔ single agent so* @member / @agent / @squad / @all are noise + would notify the* wrong people. Picker route honors `?mode=chat` and surfaces only@@ -44,7 +48,11 @@ interface Props {/** Send the serialised markdown content + the completed attachments'* server ids. Caller resets the input by setting `value=""` after a* successful send. */- onSend: (content: string, attachmentIds: string[]) => Promise<void> | void;+ onSend: (+ content: string,+ attachmentIds: string[],+ options?: { queue?: boolean },+ ) => Promise<void> | void;/** Cancel the in-flight agent task. Only callable while `sending===true`. */onStop: () => void;/** True while an agent task is running for the active session. The@@ -52,6 +60,9 @@ interface Props {sending: boolean;/** Queued tasks remain busy, but do not expose Stop without draft restore. */allowStop?: boolean;+ /** The server accepts sends while `sending` (queue-capable). Older+ * servers keep the composer stop-only during a run. */+ allowSendWhileSending?: boolean;/** Hard-disable typing + send. Used when there's no usable agent in the* workspace or the session is archived (legacy). */disabled?: boolean;@@ -68,6 +79,7 @@ export function ChatComposer({onStop,sending,allowStop = true,+ allowSendWhileSending = false,disabled = false,disabledReason,}: Props) {@@ -78,13 +90,15 @@ export function ChatComposer({async ({content,attachmentIds,+ queue,}: {content: string;attachmentIds: string[];+ queue: boolean;}) => {// `onSend` may be sync or async; await is safe in both cases. If it// throws, MessageComposer's catch restores text + chips.- await onSend(content, attachmentIds);+ await onSend(content, attachmentIds, queue ? { queue: true } : undefined);},[onSend],);@@ -105,7 +119,11 @@ export function ChatComposer({pathname: "/[workspace]/mention-picker",params: { workspace: wsSlug ?? "", mode: "chat" },}}- placeholder={sending ? t("composer.working") : t("composer.message")}+ placeholder={+ sending && !allowSendWhileSending+ ? t("composer.working")+ : t("composer.message")+ }pillLabel={sending? t("composer.working")@@ -118,6 +136,8 @@ export function ChatComposer({disabledReason={disabledReason}isSending={sending}renderStop={allowStop ? () => <StopButton onPress={handleStop} /> : undefined}+ allowSubmitWhileSending={allowSendWhileSending}+ queueAction={{ accessibilityLabel: t("composer.queue") }}manageKeyboard={false}/>);diff --git a/apps/mobile/components/chat/chat-message-list.tsx b/apps/mobile/components/chat/chat-message-list.tsxindex 05cbd457f1..b6018270f0 100644--- a/apps/mobile/components/chat/chat-message-list.tsx+++ b/apps/mobile/components/chat/chat-message-list.tsx@@ -21,11 +21,14 @@ import type {} from "@multica/core/types";import type { AgentAvailability } from "@multica/core/agents";import { continuousCorners } from "@/lib/radius";+import { THEME } from "@/lib/theme";+import { useColorScheme } from "@/lib/use-color-scheme";import { taskMessagesOptions } from "@/data/queries/chat";import { Text } from "@/components/ui/text";import { Markdown } from "@/lib/markdown";import { ImageSequenceProvider } from "@/lib/markdown/image-sequence";import { failureReasonKey } from "@/lib/failure-reason-label";+import type { QueuedChatMessage } from "@/lib/chat-queued-messages";import { formatElapsedMs } from "@/lib/format-elapsed";import { cn } from "@/lib/utils";import { useChatSelectStore } from "@/data/chat-select-store";@@ -66,6 +69,8 @@ interface Props {/** Live timeline rows for the in-flight task. Already fetched by the* parent so this list doesn't have to manage its own subscription. */liveTaskMessages?: TaskMessagePayload[];+ /** Follow-ups waiting for their turn, rendered after the live reply. */+ queuedMessages?: QueuedChatMessage[];/** Resolved availability — drives the StatusPill's "Offline" /* "Reconnecting" stages. Pass `undefined` while loading. */availability?: AgentAvailability;@@ -81,6 +86,7 @@ export function ChatMessageList({quickActionsDisabled = false,pendingTask,liveTaskMessages,+ queuedMessages = [],availability,}: Props) {// Top-level selection subscription gates the outer "tap-outside-to-dismiss"@@ -179,16 +185,21 @@ export function ChatMessageList({)}ItemSeparatorComponent={MessageSeparator}ListFooterComponent={- showLiveSection ? (+ showLiveSection || queuedMessages.length > 0 ? (<View style={{ paddingTop: 12 }} className="gap-2">{showLiveTimeline ? (<ChatTimeline items={liveTaskMessages ?? []} isStreaming />) : null}- <StatusPill- pendingTask={pendingTask}- taskMessages={liveTaskMessages}- availability={availability}- />+ {showLiveSection ? (+ <StatusPill+ pendingTask={pendingTask}+ taskMessages={liveTaskMessages}+ availability={availability}+ />+ ) : null}+ {queuedMessages.map((row) => (+ <QueuedMessageRow key={row.task_id} message={row} />+ ))}</View>) : null}@@ -231,6 +242,48 @@ function MessageSeparator() {return <View style={{ height: 12 }} />;}+/**+ * A follow-up waiting for its turn. Sits after the live reply, where it will+ * run, dimmed and captioned so it does not read as part of the current+ * reply. Read-only on mobile: removing or editing queued messages stays on+ * web and desktop. Once its turn starts the server row returns to the+ * transcript in this position.+ */+function QueuedMessageRow({ message }: { message: QueuedChatMessage }) {+ const { t } = useT("chat");+ const { colorScheme } = useColorScheme();+ return (+ <View className="self-end max-w-[80%] items-end gap-1 opacity-60">+ <View+ className="gap-1.5 rounded-xl border-2 border-transparent bg-muted px-3.5 py-2"+ style={continuousCorners}+ >+ {message.content.trim() ? (+ <Markdown+ content={message.content}+ attachments={message.attachments}+ compact+ />+ ) : null}+ <CommentAttachmentList+ attachments={message.attachments}+ content={message.content}+ />+ </View>+ <View className="flex-row items-center gap-1 px-1">+ <Ionicons+ name="time-outline"+ size={12}+ color={THEME[colorScheme].mutedForeground}+ />+ <Text className="text-xs text-muted-foreground">+ {t("status.queued")}+ </Text>+ </View>+ </View>+ );+}+function MessageRow({message,onQuickAction,diff --git a/apps/mobile/components/composer/message-composer.tsx b/apps/mobile/components/composer/message-composer.tsxindex f6cad2fd1f..21ee5fe2e9 100644--- a/apps/mobile/components/composer/message-composer.tsx+++ b/apps/mobile/components/composer/message-composer.tsx@@ -33,6 +33,9 @@* `onClearReplyTarget` from its store; chat doesn't.* - Stop visual / animation — chat passes a `renderStop()` slot when* `isSending` is true.+ * - What a send during a run means — chat opts in with+ * `allowSubmitWhileSending` and adds a `queueAction`; the composer only+ * reports which action submitted.** Cleanup: mention draft store cleared on unmount so navigating away* from comment-A's draft doesn't leak `@张三` into comment-B's composer.@@ -55,6 +58,7 @@ import * as DocumentPicker from "expo-document-picker";import { api, MAX_FILE_SIZE } from "@/data/api";import { useMentionDraftStore } from "@/data/stores/mention-draft-store";import { useColorScheme } from "@/lib/use-color-scheme";+import { composerActions } from "@/lib/composer-actions";import { stripMarkdown } from "@/lib/strip-markdown";import { THEME } from "@/lib/theme";import { continuousCorners } from "@/lib/radius";@@ -81,6 +85,8 @@ interface Props {content: string;attachmentIds: string[];mentions: MentionChip[];+ /** True when submitted through `queueAction` instead of Send. */+ queue: boolean;}) => Promise<void>;/** Push target for the `@` button. The picker route reads /@@ -117,6 +123,13 @@ interface Props {* this to show a Stop affordance while the agent is running. */isSending?: boolean;renderStop?: () => ReactNode;+ /** While `isSending`, still accept typed content. Send takes the action+ * slot whenever there is content to send; Stop stays reachable for an+ * empty composer or an upload in flight (same slot rule as web chat). */+ allowSubmitWhileSending?: boolean;+ /** Secondary submit shown beside Send while `isSending` with content.+ * Chat uses it for "queue for the next turn". */+ queueAction?: { accessibilityLabel: string };/** Hard-disable. Used when chat has no usable agent. The pill shows* `disabledReason` instead of `pillLabel`, and the pill is@@ -170,6 +183,8 @@ export function MessageComposer({expandTrigger,isSending = false,renderStop,+ allowSubmitWhileSending = false,+ queueAction,disabled = false,disabledReason,manageKeyboard = true,@@ -232,13 +247,16 @@ export function MessageComposer({return () => cancelAnimationFrame(frame);}, [expanded, triggerSeen, disabled]);- const hasInFlightUpload = attachments.some((a) => a.status === "uploading");- const canSend =- !disabled &&- !isSending &&- !submitting &&- !hasInFlightUpload &&- (text.trim().length > 0 || mentions.length > 0);+ const { canSend, showStop, showQueue } = composerActions({+ isSending,+ allowSubmitWhileSending,+ hasStop: !!renderStop,+ hasQueueAction: !!queueAction,+ hasContent: text.trim().length > 0 || mentions.length > 0,+ hasInFlightUpload: attachments.some((a) => a.status === "uploading"),+ submitting,+ disabled,+ });const expand = useCallback(() => {if (disabled) return;@@ -251,7 +269,7 @@ export function MessageComposer({requestAnimationFrame(() => inputRef.current?.focus());}, [disabled, onClearReplyTarget]);- const handleSubmit = useCallback(async () => {+ const handleSubmit = useCallback(async (queue: boolean) => {if (!canSend) return;const textSnap = text;const mentionsSnap = mentions;@@ -283,6 +301,7 @@ export function MessageComposer({content,attachmentIds: activeIds,mentions: mentionsSnap,+ queue,});// Success → fully exit composing mode. Explicit triple-step// because a missing blur leaves the keyboard up; missing@@ -589,7 +608,21 @@ export function MessageComposer({className="h-8 w-8"/><View className="flex-1" />- {isSending && renderStop ? (+ {showQueue && queueAction ? (+ <IconButton+ name="time-outline"+ iconSize={20}+ onPress={() => void handleSubmit(true)}+ disabled={!canSend}+ // No trailing slop: Send's 12pt slop already reaches into the+ // gap, and an overlap would let a Queue tap land on Send.+ hitSlop={{ top: 12, bottom: 12, left: 8, right: 0 }}+ className="mr-4 h-8 w-8"+ accessibilityLabel={queueAction.accessibilityLabel}+ accessibilityState={{ disabled: !canSend }}+ />+ ) : null}+ {showStop && renderStop ? (renderStop()) : (<IconButton@@ -597,7 +630,7 @@ export function MessageComposer({iconSize={18}color={theme.primaryForeground}variant="default"- onPress={handleSubmit}+ onPress={() => void handleSubmit(false)}disabled={!canSend}hitSlop={12}className="h-8 w-8 rounded-full"diff --git a/apps/mobile/data/api.test.ts b/apps/mobile/data/api.test.tsindex c524f70b66..223dd19a56 100644--- a/apps/mobile/data/api.test.ts+++ b/apps/mobile/data/api.test.ts@@ -66,3 +66,33 @@ describe("api.listIssues requester compatibility", () => {if (!supported) expect(String(fetchMock.mock.calls[1]?.[0])).toContain("creator_id=me");});});++describe("api.sendChatMessage steering", () => {+ const accepted = {+ message_id: "message-1",+ task_id: "task-1",+ created_at: "2026-11-16T00:00:00Z",+ };++ afterEach(() => vi.unstubAllGlobals());++ // The server decides whether a send can join the running reply; the client+ // only states intent. Default sends ask to steer, the explicit queue does not.+ it.each([+ [undefined, true],+ [{ attachmentIds: ["attachment-1"] }, true],+ [{ queue: false }, true],+ [{ queue: true }, false],+ ])("with %j sends steer=%s", async (opts, steer) => {+ const fetchMock = vi.fn(async (_url: string, _init?: RequestInit) =>+ Response.json(accepted, { status: 201 }),+ );+ vi.stubGlobal("fetch", fetchMock);++ await api.sendChatMessage("session-1", "use the new path", opts);++ const body = JSON.parse(String(fetchMock.mock.calls[0]?.[1]?.body));+ expect(body.steer).toBe(steer);+ expect(body.content).toBe("use the new path");+ });+});diff --git a/apps/mobile/data/api.ts b/apps/mobile/data/api.tsindex 2402be427b..4a12eeb849 100644--- a/apps/mobile/data/api.ts+++ b/apps/mobile/data/api.ts@@ -1168,7 +1168,7 @@ class ApiClient {async sendChatMessage(sessionId: string,content: string,- opts?: { attachmentIds?: string[] },+ opts?: { attachmentIds?: string[]; queue?: boolean },): Promise<SendChatMessageResponse> {// Strict parse — we need task_id + created_at to anchor the optimistic// StatusPill. Fallback would silently break the elapsed-time timer.@@ -1177,7 +1177,16 @@ class ApiClient {// server-side `chat.go` back-fills `chat_message_id` on the listed// attachments after the message row is inserted (see// server/internal/handler/chat.go:410-456).- const body: { content: string; attachment_ids?: string[] } = { content };+ //+ // `steer` asks the server to add this message to the running reply. The+ // server decides eligibility (plain text, direct chat, a started reply on+ // a capable daemon) and queues otherwise; older servers ignore the field+ // and queue. `queue: true` is the explicit next-turn send. Same contract+ // as web's `packages/core/api/client.ts`.+ const body: { content: string; steer: boolean; attachment_ids?: string[] } = {+ content,+ steer: opts?.queue !== true,+ };if (opts?.attachmentIds && opts.attachmentIds.length > 0) {body.attachment_ids = opts.attachmentIds;}diff --git a/apps/mobile/data/chat-schema.test.ts b/apps/mobile/data/chat-schema.test.tsindex 659c34189d..c9b19cf177 100644--- a/apps/mobile/data/chat-schema.test.ts+++ b/apps/mobile/data/chat-schema.test.ts@@ -41,4 +41,32 @@ describe("SendChatMessageResponseSchema", () => {it("ignores a malformed additive queue position", () => {expect(SendChatMessageResponseSchema.parse({ ...base, queued: "no" }).queued).toBeUndefined();});++ it("reads steering acceptance and the message's own input owner", () => {+ const parsed = SendChatMessageResponseSchema.parse({+ ...base,+ task_id: "task-retry",+ steered: true,+ message_task_id: "task-root",+ message_created_at: "2026-08-05T00:01:00Z",+ });+ expect(parsed).toMatchObject({+ steered: true,+ message_task_id: "task-root",+ message_created_at: "2026-08-05T00:01:00Z",+ });+ });++ it("degrades malformed steering fields to the legacy queued reading", () => {+ const parsed = SendChatMessageResponseSchema.parse({+ ...base,+ steered: "yes",+ message_task_id: "",+ message_created_at: 42,+ });+ expect(parsed.task_id).toBe("task-1");+ expect(parsed.steered).toBeUndefined();+ expect(parsed.message_task_id).toBeUndefined();+ expect(parsed.message_created_at).toBeUndefined();+ });});diff --git a/apps/mobile/data/realtime/chat-ws-updaters.test.ts b/apps/mobile/data/realtime/chat-ws-updaters.test.tsindex 5d5f0840e5..0cd5142695 100644--- a/apps/mobile/data/realtime/chat-ws-updaters.test.ts+++ b/apps/mobile/data/realtime/chat-ws-updaters.test.ts@@ -11,9 +11,11 @@ import {applyChatDoneToCache,applyChatQuickActionsToCache,promotePendingTaskToRunning,+ reconcileAcceptedChatSend,seedAcceptedPendingTask,seedPendingTaskFromQueued,} from "./chat-ws-updaters";+import { hideQueuedChatMessages } from "@multica/core/chat/pending";import { chatKeys } from "@/data/queries/chat";// chat-ws-updaters imports chatKeys from data/queries/chat, which transitively@@ -241,6 +243,39 @@ describe("pending task queue events", () => {expect(invalidate).toHaveBeenCalledWith({queryKey: chatKeys.pendingTask(SESSION),});+ // Re-queued guidance changes its message's owner; only a refetch moves+ // the row from the transcript to the queued rows.+ expect(invalidate).toHaveBeenCalledWith({+ queryKey: chatKeys.messages(SESSION),+ });+ });++ it("skips the messages refetch for a turn its message already names", () => {+ const qc = new QueryClient();+ qc.setQueryData<ChatMessage[]>(chatKeys.messages(SESSION), [{+ id: "message-follow-up",+ chat_session_id: SESSION,+ role: "user",+ content: "follow up",+ task_id: "task-follow-up",+ created_at: "2026-07-09T00:00:01Z",+ }]);+ const invalidate = vi.spyOn(qc, "invalidateQueries");++ seedPendingTaskFromQueued(qc, {+ task_id: "task-follow-up",+ agent_id: "agent-1",+ issue_id: "",+ chat_session_id: SESSION,+ status: "queued",+ });++ expect(invalidate).toHaveBeenCalledWith({+ queryKey: chatKeys.pendingTask(SESSION),+ });+ expect(invalidate).not.toHaveBeenCalledWith({+ queryKey: chatKeys.messages(SESSION),+ });});it("refetches pending state and messages when a task is dispatched", () => {@@ -387,3 +422,199 @@ describe("applyChatQuickActionsToCache", () => {unsub();});});++describe("reconcileAcceptedChatSend", () => {+ const ACTIVE_STARTED = "2026-11-16T00:00:00Z";+ const SENT_AT = "2026-11-16T00:05:00Z";++ function earlier(): ChatMessage[] {+ return [+ {+ id: "message-request",+ chat_session_id: SESSION,+ role: "user",+ content: "fix the build",+ task_id: "task-root",+ created_at: ACTIVE_STARTED,+ },+ ];+ }++ // The state handleSend leaves behind before the POST: the optimistic bubble+ // at the end of the transcript and a placeholder behind the running head.+ function sendingDuringReply(head: ChatPendingTask = {+ task_id: "task-retry",+ status: "running",+ created_at: ACTIVE_STARTED,+ supports_queue: true,+ }) {+ const qc = new QueryClient();+ qc.setQueryData<ChatMessage[]>(chatKeys.messages(SESSION), [+ ...earlier(),+ {+ id: "optimistic-1",+ chat_session_id: SESSION,+ role: "user",+ content: "use the new path",+ task_id: null,+ created_at: SENT_AT,+ },+ ]);+ qc.setQueryData<ChatPendingTask>(chatKeys.pendingTask(SESSION), {+ ...head,+ queued_tasks: [{+ task_id: "optimistic-optimistic-1",+ status: "queued",+ created_at: SENT_AT,+ message_id: "optimistic-1",+ content: "use the new path",+ }],+ });+ return qc;+ }++ function reconcile(+ qc: QueryClient,+ result: Parameters<typeof reconcileAcceptedChatSend>[1]["result"],+ ) {+ reconcileAcceptedChatSend(qc, {+ chat_session_id: SESSION,+ optimistic_message_id: "optimistic-1",+ optimistic_task_id: "optimistic-optimistic-1",+ content: "use the new path",+ result,+ });+ }++ it("keeps the running retry and files steered guidance under its root request", () => {+ const qc = sendingDuringReply();+ const invalidate = vi.spyOn(qc, "invalidateQueries");++ reconcile(qc, {+ message_id: "message-guidance",+ task_id: "task-retry",+ created_at: ACTIVE_STARTED,+ supports_queue: true,+ queued: false,+ steered: true,+ message_task_id: "task-root",+ message_created_at: SENT_AT,+ });++ // Same head, same start time: the status pill keeps its identity and+ // elapsed timer, and no turn is invented for the guidance.+ expect(qc.getQueryData<ChatPendingTask>(chatKeys.pendingTask(SESSION))).toEqual({+ task_id: "task-retry",+ status: "running",+ created_at: ACTIVE_STARTED,+ supports_queue: true,+ queued_tasks: [],+ });+ // The guidance stays after the request it amends, with its own time.+ expect(qc.getQueryData<ChatMessage[]>(chatKeys.messages(SESSION))).toEqual([+ ...earlier(),+ expect.objectContaining({+ id: "message-guidance",+ task_id: "task-root",+ created_at: SENT_AT,+ }),+ ]);+ expect(invalidate).toHaveBeenCalledWith({+ queryKey: chatKeys.messages(SESSION),+ });+ });++ it("tracks an explicitly queued send as the next turn", () => {+ const qc = sendingDuringReply();++ reconcile(qc, {+ message_id: "message-next",+ task_id: "task-next",+ created_at: SENT_AT,+ supports_queue: true,+ queued: true,+ steered: false,+ message_task_id: "task-next",+ message_created_at: SENT_AT,+ });++ const pending = qc.getQueryData<ChatPendingTask>(chatKeys.pendingTask(SESSION));+ expect(pending).toMatchObject({+ task_id: "task-retry",+ status: "running",+ queued_tasks: [{+ task_id: "task-next",+ message_id: "message-next",+ content: "use the new path",+ }],+ });+ const messages = qc.getQueryData<ChatMessage[]>(chatKeys.messages(SESSION)) ?? [];+ // The shared filter now hides it from the transcript; the queued rows+ // under the live reply show it instead.+ expect(hideQueuedChatMessages(messages, pending).map((m) => m.id)).toEqual([+ "message-request",+ ]);+ });++ it("reads a pre-steering server response as a queued follow-up", () => {+ const qc = sendingDuringReply({+ task_id: "task-active",+ status: "running",+ created_at: ACTIVE_STARTED,+ supports_queue: true,+ });++ reconcile(qc, {+ message_id: "message-next",+ task_id: "task-next",+ created_at: SENT_AT,+ supports_queue: true,+ queued: true,+ });++ expect(qc.getQueryData<ChatMessage[]>(chatKeys.messages(SESSION))?.at(-1)).toMatchObject({+ id: "message-next",+ task_id: "task-next",+ created_at: SENT_AT,+ });+ expect(qc.getQueryData<ChatPendingTask>(chatKeys.pendingTask(SESSION))).toMatchObject({+ task_id: "task-active",+ status: "running",+ queued_tasks: [{ task_id: "task-next", message_id: "message-next" }],+ });+ });++ it("starts a new turn when nothing was running", () => {+ const qc = new QueryClient();+ qc.setQueryData<ChatMessage[]>(chatKeys.messages(SESSION), [{+ id: "optimistic-1",+ chat_session_id: SESSION,+ role: "user",+ content: "use the new path",+ task_id: null,+ created_at: SENT_AT,+ }]);+ qc.setQueryData<ChatPendingTask>(chatKeys.pendingTask(SESSION), {+ task_id: "optimistic-optimistic-1",+ status: "queued",+ created_at: SENT_AT,+ });++ reconcile(qc, {+ message_id: "message-1",+ task_id: "task-1",+ created_at: SENT_AT,+ supports_queue: true,+ queued: false,+ steered: false,+ message_task_id: "task-1",+ message_created_at: SENT_AT,+ });++ expect(qc.getQueryData<ChatPendingTask>(chatKeys.pendingTask(SESSION))).toMatchObject({+ task_id: "task-1",+ status: "queued",+ queued_tasks: [],+ });+ });+});diff --git a/apps/mobile/data/realtime/chat-ws-updaters.ts b/apps/mobile/data/realtime/chat-ws-updaters.tsindex cc1efb60c3..a9c3621888 100644--- a/apps/mobile/data/realtime/chat-ws-updaters.ts+++ b/apps/mobile/data/realtime/chat-ws-updaters.ts@@ -31,6 +31,7 @@ import type {ChatQuickActionsPayload,ChatSession,ChatSessionDeletedPayload,+ SendChatMessageResponse,TaskMessagePayload,TaskQueuedPayload,TaskDispatchPayload,@@ -211,6 +212,19 @@ export function seedPendingTaskFromQueued(// A follow-up can be queued while another task is active. The event does// not carry enough queue state to replace that active head safely.invalidatePendingTask(qc, payload.chat_session_id);+ // Guidance the running reply could not take is re-queued by moving its+ // message to a new turn. Only the refetched row carries that owner, which+ // is what moves it out of the transcript and into the queued rows. A turn+ // whose message already names it (this device's reconciled send) needs no+ // second refetch.+ const messages = qc.getQueryData<ChatMessage[]>(+ chatKeys.messages(payload.chat_session_id),+ );+ if (!messages?.some((message) => message.task_id === payload.task_id)) {+ qc.invalidateQueries({+ queryKey: chatKeys.messages(payload.chat_session_id),+ });+ }}export function promotePendingTaskToRunning(@@ -290,6 +304,62 @@ export function seedAcceptedPendingTask(invalidatePendingTask(qc, payload.chat_session_id);}+/**+ * Reconcile this device's optimistic send with the server's acceptance.+ *+ * The message row takes its own input owner and timestamp: guidance that+ * joins a reply belongs to that reply's root request (which differs from+ * `task_id` when the reply is a retry) and is newer than the task. Servers+ * before steering omit both fields, and for a new turn the task's values are+ * the message's own.+ *+ * Steered guidance creates no turn, so only the local placeholder leaves the+ * pending cache; the active head keeps its identity and elapsed timer. Every+ * other acceptance is a turn the pending state must track.+ */+export function reconcileAcceptedChatSend(+ qc: QueryClient,+ payload: {+ chat_session_id: string;+ optimistic_message_id: string;+ optimistic_task_id: string;+ content: string;+ result: SendChatMessageResponse;+ },+) {+ const { chat_session_id: sessionId, result } = payload;+ qc.setQueryData<ChatMessage[]>(chatKeys.messages(sessionId), (old) =>+ old?.map((message) =>+ message.id === payload.optimistic_message_id+ ? {+ ...message,+ id: result.message_id,+ task_id: result.message_task_id ?? result.task_id,+ created_at: result.message_created_at ?? result.created_at,+ }+ : message,+ ),+ );+ if (result.steered === true) {+ qc.setQueryData<ChatPendingTask>(chatKeys.pendingTask(sessionId), (old) =>+ removePendingChatTask(old, payload.optimistic_task_id),+ );+ invalidatePendingTask(qc, sessionId);+ } else {+ seedAcceptedPendingTask(qc, {+ chat_session_id: sessionId,+ task_id: result.task_id,+ created_at: result.created_at,+ message_id: result.message_id,+ content: payload.content,+ optimistic_task_id: payload.optimistic_task_id,+ supports_queue: result.supports_queue,+ queued: result.queued,+ });+ }+ qc.invalidateQueries({ queryKey: chatKeys.messages(sessionId) });+}+// Task messages (live timeline, keyed by taskId)/**diff --git a/apps/mobile/data/realtime/use-chat-session-realtime.ts b/apps/mobile/data/realtime/use-chat-session-realtime.tsindex 01406636f6..528361655a 100644--- a/apps/mobile/data/realtime/use-chat-session-realtime.ts+++ b/apps/mobile/data/realtime/use-chat-session-realtime.ts@@ -11,7 +11,11 @@* - chat:done → patch messages inline + refresh pendingTask* - chat:quick_actions → patch the async quick-actions supplement* onto the assistant message- * - task:queued / dispatch → seed / promote pendingTask+ * - task:queued → refresh pendingTask, and messages+ * unless the turn's message is already+ * cached (a re-queued steer moves its+ * message to a new turn)+ * - task:dispatch → promote pendingTask* - task:cancelled → refresh pendingTask + messages* - chat:cancel_finalized → refresh the durable cancellation outcome* - task:completed → no-op for messages (chat:done alreadydiff --git a/apps/mobile/data/schemas.ts b/apps/mobile/data/schemas.tsindex f37c3f95b6..e45890c42a 100644--- a/apps/mobile/data/schemas.ts+++ b/apps/mobile/data/schemas.ts@@ -325,11 +325,16 @@ export const ChatPendingTaskSchema: z.ZodType<ChatPendingTask> = z.object({export const EMPTY_CHAT_PENDING_TASK: ChatPendingTask = {};+// Steering fields are additive: servers before #10715 omit them and a+// malformed value degrades to the legacy queued reading, never a failed send.export const SendChatMessageResponseSchema: z.ZodType<SendChatMessageResponse> = z.object({message_id: z.string(),task_id: z.string(),supports_queue: z.boolean().optional(),queued: z.boolean().optional().catch(undefined),+ steered: z.boolean().optional().catch(undefined),+ message_task_id: z.string().min(1).optional().catch(undefined),+ message_created_at: z.string().min(1).optional().catch(undefined),created_at: z.string().default(""),}).loose();diff --git a/apps/mobile/lib/chat-queued-messages.test.ts b/apps/mobile/lib/chat-queued-messages.test.tsnew file mode 100644index 0000000000..96a964e0d8--- /dev/null+++ b/apps/mobile/lib/chat-queued-messages.test.ts@@ -0,0 +1,143 @@+// @vitest-environment node+import { describe, expect, it } from "vitest";+import type {+ Attachment,+ ChatMessage,+ ChatPendingTask,+} from "@multica/core/types";+import { queuedChatMessages } from "./chat-queued-messages";++function userMessage(+ id: string,+ taskId: string | null,+ over: Partial<ChatMessage> = {},+): ChatMessage {+ return {+ id,+ chat_session_id: "session-1",+ role: "user",+ content: id,+ task_id: taskId,+ created_at: "2026-11-16T00:00:00Z",+ ...over,+ };+}++const screenshot = {+ id: "attachment-1",+ filename: "screenshot.png",+ content_type: "image/png",+} as Attachment;++const pending: ChatPendingTask = {+ task_id: "task-active",+ status: "running",+ supports_queue: true,+ queued_tasks: [+ {+ task_id: "task-next",+ status: "queued",+ created_at: "2026-11-16T00:00:02Z",+ message_id: "message-next",+ content: "then update the docs",+ },+ {+ task_id: "task-last",+ status: "queued",+ created_at: "2026-11-16T00:00:03Z",+ message_id: "message-last",+ content: "and open a PR",+ },+ ],+};++describe("queuedChatMessages", () => {+ it("shows the queued messages the transcript hides, in run order", () => {+ const messages = [+ userMessage("message-active", "task-active"),+ userMessage("message-next", "task-next"),+ userMessage("message-last", "task-last"),+ ];++ expect(queuedChatMessages(pending, messages).map((row) => row.content)).toEqual([+ "then update the docs",+ "and open a PR",+ ]);+ });++ it("carries the hidden message's attachments, including attachment-only sends", () => {+ const withFiles: ChatPendingTask = {+ ...pending,+ queued_tasks: [+ { ...pending.queued_tasks![0]! },+ {+ task_id: "task-file",+ status: "queued",+ created_at: "2026-11-16T00:00:04Z",+ message_id: "message-file",+ },+ ],+ };+ const messages = [+ userMessage("message-active", "task-active"),+ userMessage("message-next", "task-next", { attachments: [screenshot] }),+ userMessage("message-file", "task-file", {+ content: "",+ attachments: [screenshot],+ }),+ ];++ expect(queuedChatMessages(withFiles, messages)).toEqual([+ {+ task_id: "task-next",+ content: "then update the docs",+ attachments: [screenshot],+ },+ { task_id: "task-file", content: "", attachments: [screenshot] },+ ]);+ });++ it("skips a send still shown as its optimistic bubble", () => {+ const withPlaceholder: ChatPendingTask = {+ ...pending,+ queued_tasks: [{+ task_id: "optimistic-optimistic-1",+ status: "queued",+ created_at: "2026-11-16T00:00:04Z",+ message_id: "optimistic-1",+ content: "use the new path",+ }],+ };++ expect(queuedChatMessages(withPlaceholder, [+ userMessage("optimistic-1", null),+ ])).toEqual([]);+ });++ it("skips guidance the transcript still shows under its earlier owner", () => {+ // A re-queued steer moves to a new task; until messages refetch, the row+ // still carries the reply it joined and stays in the transcript.+ const requeued: ChatPendingTask = {+ ...pending,+ queued_tasks: [{+ task_id: "task-requeued",+ status: "queued",+ created_at: "2026-11-16T00:00:05Z",+ message_id: "message-guidance",+ content: "use the new path",+ }],+ };++ expect(queuedChatMessages(requeued, [+ userMessage("message-guidance", "task-active"),+ ])).toEqual([]);+ });++ it("returns nothing without anything to show", () => {+ expect(queuedChatMessages(undefined, [])).toEqual([]);+ expect(queuedChatMessages({+ task_id: "task-active",+ queued_tasks: [{ task_id: "task-next", status: "queued", created_at: "" }],+ }, [])).toEqual([]);+ });+});diff --git a/apps/mobile/lib/chat-queued-messages.ts b/apps/mobile/lib/chat-queued-messages.tsnew file mode 100644index 0000000000..060a4353d5--- /dev/null+++ b/apps/mobile/lib/chat-queued-messages.ts@@ -0,0 +1,43 @@+import type {+ Attachment,+ ChatMessage,+ ChatPendingTask,+} from "@multica/core/types";+import { hideQueuedChatMessages } from "@multica/core/chat/pending";++export interface QueuedChatMessage {+ task_id: string;+ content: string;+ attachments: Attachment[];+}++/**+ * Queued follow-ups to show under the live reply, in run order.+ *+ * `hideQueuedChatMessages` takes these messages out of the transcript, and+ * mobile has no separate queue panel, so this is the only place a queued+ * message stays visible. The hidden transcript row supplies attachments,+ * which the queue summary does not carry. A row whose message the+ * transcript still shows (a send whose response has not arrived, or a cache+ * the refetch has not caught up yet) is skipped so the same message never+ * appears twice. Rows with neither text nor attachments have nothing to show.+ */+export function queuedChatMessages(+ pending: ChatPendingTask | null | undefined,+ messages: ChatMessage[],+): QueuedChatMessage[] {+ const queued = pending?.queued_tasks ?? [];+ if (queued.length === 0) return [];+ const shown = new Set(+ hideQueuedChatMessages(messages, pending ?? undefined).map((m) => m.id),+ );+ const byId = new Map(messages.map((message) => [message.id, message]));+ return queued.flatMap((task) => {+ if (task.message_id && shown.has(task.message_id)) return [];+ const message = task.message_id ? byId.get(task.message_id) : undefined;+ const content = task.content ?? message?.content ?? "";+ const attachments = message?.attachments ?? [];+ if (!content.trim() && attachments.length === 0) return [];+ return [{ task_id: task.task_id, content, attachments }];+ });+}diff --git a/apps/mobile/lib/composer-actions.test.ts b/apps/mobile/lib/composer-actions.test.tsnew file mode 100644index 0000000000..041caeaceb--- /dev/null+++ b/apps/mobile/lib/composer-actions.test.ts@@ -0,0 +1,76 @@+// @vitest-environment node+import { describe, expect, it } from "vitest";+import { composerActions, type ComposerActionInput } from "./composer-actions";++const chatDuringReply: ComposerActionInput = {+ isSending: true,+ allowSubmitWhileSending: true,+ hasStop: true,+ hasQueueAction: true,+ hasContent: true,+ hasInFlightUpload: false,+ submitting: false,+ disabled: false,+};++describe("composerActions", () => {+ it("offers Send and Queue for content typed during a reply", () => {+ expect(composerActions(chatDuringReply)).toEqual({+ canSend: true,+ showStop: false,+ showQueue: true,+ });+ });++ it("keeps Stop for an empty composer during a reply", () => {+ expect(composerActions({ ...chatDuringReply, hasContent: false })).toEqual({+ canSend: false,+ showStop: true,+ showQueue: false,+ });+ });++ it("keeps Stop reachable while an attachment uploads", () => {+ expect(composerActions({ ...chatDuringReply, hasInFlightUpload: true })).toEqual({+ canSend: false,+ showStop: true,+ showQueue: false,+ });+ });++ it("holds a disabled Send, not Stop, while the send is in flight", () => {+ expect(composerActions({+ ...chatDuringReply,+ hasContent: false,+ submitting: true,+ })).toEqual({ canSend: false, showStop: false, showQueue: false });+ });++ it("stays stop-only during a reply when the server cannot take sends", () => {+ expect(composerActions({+ ...chatDuringReply,+ allowSubmitWhileSending: false,+ })).toEqual({ canSend: false, showStop: true, showQueue: false });+ });++ it("offers Send without a Stop control while the head has not started", () => {+ // Chat withholds Stop for a queued head; content can still be sent.+ expect(composerActions({ ...chatDuringReply, hasStop: false })).toEqual({+ canSend: true,+ showStop: false,+ showQueue: true,+ });+ });++ it("sends normally when idle, without a queue action", () => {+ expect(composerActions({ ...chatDuringReply, isSending: false })).toEqual({+ canSend: true,+ showStop: false,+ showQueue: false,+ });+ });++ it("blocks every send while disabled", () => {+ expect(composerActions({ ...chatDuringReply, disabled: true }).canSend).toBe(false);+ });+});diff --git a/apps/mobile/lib/composer-actions.ts b/apps/mobile/lib/composer-actions.tsnew file mode 100644index 0000000000..3b7b539111--- /dev/null+++ b/apps/mobile/lib/composer-actions.ts@@ -0,0 +1,50 @@+export interface ComposerActionInput {+ /** A run is active for this conversation. */+ isSending: boolean;+ /** The owner accepts sends during a run (chat on a queue-capable server). */+ allowSubmitWhileSending: boolean;+ /** The owner provided a Stop control. */+ hasStop: boolean;+ /** The owner provided a queue-for-later action. */+ hasQueueAction: boolean;+ hasContent: boolean;+ hasInFlightUpload: boolean;+ submitting: boolean;+ disabled: boolean;+}++export interface ComposerActions {+ canSend: boolean;+ showStop: boolean;+ showQueue: boolean;+}++/**+ * Which trailing actions the composer offers. One slot holds Send or Stop:+ * during a run that accepts sends, content claims the slot for Send and an+ * empty composer (or an upload) keeps Stop reachable, matching web chat.+ * While a send is in flight the slot stays on a disabled Send: the composer+ * clears optimistically, and swapping straight to Stop would put a+ * run-ending button under the finger that just tapped Send.+ */+export function composerActions(input: ComposerActionInput): ComposerActions {+ const submitWhileSending = input.isSending && input.allowSubmitWhileSending;+ const canSend =+ !input.disabled &&+ (!input.isSending || input.allowSubmitWhileSending) &&+ !input.submitting &&+ !input.hasInFlightUpload &&+ input.hasContent;+ const showStop =+ input.isSending &&+ input.hasStop &&+ (!submitWhileSending ||+ input.hasInFlightUpload ||+ (!input.hasContent && !input.submitting));+ const showQueue =+ submitWhileSending &&+ input.hasQueueAction &&+ input.hasContent &&+ !input.hasInFlightUpload;+ return { canSend, showStop, showQueue };+}diff --git a/apps/mobile/locales/en/chat.json b/apps/mobile/locales/en/chat.jsonindex 1ae626abe8..bc92155d44 100644--- a/apps/mobile/locales/en/chat.json+++ b/apps/mobile/locales/en/chat.json@@ -14,6 +14,7 @@"upload_image": "Upload image","upload_file": "Upload file","send": "Send",+ "queue": "Queue message","default_placeholder": "Type a message…","unavailable": "Chat unavailable","stop_agent": "Stop agent",diff --git a/apps/mobile/locales/zh-Hans/chat.json b/apps/mobile/locales/zh-Hans/chat.jsonindex 4ce8bb762a..5d570a420a 100644--- a/apps/mobile/locales/zh-Hans/chat.json+++ b/apps/mobile/locales/zh-Hans/chat.json@@ -14,6 +14,7 @@"upload_image": "上传图片","upload_file": "上传文件","send": "发送",+ "queue": "排队发送","default_placeholder": "输入消息...","unavailable": "聊天不可用","stop_agent": "停止智能体",diff --git a/apps/mobile/locales/zh-Hant/chat.json b/apps/mobile/locales/zh-Hant/chat.jsonindex a45dd2eab3..34ee868193 100644--- a/apps/mobile/locales/zh-Hant/chat.json+++ b/apps/mobile/locales/zh-Hant/chat.json@@ -14,6 +14,7 @@"upload_image": "上傳圖片","upload_file": "上傳檔案","send": "傳送",+ "queue": "排隊傳送","default_placeholder": "輸入訊息...","unavailable": "聊天不可用","stop_agent": "停止 AI 代理",