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 a stopped reply as markdown
M3gA-Mind02f89ae1f99b
diff --git a/app/src/components/assistant-ui/elements/stopped-run.tsx b/app/src/components/assistant-ui/elements/stopped-run.tsxindex bb775f9a6f..1916f0ed6a 100644--- a/app/src/components/assistant-ui/elements/stopped-run.tsx+++ b/app/src/components/assistant-ui/elements/stopped-run.tsx@@ -7,6 +7,9 @@* - `cn` import path (`@/components/assistant-ui/lib/utils`).* - "Continue"/"Discard" are `continueLabel`/`discardLabel` props with* English defaults, for `useT()`.+ * - No `words` paragraph: the stopped reply's text renders through the+ * message's normal markdown part, so this element is only the reason chip+ * and the Continue/Discard actions (#7729).*/import { cn } from '@/components/assistant-ui/lib/utils';import { ArrowRightIcon, SquareIcon } from 'lucide-react';@@ -15,7 +18,6 @@ import type { ComponentProps } from 'react';import { field, mono } from './surfaces';export function StoppedRun({- words,reason,onContinue,onDiscard,@@ -23,8 +25,7 @@ export function StoppedRun({discardLabel = 'Discard',className,...props-}: Omit<ComponentProps<'div'>, 'children' | 'words' | 'reason' | 'onContinue' | 'onDiscard'> & {- words: readonly string[];+}: Omit<ComponentProps<'div'>, 'children' | 'reason' | 'onContinue' | 'onDiscard'> & {reason: string;onContinue?: () => void;onDiscard?: () => void;@@ -33,14 +34,6 @@ export function StoppedRun({}) {return (<div data-slot="stopped-run" className={cn('flex w-full flex-col gap-3', className)} {...props}>- <p className="text-foreground/80 text-[13.5px] leading-relaxed">- {words.join(' ')}- <span- aria-hidden- className="bg-foreground/20 ms-1 inline-block h-[1em] w-[2px] translate-y-[0.15em] rounded-full"- />- </p>-<div className="flex items-center gap-2"><spanclassName={cn(diff --git a/app/src/components/assistant-ui/thread.tsx b/app/src/components/assistant-ui/thread.tsxindex 0884cadaf0..e1f86b804a 100644--- a/app/src/components/assistant-ui/thread.tsx+++ b/app/src/components/assistant-ui/thread.tsx@@ -1090,21 +1090,10 @@ const isStoppedRun = (s: AssistantState): boolean =>s.message.status?.type === 'incomplete' && s.message.status.reason === 'cancelled';/**- * The stopped turn's own text, split into words for the vendored- * `StoppedRun` element, plus `cancel_reason`/`superseded_by`- * (wire-contract.md `chat_cancelled`, carried through- * `metadata.custom.extraMetadata` by `assistantUiMessages.ts`) so the reason- * chip can distinguish a user-initiated Stop from a turn the core superseded.+ * `cancel_reason` (wire-contract.md `chat_cancelled`, carried through+ * `metadata.custom.extraMetadata` by `assistantUiMessages.ts`), so the reason+ * chip can tell a user-initiated Stop from a turn the core superseded.*/-// Two primitive selectors rather than one object-returning selector:-// `useAuiState`'s selector is compared by `Object.is`, so an inline `{...}`-// literal differs from itself on every store tick and free-runs the-// subscription — exactly the "Maximum update depth exceeded" loop this file-// hit once already. `words` (an array) is derived from `text` with-// `useMemo` in the component below instead of being computed here.-const selectStoppedRunText = (s: AssistantState): string =>- s.message.parts.flatMap(part => (part.type === 'text' ? [part.text] : [])).join(' ');-const selectStoppedRunCancelReason = (s: AssistantState): string | undefined => {const custom = s.message.metadata?.custom as| { extraMetadata?: { cancelReason?: string; supersededBy?: string } }@@ -1124,9 +1113,7 @@ const selectStoppedRunCancelReason = (s: AssistantState): string | undefined =>const StoppedRunSlot: FC = () => {const aui = useAui();const { t } = useT();- const text = useAuiState(selectStoppedRunText);const cancelReason = useAuiState(selectStoppedRunCancelReason);- const words = useMemo(() => (text.length > 0 ? text.split(/\s+/).filter(Boolean) : []), [text]);const { disabled: reloadDisabled, reload } = useActionBarReload();const reasonLabel =cancelReason === 'superseded'@@ -1135,7 +1122,6 @@ const StoppedRunSlot: FC = () => {return (<StoppedRundata-testid="stopped-marker"- words={words}reason={reasonLabel}onContinue={() => {if (!reloadDisabled) reload();@@ -1213,10 +1199,9 @@ const AssistantMessage: FC = () => {case 'group-source':return SourceGroup ? <SourceGroupSlot Component={SourceGroup} /> : null;case 'text':- // A stopped/cancelled turn's text renders once, inside- // `StoppedRunSlot` below (as `words`), not here — see that- // component's docstring.- return stopped ? null : <MarkdownText />;+ // A stopped turn's partial is markdown like any reply (#7729);+ // `StoppedRunSlot` below adds only the reason and actions.+ return <MarkdownText />;case 'reasoning':// A step inside the activity group, not a disclosure of its own.return (diff --git a/app/src/pages/__tests__/Conversations.render.test.tsx b/app/src/pages/__tests__/Conversations.render.test.tsxindex d22ab0995c..d1551e9e94 100644--- a/app/src/pages/__tests__/Conversations.render.test.tsx+++ b/app/src/pages/__tests__/Conversations.render.test.tsx@@ -1534,7 +1534,7 @@ describe('Conversations — smoke render (#1123 welcome-lock removal)', () => {expect(textarea).toHaveTextContent('a fresh follow-up');});- it('renders a Stopped marker on a stopped partial reply (#4862)', async () => {+ it('renders a stopped partial reply as markdown with a Stopped marker (#4862, #7729)', async () => {const thread = makeThread({ id: 'stopped-marker-thread', title: 'Stopped' });const messages: ThreadMessage[] = [{@@ -1549,7 +1549,12 @@ describe('Conversations — smoke render (#1123 welcome-lock removal)', () => {id: 'a',sender: 'agent',type: 'text',- content: 'partial reply that got cut off',+ content: [+ '## Verification',+ 'First paragraph.',+ 'Second paragraph.',+ '| Check | Result |\n|---|---|\n| npm test | pass |',+ ].join('\n\n'),extraMetadata: { stopped: true },createdAt: '2026-01-01T00:01:00.000Z',},@@ -1568,7 +1573,15 @@ describe('Conversations — smoke render (#1123 welcome-lock removal)', () => {});});- expect(screen.getByTestId('stopped-marker')).toHaveTextContent('Stopped');+ const marker = screen.getByTestId('stopped-marker');+ expect(marker).toHaveTextContent('Stopped');+ // The partial keeps its structure instead of one flattened paragraph, and+ // renders once: the marker holds only the reason and actions.+ expect(screen.getByRole('heading', { level: 2, name: 'Verification' })).toBeInTheDocument();+ expect(screen.getByText('First paragraph.').tagName).toBe('P');+ expect(screen.getByText('Second paragraph.').tagName).toBe('P');+ expect(screen.getByRole('table')).toHaveTextContent('npm test');+ expect(marker).not.toHaveTextContent('First paragraph.');});it('shows no Stop button while the thread is idle (#4862)', async () => {