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
fix(chat): render the plan-review and workflow-proposal gates on /chat
M3gA-Mind44fb8889406d
diff --git a/app/src/features/conversations/Conversations.tsx b/app/src/features/conversations/Conversations.tsxindex 5596868489..3c1cc21999 100644--- a/app/src/features/conversations/Conversations.tsx+++ b/app/src/features/conversations/Conversations.tsx@@ -1945,6 +1945,51 @@ const Conversations = ({/>);+ // The two turn-gate cards that must render on BOTH main panels.+ //+ // They used to live inline in `legacyMainPanel`, which `/chat` never mounts:+ // `mainPanel` below is an either/or — assistant-ui for text, legacy for+ // mic-cloud voice — so a parked plan review and a drafted workflow were+ // invisible on the surface every user actually sees. The plan gate hung the+ // turn with nothing to decide, and `propose_workflow`'s only route to+ // `flows_create` was unreachable. Hoisted to a shared fragment so the+ // assistant-ui composer header can render the same cards without voice mode+ // losing them; the two panels are mutually exclusive, so nothing doubles up.+ const agentGateCards = (+ <>+ {/* Plan-mode review: the orchestrator parked the live turn on a+ thread-scoped plan (request_plan_review gate). Surface it for the+ user to Approve / Reject / send feedback on before anything executes;+ the card resolves the parked turn via plan_review_decide. */}+ {selectedThreadId && pendingPlanReview && (+ // Key by request id so a re-parked (revised) plan — or a thread switch —+ // remounts the card and resets its local decision/feedback state,+ // matching the ApprovalRequestCard pattern above.+ <PlanReviewCard+ key={pendingPlanReview.requestId}+ threadId={selectedThreadId}+ review={pendingPlanReview}+ />+ )}++ {/* Agent-first Workflow authoring (issue B4): the agent drafted a+ candidate automation via `propose_workflow`. The tool only+ validates — it never creates the flow — so this card is the ONLY+ path from proposal to saved automation via "Save & enable"+ (`flows_create`), or the user can Dismiss it outright. */}+ {selectedThreadId && pendingWorkflowProposal && (+ // Keyed by name so a second proposal in the same thread (before the+ // first is resolved) remounts the card and resets its local+ // saving/error state, matching the PlanReviewCard pattern above.+ <WorkflowProposalCard+ key={pendingWorkflowProposal.name}+ threadId={selectedThreadId}+ proposal={pendingWorkflowProposal}+ />+ )}+ </>+ );+// Main chat area (right pane): header, message list, composer.const legacyMainPanel = (<div@@ -2178,41 +2223,12 @@ const Conversations = ({);})()}+ {agentGateCards}+{/* Thread-scoped todo list the agent maintains as it works — read-only,pinned above the composer. Distinct from the Intelligence-tab kanban(global `user-tasks`). Renders nothing when the thread has no activecards. */}- {/* Plan-mode review: the orchestrator parked the live turn on a- thread-scoped plan (request_plan_review gate). Surface it for the- user to Approve / Reject / send feedback on before anything executes;- the card resolves the parked turn via plan_review_decide. */}- {selectedThreadId && pendingPlanReview && (- // Key by request id so a re-parked (revised) plan — or a thread switch —- // remounts the card and resets its local decision/feedback state,- // matching the ApprovalRequestCard pattern above.- <PlanReviewCard- key={pendingPlanReview.requestId}- threadId={selectedThreadId}- review={pendingPlanReview}- />- )}-- {/* Agent-first Workflow authoring (issue B4): the agent drafted a- candidate automation via `propose_workflow`. The tool only- validates — it never creates the flow — so this card is the ONLY- path from proposal to saved automation via "Save & enable"- (`flows_create`), or the user can Dismiss it outright. */}- {selectedThreadId && pendingWorkflowProposal && (- // Keyed by name so a second proposal in the same thread (before the- // first is resolved) remounts the card and resets its local- // saving/error state, matching the PlanReviewCard pattern above.- <WorkflowProposalCard- key={pendingWorkflowProposal.name}- threadId={selectedThreadId}- proposal={pendingWorkflowProposal}- />- )}-{selectedThreadId && (<ThreadTodoStripboard={selectedTaskBoard}@@ -2476,6 +2492,13 @@ const Conversations = ({const assistantComposerHeader = (<>+ {/* Turn gates first: a parked plan review and a drafted workflow both+ block progress until the user decides, so they sit above the transient+ attach error and the queued-followup strip. `ComposerHeader` is the+ only host slot assistant-ui threads arbitrary React through+ (`thread.tsx:385`), and it renders directly above the input — the same+ place `legacyMainPanel` put these cards. */}+ {agentGateCards}{attachError && (<div className="rounded-lg border border-coral-200 bg-coral-50 px-3 py-2"><p className="text-xs text-coral-500" data-chat-send-error-code={attachError.code}>diff --git a/app/src/features/conversations/components/AssistantUiChat.tsx b/app/src/features/conversations/components/AssistantUiChat.tsxindex 0af6b52e56..02e3d0da3f 100644--- a/app/src/features/conversations/components/AssistantUiChat.tsx+++ b/app/src/features/conversations/components/AssistantUiChat.tsx@@ -146,7 +146,20 @@ export function AssistantUiChat({),[contextUsage, threadGoal]);- const ComposerHeader = useCallback(() => <>{composerHeader}</>, [composerHeader]);+ // Stable component identity, latest node read through a ref.+ //+ // `<ComposerHeader />` is rendered by type (`thread.tsx:385`), so a callback+ // that closes over `composerHeader` gives React a NEW type on every host+ // render — the whole header subtree unmounts and remounts. That was invisible+ // while the header only held an error string and the queued-followup strip,+ // but the turn-gate cards it now carries (`PlanReviewCard`,+ // `WorkflowProposalCard`) own local state: half-typed plan feedback and an+ // in-flight "Save & enable" would be wiped by any unrelated re-render, e.g.+ // a keystroke in the composer. Nothing in `thread.tsx` is memoized, so this+ // subtree re-renders with its host and the ref is always current.+ const composerHeaderRef = useRef(composerHeader);+ composerHeaderRef.current = composerHeader;+ const ComposerHeader = useCallback(() => <>{composerHeaderRef.current}</>, []);const ComposerAttachments = useCallback(() => (<AttachmentPreviewdiff --git a/app/src/pages/__tests__/Conversations.render.test.tsx b/app/src/pages/__tests__/Conversations.render.test.tsxindex 746324259d..be004e0787 100644--- a/app/src/pages/__tests__/Conversations.render.test.tsx+++ b/app/src/pages/__tests__/Conversations.render.test.tsx@@ -23,8 +23,10 @@ import chatRuntimeReducer, {bumpInferenceHeartbeatForThread,markInferenceTurnStreaming,setInferenceStatusForThread,+ setPendingPlanReviewForThread,setStreamingAssistantForThread,setToolTimelineForThread,+ setWorkflowProposalForThread,} from '../../store/chatRuntimeSlice';import layoutReducer from '../../store/layoutSlice';import socketReducer from '../../store/socketSlice';@@ -2104,3 +2106,120 @@ describe('Conversations — external-transfer disclosure card removed', () => {expect(screen.queryByText('Leaving your device')).toBeNull();});});++/**+ * The two turn gates the agent parks on. Both used to render only inside+ * `legacyMainPanel`, which `/chat` never mounts — the text surface is+ * assistant-ui and the two panels are an either/or — so a parked plan review+ * hung the turn with nothing to decide, and a `propose_workflow` draft lost its+ * only route to `flows_create`. They are now rendered from the shared+ * `agentGateCards` fragment, which the assistant-ui composer header carries.+ */+describe('Conversations — turn gates on the assistant-ui surface', () => {+ beforeEach(() => {+ vi.clearAllMocks();+ window.localStorage.clear();+ mockGetThreads.mockResolvedValue({ threads: [], count: 0 });+ mockGetThreadMessages.mockResolvedValue({ messages: [], count: 0 });+ });++ async function renderGatedConversation() {+ const thread = makeThread({ id: 'gate-thread', title: 'Gate Thread' });+ mockGetThreads.mockResolvedValue({ threads: [thread], count: 1 });+ mockGetThreadMessages.mockResolvedValue({ messages: [], count: 0 });++ let store: ReturnType<typeof buildStore> | undefined;+ await act(async () => {+ store = await renderConversations({+ thread: selectedThreadState(thread),+ socket: socketState('connected'),+ });+ });+ // The default composer is 'text', so this is the assistant-ui panel — the+ // legacy panel is not in the tree at all.+ expect(screen.getByTestId('chat-message-input')).toBeInTheDocument();+ return { thread, store: store! };+ }++ it('surfaces a parked plan review above the assistant-ui composer', async () => {+ const { thread, store } = await renderGatedConversation();++ await act(async () => {+ store.dispatch(+ setPendingPlanReviewForThread({+ threadId: thread.id,+ review: {+ requestId: 'plan-req-1',+ summary: 'Refactor the billing module',+ steps: ['Read the invoices module', 'Extract the tax helper'],+ },+ })+ );+ });++ const card = await screen.findByTestId('plan-review-card');+ expect(card).toBeInTheDocument();+ expect(within(card).getByText('Refactor the billing module')).toBeInTheDocument();+ expect(within(card).getByText('Extract the tax helper')).toBeInTheDocument();+ });++ it('surfaces a drafted workflow proposal above the assistant-ui composer', async () => {+ const { thread, store } = await renderGatedConversation();++ await act(async () => {+ store.dispatch(+ setWorkflowProposalForThread({+ threadId: thread.id,+ proposal: {+ name: 'Morning digest',+ graph: { nodes: [], edges: [] },+ requireApproval: false,+ summary: {+ trigger: 'schedule: 0 9 * * *',+ steps: [{ kind: 'agent', name: 'Summarize inbox' }],+ },+ },+ })+ );+ });++ const card = await screen.findByTestId('workflow-proposal-card');+ expect(card).toBeInTheDocument();+ expect(within(card).getByText('Morning digest')).toBeInTheDocument();+ });++ it('keeps half-typed plan feedback across an unrelated host re-render', async () => {+ const { thread, store } = await renderGatedConversation();++ await act(async () => {+ store.dispatch(+ setPendingPlanReviewForThread({+ threadId: thread.id,+ review: { requestId: 'plan-req-2', summary: 'Ship it', steps: [] },+ })+ );+ });++ const feedback = await screen.findByTestId('plan-review-feedback');+ await act(async () => {+ fireEvent.change(feedback, { target: { value: 'use the staging bucket' } });+ });+ expect(screen.getByTestId('plan-review-feedback')).toHaveValue('use the staging bucket');++ // Any unrelated re-render of Conversations rebuilds the composer-header+ // node. The header is rendered by component type (`thread.tsx`), so a+ // header component that closes over that node changes type every render and+ // React remounts the whole subtree — silently wiping this textarea.+ await act(async () => {+ store.dispatch(bumpInferenceHeartbeatForThread({ threadId: thread.id }));+ store.dispatch(+ setStreamingAssistantForThread({+ threadId: thread.id,+ streaming: { requestId: 'req-x', content: 'thinking out loud', thinking: '' },+ })+ );+ });++ expect(screen.getByTestId('plan-review-feedback')).toHaveValue('use the staging bucket');+ });+});