⛴️ fix: Align Canary Timing Types and CI Formatting

(cherry picked from commit 5bd84bb627)

Original-PR: https://github.com/LibreChat-AI/LibreChat/pull/16457
This commit is contained in:
Lia 2026-09-30 01:41:15 +00:00
parent 70bf641e50
commit 206ef476f6
13 changed files with 186 additions and 36 deletions

View file

@ -86,7 +86,7 @@ const TwoFactorScreen: React.FC = React.memo(() => {
return (
<div className="mt-4">
<form onSubmit={handleSubmit(onSubmit)}>
<Label className="text-text-primary flex justify-center break-keep text-center text-sm">
<Label className="text-text-primary flex justify-center text-center text-sm break-keep">
{localize('com_auth_two_factor')}
</Label>
{!useBackup && (

View file

@ -53,7 +53,7 @@ const InterruptSteerButton = React.memo((props: InterruptSteerButtonProps) => {
disabled={disabled}
onClick={onClick}
className={cn(
'size-theme-control rounded-theme-control-round border-border-light flex items-center justify-center border',
'border-border-light size-theme-control rounded-theme-control-round flex items-center justify-center border',
'text-text-secondary duration-theme-normal transition-colors',
'hover:bg-surface-composer-hover hover:text-text-primary',
'focus-visible:ring-border-xheavy focus-visible:ring-2 focus-visible:outline-hidden',

View file

@ -483,7 +483,7 @@ function FailedPeek({
type="button"
className={cn(
TOOL_ROW_CLASSES,
'w-full pl-6 text-left text-text-secondary hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-border-heavy',
'text-text-secondary hover:text-text-primary focus-visible:ring-border-heavy w-full pl-6 text-left focus-visible:ring-2 focus-visible:outline-none focus-visible:ring-inset',
)}
onClick={onReveal}
data-testid="activity-phase-failed-peek"
@ -492,7 +492,7 @@ function FailedPeek({
<TriangleAlert size={14} />
</span>
<span className="tool-status-text flex min-w-0 items-center gap-2">
<span className="min-w-0 max-w-full shrink-0 truncate font-medium text-status-error">
<span className="text-status-error max-w-full min-w-0 shrink-0 truncate font-medium">
{first.text}
</span>
{first.detail !== '' && (
@ -808,7 +808,12 @@ export default function ActivityPhaseGroup({
* keyboard users with no focus indicator. The ghost variant
* supplies it today; stating it here keeps the requirement with
* the element that depends on it. */
className="text-text-secondary hover:text-text-primary focus-visible:ring-border-heavy flex h-auto min-h-7 w-full items-center justify-start gap-2 rounded-none bg-transparent p-0 py-1 text-left font-medium hover:bg-transparent focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:ring-inset"
className={cn(
'text-text-secondary hover:text-text-primary focus-visible:ring-border-heavy flex h-auto min-h-7 min-w-0 flex-1 items-center justify-start gap-2 rounded-none bg-transparent p-0 py-1 text-left font-medium hover:bg-transparent focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:outline-none focus-visible:ring-inset',
/** The open card's title: the one semibold, primary-colour line
* in the fold, so the rows under it read as its contents. */
isExpanded && 'text-text-primary font-semibold',
)}
onClick={handleToggle}
aria-expanded={isExpanded}
aria-controls={panelId}

View file

@ -198,7 +198,7 @@ const Part = memo(function Part({
const failed = part.status === 'failed' || part.status === 'partial';
return (
<div
className={`my-1 break-words pl-1 text-sm italic ${failed ? 'text-text-warning' : 'text-text-secondary'}`}
className={`my-1 pl-1 text-sm break-words italic ${failed ? 'text-text-warning' : 'text-text-secondary'}`}
>
{display}
</div>

View file

@ -213,12 +213,24 @@ export default function ProgressText({
</span>
)}
{/* The label names the card and stays whole; a subtitle can be
arbitrary authored text (a question, a server name), so it takes
essentially all of the shrink and ellipsizes instead of pushing
the line past the message column. */}
{subtitle && (
<span className="text-text-secondary min-w-0 shrink-[100] truncate font-normal">
{subtitle}
arbitrary authored text (a question, an error line), so it takes
ALL of the shrink and ellipsizes instead of pushing the line past
the message column. All, not most: a weighted share left the label
a fraction of a pixel short of its text, and that fraction is
enough for `truncate` to swap its last letters for an ellipsis.
The pair sits in its own shrinking box so the verdict, the
duration and the chevron after it never lose width: the box gives
up the subtitle first, and a label wider than the box truncates at
the box (`max-w-full`), not past the row. */}
<span className="flex min-w-0 items-center gap-2">
<span
className={cn(
showShimmer ? 'shimmer' : '',
'max-w-full min-w-0 truncate font-medium',
subtitle && 'shrink-0',
)}
>
{text}
</span>
{subtitle && (
<span className="min-w-0 shrink truncate font-normal text-text-secondary">

View file

@ -433,7 +433,7 @@ export default function ToolCall({
</div>
{showOAuth && (
<div className="flex w-full flex-col gap-2.5">
<div className="mb-1 mt-2">
<div className="mt-2 mb-1">
<Button
className="inline-flex items-center justify-center rounded-xl px-4 py-2 text-sm font-medium"
variant="default"

View file

@ -515,25 +515,66 @@ export default function ToolCallGroup({
return (
<div className="mt-1 mb-2" ref={rootRef}>
<Button
variant="ghost"
type="button"
className="text-text-secondary hover:text-text-secondary focus-visible:ring-border-heavy inline-flex h-auto w-full items-center justify-start gap-2 rounded-none bg-transparent p-0 py-1 hover:bg-transparent focus-visible:ring-2 focus-visible:ring-offset-0"
onClick={handleToggle}
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". */
<div
<div className="flex w-full items-center gap-2">
<button
type="button"
className={cn(
'text-text-secondary hover:text-text-secondary focus-visible:ring-border-heavy inline-flex h-auto min-w-0 flex-1 items-center justify-start gap-2 rounded-none bg-transparent p-0 py-1 hover:bg-transparent focus-visible:ring-2 focus-visible:ring-offset-0 focus-visible:outline-none',
/** An open header is the title of the rows under it, so it is the
* one line in the fold set in the primary colour. */
isExpanded && 'text-text-primary hover:text-text-primary',
)}
onClick={handleToggle}
aria-expanded={isExpanded}
aria-label={groupAriaLabel}
>
{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,
'text-text-secondary',
isGroupLive && 'text-text-primary animate-pulse',
)}
aria-hidden="true"
>
<CategoryIcon size={14} />
</div>
) : (
<div className={ROW_GLYPH_SLOT} aria-hidden="true">
<StackedToolIcons
toolNames={iconToolNames}
mcpIconMap={mcpIconMap}
maxIcons={4}
sourceDomains={sourceDomains}
status={iconStatus}
isAnimating={isGroupLive}
/>
</div>
)}
<span
className={cn(
ROW_GLYPH_SLOT,
'text-text-secondary',
isGroupLive && 'text-text-primary animate-pulse',
'tool-status-text min-w-0 truncate font-medium',
activityFailed && 'text-text-warning',
)}
role="status"
title={groupLabel}
>
{groupLabel}
</span>
{visibleGroupDetail && (
<span
className="text-text-secondary max-w-[40%] min-w-0 truncate text-xs font-normal"
title={visibleGroupDetail}
>
· {visibleGroupDetail}
</span>
)}
<ChevronDown
className={cn(
'text-text-secondary size-4 shrink-0 transition-transform duration-200 ease-out',
isExpanded && 'rotate-180',
)}
aria-hidden="true"
/>

View file

@ -127,7 +127,7 @@ export function FailedRevealPill({
<button
type="button"
className={cn(
'bg-status-error-subtle text-status-error inline-flex h-5 shrink-0 items-center gap-1 rounded-full border border-transparent px-2 text-xs font-semibold leading-none',
'bg-status-error-subtle text-status-error inline-flex h-5 shrink-0 items-center gap-1 rounded-full border border-transparent px-2 text-xs leading-none font-semibold',
'hover:border-status-error-border focus-visible:border-status-error focus-visible:outline-none',
className,
)}

View file

@ -162,7 +162,7 @@ export default function MCPToolItem({
expanded ? 'opacity-100' : 'opacity-0',
)}
>
<p className="text-text-secondary max-h-44 overflow-y-auto whitespace-pre-wrap text-xs leading-relaxed">
<p className="text-text-secondary max-h-44 overflow-y-auto text-xs leading-relaxed whitespace-pre-wrap">
{description || localize('com_ui_mcp_no_description')}
</p>
</div>

View file

@ -440,7 +440,7 @@ export default function McpSection({ item }: Props) {
return (
<div className="flex flex-col gap-5">
{item.description && (
<p className="text-text-secondary max-h-40 overflow-y-auto whitespace-pre-wrap text-sm leading-relaxed">
<p className="text-text-secondary max-h-40 overflow-y-auto text-sm leading-relaxed whitespace-pre-wrap">
{item.description}
</p>
)}
@ -489,7 +489,7 @@ export default function McpSection({ item }: Props) {
<div className="flex flex-col gap-2">
<div className="flex min-h-7 items-center justify-between">
<span className="text-text-secondary text-[11px] font-medium uppercase tracking-wide">
<span className="text-text-secondary text-[11px] font-medium tracking-wide uppercase">
{localize('com_ui_tools_mcp_tools_section')}
</span>
{(hasTools || runtimeToolsAvailable) && (

View file

@ -457,6 +457,90 @@ describe('steps', () => {
expect(replayed.message.content).toEqual(closed.content);
});
it('retains existing timing metadata when a delta and closure omit new timing', () => {
const stamps = { toolPreparationStartedAt: 1_000, toolDispatchedAt: 1_100 };
const opened = applyToolCallsStep(createResponse(), search, 0, () => stamps).message;
const streamed = applyToolCallDelta(
opened,
search,
argsDelta(search.id, '{}'),
'call-1',
0,
) as TMessage;
const closed = applyRunStepClosed(
streamed,
search,
{
id: search.id,
index: 1,
type: StepTypes.TOOL_CALLS,
status: 'completed',
created_at: 1_000,
closed_at: 1_250,
},
0,
);
expect(closed?.content?.[1]).toMatchObject({
tool_call: {
...stamps,
args: '{}',
runStepStatus: 'completed',
runStepDurationMs: 250,
runStepClosedAt: 1_250,
},
});
expect(closed?.content?.[1]).not.toHaveProperty('tool_call.toolPreparationDurationMs');
expect(closed?.content?.[1]).not.toHaveProperty('tool_call.toolExecutionDurationMs');
});
it('preserves tool timing through completion and settled-step replay', () => {
const getTiming = () => ({ toolPreparationStartedAt: 1_000, toolDispatchedAt: 1_100 });
const opened = applyToolCallsStep(createResponse(), search, 0, getTiming).message;
const streamed = applyToolCallDelta(
opened,
search,
argsDelta(search.id, '{}'),
'call-1',
0,
getTiming,
) as TMessage;
const completed = applyToolCallCompleted(
streamed,
search,
toolEnd(search.id, { id: 'call-1', name: 'search', output: 'done' }),
0,
);
const closed = applyRunStepClosed(
completed,
search,
{
id: search.id,
index: 1,
type: StepTypes.TOOL_CALLS,
status: 'completed',
created_at: 1_000,
closed_at: 1_250,
},
0,
{ toolPreparationDurationMs: 100, toolExecutionDurationMs: 150 },
) as TMessage;
expect(closed.content?.[1]).toMatchObject({
tool_call: {
args: '{}',
output: 'done',
progress: 1,
toolPreparationStartedAt: 1_000,
toolDispatchedAt: 1_100,
toolPreparationDurationMs: 100,
toolExecutionDurationMs: 150,
runStepDurationMs: 250,
},
});
expect(applyToolCallsStep(closed, search, 0, getTiming).message.content).toEqual(
closed.content,
);
});
it('keeps streamed args when the completion omits them', () => {
const opened = applyToolCallsStep(createResponse(), search, 0).message;
const streamed = applyToolCallDelta(opened, search, argsDelta(search.id, '{}'), 'call-1', 0);

View file

@ -299,7 +299,9 @@ export function updateContent(
};
} else if (contentType === ContentTypes.TOOL_CALL && 'tool_call' in contentPart) {
const existingContent = updatedContent[index] as Agents.ToolCallContent | undefined;
const existingToolCall = existingContent?.tool_call;
const existingToolCall = existingContent?.tool_call as
| (Agents.ToolCall & PartMetadata)
| undefined;
const toolCallArgs = (contentPart.tool_call as Agents.ToolCall).args;
/** When args are a valid object, they are likely already invoked */
let args =

View file

@ -2,6 +2,11 @@ import { StepTypes, ContentTypes, getRunStepDurationMs } from 'librechat-data-pr
import type { Agents, TMessage, PartMetadata } from 'librechat-data-provider';
import { getStepMetadata, updateContent } from './content';
type ToolTimingLookup = (
callId: string,
index?: number,
) => Pick<PartMetadata, 'toolPreparationStartedAt' | 'toolDispatchedAt'>;
/** Mirrors `SKILL_FILE_PREFIX` in `@librechat/api` file-authoring handlers. */
const SKILL_FILE_PREFIX = 'skills/';
const FILE_AUTHORING_TOOLS = new Set(['create_file', 'edit_file']);
@ -150,6 +155,7 @@ export function applyRunStepClosed(
runStep: Agents.RunStep,
closed: Agents.RunStepClosedEvent,
editPrefixOffset: number,
timing: Pick<PartMetadata, 'toolPreparationDurationMs' | 'toolExecutionDurationMs'> = {},
): TMessage | undefined {
const index = runStep.index + editPrefixOffset;
const existing = message.content?.[index];