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
📟 feat: Render System Events as Distinct Turns (#16119)
Danny Avilaf1bdc5640bae
diff --git a/client/src/components/Chat/Messages/Content/Wakeup.tsx b/client/src/components/Chat/Messages/Content/Wakeup.tsxindex 30cbb68089..53c8b48cd7 100644--- a/client/src/components/Chat/Messages/Content/Wakeup.tsx+++ b/client/src/components/Chat/Messages/Content/Wakeup.tsx@@ -1,10 +1,14 @@import { memo, useCallback, useMemo, useState } from 'react';+import { Users } from 'lucide-react';import { useRecoilValue } from 'recoil';import { Button } from '@librechat/client';-import { ChevronDown, Users } from 'lucide-react';import type { ActiveSubagentPanel } from '~/components/Chat/Subagents/state';import type { WakeupDisplay, WakeupTask } from './Parts/wakeup';import type { TranslationKeys } from '~/hooks';+import SystemEventHeader, {+ SystemEventIcon,+ systemEventHeaderClasses,+} from '~/components/Chat/Messages/ui/SystemEvent';import { subagentStatusIcon, subagentStatusLabelKey } from '~/components/Chat/Subagents/status';import { useParentSubagents } from '~/components/Chat/Subagents/ParentSubagentsProvider';import { durableSubagentSelection } from '~/components/Chat/Subagents/eventSelection';@@ -187,46 +191,30 @@ const Wakeup = memo(function Wakeup({);return (- <div className="mb-2 mt-1 w-full">+ <div className={cn('max-w-full', isExpanded && 'w-[36rem]')}><Buttonvariant="ghost"type="button"- className="inline-flex h-auto w-full items-center justify-start gap-2 rounded-none bg-transparent p-0 py-1 text-text-secondary hover:bg-transparent hover:text-text-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-heavy focus-visible:ring-offset-0"+ className={systemEventHeaderClasses}onClick={handleToggle}aria-expanded={isExpanded}aria-label={headerLabel}>- {display.kind === 'subagent' ? (- <div- className="flex h-5 w-5 shrink-0 items-center justify-center text-text-secondary"- aria-hidden="true"- >- <Users size={14} />- </div>- ) : (- <StackedToolIcons toolNames={toolIconNames} mcpIconMap={mcpIconMap} maxIcons={4} />- )}- <span- className={cn(- 'tool-status-text min-w-0 truncate font-medium',- anyFailed && 'text-text-warning',- )}- role="status"- title={headerLabel}- >- {headerLabel}- </span>- {nameSummary !== '' && (- <span className="min-w-0 max-w-[40%] truncate text-xs font-normal text-text-secondary">- · {nameSummary}- </span>- )}- <ChevronDown- className={cn(- 'size-4 shrink-0 text-text-secondary transition-transform duration-200 ease-out',- isExpanded && 'rotate-180',- )}- aria-hidden="true"+ <SystemEventHeader+ live+ icon={+ display.kind === 'subagent' ? (+ <SystemEventIcon>+ <Users size={14} />+ </SystemEventIcon>+ ) : (+ <StackedToolIcons toolNames={toolIconNames} mcpIconMap={mcpIconMap} maxIcons={4} />+ )+ }+ label={headerLabel}+ detail={nameSummary}+ expanded={isExpanded}+ warning={anyFailed}/></Button><div@@ -237,7 +225,7 @@ const Wakeup = memo(function Wakeup({>{shouldRenderBody && (<div className="overflow-hidden" ref={expandRef}>- <div className="py-0.5 pl-4">+ <div className="pb-1"><div className="mt-1 text-xs text-text-secondary">{localize('com_ui_wakeup_explainer')}</div>diff --git a/client/src/components/Chat/Messages/ui/MessageRender.tsx b/client/src/components/Chat/Messages/ui/MessageRender.tsxindex 5b7c236f99..37a3a9f8d0 100644--- a/client/src/components/Chat/Messages/ui/MessageRender.tsx+++ b/client/src/components/Chat/Messages/ui/MessageRender.tsx@@ -172,7 +172,7 @@ const MessageRender = memo(function MessageRender({hasParallelContent={hasParallelContent}fullWidth={maximizeChatSpace}isEditing={edit}- plain={wakeupDisplay != null && !edit}+ systemLabel={wakeupDisplay != null && !edit ? localize('com_ui_system_event') : undefined}footer={<SubRow classes={cn(messageFooterClasses, msg.isCreatedByUser && 'justify-end')}>{/* The reading holds the column start: it takes over the slot the streamingdiff --git a/client/src/components/Chat/Messages/ui/MessageRow.tsx b/client/src/components/Chat/Messages/ui/MessageRow.tsxindex dd3b20dd51..a6a1add73d 100644--- a/client/src/components/Chat/Messages/ui/MessageRow.tsx+++ b/client/src/components/Chat/Messages/ui/MessageRow.tsx@@ -1,3 +1,4 @@+import { Zap } from 'lucide-react';import type { ReactNode } from 'react';import MessageTimestamp from './MessageTimestamp';import HeaderLabel from './HeaderLabel';@@ -17,9 +18,10 @@ type MessageRowProps = {hasParallelContent?: boolean;fullWidth?: boolean;isEditing?: boolean;- /** Full-width block without the author header or user bubble — for rows- * whose body carries its own header (e.g. wake-up task cards). */- plain?: boolean;+ /** Marks a host-authored turn (wake-up results, subagent triggers): it keeps+ * the user's position and bubble shape, outlined instead of filled, under+ * this visible heading in place of the author's name. */+ systemLabel?: string;className?: string;};@@ -50,11 +52,13 @@ export default function MessageRow({hasParallelContent = false,fullWidth = false,isEditing = false,- plain = false,+ systemLabel,}: MessageRowProps) {// Same column as ChatForm: max-width plus `sm:px-2`, so the body lines// up with the composer surface rather than the form's outer box.const widthClass = getMessageRowWidthClass({ fullWidth, hasParallelContent });+ const isSystem = systemLabel != null && systemLabel !== '';+ const isUserSide = isCreatedByUser || isSystem;return (<div@@ -64,7 +68,7 @@ export default function MessageRow({className={cn('message-render group mx-auto flex min-w-0 flex-1 font-theme-ui transition-[max-width] duration-theme-normal motion-reduce:transition-none','focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-text-primary',- isCreatedByUser && !plain ? 'justify-end' : 'items-start',+ isUserSide ? 'justify-end' : 'items-start',widthClass,className,)}@@ -72,17 +76,25 @@ export default function MessageRow({<divclassName={cn('relative flex min-w-0 flex-col',- isCreatedByUser ? 'user-turn' : 'agent-turn',- (hasParallelContent || isEditing || plain) && 'w-full',+ isUserSide ? 'user-turn' : 'agent-turn',+ (hasParallelContent || isEditing) && 'w-full',!hasParallelContent &&- !plain &&- isCreatedByUser &&+ isUserSide &&cn('ml-auto items-end', !isEditing && 'w-fit max-w-[90%] sm:max-w-[85%]'),- !hasParallelContent && !isCreatedByUser && !isEditing && 'flex-1',+ !hasParallelContent && !isUserSide && !isEditing && 'flex-1',)}>+ {isSystem && (+ <h2 className="mb-1 flex select-none items-center gap-1.5 pr-1.5 text-xs font-medium uppercase tracking-wide text-text-secondary">+ <Zap size={12} aria-hidden="true" />+ {systemLabel}+ <span className="sr-only">+ <MessageTimestamp value={timestamp} />+ </span>+ </h2>+ )}{!hasParallelContent &&- !plain &&+ !isSystem &&(isCreatedByUser ? (<h2 className="sr-only">{headerPrefix}@@ -104,21 +116,22 @@ export default function MessageRow({</h2>))}- <div className={cn('flex w-full flex-col gap-1', isCreatedByUser && !plain && 'items-end')}>+ <div className={cn('flex w-full flex-col gap-1', isUserSide && 'items-end')}><divclassName={cn('flex min-h-[20px] max-w-full flex-grow flex-col gap-0',- isCreatedByUser && !isEditing && !plain- ? 'w-fit rounded-theme-surface rounded-br-theme-control bg-surface-tertiary px-theme-normal py-2.5'+ isUserSide && !isEditing+ ? cn(+ 'w-fit rounded-theme-surface rounded-br-theme-control px-theme-normal',+ isSystem ? 'border border-border-medium py-1.5' : 'bg-surface-tertiary py-2.5',+ ): 'w-full',)}data-testid="message-body">{children}</div>- <div className={cn('w-full', isCreatedByUser && !plain && 'flex justify-end')}>- {footer}- </div>+ <div className={cn('w-full', isUserSide && 'flex justify-end')}>{footer}</div></div></div></div>diff --git a/client/src/components/Chat/Messages/ui/SystemEvent.tsx b/client/src/components/Chat/Messages/ui/SystemEvent.tsxnew file mode 100644index 0000000000..f898e1fb04--- /dev/null+++ b/client/src/components/Chat/Messages/ui/SystemEvent.tsx@@ -0,0 +1,72 @@+import { ChevronDown } from 'lucide-react';+import type { ReactNode } from 'react';+import { cn } from '~/utils';++type SystemEventHeaderProps = {+ icon: ReactNode;+ label: string;+ detail?: string;+ /** Present when the header toggles a disclosure; drives the chevron. */+ expanded?: boolean;+ warning?: boolean;+ /** Announces the label when the row arrives mid-conversation. */+ live?: boolean;+};++export function SystemEventIcon({ children }: { children: ReactNode }) {+ return (+ <span+ aria-hidden="true"+ className="flex size-5 shrink-0 items-center justify-center text-text-secondary"+ >+ {children}+ </span>+ );+}++/**+ * Header line of a system turn — icon, event label, muted detail, chevron.+ * Main chat wake-ups and subagent panel triggers both render it, so the two+ * surfaces cannot drift apart.+ */+export default function SystemEventHeader({+ icon,+ label,+ detail,+ expanded,+ warning = false,+ live = false,+}: SystemEventHeaderProps) {+ return (+ <>+ {icon}+ <span+ className={cn(+ 'tool-status-text min-w-0 truncate font-medium',+ warning && 'text-text-warning',+ )}+ title={label}+ role={live ? 'status' : undefined}+ >+ {label}+ </span>+ {detail != null && detail !== '' && (+ <span className="min-w-0 max-w-[50%] truncate text-xs font-normal text-text-secondary">+ · {detail}+ </span>+ )}+ {expanded != null && (+ <ChevronDown+ className={cn(+ 'ml-auto size-4 shrink-0 text-text-secondary transition-transform duration-200 ease-out motion-reduce:transition-none',+ expanded && 'rotate-180',+ )}+ aria-hidden="true"+ />+ )}+ </>+ );+}++export const systemEventHeaderClasses =+ 'inline-flex h-auto w-full items-center justify-start gap-2 rounded-none bg-transparent p-0 py-1 text-sm text-text-secondary hover:bg-transparent hover:text-text-secondary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-heavy focus-visible:ring-offset-0';diff --git a/client/src/components/Chat/Messages/ui/__tests__/MessageRow.spec.tsx b/client/src/components/Chat/Messages/ui/__tests__/MessageRow.spec.tsxindex a0e61ad2fd..b2f95dc25b 100644--- a/client/src/components/Chat/Messages/ui/__tests__/MessageRow.spec.tsx+++ b/client/src/components/Chat/Messages/ui/__tests__/MessageRow.spec.tsx@@ -15,13 +15,13 @@ const renderRow = ({hasParallelContent = false,fullWidth = false,isEditing = false,- plain = false,+ systemLabel,}: {isCreatedByUser: boolean;hasParallelContent?: boolean;fullWidth?: boolean;isEditing?: boolean;- plain?: boolean;+ systemLabel?: string;}) =>render(<MessageRow@@ -36,23 +36,26 @@ const renderRow = ({hasParallelContent={hasParallelContent}fullWidth={fullWidth}isEditing={isEditing}- plain={plain}+ systemLabel={systemLabel}><p>{MESSAGE_BODY}</p></MessageRow>,);describe('MessageRow', () => {- it('renders a plain user row as a full-width block without header or bubble', () => {- renderRow({ isCreatedByUser: true, plain: true });+ it('renders a system row on the user side as an outlined bubble under a visible heading', () => {+ renderRow({ isCreatedByUser: true, systemLabel: 'System' });const row = screen.getByLabelText('User message');const messageSurface = screen.getByText(MESSAGE_BODY).parentElement;+ const heading = screen.getByRole('heading', { name: 'System' });- expect(row).not.toHaveClass('justify-end');+ expect(row).toHaveClass('justify-end');+ expect(row.querySelector('.user-turn')).toHaveClass('items-end');+ expect(messageSurface).toHaveClass('border', 'border-border-medium', 'rounded-theme-surface');expect(messageSurface).not.toHaveClass('bg-surface-tertiary');- expect(messageSurface).toHaveClass('w-full');- expect(screen.queryByRole('heading', { hidden: true })).not.toBeInTheDocument();+ expect(heading).not.toHaveClass('sr-only');+ expect(screen.queryByText('You')).not.toBeInTheDocument();expect(screen.getByTestId('message-actions')).toBeInTheDocument();});diff --git a/client/src/components/Chat/Subagents/SubagentConversation.test.tsx b/client/src/components/Chat/Subagents/SubagentConversation.test.tsxindex 8db9a89956..03bc4c93fc 100644--- a/client/src/components/Chat/Subagents/SubagentConversation.test.tsx+++ b/client/src/components/Chat/Subagents/SubagentConversation.test.tsx@@ -59,6 +59,7 @@ jest.mock('lucide-react', () => ({CornerDownRight: () => null,Radio: () => null,XCircle: () => null,+ Zap: () => null,}));const turns: ChildConversationTurn[] = [@@ -113,8 +114,9 @@ describe('SubagentConversation', () => {</ChatSurfaceHarness>,);- expect(screen.getAllByText('com_ui_subagent_trigger_parent_dispatch')).toHaveLength(2);- expect(screen.getAllByText('com_ui_subagent_trigger_external_event')).toHaveLength(2);+ expect(screen.getByText('com_ui_subagent_trigger_parent_dispatch')).toBeInTheDocument();+ expect(screen.getByText('com_ui_subagent_trigger_external_event')).toBeInTheDocument();+ expect(screen.getAllByRole('heading', { name: /^com_ui_system_event/ })).toHaveLength(2);expect(screen.getByText('Investigate the release.')).toBeInTheDocument();expect(screen.getByText('Checked the constraints.')).toBeInTheDocument();expect(screen.getByText('search')).toBeInTheDocument();diff --git a/client/src/components/Chat/Subagents/SubagentConversation.tsx b/client/src/components/Chat/Subagents/SubagentConversation.tsxindex f39c6efe7b..fa69eac144 100644--- a/client/src/components/Chat/Subagents/SubagentConversation.tsx+++ b/client/src/components/Chat/Subagents/SubagentConversation.tsx@@ -1,12 +1,16 @@import { useMemo, useState } from 'react';import { useAtomValue } from 'jotai';-import { ChevronDown, CornerDownRight, Radio } from 'lucide-react';+import { CornerDownRight, Radio } from 'lucide-react';import { ContentTypes, EModelEndpoint } from 'librechat-data-provider';import { Button, Collapsible, CollapsibleContent, CollapsibleTrigger } from '@librechat/client';import type { TMessageContentParts } from 'librechat-data-provider';import type { ReactNode } from 'react';import type { ChildConversationTurn } from './adapters';import type { TranslationKeys } from '~/hooks';+import SystemEventHeader, {+ SystemEventIcon,+ systemEventHeaderClasses,+} from '~/components/Chat/Messages/ui/SystemEvent';import { SubagentActivityContent, SubagentStatus } from './SubagentActivity';import ContentParts from '~/components/Chat/Messages/Content/ContentParts';import { isAbnormalTerminalStatus, isLiveSubagentStatus } from './status';@@ -29,9 +33,9 @@ const TRIGGER_LABELS = {function TriggerIcon({ kind }: { kind: ChildConversationTurn['trigger']['kind'] }) {const Icon = kind === 'external_event' ? Radio : CornerDownRight;return (- <span className="flex size-6 items-center justify-center rounded-full bg-surface-tertiary text-text-secondary">- <Icon size={14} aria-hidden />- </span>+ <SystemEventIcon>+ <Icon size={14} />+ </SystemEventIcon>);}@@ -49,34 +53,25 @@ function ExternalEventTrigger({let body: ReactNode;if (details == null) {body = (- <div className="flex items-center gap-1.5 text-xs font-medium text-text-secondary">- <TriggerIcon kind="external_event" />- <span>{label}</span>+ <div className="flex items-center gap-2 py-1 text-sm text-text-secondary">+ <SystemEventHeader icon={<TriggerIcon kind="external_event" />} label={label} /></div>);} else {body = (<Collapsible open={expanded} onOpenChange={setExpanded}><CollapsibleTrigger asChild>- <Button- type="button"- variant="ghost"- className="h-auto min-h-6 w-full justify-start gap-1.5 px-0 text-left text-xs font-medium text-text-secondary hover:bg-transparent hover:text-text-primary"- >- <TriggerIcon kind="external_event" />- <span>{label}</span>- <span className="min-w-0 truncate font-normal">- {details.eventType} · {details.sourceType}- </span>- <span className="sr-only">{details.occurredAt}</span>- <ChevronDown- size={14}- aria-hidden- className={`ml-auto shrink-0 transition-transform ${expanded ? 'rotate-180' : ''}`}+ <Button type="button" variant="ghost" className={systemEventHeaderClasses}>+ <SystemEventHeader+ icon={<TriggerIcon kind="external_event" />}+ label={label}+ detail={`${details.eventType} · ${details.sourceType}`}+ expanded={expanded}/>+ <span className="sr-only">{details.occurredAt}</span></Button></CollapsibleTrigger>- <CollapsibleContent className="ml-8 border-l border-border-light py-1 pl-3 text-xs text-text-secondary">+ <CollapsibleContent className="pb-1 pt-0.5 text-xs text-text-secondary"><dl className="grid grid-cols-[auto_1fr] gap-x-3 gap-y-1"><dt>{localize('com_ui_subagent_event_type')}</dt><dd className="break-words text-text-primary">{details.eventType}</dd>@@ -107,6 +102,7 @@ function ExternalEventTrigger({ariaLabel={label}headerPrefix=""isCreatedByUser={true}+ systemLabel={localize('com_ui_system_event')}fullWidth={fullWidth}>{body}@@ -143,11 +139,11 @@ function TriggerMessage({ turn, fullWidth }: { turn: ChildConversationTurn; fullariaLabel={label}headerPrefix=""isCreatedByUser={true}+ systemLabel={localize('com_ui_system_event')}fullWidth={fullWidth}>- <div className="mb-1 flex items-center gap-1.5 text-xs font-medium text-text-secondary">- <TriggerIcon kind={turn.trigger.kind} />- <span>{label}</span>+ <div className="flex items-center gap-2 py-1 text-sm text-text-secondary">+ <SystemEventHeader icon={<TriggerIcon kind={turn.trigger.kind} />} label={label} /></div>{content.length > 0 && (<ContentPartsdiff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.jsonindex ae67d26eeb..f3d8c6eef8 100644--- a/client/src/locales/en/translation.json+++ b/client/src/locales/en/translation.json@@ -2585,6 +2585,7 @@"com_ui_support_contact_name": "Name","com_ui_support_contact_name_min_length": "Name must be at least {{minLength}} characters","com_ui_support_contact_name_placeholder": "Support contact name",+ "com_ui_system_event": "System","com_ui_table_error": "Table error","com_ui_table_error_description": "The table failed to load. Refresh the page or try again.","com_ui_teach_or_explain": "Learning",