Skip to content

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

📟 refactor: Present Background Task Checks as a Distinct Activity (#16414)

lia-by-librechat[bot]d297530def02
diff --git a/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx b/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx
index f86047be90..aa67c094f5 100644
--- a/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx
+++ b/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx
@@ -301,7 +301,10 @@ function LivePhaseHeader({
* and suppressed count together so neither can paint with the old value. */
const comboCount = showSandboxStartup ? 1 : activity.comboCount;
const { source } = activity;
- const line = useMemo(() => ({ text, source, comboCount }), [text, source, comboCount]);
+ const line = useMemo(
+ () => ({ text, source, comboCount, isBackgroundTaskCheck: activity.isBackgroundTaskCheck }),
+ [text, source, comboCount, activity.isBackgroundTaskCheck],
+ );
/** A thought's line is a finished sentence and holds for a beat; everything
* else repaints at the ordinary cadence. */
const painted = useThrottledValue(
@@ -316,7 +319,12 @@ function LivePhaseHeader({
* fail while a later one runs, and the line alone would never say so. The
* hidden group header carries the same counts in the same words. */
const { failed, cancelled } = activity.outcome;
- const combo = painted.comboCount > 1 ? `×${painted.comboCount}` : '';
+ let combo = '';
+ if (painted.comboCount > 1) {
+ combo = painted.isBackgroundTaskCheck
+ ? `· ${localize('com_ui_background_tasks_n_checks', { 0: String(painted.comboCount) })}`
+ : `×${painted.comboCount}`;
+ }
const failedNote =
failed > 0
? localize(failed === 1 ? 'com_ui_one_action_failed' : 'com_ui_n_actions_failed', {
diff --git a/client/src/components/Chat/Messages/Content/ToolCallGroup.tsx b/client/src/components/Chat/Messages/Content/ToolCallGroup.tsx
index 1a47e3a701..c0080bf4cd 100644
--- a/client/src/components/Chat/Messages/Content/ToolCallGroup.tsx
+++ b/client/src/components/Chat/Messages/Content/ToolCallGroup.tsx
@@ -1,8 +1,8 @@
import { useState, useRef, useMemo, useEffect, useCallback } from 'react';
import { useRecoilValue } from 'recoil';
import { Button } from '@librechat/client';
-import { ChevronDown, MessageCircleQuestion, Users } from 'lucide-react';
import { Tools, Constants, ContentTypes } from 'librechat-data-provider';
+import { ChevronDown, ListChecks, MessageCircleQuestion, Users } from 'lucide-react';
import type { TAttachment, TMessageContentParts } from 'librechat-data-provider';
import type { PartWithIndex } from './ParallelContent';
import type { ToolMeta } from './outcome';
@@ -144,6 +144,7 @@ export default function ToolCallGroup({
let fileSearchCount = 0;
let subagentCount = 0;
let askQuestionCount = 0;
+ let taskCheckCount = 0;
let failedCount = 0;
let cancelledCount = 0;
@@ -156,6 +157,8 @@ export default function ToolCallGroup({
subagentCount++;
} else if (tool.name === ASK_USER_QUESTION) {
askQuestionCount++;
+ } else if (tool.name === Constants.CHECK_BACKGROUND_TASK) {
+ taskCheckCount++;
}
if (tool.failed) {
failedCount++;
@@ -183,6 +186,7 @@ export default function ToolCallGroup({
fileSearchCount,
subagentCount,
askQuestionCount,
+ taskCheckCount,
failedCount,
cancelledCount,
toolNameSummary,
@@ -215,6 +219,8 @@ export default function ToolCallGroup({
* tools: ask_user_question") with a question glyph. */
const allAskQuestions =
activitySummary.askQuestionCount > 0 && activitySummary.askQuestionCount === count;
+ const allTaskChecks =
+ activitySummary.taskCheckCount > 0 && activitySummary.taskCheckCount === count;
/**
* An answered question is the group's completion proof. The `tool_call`
* part carries no output until the turn finalizes, so `allCompleted` stays
@@ -405,6 +411,11 @@ export default function ToolCallGroup({
? localize('com_ui_asked_n_questions', { 0: String(count) })
: localize('com_ui_asking_n_questions', { 0: String(count) });
}
+ if (allTaskChecks) {
+ return localize(
+ groupDone ? 'com_ui_background_tasks_checked' : 'com_ui_background_tasks_checking',
+ );
+ }
if (activitySummary.webSearchCount === count) {
return localize(groupDone ? 'com_ui_web_searched' : 'com_ui_web_searching');
}
@@ -430,6 +441,8 @@ export default function ToolCallGroup({
const groupDetailParts: string[] = [];
if (searchesOnly && count > 1) {
groupDetailParts.push(localize('com_ui_n_searches', { 0: String(count) }));
+ } else if (allTaskChecks && count > 1) {
+ groupDetailParts.push(localize('com_ui_background_tasks_n_checks', { 0: String(count) }));
} else if (!allSubagents && !allAskQuestions && count > 1) {
groupDetailParts.push(activitySummary.toolNameSummary);
}
@@ -471,7 +484,12 @@ export default function ToolCallGroup({
? groupDetailParts.filter((part) => part && part !== failedNote).join(' · ')
: groupDetail;
/** Single category glyph for homogeneous groups (else StackedToolIcons). */
- const CategoryIcon = allSubagents ? Users : MessageCircleQuestion;
+ let CategoryIcon = ListChecks;
+ if (allSubagents) {
+ CategoryIcon = Users;
+ } else if (allAskQuestions) {
+ CategoryIcon = MessageCircleQuestion;
+ }
const iconStatus = getOutcomeStatus({
failed: activityFailed ? 1 : activitySummary.failedCount,
cancelled: activitySummary.cancelledCount,
@@ -509,12 +527,9 @@ export default function ToolCallGroup({
aria-expanded={isExpanded}
aria-label={groupAriaLabel}
>
- {iconStatus == null && (allSubagents || allAskQuestions) ? (
- /** Homogeneous category groups get a single category glyph instead
- * of StackedToolIcons' generic wrenches: a Users glyph for
- * subagents, a question glyph for ask_user_question — matching
- * their individual card headers and reading as the category
- * rather than "tools". */
+ {iconStatus == null && (allSubagents || allAskQuestions || allTaskChecks) ? (
+ /** Homogeneous categories keep the same glyph as their individual
+ * cards instead of stacking identical tool icons. */
<div
className={cn(
ROW_GLYPH_SLOT,
diff --git a/client/src/components/Chat/Messages/Content/__tests__/LiveParity.test.tsx b/client/src/components/Chat/Messages/Content/__tests__/LiveParity.test.tsx
index 0eae37dc85..439b494a29 100644
--- a/client/src/components/Chat/Messages/Content/__tests__/LiveParity.test.tsx
+++ b/client/src/components/Chat/Messages/Content/__tests__/LiveParity.test.tsx
@@ -309,6 +309,80 @@ describe('live fold parity with the cards it hides', () => {
expect(screen.queryByTestId('activity-phase-card')).toBeNull();
});
+ it('describes repeated background-task polls as checks in the live fold', () => {
+ jest.useFakeTimers();
+ const poll = (id: string, output: string) =>
+ toPart(
+ {
+ name: Constants.CHECK_BACKGROUND_TASK,
+ args: { background_task_id: 'same-task' },
+ output,
+ },
+ id,
+ );
+ const completed = JSON.stringify({
+ background_task_id: 'same-task',
+ tool: Tools.bash_tool,
+ status: 'running',
+ });
+ const view = mount(
+ [poll('first', completed), poll('second', completed), poll('third', completed)],
+ undefined,
+ true,
+ );
+ const header = within(screen.getByTestId('activity-phase-card')).getByRole('button');
+
+ expect(header).toHaveAccessibleName('Checked background tasks · 3 checks');
+ expect(screen.getByTestId('live-phase-combo')).toHaveTextContent('· 3 checks');
+ expect(header).not.toHaveTextContent('check_background_task');
+
+ view.rerender(
+ <QueryClientProvider client={new QueryClient()}>
+ <RecoilRoot>
+ <ContentParts
+ content={[
+ poll('first', completed),
+ poll('second', completed),
+ poll('third', completed),
+ poll('fourth', ''),
+ ]}
+ messageId="m1"
+ conversationId="c1"
+ isCreatedByUser={false}
+ isLast
+ isLatestMessage
+ isSubmitting
+ showThinking={false}
+ />
+ </RecoilRoot>
+ </QueryClientProvider>,
+ );
+ act(() => {
+ jest.advanceTimersByTime(500);
+ });
+ expect(header).toHaveAccessibleName('Checking background tasks · 4 checks');
+ });
+
+ it.each([
+ ['error', 'Failed: Background tasks · 1 failed'],
+ ['cancelled', 'Cancelled · 1 cancelled'],
+ ])('keeps the %s verdict of a polled background task in the live fold', (status, label) => {
+ const output = JSON.stringify({
+ background_task_id: 'bg1',
+ tool: Tools.bash_tool,
+ status,
+ });
+ mount(
+ [toPart({ name: Constants.CHECK_BACKGROUND_TASK, output, runStepStatus: 'completed' })],
+ undefined,
+ true,
+ );
+ expect(
+ within(screen.getByTestId('activity-phase-card')).getAllByRole('button')[0],
+ ).toHaveAccessibleName(label);
+ expect(screen.queryByTestId('live-phase-combo')).toBeNull();
+ });
+
it('shows a multiplier for consecutive uses of the same tool and resets on a different tool', () => {
jest.useFakeTimers();
const first = toPart({ name: 'create_file', output: 'created' }, 'first');
diff --git a/client/src/components/Chat/Messages/Content/__tests__/ToolCallGroup.test.tsx b/client/src/components/Chat/Messages/Content/__tests__/ToolCallGroup.test.tsx
index f7fdad90ba..cc6c1c6528 100644
--- a/client/src/components/Chat/Messages/Content/__tests__/ToolCallGroup.test.tsx
+++ b/client/src/components/Chat/Messages/Content/__tests__/ToolCallGroup.test.tsx
@@ -21,6 +21,15 @@ jest.mock('~/hooks', () => ({
if (key === 'com_ui_n_searches') {
return `${values?.[0]} searches`;
}
+ if (key === 'com_ui_background_tasks_checked') {
+ return 'Checked background tasks';
+ }
+ if (key === 'com_ui_background_tasks_checking') {
+ return 'Checking background tasks';
+ }
+ if (key === 'com_ui_background_tasks_n_checks') {
+ return `${values?.[0]} checks`;
+ }
if (key === 'com_ui_n_actions_failed') {
return `${values?.[0]} failed`;
}
@@ -110,6 +119,7 @@ jest.mock('lucide-react', () => ({
),
Users: () => <span>{'users'}</span>,
MessageCircleQuestion: () => <span data-testid="question-icon">{'question'}</span>,
+ ListChecks: () => <span data-testid="task-check-icon">{'checks'}</span>,
TriangleAlert: () => <span>{'warning'}</span>,
}));
@@ -858,6 +868,72 @@ describe('ToolCallGroup image hoisting', () => {
).toBeInTheDocument();
});
+ it('summarizes repeated task checks as checks rather than separate tasks or generic actions', () => {
+ const parts = Array.from({ length: 3 }, (_, idx) => ({
+ part: makePart(
+ `check-${idx}`,
+ JSON.stringify({
+ background_task_id: 'same-task',
+ tool: 'bash_tool',
+ status: 'running',
+ }),
+ Constants.CHECK_BACKGROUND_TASK,
+ ),
+ idx,
+ }));
+ renderGroup({ ...baseProps, parts, lastContentIdx: 2 });
+
+ expect(
+ screen.getByRole('button', { name: 'Checked background tasks, 3 checks' }),
+ ).toBeInTheDocument();
+ expect(screen.getByText('· 3 checks')).toBeInTheDocument();
+ expect(screen.getByTestId('task-check-icon')).toBeInTheDocument();
+ expect(screen.queryByTestId('stacked-icons')).not.toBeInTheDocument();
+ expect(screen.queryByText(/Ran 3 actions|check_background_task/)).not.toBeInTheDocument();
+ });
+
+ it('keeps the check group active until its outstanding poll settles', () => {
+ renderGroup({
+ ...baseProps,
+ isSubmitting: true,
+ parts: [
+ { part: makePart('check-1', '{"tasks":[]}', Constants.CHECK_BACKGROUND_TASK), idx: 0 },
+ { part: makePart('check-2', '', Constants.CHECK_BACKGROUND_TASK), idx: 1 },
+ ],
+ });
+
+ expect(
+ screen.getByRole('button', { name: 'Checking background tasks, 2 checks' }),
+ ).toBeInTheDocument();
+ expect(screen.getByTestId('task-check-icon').parentElement).toHaveClass('animate-pulse');
+ });
+
+ it('uses the same check verb for one poll and preserves mixed-tool summaries', () => {
+ const check = makePart('check-1', '{"tasks":[]}', Constants.CHECK_BACKGROUND_TASK);
+ const { rerender } = renderGroup({
+ ...baseProps,
+ parts: [{ part: check, idx: 0 }],
+ lastContentIdx: 0,
+ });
+ expect(screen.getByRole('button', { name: 'Checked background tasks' })).toBeInTheDocument();
+
+ rerender(
+ <RecoilRoot>
+ <ToolCallGroup
+ {...baseProps}
+ parts={[
+ { part: check, idx: 0 },
+ { part: makePart('b1', 'done', Tools.bash_tool), idx: 1 },
+ ]}
+ />
+ </RecoilRoot>,
+ );
+ expect(
+ screen.getByRole('button', { name: 'Ran 2 actions, Background tasks, Code' }),
+ ).toBeInTheDocument();
+ expect(screen.getByTestId('stacked-icons')).toBeInTheDocument();
+ });
+
it.each([
['error', '1 failed'],
['cancelled', '1 cancelled'],
@@ -883,7 +959,9 @@ describe('ToolCallGroup image hoisting', () => {
lastContentIdx: 0,
});
- expect(screen.getByRole('button', { name: `Background tasks, ${suffix}` })).toBeInTheDocument();
+ expect(
+ screen.getByRole('button', { name: `Checked background tasks, ${suffix}` }),
+ ).toBeInTheDocument();
});
it.each(['invalid', 'rejected', 'unavailable', 'outcome_unknown', 'result_unavailable'])(
@@ -897,7 +975,7 @@ describe('ToolCallGroup image hoisting', () => {
Object.assign(part[ContentTypes.TOOL_CALL] ?? {}, { runStepStatus: 'completed' });
renderGroup({ ...baseProps, parts: [{ part, idx: 0 }], lastContentIdx: 0 });
expect(
- screen.getByRole('button', { name: 'Background tasks, 1 failed' }),
+ screen.getByRole('button', { name: 'Checked background tasks, 1 failed' }),
).toBeInTheDocument();
},
);
@@ -917,7 +995,9 @@ describe('ToolCallGroup image hoisting', () => {
],
lastContentIdx: 0,
});
- expect(screen.getByRole('button', { name: 'Background tasks, 1 failed' })).toBeInTheDocument();
+ expect(
+ screen.getByRole('button', { name: 'Checked background tasks, 1 failed' }),
+ ).toBeInTheDocument();
});
it('counts background failures per step when provider call IDs repeat', () => {
diff --git a/client/src/components/Chat/Messages/Content/live.ts b/client/src/components/Chat/Messages/Content/live.ts
index dceaaa2d51..216cc2e4c1 100644
--- a/client/src/components/Chat/Messages/Content/live.ts
+++ b/client/src/components/Chat/Messages/Content/live.ts
@@ -39,6 +39,8 @@ export type LiveActivity = {
* only while the line is the tool's own generic label, which is the only
* thing a count of that tool can modify. */
comboCount: number;
+ /** The generic line counts checks of a task rather than independent tool actions. */
+ isBackgroundTaskCheck?: boolean;
/** Failed and stopped calls anywhere in the span, not just the newest line. */
outcome: SpanOutcome;
};
@@ -133,6 +135,16 @@ function toolCallLine(
if (intent != null) {
return { text: intent, generic: false };
}
+ if (toolCall.name === Constants.CHECK_BACKGROUND_TASK) {
+ return {
+ text: localize(
+ meta?.hasOutput === true
+ ? 'com_ui_background_tasks_checked'
+ : 'com_ui_background_tasks_checking',
+ ),
+ generic: true,
+ };
+ }
if (!label) {
return { text: localize('com_assistants_running_action'), generic: true };
}
@@ -270,7 +282,10 @@ function newestLine(
serverNames: readonly string[],
span: SpanSummary,
preferLabels: boolean,
-): Pick<LiveActivity, 'text' | 'source' | 'pendingToolCallId' | 'comboCount'> {
+): Pick<
+ LiveActivity,
+ 'text' | 'source' | 'pendingToolCallId' | 'comboCount' | 'isBackgroundTaskCheck'
+> {
for (let position = parts.length - 1; position >= 0; position -= 1) {
const part = parts[position];
if (part == null) {
@@ -340,6 +355,7 @@ function newestLine(
* own work, or reports how it ended, the count has nothing left to
* multiply and reads as a claim about that sentence. */
comboCount: line.generic ? Math.max(1, span.trailingToolCount) : 1,
+ ...(toolCall.name === Constants.CHECK_BACKGROUND_TASK && { isBackgroundTaskCheck: true }),
...(isAwaitingStartup(part, toolCall, span) && { pendingToolCallId: toolCall.id }),
};
}
diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.json
index 5e8dbc38aa..2ae5ecd7f3 100644
--- a/client/src/locales/en/translation.json
+++ b/client/src/locales/en/translation.json
@@ -11,6 +11,7 @@
"com_ui_background_tasks_finished": "Finished",
"com_ui_background_tasks_incomplete": "Some background results may not be shown. Check again later.",
"com_ui_background_tasks_label": "Background tasks, {{0}} running",
+ "com_ui_background_tasks_n_checks": "{{0}} checks",
"com_ui_background_tasks_no_output": "No output returned",
"com_ui_background_tasks_not_running": "No longer running",
"com_ui_background_tasks_pending_label": "Background tasks, {{0}} results pending",