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
Merge upstream/main into legacy-chat-thread-removal
Steven Enamakel0352eb0564e5
diff --cc app/src/components/flows/WorkflowCopilotPanel.tsxindex a55c7948c6,94b368f88d..89d47c3f62--- a/app/src/components/flows/WorkflowCopilotPanel.tsx+++ b/app/src/components/flows/WorkflowCopilotPanel.tsx@@@ -27,18 -27,10 +27,15 @@@* rather than silently discarding it. Reject remains local-only (revert the* overlay, no persistence call).*/+import { Thread, type ThreadComponents } from '@/components/assistant-ui/thread';import createDebug from 'debug';-import { useCallback, useEffect, useRef, useState } from 'react';+import { useCallback, useEffect, useMemo, useRef, useState } from 'react';-import { ChatThreadView } from '../../features/conversations/components/ChatThreadView';+import { AssistantUiInferenceStatus } from '../../features/conversations/components/AssistantUiInferenceStatus';+import { ChatSources } from '../../features/conversations/components/aui/ChatSources';+import { SubagentDrawerHost } from '../../features/conversations/components/aui/subagentDrawerHost';+import { TranscriptOverlays } from '../../features/conversations/components/aui/TranscriptOverlays';- import {- ChatToolFallback,- ChatToolGroup,- } from '../../features/conversations/components/ChatToolParts';++import { ChatToolFallback } from '../../features/conversations/components/ChatToolParts';import { useChatSurfaceRegistration } from '../../features/conversations/hooks/useChatSurfaceRegistration';import { useWorkflowBuilderChat } from '../../hooks/useWorkflowBuilderChat';import { diffGraphs } from '../../lib/flows/graphDiff';@@@ -501,196 -485,6 +498,195 @@@ export default function WorkflowCopilotconst diff = proposal ? diffGraphs(graph, proposal.graph as WorkflowGraph) : null;+ // The sub-agent drawer for delegation cards in the transcript. Resolved from+ // this thread's live timeline, exactly as the home chat resolves it.+ const toolTimeline = useAppSelector(state =>+ threadId+ ? (state.chatRuntime.toolTimelineByThread?.[threadId] ?? EMPTY_TIMELINE)+ : EMPTY_TIMELINE+ );+ const processing = useAppSelector(state =>+ threadId+ ? (state.chatRuntime.processingByThread?.[threadId] ?? EMPTY_TRANSCRIPT)+ : EMPTY_TRANSCRIPT+ );+ const [openSubagentTaskId, setOpenSubagentTaskId] = useState<string | null>(null);+ const canOpenSubagent = useCallback(+ (taskId: string) => toolTimeline.some(entry => entry.subagent?.taskId === taskId),+ [toolTimeline]+ );++ // The copilot's authoring footer: error line, proposal preview, capped card+ // and the builder composer. Parked approvals are NOT repeated here — the+ // assistant-ui transcript renders them inline on the gated tool call (see+ // `ChatToolParts`), the same place the home chat answers them.+ const footer = (+ <div className="space-y-3 border-t border-line pt-2.5">+ {error && (+ <p+ className="text-xs text-coral-600 dark:text-coral-400"+ data-testid="workflow-copilot-error">+ {error === 'offline' ? t('flows.copilot.offline') : t('flows.copilot.error')}+ </p>+ )}++ {proposal && diff && (+ <div+ data-testid="workflow-copilot-proposal"+ className="rounded-xl border border-primary-300 bg-surface p-3 dark:border-primary-700">+ <p className="text-xs font-semibold text-primary-900 dark:text-primary-100">+ {proposal.name || t('flows.copilot.proposalTitle')}+ </p>+ <p className="mt-1 text-[11px] text-content-muted">{t('flows.copilot.previewHint')}</p>++ <div className="mt-2 flex flex-wrap gap-1.5 text-[11px]">+ {diff.addedNodeIds.size > 0 && (+ <span+ data-testid="workflow-copilot-added"+ className="rounded-full bg-sage-100 px-2 py-0.5 font-medium text-sage-700 dark:bg-sage-500/15 dark:text-sage-300">+ {t('flows.copilot.added').replace('{count}', String(diff.addedNodeIds.size))}+ </span>+ )}+ {diff.removedNodeIds.size > 0 && (+ <span+ data-testid="workflow-copilot-removed"+ className="rounded-full bg-coral-100 px-2 py-0.5 font-medium text-coral-700 dark:bg-coral-500/15 dark:text-coral-300">+ {t('flows.copilot.removed').replace('{count}', String(diff.removedNodeIds.size))}+ </span>+ )}+ {!diff.hasChanges && (+ <span className="text-content-faint">{t('flows.copilot.noChanges')}</span>+ )}+ </div>++ <div className="mt-3 flex flex-wrap items-center gap-2">+ <Button+ type="button"+ variant="primary"+ size="sm"+ analyticsId="workflow-copilot-accept"+ disabled={acceptBusy}+ data-testid="workflow-copilot-accept"+ onClick={() => void accept()}>+ {acceptState === 'saving'+ ? t('flows.copilot.saving')+ : t('flows.copilot.acceptAndSave')}+ </Button>+ <Button+ type="button"+ variant="primary"+ size="sm"+ analyticsId="workflow-copilot-accept-and-enable"+ disabled={acceptBusy}+ data-testid="workflow-copilot-accept-and-enable"+ onClick={() => void acceptAndEnable()}>+ {acceptState === 'enabling'+ ? t('flows.copilot.enabling')+ : t('flows.copilot.saveAndEnable')}+ </Button>+ <Button+ type="button"+ variant="secondary"+ size="sm"+ disabled={acceptBusy}+ data-testid="workflow-copilot-reject"+ onClick={reject}>+ {t('flows.copilot.reject')}+ </Button>+ </div>+ {acceptState === 'idle' && enableError && (+ <p+ className="mt-2 text-xs text-coral-600 dark:text-coral-400"+ data-testid="workflow-copilot-enable-error">+ {t('flows.copilot.enableError')}+ </p>+ )}+ </div>+ )}++ {/* (B34) The turn hit the agent's iteration limit with no proposal+ yet — distinguish this from a voluntary clarifying question (which+ renders as a plain agent bubble in the transcript, no card) with an+ explicit "reached its iteration limit" signal and a one-click resume+ that continues building from the current draft (see `continueBuilding`+ above for why this is accurate rather than a seamless resume).+ Never shown alongside `sending` (a fresh turn already cleared+ `capped`) or a proposal (mutually exclusive server-side — see+ `ops.rs`). */}+ {capped && !sending && !proposal && (+ <div+ data-testid="workflow-copilot-capped"+ className="rounded-xl border border-amber-300 bg-surface p-3 dark:border-amber-700">+ <p className="text-xs text-content-secondary">{t('flows.copilot.cappedNotice')}</p>+ <div className="mt-2">+ <Button+ type="button"+ variant="secondary"+ size="sm"+ data-testid="workflow-copilot-continue"+ onClick={continueBuilding}>+ {t('flows.copilot.continueBuilding')}+ </Button>+ </div>+ </div>+ )}++ <ChatComposer+ inputValue={text}+ setInputValue={setText}+ onSend={submit}+ textInputRef={textInputRef}+ fileInputRef={fileInputRef}+ composerInteractionBlocked={sending}+ isSending={sending}+ onStopGeneration={stop}+ attachments={[]}+ onAttachFiles={noopAttach}+ onRemoveAttachment={noop}+ attachError={null}+ onSwitchToMicCloud={noop}+ handleInputKeyDown={handleInputKeyDown}+ inlineCompletionSuffix=""+ isComposingTextRef={isComposingTextRef}+ maxAttachments={0}+ allowedMimeTypes={[]}+ attachmentsEnabled={false}+ micEnabled={false}+ placeholder={t('flows.copilot.placeholder')}+ />+ </div>+ );++ // Rendered by type from inside `Thread`, so the slot must keep one identity+ // across renders (a new type would remount the composer and drop focus and+ // the draft). It reads the latest footer through a ref instead; `thread.tsx`+ // memoizes nothing, so the slot re-renders with this panel.+ const footerRef = useRef(footer);+ footerRef.current = footer;+ const CopilotComposer = useCallback(() => <>{footerRef.current}</>, []);+ const emptyHintRef = useRef(t('flows.copilot.emptyState'));+ emptyHintRef.current = t('flows.copilot.emptyState');+ const CopilotWelcome = useCallback(+ () => (+ <div className="flex flex-1 items-center justify-center px-3 py-6">+ <p className="text-xs text-content-muted" data-testid="workflow-copilot-empty">+ {emptyHintRef.current}+ </p>+ </div>+ ),+ []+ );+ const components = useMemo<ThreadComponents>(+ () => ({+ ToolFallback: ChatToolFallback,- ToolGroup: ChatToolGroup,+ RunningStatus: AssistantUiInferenceStatus,+ SourceGroup: ChatSources,+ Welcome: CopilotWelcome,+ Composer: CopilotComposer,+ }),+ [CopilotComposer, CopilotWelcome]+ );+return (<asidedata-testid="workflow-copilot-panel"diff --cc app/src/features/conversations/Conversations.processSourceCommand.test.tsxindex e3af84edd1,240262f809..129a06f66a--- a/app/src/features/conversations/Conversations.processSourceCommand.test.tsx+++ b/app/src/features/conversations/Conversations.processSourceCommand.test.tsx@@@ -174,23 -179,19 +174,23 @@@ describe('the agent-process-source commconst action = registry.getAction(ACTION_ID);expect(action, 'the command must be registered on the text composer').toBeDefined();- expect(action?.enabled?.()).toBe(true);+ expect(action?.enabled?.()).toBe(false);// The palette runs it through `runAction`, which re-checks `enabled`.- expect(registry.runAction(ACTION_ID)).toBe(true);+ expect(registry.runAction(ACTION_ID)).toBe(false);});- it('is disabled in mic-cloud voice mode, where nothing renders the panel', async () => {+ it('is enabled in mic-cloud voice mode too, which renders the same assistant-ui panel', async () => {await renderChat('mic-cloud');+ // Voice mode swaps only the composer: the transcript is the assistant-ui+ // viewport and the text composer is replaced by the voice composer.+ expect(document.querySelector('[data-slot="aui_thread-viewport"]')).not.toBeNull();+ expect(document.querySelector('[data-testid="voice-composer"]')).not.toBeNull();+ expect(document.querySelector('[data-slot="aui_composer-shell"]')).toBeNull();+const action = registry.getAction(ACTION_ID);- // Registered but refused - `Conversations` is mounted either way, so the- // action does not disappear; it must report itself unavailable.- expect(action, 'the command is still registered in voice mode').toBeDefined();- expect(action?.enabled?.()).toBe(false);- expect(registry.runAction(ACTION_ID)).toBe(false);+ expect(action, 'the command is registered in voice mode').toBeDefined();+ expect(action?.enabled?.()).toBe(true);+ expect(registry.runAction(ACTION_ID)).toBe(true);});});diff --cc app/src/features/conversations/Conversations.tsxindex 1950e63a1d,3623913560..42c8fd227e--- a/app/src/features/conversations/Conversations.tsx+++ b/app/src/features/conversations/Conversations.tsx@@@ -279,9 -315,32 +279,21 @@@ const Conversations = (labelKey: 'conversations.agentTaskInsights.viewProcessSource',group: 'Chat',handler: () => setShowProcessSource(true),- enabled: () => selectedThreadId !== null,+ enabled: () => {- if (selectedThreadId === null || composer === 'mic-cloud') return false;++ if (selectedThreadId === null) return false;+ return (+ (toolTimelineByThread[selectedThreadId]?.length ?? 0) > 0 ||+ (processingByThread[selectedThreadId]?.length ?? 0) > 0 ||- Object.values(turnTimelinesByThread[selectedThreadId] ?? {}).some(entries => entries.length > 0) ||++ Object.values(turnTimelinesByThread[selectedThreadId] ?? {}).some(++ entries => entries.length > 0++ ) ||+ Object.values(turnTranscriptsByThread[selectedThreadId] ?? {}).some(+ transcript => transcript.length > 0+ )+ );+ },keywords: ['agent', 'process', 'source', 'timeline', 'run'],});- const [inputMode, setInputMode] = useState<InputMode>('text');- const [replyMode, setReplyMode] = useState<ReplyMode>('text');- const [isRecording, setIsRecording] = useState(false);- const [isTranscribing, setIsTranscribing] = useState(false);- const [voiceStatus, setVoiceStatus] = useState<string | null>(null);- const [isPlayingReply, setIsPlayingReply] = useState(false);- // Measured height of the floating composer footer (page variant only). The- // footer is `absolute`ly positioned over the scroll area, so the message list- // needs matching bottom padding to keep its tail visible. Defaults to 128px- // (the old static `pb-32`) so layout is unchanged until the ResizeObserver- // reports a real height — and grows automatically when the queued-followups- // panel, approval cards, or error banners expand the footer (#4268).- const [composerFooterHeight, setComposerFooterHeight] = useState(128);// Thread-list filtering is fixed to the General bucket — the in-sidebar// General/Subconscious/Tasks chips were removed. Subconscious reflections and// task/worker threads have dedicated surfaces (Intelligence, Tasks board).@@@ -348,7 -407,12 +360,11 @@@// behaviour stays intact.const uiLocale = useAppSelector(state => state.locale?.current ?? 'en');const toolTimelineByThread = useAppSelector(state => state.chatRuntime.toolTimelineByThread);+ const turnTimelinesByThread = useAppSelector(state => state.chatRuntime.turnTimelinesByThread);- const interruptedAssistantByThread = useAppSelector(- state => state.chatRuntime.interruptedAssistantByThread- );const processingByThread = useAppSelector(state => state.chatRuntime.processingByThread);- const turnTranscriptsByThread = useAppSelector(state => state.chatRuntime.turnTranscriptsByThread);++ const turnTranscriptsByThread = useAppSelector(++ state => state.chatRuntime.turnTranscriptsByThread++ );const inferenceStatusByThread = useAppSelector(state => state.chatRuntime.inferenceStatusByThread);@@@ -1430,9 -1869,26 +1446,25 @@@const selectedThreadProcessing = selectedThreadId? (processingByThread[selectedThreadId] ?? EMPTY_PROCESSING): EMPTY_PROCESSING;+ // The command-palette panel describes the whole selected conversation, not+ // only a currently streaming turn. Settled trails are stored per-turn, so+ // combine them with live data here instead of opening an empty panel after a+ // thread is reloaded.+ const selectedThreadProcessSourceEntries = selectedThreadId+ ? [+ ...Object.values(turnTimelinesByThread[selectedThreadId] ?? {}).flat(),+ ...selectedThreadToolTimeline,+ ]+ : EMPTY_TOOL_TIMELINE;+ const selectedThreadProcessSourceTranscript = selectedThreadId+ ? [+ ...Object.values(turnTranscriptsByThread[selectedThreadId] ?? {}).flat(),+ ...selectedThreadProcessing,+ ]+ : EMPTY_PROCESSING;// Detached background sub-agents (mode === 'async') spawned in this thread.- // Kept here (in addition to ChatThreadView's own copy) because the header's- // background-processes badge needs the count/status without reaching into- // the transcript component.+ // The composer's background-processes badge needs the count/status, and+ // `TranscriptOverlays` lists them.const backgroundProcesses = useMemo(() => selectBackgroundProcesses(selectedThreadToolTimeline),[selectedThreadToolTimeline]@@@ -1973,14 -2778,16 +2005,14 @@@canOpenSubagent={canOpenSubagentDrawer}onModelChange={applyComposerModel}/>- {/* The three transcript-local modals. `ChatThreadView` hosts an identical- trio, but it is the legacy panel's transcript and is not mounted here,- so on `/chat` the background-processes button had nothing to open and- the sub-agent drawer / process-source panel could not be reached at- all. Mounted beside the Thread (not inside it) because each is its own- overlay, positioned against the viewport. */}+ {/* The three transcript-local modals: background processes, the+ sub-agent drawer and the Agent Process Source panel. Mounted beside+ the Thread (not inside it) because each is its own overlay,+ positioned against the viewport. */}<TranscriptOverlaysthreadId={selectedThreadId ?? null}- entries={selectedThreadToolTimeline}- transcript={selectedThreadProcessing}+ entries={selectedThreadProcessSourceEntries}+ transcript={selectedThreadProcessSourceTranscript}backgroundProcesses={backgroundProcesses}showBackgroundProcesses={showBackgroundProcesses}onCloseBackgroundProcesses={() => setShowBackgroundProcesses(false)}diff --cc app/src/providers/ChatRuntimeProvider.tsxindex 816b032c03,dbde30ee9b..7f9f2d9208--- a/app/src/providers/ChatRuntimeProvider.tsx+++ b/app/src/providers/ChatRuntimeProvider.tsx@@@ -642,7 -643,7 +642,9 @@@ const ChatRuntimeProvider = ({ childre// Snapshot polling can outlive this completed turn. Capture the rows it// owns before awaiting it so a newer turn on the same thread is never// cancelled by this recovery path.-- const unresolvedRowIds = (store.getState().chatRuntime.toolTimelineByThread[event.thread_id] ?? [])++ const unresolvedRowIds = (++ store.getState().chatRuntime.toolTimelineByThread[event.thread_id] ?? []++ ).filter(entry => entry.status === 'running' && entry.subagent?.mode !== 'async').map(entry => entry.id);// Socket reducers keep only the current iteration's prose in the live@@@ -655,7 -656,7 +657,9 @@@fetchAndHydrateCompletedTurnState(event.thread_id)).unwrap();if (!completedSnapshot) {-- dispatch(cancelUnresolvedTurnTimeline({ threadId: event.thread_id, rowIds: unresolvedRowIds }));++ dispatch(++ cancelUnresolvedTurnTimeline({ threadId: event.thread_id, rowIds: unresolvedRowIds })++ );}};