The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.
Rust agent-orchestrationai-agentsai-assistantdesktopllmlocal-firstmcppersonal-aiprivacyrustsecond-braintauri
feat(chat): add queued message support for offline threads
Steven Enamakeld00e739dbcc1
diff --git a/app/src/providers/ChatRuntimeProvider.tsx b/app/src/providers/ChatRuntimeProvider.tsxindex 1f84fa52f1..26c67b9826 100644--- a/app/src/providers/ChatRuntimeProvider.tsx+++ b/app/src/providers/ChatRuntimeProvider.tsx@@ -643,12 +643,18 @@ const ChatRuntimeProvider = ({ children }: { children: React.ReactNode }) => {const queued = store.getState().queue.pendingFollowupsByThread[threadId] ?? [];// Persist sequentially so the queued prompts land in the append-log in the// order the user queued them (concurrent dispatches would race), and- // surface failures instead of dropping them silently. The stored message- // carries the original upload markers in memory. The append boundary- // saves originals and returns durable references before writing history.+ // surface failures instead of dropping them silently. The typed+ // attachments are held in memory beside the text; the append boundary+ // saves the originals and returns durable references before writing history.for (const item of queued) {try {- await dispatch(addMessageLocal({ threadId, message: item.message })).unwrap();+ await dispatch(+ addMessageLocal({+ threadId,+ message: item.message,+ attachments: item.attachments,+ })+ ).unwrap();} catch (error) {rtLog('flush_followup_append_failed', {thread: threadId,diff --git a/app/src/services/api/threadApi.ts b/app/src/services/api/threadApi.tsindex 6a139b01b4..ce06fe89d4 100644--- a/app/src/services/api/threadApi.ts+++ b/app/src/services/api/threadApi.ts@@ -1,5 +1,6 @@import debug from 'debug';+import type { ContentPart } from '../chatWire';import type {DerivedTranscriptGetOptions,DerivedTranscriptPage,diff --git a/app/src/services/chatService.ts b/app/src/services/chatService.tsindex 86930801bf..46cdbc7ce1 100644--- a/app/src/services/chatService.ts+++ b/app/src/services/chatService.ts@@ -42,6 +42,7 @@ import type {ChatToolArgsDeltaEvent,ChatToolCallEvent,ChatToolResultEvent,+ ContentPart,ExternalTransferPendingEvent,ProactiveMessageEvent,QueueItemEvent,@@ -881,6 +882,12 @@ type QueueMode = 'interrupt' | 'steer' | 'followup' | 'collect' | 'parallel';interface ChatSendParams {threadId: string;message: string;+ /**+ * Typed attachments (`image`/`video`/`file` parts with an inline `data:` URI)+ * sent beside `message`; the core stages them. Never splice upload markers+ * into `message`.+ */+ attachments?: ContentPart[];model?: string;/*** BCP-47 UI locale (e.g. `'ar'`, `'zh-CN'`) — drives the core's@@ -943,6 +950,7 @@ export async function chatSend(params: ChatSendParams): Promise<string | undefinclient_id: clientId,thread_id: params.threadId,message: params.message,+ attachments: params.attachments?.length ? params.attachments : undefined,model_override: params.model ?? undefined,locale: params.locale ?? undefined,speak_reply: params.speakReply ?? undefined,@@ -1155,6 +1163,8 @@ export async function editMessage(params: {threadId: string;messageId: string;content: string;+ /** Typed attachments sent with the replacement content. */+ attachments?: ContentPart[];}): Promise<void> {const socket = socketService.getSocket();const clientId = socket?.id;@@ -1164,6 +1174,7 @@ export async function editMessage(params: {thread_id: params.threadId,message_id: params.messageId,content: params.content,+ attachments: params.attachments?.length ? params.attachments : undefined,client_id: clientId ?? undefined,},});diff --git a/app/src/store/queueSlice.ts b/app/src/store/queueSlice.tsindex d69bd76ec0..031c1b0e6d 100644--- a/app/src/store/queueSlice.ts+++ b/app/src/store/queueSlice.ts@@ -22,6 +22,7 @@ import { createSlice, type PayloadAction } from '@reduxjs/toolkit';import { parseAttachmentReferences } from '../lib/attachments';import type { QueueItemPayload } from '../services/chatService';+import type { ContentPart } from '../services/chatWire';import type { ThreadMessage } from '../types/thread';import { clearAllChatRuntime, clearRuntimeForThread, endInferenceTurn } from './chatRuntimeSlice';import { resetUserScopedState } from './resetActions';@@ -38,8 +39,10 @@ export interface RunQueueItem {/** A follow-up this client queued, held until it can be persisted. */export interface PendingFollowup {- /** The user message exactly as an interactive send would store it. */+ /** The user message exactly as an interactive send would store it (text only). */message: ThreadMessage;+ /** Its typed attachments; the core stages them when the follow-up is persisted. */+ attachments: ContentPart[];/** `clipQueuePreview` of the text sent to the core; matches the item's preview. */preview: string;}@@ -54,8 +57,10 @@ const initialState: QueueState = { itemsByThread: {}, pendingFollowupsByThread:/** Mirrors core queue previews: caption or filenames, clipped at 80 code points. */const QUEUE_PREVIEW_CHARS = 80;-export function clipQueuePreview(text: string): string {- const names: string[] = [];+export function clipQueuePreview(text: string, attachments: ContentPart[] = []): string {+ const names: string[] = attachments.map(part =>+ 'media' in part ? (part.media.fileName ?? 'attachment') : 'attachment'+ );const caption = text.replace(/\[(IMAGE|FILE|ATTACHMENT):([^\]]+)\]/g, (marker, kind: string, source: string) => {if (kind === 'ATTACHMENT') {@@ -129,11 +134,16 @@ const queueSlice = createSlice({/** Record a follow-up the core accepted; `text` is what was sent to it. */pendingFollowupAdded: (state,- action: PayloadAction<{ threadId: string; message: ThreadMessage; text: string }>+ action: PayloadAction<{+ threadId: string;+ message: ThreadMessage;+ text: string;+ attachments?: ContentPart[];+ }>) => {- const { threadId, message, text } = action.payload;+ const { threadId, message, text, attachments = [] } = action.payload;const bucket = state.pendingFollowupsByThread[threadId] ?? [];- bucket.push({ message, preview: clipQueuePreview(text) });+ bucket.push({ message, attachments, preview: clipQueuePreview(text, attachments) });state.pendingFollowupsByThread[threadId] = bucket;},},diff --git a/app/src/store/threadSlice.ts b/app/src/store/threadSlice.tsindex 678948b5e1..6d7c72ec8a 100644--- a/app/src/store/threadSlice.ts+++ b/app/src/store/threadSlice.ts@@ -2,6 +2,7 @@ import { createAsyncThunk, createSlice, type PayloadAction } from '@reduxjs/toolimport { extractWorkflowProposalFromMessages } from '../lib/workflows/workflowProposal';import { threadApi } from '../services/api/threadApi';+import type { ContentPart } from '../services/chatWire';import { isThreadNotFoundCoreRpcError } from '../services/coreRpcClient';import type { Thread, ThreadMessage } from '../types/thread';import { IS_DEV } from '../utils/config';