Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active
TypeScript aianthropicartifactsawsazurechatgptchatgpt-cloneclaudeclonedeepseekgeminigooglegpt-5librechatmcpo1openairesponses-apivisionwebui
🧘 fix: Settle Stale Response Parts (#15743)
Danny Avila3bff323ac899
diff --git a/client/src/components/Chat/Messages/Content/ContentParts.tsx b/client/src/components/Chat/Messages/Content/ContentParts.tsxindex 0db9c2b8c5..28edd1f613 100644--- a/client/src/components/Chat/Messages/Content/ContentParts.tsx+++ b/client/src/components/Chat/Messages/Content/ContentParts.tsx@@ -165,6 +165,13 @@ const PartWithContext = memo(function PartWithContext({[messageId, conversationId, idx, nextType, isSubmitting, isLatestMessage],);+ /** Being last WITHIN a body is not being last in the message: activity+ * phases split one response into several bodies, so every settled phase has+ * a trailing part too. Only the body that holds the message's cursor can+ * own a live part — otherwise a phase from minutes ago keeps its reasoning+ * shimmering and its peek scrolling while later phases stream. */+ const holdsCursor = isLastPart && isLast;+return (<MessageContext.Provider value={contextValue}><Part@@ -173,8 +180,8 @@ const PartWithContext = memo(function PartWithContext({isSubmitting={isSubmitting}key={`part-${messageId}-${getPartKeyIndex(part, idx)}`}isCreatedByUser={isCreatedByUser}- isLast={isLastPart}- showCursor={isLastPart && isLast}+ isLast={holdsCursor}+ showCursor={holdsCursor}hideAttachments={hideAttachments}onToolExpand={onToolExpand}/>@@ -1053,8 +1060,9 @@ const ContentPartsBody = memo(function ContentPartsBody({* mark its group as last or nothing holds the streaming* cursor until the next delta. */isLast={- group.parts.some((p) => p.idx === lastContentIdx) ||- group.labelPart?.idx === lastContentIdx+ isLast &&+ (group.parts.some((p) => p.idx === lastContentIdx) ||+ group.labelPart?.idx === lastContentIdx)}renderPart={renderGroupedPart}lastContentIdx={lastContentIdx}diff --git a/client/src/components/Chat/Messages/Content/ToolCallGroup.tsx b/client/src/components/Chat/Messages/Content/ToolCallGroup.tsxindex 10505e94c7..feb18a4f01 100644--- a/client/src/components/Chat/Messages/Content/ToolCallGroup.tsx+++ b/client/src/components/Chat/Messages/Content/ToolCallGroup.tsx@@ -20,6 +20,7 @@ import {} from '~/utils';import { useLocalize, useExpandCollapse, scheduleMessageContentLayoutReconcile } from '~/hooks';import { parseBackgroundHandle, splitBackgroundAttachments } from './Parts/handle';+import { ASK_USER_QUESTION, getSubmittedAskAnswer } from '~/utils/approval';import { mapAttachments, filterAttachmentsForPart } from '~/utils/map';import { ToolAuthWarning, ToolAuthWarningContext } from './auth';import { useMCPIconMap, useMCPServerNames } from '~/hooks/MCP';@@ -28,7 +29,6 @@ import { AttachmentGroup, ReasoningCompact } from './Parts';import { isMemoryFailureOutput } from './Parts/MemoryCall';import { isError, StackedToolIcons } from './ToolOutput';import { isBashProgrammaticToolCall } from './routing';-import { ASK_USER_QUESTION } from '~/utils/approval';import SearchVerticals from './verticals';import { ROW_GLYPH_SLOT } from './rows';import store from '~/store';@@ -368,10 +368,46 @@ export default function ToolCallGroup({* tools: ask_user_question") with a question glyph. */const allAskQuestions =activitySummary.askQuestionCount > 0 && activitySummary.askQuestionCount === count;+ /**+ * An answered question is the group's completion proof. The `tool_call`+ * part carries no output until the turn finalizes, so `allCompleted` stays+ * false and the header read "Asking 1 question" for the rest of the turn,+ * long after the user answered. Position cannot settle it either: a LIVE+ * pause appends its interactive card after this group, so the group is not+ * the message's last part precisely while the question is open.+ *+ * The locally-recorded answer is the same fallback the durable record card+ * uses — the streaming handler's message copy can overwrite the optimistic+ * output stamp mid-stream, and only this survives it.+ */+ const askQuestionsAnswered = useMemo(+ () =>+ parts.every(({ part }) => {+ if (part.type !== ContentTypes.TOOL_CALL) {+ return true;+ }+ const toolCall = part[ContentTypes.TOOL_CALL] as+ | { name?: string; id?: string; output?: string | null }+ | undefined;+ if (toolCall?.name !== ASK_USER_QUESTION) {+ return true;+ }+ return (+ (toolCall.output?.length ?? 0) > 0 || getSubmittedAskAnswer(toolCall.id) !== undefined+ );+ }),+ [parts],+ );/** Past tense once the turn is settled — matches the Asking/Asked record* card. While a multi-question turn streams, the still-open question's* tool_call part has no output yet, so keep the present tense. */- const askQuestionsDone = allAskQuestions && (allCompleted || !isSubmitting);+ const groupDone = allCompleted || !isSubmitting;+ const askQuestionsDone = allAskQuestions && (groupDone || askQuestionsAnswered);++ /** One verdict for the header's tense, its glyph and its icon animation —+ * they read as a single control, so a group whose label already says+ * "Asked 1 question" must not keep pulsing beside it. */+ const isGroupLive = allAskQuestions ? !askQuestionsDone : !groupDone;/** For a single-tool group, lead with the tool's own (capitalized) label* instead of the generic "Used 1 tool: name", which reads awkwardly. */@@ -486,7 +522,6 @@ export default function ToolCallGroup({const searchCount = activitySummary.webSearchCount + activitySummary.fileSearchCount;const searchesOnly = count > 0 && searchCount === count;- const groupDone = allCompleted || !isSubmitting;/** Outcome-first header verb. Homogeneous searches, subagents, and questions* read as the activity the assistant performed. Mixed implementation-level@@ -602,7 +637,7 @@ export default function ToolCallGroup({className={cn(ROW_GLYPH_SLOT,'text-text-secondary',- !allCompleted && isSubmitting && 'animate-pulse text-text-primary',+ isGroupLive && 'animate-pulse text-text-primary',)}aria-hidden="true">@@ -614,7 +649,7 @@ export default function ToolCallGroup({toolNames={iconToolNames}mcpIconMap={mcpIconMap}maxIcons={4}- isAnimating={!allCompleted && isSubmitting}+ isAnimating={isGroupLive}/></div>)}diff --git a/client/src/components/Chat/Messages/Content/__tests__/ContentParts.test.tsx b/client/src/components/Chat/Messages/Content/__tests__/ContentParts.test.tsxindex bd5a2fb7ec..4be9ce3c90 100644--- a/client/src/components/Chat/Messages/Content/__tests__/ContentParts.test.tsx+++ b/client/src/components/Chat/Messages/Content/__tests__/ContentParts.test.tsx@@ -135,15 +135,18 @@ jest.mock('../Part', () => ({part,idx,showCursor,+ isLast,}: {part: TMessageContentParts;idx: number;showCursor?: boolean;+ isLast?: boolean;}) => (<divdata-testid={`real-part-${part.type}`}data-index={idx}data-show-cursor={String(showCursor === true)}+ data-is-last={String(isLast === true)}/>),}));@@ -511,6 +514,48 @@ describe('ContentParts — activity phase state', () => {expect(textParts[1]).toHaveAttribute('data-show-cursor', 'false');});+ /** Activity phases split one response into several bodies, and every settled+ * body has a trailing part. Only the body holding the message's cursor may+ * own a live one — otherwise a phase that finished minutes ago keeps its+ * reasoning shimmering while later phases stream. */+ it("leaves an earlier phase's trailing part settled while a later part streams", () => {+ const think = {+ type: ContentTypes.THINK,+ think: 'weighing the options',+ } as unknown as TMessageContentParts;+ const phase = {+ type: ContentTypes.ACTIVITY_LABEL,+ [ContentTypes.ACTIVITY_LABEL]: 'Mapped the schema',+ activity_label_type: 'phase',+ activity_start_index: 0,+ activity_end_index: 1,+ activity_count: 1,+ pending: false,+ } as unknown as TMessageContentParts;+ render(+ <ContentParts+ {...baseProps}+ content={[+ think,+ phase,+ { type: ContentTypes.TEXT, text: 'Good — schema mapped.' } as TMessageContentParts,+ ]}+ isLast+ isSubmitting+ isLatestMessage+ />,+ );++ expect(screen.getByTestId(`real-part-${ContentTypes.THINK}`)).toHaveAttribute(+ 'data-is-last',+ 'false',+ );+ expect(screen.getByTestId(`real-part-${ContentTypes.TEXT}`)).toHaveAttribute(+ 'data-is-last',+ 'true',+ );+ });+it('renders a completion-appended parent before the final root text', () => {const tool = {type: ContentTypes.TOOL_CALL,diff --git a/client/src/components/Chat/Messages/Content/__tests__/ToolCallGroup.test.tsx b/client/src/components/Chat/Messages/Content/__tests__/ToolCallGroup.test.tsxindex 04a5ae9180..745af4a8a9 100644--- a/client/src/components/Chat/Messages/Content/__tests__/ToolCallGroup.test.tsx+++ b/client/src/components/Chat/Messages/Content/__tests__/ToolCallGroup.test.tsx@@ -112,8 +112,12 @@ jest.mock('lucide-react', () => ({TriangleAlert: () => <span>{'warning'}</span>,}));+const mockSubmittedAskAnswers = new Map<string, string>();+jest.mock('~/utils/approval', () => ({ASK_USER_QUESTION: 'ask_user_question',+ getSubmittedAskAnswer: (toolCallId?: string) =>+ toolCallId != null ? mockSubmittedAskAnswers.get(toolCallId) : undefined,}));jest.mock('~/utils', () => ({@@ -271,6 +275,7 @@ describe('ToolCallGroup image hoisting', () => {beforeEach(() => {mockScheduleMessageContentLayoutReconcile.mockClear();mockMCPServerNames.length = 0;+ mockSubmittedAskAnswers.clear();});it('renders an AttachmentGroup outside the collapsible container with all attachments', () => {@@ -986,6 +991,7 @@ describe('ToolCallGroup image hoisting', () => {});expect(screen.getByRole('button', { name: 'Asking 2 questions' })).toBeInTheDocument();+ expect(screen.getByTestId('question-icon').parentElement).toHaveClass('animate-pulse');});it('uses a singular completed label for one question grouped with reasoning', () => {@@ -998,6 +1004,39 @@ describe('ToolCallGroup image hoisting', () => {expect(screen.getByRole('button', { name: 'Asked 1 question' })).toBeInTheDocument();});+ /** The `tool_call` part carries no output until the turn finalizes, so a group+ * the user already answered kept reading "Asking 1 question" for the rest of+ * the turn. Position cannot settle it: a live pause appends its interactive+ * card AFTER this group, so the group is not the last part exactly while the+ * question is open. */+ it('settles the question label once the answer is recorded locally', () => {+ mockSubmittedAskAnswers.set('q1', 'Option A');+ renderGroup({+ ...baseProps,+ isSubmitting: true,+ parts: [{ part: makePart('q1', '', 'ask_user_question'), idx: 0 }],+ lastContentIdx: 0,+ });++ expect(screen.getByRole('button', { name: 'Asked 1 question' })).toBeInTheDocument();+ /** The glyph reads as part of the same control, so it settles with it. */+ expect(screen.getByTestId('question-icon').parentElement).not.toHaveClass('animate-pulse');+ });++ it('keeps the active label while one question of a batch is unanswered', () => {+ mockSubmittedAskAnswers.set('q1', 'Option A');+ renderGroup({+ ...baseProps,+ isSubmitting: true,+ parts: [+ { part: makePart('q1', '', 'ask_user_question'), idx: 0 },+ { part: makePart('q2', '', 'ask_user_question'), idx: 1 },+ ],+ });++ expect(screen.getByRole('button', { name: 'Asking 2 questions' })).toBeInTheDocument();+ });+it('uses a singular active label for one question grouped with reasoning', () => {renderGroup({...baseProps,