From 8b46f3b3e1863b3249e6339bb7d14840ea486948 Mon Sep 17 00:00:00 2001 From: Marco Beretta <81851188+berry-13@users.noreply.github.com> Date: Sat, 10 Oct 2026 15:35:59 +0200 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20style:=20Quiet=20Failed=20Tool?= =?UTF-8?q?=20Activity=20(#16949)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * style: Reduce noise in failed tool activity * fix: Keep thought previews inside visible reasoning rows * style: Sort activity phase imports * style: Unify system events with tool disclosures * fix: Preserve system footer alignment and partial summaries * fix: Preserve partial phases without surviving tool outcomes * fix: Honor partial markers over surviving failed rows * fix: Retain partial status when failed outcomes are missing * fix: Preserve partial status in sparse tool groups * fix: Preserve failed batch markers without tool rows * fix: Exclude system events from assistant code shortcuts * fix: Identify system events in message navigation * test: Align bash failure mock with specific verdict labels --- .../Messages/Content/ActivityPhaseGroup.tsx | 110 +++++++--------- .../Messages/Content/BackgroundTaskCard.tsx | 17 +-- .../Chat/Messages/Content/Parts/BashCall.tsx | 24 +++- .../Content/Parts/__tests__/BashCall.test.tsx | 26 +++- .../Chat/Messages/Content/ProgressText.tsx | 9 +- .../Chat/Messages/Content/ToolCallGroup.tsx | 77 ++++++----- .../Content/ToolOutput/StackedToolIcons.tsx | 10 +- .../Chat/Messages/Content/Wakeup.tsx | 6 +- .../__tests__/ActivityPhaseGroup.test.tsx | 122 ++++++++++++++++-- .../ContentParts.integration.test.tsx | 7 +- .../Content/__tests__/LiveParity.test.tsx | 12 +- .../Content/__tests__/ProgressText.test.tsx | 7 +- .../__tests__/StackedToolIcons.test.tsx | 2 +- .../Content/__tests__/ToolCall.test.tsx | 1 + .../Content/__tests__/ToolCallGroup.test.tsx | 87 ++++++++++++- .../Content/__tests__/Wakeup.test.tsx | 13 ++ .../Content/__tests__/outcome.test.ts | 16 ++- .../Chat/Messages/Content/outcome.ts | 14 +- .../Chat/Messages/Content/reveal.tsx | 23 ++-- .../components/Chat/Messages/MessageNav.tsx | 23 +++- .../Messages/__tests__/MessageNav.spec.tsx | 23 ++++ .../Chat/Messages/ui/MessageRender.tsx | 6 +- .../Chat/Messages/ui/MessageRow.tsx | 14 +- .../__tests__/MessageRender.wakeup.spec.tsx | 13 +- .../Messages/ui/__tests__/MessageRow.spec.tsx | 23 +++- .../Subagents/SubagentConversation.test.tsx | 2 +- .../Chat/Subagents/SubagentConversation.tsx | 2 +- client/src/components/Share/Message.tsx | 3 +- client/src/locales/en/translation.json | 3 + e2e/specs/mock/activity-thought.spec.ts | 4 +- .../mock/scenarios/thought-peek-tools.spec.ts | 6 +- 31 files changed, 516 insertions(+), 189 deletions(-) diff --git a/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx b/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx index 29c11b7baf..37efc9d47a 100644 --- a/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx +++ b/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx @@ -2,7 +2,7 @@ import { memo, useId, useCallback, useEffect, useMemo, useRef, useState, useCont import { useAtomValue } from 'jotai'; import { useTranslation } from 'react-i18next'; import { ContentTypes } from 'librechat-data-provider'; -import { Check, Lightbulb, ChevronDown, TriangleAlert } from 'lucide-react'; +import { Check, CircleX, Lightbulb, ChevronDown, TriangleAlert } from 'lucide-react'; import type { TAttachment, TMessageContentParts } from 'librechat-data-provider'; import type { CSSProperties, ReactNode } from 'react'; import type { RailHover } from './rail'; @@ -30,12 +30,11 @@ import { } from './rail'; import { FailedRevealContext, FailedRevealPill, useFailedRevealTrigger } from './reveal'; import { FOLD_RAIL_CLASSES, ROW_GLYPH_SLOT, TOOL_ROW_CLASSES } from './rows'; +import { getOutcomeStatus, isSpanFailed, summarizeSpan } from './outcome'; import useSmoothStreaming from '~/hooks/Messages/useSmoothStreaming'; import useThrottledValue from '~/hooks/Messages/useThrottledValue'; -import { AttachmentGroup, StreamingThoughtPeek } from './Parts'; import { useMCPIconMap, useMCPServerNames } from '~/hooks/MCP'; import { getActivityLabelText } from '~/utils/activityLabels'; -import { getOutcomeStatus, summarizeSpan } from './outcome'; import { MCPAppViews } from '~/components/MCPUIResource'; import { sandboxStartingByToolCallId } from '~/store'; import { MessageSurfaceContext } from '../ui/surface'; @@ -45,6 +44,7 @@ import { StackedToolIcons } from './ToolOutput'; import useTimeTick from '~/hooks/useTimeTick'; import { getSourceDomains } from './sources'; import { mapAttachments } from '~/utils/map'; +import { AttachmentGroup } from './Parts'; import SearchVerticals from './verticals'; /** Matches `EXPAND_TRANSITION` so the panel and the label ticker resolve on @@ -92,13 +92,18 @@ function schedulePostPaint(callback: () => void): () => void { * rendered without one sits to the left of the rows it replaces — the fold * then moves its own text sideways at the moment the reader is trying to * follow it. */ -function PhaseGlyph({ failed }: { failed: boolean }) { - const Icon = failed ? TriangleAlert : Check; +function PhaseGlyph({ failed, partial = false }: { failed: boolean; partial?: boolean }) { + let Icon = Check; + let tone = 'text-text-secondary'; + if (failed) { + Icon = CircleX; + tone = 'text-status-error'; + } else if (partial) { + Icon = TriangleAlert; + tone = 'text-status-warning'; + } return ( - @@ -405,7 +407,6 @@ function LivePhaseHeader({ ; attachmentsById: Record; count: number; + total: number; onReveal: () => void; }) { const localize = useLocalize(); @@ -506,10 +509,15 @@ function FailedPeek({ data-testid="activity-phase-failed-peek" > - + {first.text} {first.detail !== '' && ( @@ -565,7 +573,10 @@ export default function ActivityPhaseGroup({ const messageSurface = useContext(MessageSurfaceContext); const isLive = liveParts != null; const label = getActivityLabelText(labelPart); - const hasFailure = labelPart.status === 'failed' || labelPart.status === 'partial'; + /** Only a phase in which every call failed reads as failed in its header. + * A partial phase contains a mixture of outcomes; the count beside it and the failed + * rows inside say what went wrong without restyling the title. */ + const allFailed = labelPart.status === 'failed'; const outcomeParts = spanParts ?? liveParts; const attachmentsById = useMemo(() => mapAttachments(attachments ?? []), [attachments]); /** The span's failed calls, for the peek under a collapsed header and the @@ -577,6 +588,10 @@ export default function ActivityPhaseGroup({ [outcomeParts, attachmentsById], ); + const partialMarkerFallback = + labelPart.status === 'partial' && + (!hasContent || failedCount === 0 || isSpanFailed(failedCount, toolCount)); + /** Already `smoothStreaming && !reducedMotion` — it owns the media query, so * a second subscription here would install one `matchMedia` listener per * phase card without changing the answer. */ @@ -717,6 +732,7 @@ export default function ActivityPhaseGroup({ parts={outcomeParts} attachmentsById={attachmentsById} count={failedCount} + total={toolCount} onReveal={handleRevealFailed} /> ) : null; @@ -747,37 +763,13 @@ export default function ActivityPhaseGroup({ * right for the streaming-markdown cursor, wrong here — so `after:!static` * puts that one pseudo-element back in flow for the slot to center; the * `!` is what outranks the dot rule's three-class selector. */ - /** The thought streaming at the tail of a collapsed live card, shown the - * way an unfolded thought shows it: the trailing sentences in a short - * fading window under the header (#14546). The fold had swallowed that - * peek with the rows, leaving one throttled sentence on the header to - * stand for a paragraph of live reasoning. It takes the cursor's place: - * moving text is its own sign the run is alive. Only a card that is still - * just thinking shows it: once tool calls fold in with the thought, the - * header names the mix and the cursor stands in for the reasoning (#16680). */ - const streamingThought = useMemo(() => { - if (!isLive || isExpanded || liveParts == null) { - return ''; - } - const tail = liveParts[liveParts.length - 1]; - if (tail?.type !== ContentTypes.THINK) { - return ''; - } - if (liveParts.some((part) => part?.type === ContentTypes.TOOL_CALL)) { - return ''; - } - return typeof tail.think === 'string' ? tail.think : (tail.think?.value ?? ''); - }, [isLive, isExpanded, liveParts]); - const thoughtPeek = - streamingThought.trim() !== '' ? : null; - const cursor = - showCursor && thoughtPeek == null ? ( -
-
- ) : null; + const cursor = showCursor ? ( +
+
+ ) : null; /** `AttachmentGroup` drops `web_search` attachments, and the nested segment * renders with `hideAttachments` so its own `WebSearch` row stands down * for this hoist — so without `SearchVerticals` here a phase containing a @@ -807,12 +799,9 @@ export default function ActivityPhaseGroup({ )} data-testid="activity-phase-card" > - + @@ -884,13 +873,13 @@ export default function ActivityPhaseGroup({ ) : ( <> - {outcomeParts != null && !hasFailure ? ( + {outcomeParts != null && !allFailed && !partialMarkerFallback ? ( ) : ( - + )} - + )} {group} - {thoughtPeek} {media} {cursor} diff --git a/client/src/components/Chat/Messages/Content/BackgroundTaskCard.tsx b/client/src/components/Chat/Messages/Content/BackgroundTaskCard.tsx index f887d514db..aabcb63650 100644 --- a/client/src/components/Chat/Messages/Content/BackgroundTaskCard.tsx +++ b/client/src/components/Chat/Messages/Content/BackgroundTaskCard.tsx @@ -82,12 +82,9 @@ export default function BackgroundTaskCard({ } return ( -
+
- +
@@ -108,7 +105,7 @@ export default function BackgroundTaskCard({
@@ -135,7 +132,7 @@ export default function BackgroundTaskCard({
)} {result && ( -
+
{localize(failed && !error ? 'com_ui_error' : 'com_ui_output')}
-
+
)} {error && ( -
+
{localize('com_ui_error')}
-
+
parseJsonField(args, commandField), [args, commandField]); const isWritingCommand = !command || !areToolCallArgsComplete(args); const { useSandboxStarting } = useMessagePartsHost(); @@ -93,9 +95,11 @@ export default function BashCall({ text: result.stderr, className: result.failed ? 'text-status-error' : 'text-text-secondary', }, - { text: result.trailer, className: 'text-text-tertiary' }, + ...(!result.timedOut || showTimeoutDetails + ? [{ text: result.trailer, className: 'text-text-tertiary' }] + : []), ], - [result], + [result, showTimeoutDetails], ); /** A backgrounded call's persisted output stays the dispatch handle until * the detached run settles and patches it; render a background state @@ -276,6 +280,22 @@ export default function BashCall({ variant="terminal" /> )} + {result?.timedOut === true && ( +
+ + {localize('com_ui_command_timeout_note')} + + +
+ )}
)}
diff --git a/client/src/components/Chat/Messages/Content/Parts/__tests__/BashCall.test.tsx b/client/src/components/Chat/Messages/Content/Parts/__tests__/BashCall.test.tsx index 0960cd1a8f..c1d79310d2 100644 --- a/client/src/components/Chat/Messages/Content/Parts/__tests__/BashCall.test.tsx +++ b/client/src/components/Chat/Messages/Content/Parts/__tests__/BashCall.test.tsx @@ -59,8 +59,7 @@ jest.mock('~/components/Chat/Messages/Content/ProgressText', () => ({ }) => (
{phase === 'running' ? inProgressText : finishedText} - {phase === 'failed' ? ' — tool failed' : ''} - {phase === 'failed' && verdict ? ` · ${verdict}` : ''} + {phase === 'failed' ? ` · ${verdict || 'tool failed'}` : ''}
), })); @@ -425,7 +424,7 @@ describe('BashCall sole tool disclosure', () => { , ); - expect(screen.getByTestId('progress-text')).toHaveTextContent('tool failed'); + expect(screen.getByTestId('progress-text')).toHaveTextContent('exit code 1'); }); it('keeps its row for a detached task whose dispatch step has closed', () => { @@ -661,6 +660,21 @@ describe('BashCall exit status', () => { , ); + it('hides timeout executor guidance until details are opened', () => { + renderSettled( + 'stdout:\nsleeping\n\n[terminated by SIGKILL][timed out]\nCommand reached timeoutMs: 30000. Before retrying, check for partial side effects.', + ); + expect(screen.queryByText(/Before retrying/)).not.toBeInTheDocument(); + }); + + it('reveals the complete timeout trailer through details', () => { + renderSettled( + 'stdout:\nsleeping\n\n[terminated by SIGKILL][timed out]\nCommand reached timeoutMs: 30000. Before retrying, check for partial side effects.', + ); + fireEvent.click(screen.getByRole('button', { name: 'com_ui_details' })); + expect(screen.getByText(/Before retrying/)).toBeInTheDocument(); + }); + it('does not read a trailer the sandbox command printed itself', () => { const { container } = renderSettled('stdout:\n[exit code: 1]', false); expect(screen.getByTestId('progress-text')).toHaveTextContent('Ran command'); @@ -670,12 +684,12 @@ describe('BashCall exit status', () => { it('fails the same output when the server marked it attached-workspace', () => { renderSettled('stdout:\n[exit code: 1]'); - expect(screen.getByTestId('progress-text')).toHaveTextContent(/tool failed · exit code 1$/); + expect(screen.getByTestId('progress-text')).toHaveTextContent(/Ran command · exit code 1$/); }); it('fails a non-zero exit even when the output matches no error pattern', () => { renderSettled('stdout:\n1 test failed\n\n[exit code: 2]'); - expect(screen.getByTestId('progress-text')).toHaveTextContent(/tool failed · exit code 2$/); + expect(screen.getByTestId('progress-text')).toHaveTextContent(/Ran command · exit code 2$/); }); it('keeps a zero exit successful even when stderr reads like an error', () => { @@ -700,7 +714,7 @@ describe('BashCall exit status', () => { ['Command completed with no output.\n[terminated by SIGTERM]', 'terminated by SIGTERM'], ])('names the reason for a stopped command: %s', (output, reason) => { renderSettled(output); - expect(screen.getByTestId('progress-text')).toHaveTextContent(`tool failed · ${reason}`); + expect(screen.getByTestId('progress-text')).toHaveTextContent(`Ran command · ${reason}`); }); it('keeps the text heuristic for sandbox output without an exit trailer', () => { diff --git a/client/src/components/Chat/Messages/Content/ProgressText.tsx b/client/src/components/Chat/Messages/Content/ProgressText.tsx index 6252a30ac7..733fbf947f 100644 --- a/client/src/components/Chat/Messages/Content/ProgressText.tsx +++ b/client/src/components/Chat/Messages/Content/ProgressText.tsx @@ -100,7 +100,7 @@ export default function ProgressText({ hasInput?: boolean; popover?: boolean; isExpanded?: boolean; - /** Why a failed card failed ("exit code 2"), shown after the failure + /** Why a failed card failed ("exit code 2"), shown in place of the generic failure * suffix. Plain text inside the button, so it is part of its name. */ verdict?: string; }) { @@ -236,11 +236,10 @@ export default function ProgressText({ )} + {/* A reason ("timed out", "exit code 2") already says the call failed, + so it replaces the generic word instead of following it. */} {errorSuffix && ( - · {errorSuffix} - )} - {errorSuffix && verdict && ( - · {verdict} + · {verdict || errorSuffix} )} {isRunning && phaseStartAt != null && localPhaseStart != null && ( diff --git a/client/src/components/Chat/Messages/Content/ToolCallGroup.tsx b/client/src/components/Chat/Messages/Content/ToolCallGroup.tsx index 53493a6a1f..e36555756e 100644 --- a/client/src/components/Chat/Messages/Content/ToolCallGroup.tsx +++ b/client/src/components/Chat/Messages/Content/ToolCallGroup.tsx @@ -1,6 +1,6 @@ import { useState, useRef, useMemo, useEffect, useContext, useCallback } from 'react'; import { Tools, Constants, ContentTypes } from 'librechat-data-provider'; -import { ChevronDown, ListChecks, MessageCircleQuestion, Users } from 'lucide-react'; +import { ChevronDown, ListChecks, MessageCircleQuestion, TriangleAlert, Users } from 'lucide-react'; import type { TAttachment, TMessageContentParts } from 'librechat-data-provider'; import type { PartWithIndex } from './ParallelContent'; import type { ToolMeta } from './outcome'; @@ -133,7 +133,9 @@ export default function ToolCallGroup({ ); const activityLabel = getBatchActivityLabelPart(labelPart?.part); const activityLabelText = getActivityLabelText(activityLabel); - const activityFailed = activityLabel?.status === 'failed' || activityLabel?.status === 'partial'; + /** The label's verdict outranks the calls' only when the whole batch failed; + * a partial batch has mixed outcomes, and its failed rows say what went wrong. */ + const activityFailed = activityLabel?.status === 'failed'; /** A settled, filled label is itself a completion proof: the PostToolBatch * claim only happens after every output in the batch returned. Without * it, a tool that legitimately returns an empty string reads as @@ -605,10 +607,16 @@ export default function ToolCallGroup({ } else if (allAskQuestions) { CategoryIcon = MessageCircleQuestion; } - const iconStatus = getOutcomeStatus({ - failed: activityFailed ? 1 : activitySummary.failedCount, - cancelled: activitySummary.cancelledCount, - }); + const partialMarkerFallback = + activityLabel?.status === 'partial' && + (activitySummary.failedCount === 0 || activitySummary.failedCount >= count); + const iconStatus = activityFailed + ? 'failed' + : getOutcomeStatus({ + failed: activitySummary.failedCount, + cancelled: activitySummary.cancelledCount, + total: count, + }); const hasActiveToolCall = useMemo( () => isSubmitting && toolMetadata.some((m) => m && !m.hasOutput), @@ -642,37 +650,38 @@ export default function ToolCallGroup({ aria-label={groupAriaLabel} > - {iconStatus == null && (allSubagents || allAskQuestions || allTaskChecks) ? ( - /** Homogeneous categories keep the same glyph as their individual - * cards instead of stacking identical tool icons. */ - - ) : ( - + {partialMarkerFallback && ( + diff --git a/client/src/components/Chat/Messages/Content/ToolOutput/StackedToolIcons.tsx b/client/src/components/Chat/Messages/Content/ToolOutput/StackedToolIcons.tsx index af79fee79d..2cf7fae9b0 100644 --- a/client/src/components/Chat/Messages/Content/ToolOutput/StackedToolIcons.tsx +++ b/client/src/components/Chat/Messages/Content/ToolOutput/StackedToolIcons.tsx @@ -1,5 +1,5 @@ import { useMemo } from 'react'; -import { TriangleAlert, X } from 'lucide-react'; +import { CircleX, X } from 'lucide-react'; import type { ToolIconType } from './ToolIcon'; import ToolIcon, { getToolIconType, getMCPServerName } from './ToolIcon'; import { FaviconImage } from '~/components/Web/SourceHovercard'; @@ -61,9 +61,11 @@ export default function StackedToolIcons({ return result; }, [toolNames, mcpIconMap, mcpServerNames, sourceDomains]); - if (status != null) { - const StatusIcon = status === 'failed' ? TriangleAlert : X; - return