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

🧑‍🤝‍🧑 style: Seat the Live Multiplier Beside Its Status Line (#16220)

lia-by-librechat[bot]a9d63d0fe29e
diff --git a/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx b/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx
index 289b68d36d..15118d14f1 100644
--- a/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx
+++ b/client/src/components/Chat/Messages/Content/ActivityPhaseGroup.tsx
@@ -123,6 +123,7 @@ const PhaseLabel = memo(function PhaseLabel({
failed,
source,
live = false,
+ grow = true,
lineId,
previewRef,
}: {
@@ -134,6 +135,10 @@ const PhaseLabel = memo(function PhaseLabel({
* in would read as flicker — so an unchanged source extends in place. */
source?: string;
live?: boolean;
+ /** Claim the row's free space, the default. Cleared when something has to
+ * sit immediately after the text — the box then measures the line itself,
+ * so its neighbour reads as part of it instead of drifting to the margin. */
+ grow?: boolean;
/** Id for the current line, so a live disclosure can be named by it alone. */
lineId?: string;
previewRef?: RefObject<HTMLSpanElement>;
@@ -171,7 +176,10 @@ const PhaseLabel = memo(function PhaseLabel({
return (
<span
- className="tool-status-text relative block min-w-0 flex-1 overflow-hidden text-left"
+ className={cn(
+ 'tool-status-text relative block min-w-0 overflow-hidden text-left',
+ grow && 'flex-1',
+ )}
title={text}
>
{lines.retired != null && (
@@ -264,6 +272,7 @@ function LivePhaseHeader({
parts,
animate,
lineId,
+ comboId,
detailId,
attachments,
onAnnounce,
@@ -271,6 +280,7 @@ function LivePhaseHeader({
parts: ReadonlyArray<TMessageContentParts | undefined>;
animate: boolean;
lineId: string;
+ comboId: string;
detailId: string;
attachments?: TAttachment[];
onAnnounce: (text: string) => void;
@@ -299,6 +309,10 @@ function LivePhaseHeader({
[text, source, activity.comboCount],
);
const previewRef = useRef<HTMLSpanElement>(null);
+ /** The full width the line may occupy, which is the flex track rather than
+ * the label box: the box shrinks to its text whenever the multiplier rides
+ * beside it, and measuring that would call every line full. */
+ const lineRowRef = useRef<HTMLSpanElement>(null);
const [isPreviewFull, setIsPreviewFull] = useState(false);
const painted = useThrottledValue(
line,
@@ -306,7 +320,7 @@ function LivePhaseHeader({
);
const measurePreview = useCallback(() => {
const preview = previewRef.current;
- const width = preview?.parentElement?.clientWidth ?? 0;
+ const width = lineRowRef.current?.clientWidth ?? 0;
setIsPreviewFull(width > 0 && (preview?.scrollWidth ?? 0) >= width);
}, []);
@@ -315,7 +329,7 @@ function LivePhaseHeader({
useLayoutEffect(measurePreview, [measurePreview, painted.text, painted.source]);
useLayoutEffect(() => {
const preview = previewRef.current;
- const row = preview?.parentElement;
+ const row = lineRowRef.current;
if (!preview || !row || typeof ResizeObserver === 'undefined') {
return;
}
@@ -391,31 +405,44 @@ function LivePhaseHeader({
/>
</span>
)}
- <PhaseLabel
- text={painted.text}
- source={painted.source}
- failed={false}
- animate={animate}
- live
- lineId={lineId}
- previewRef={previewRef}
- />
- {(combo || detail) && (
+ {/** The multiplier counts the line it is printed next to, so it travels
+ * with that line instead of sitting out at the row's right edge beside
+ * the chevron, where it read as a property of the row. `Create File ×2`
+ * in the unfolded group is the same phrase in the same order. It is a
+ * separate element rather than part of the line's text so the
+ * disclosure's name keeps a space before it and the ticker still
+ * animates one sentence at a time. */}
+ <span className="flex min-w-0 flex-1 items-center gap-1.5" ref={lineRowRef}>
+ <PhaseLabel
+ text={painted.text}
+ source={painted.source}
+ failed={false}
+ animate={animate}
+ live
+ grow={combo === ''}
+ lineId={lineId}
+ previewRef={previewRef}
+ />
+ {combo !== '' && (
+ <span
+ id={comboId}
+ className="shrink-0 text-xs font-normal text-text-secondary"
+ data-testid="live-phase-combo"
+ >
+ {combo}
+ </span>
+ )}
+ </span>
+ {detail !== '' && (
<span
id={detailId}
- className={cn(
- 'shrink-0 text-xs font-normal',
- detail ? 'text-text-warning' : 'text-text-secondary',
- )}
- data-testid={detail ? 'live-phase-outcome' : 'live-phase-combo'}
+ className="shrink-0 text-xs font-normal text-text-warning"
+ data-testid="live-phase-outcome"
>
- {combo && <span>{combo}</span>}
- {detail && (
- <>
- <span className={cn(combo ? 'mx-1' : 'mr-1', 'text-text-secondary')}>·</span>
- <span>{detail}</span>
- </>
- )}
+ {/** The verdict is the span's, not the newest line's, so it keeps its
+ * own separator from whatever the row happens to be saying. */}
+ <span className="mr-1 text-text-secondary">·</span>
+ <span>{detail}</span>
</span>
)}
</>
@@ -482,6 +509,7 @@ export default function ActivityPhaseGroup({
const rootRef = useRef<HTMLDivElement | null>(null);
const panelId = useId();
const lineId = useId();
+ const comboId = useId();
const detailId = useId();
/** One polite region for the card's whole life. It sits outside the button,
* so it never joins the disclosure's name, and it outlives the live header:
@@ -657,13 +685,16 @@ export default function ActivityPhaseGroup({
* the previous line, and `sr-only` text still counts toward a
* button's computed name. */
aria-label={isLive ? undefined : label}
- aria-labelledby={isLive ? `${lineId} ${detailId}` : undefined}
+ /** Unresolved ids are skipped, so one list covers a row with no
+ * multiplier and no outcome note as well as a row with both. */
+ aria-labelledby={isLive ? `${lineId} ${comboId} ${detailId}` : undefined}
>
{isLive ? (
<LivePhaseHeader
parts={liveParts}
animate={smoothStreaming}
lineId={lineId}
+ comboId={comboId}
detailId={detailId}
attachments={attachments}
onAnnounce={setAnnouncement}
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 9067e1f748..255644c95a 100644
--- a/client/src/components/Chat/Messages/Content/__tests__/LiveParity.test.tsx
+++ b/client/src/components/Chat/Messages/Content/__tests__/LiveParity.test.tsx
@@ -335,6 +335,63 @@ describe('live fold parity with the cards it hides', () => {
expect(screen.queryByTestId('live-phase-combo')).toBeNull();
});
+ it('prints the multiplier beside the line it counts, not at the row edge', () => {
+ mount(
+ [
+ toPart({ name: 'create_file', output: 'created' }, 'first'),
+ toPart({ name: 'create_file', output: '' }, 'second'),
+ ],
+ undefined,
+ true,
+ );
+ const header = within(screen.getByTestId('activity-phase-card')).getAllByRole('button')[0];
+ const [lineId] = (header.getAttribute('aria-labelledby') ?? '').split(' ');
+ const line = document.getElementById(lineId);
+ const combo = screen.getByTestId('live-phase-combo');
+
+ expect(line).not.toBeNull();
+ /** One flex track with the line, directly after the box holding it: the
+ * count belongs to that line, so nothing may sit between them and the
+ * row's free space has to open up after the pair, not inside it. */
+ expect(combo.parentElement).toContainElement(line);
+ expect(combo.previousElementSibling).toContainElement(line);
+ expect(combo.previousElementSibling?.className).not.toContain('flex-1');
+ expect(combo.nextElementSibling).toBeNull();
+ });
+
+ it('keeps the whole row for a line with no multiplier', () => {
+ /** The reasoning preview decides whether it may stream freely by comparing
+ * itself to the row, so a lone line must still be measured full width. */
+ mount([toPart({ name: 'create_file', output: '' }, 'only')], undefined, true);
+ const header = within(screen.getByTestId('activity-phase-card')).getAllByRole('button')[0];
+ const [lineId] = (header.getAttribute('aria-labelledby') ?? '').split(' ');
+
+ expect(screen.queryByTestId('live-phase-combo')).toBeNull();
+ expect(document.getElementById(lineId)?.parentElement?.className).toContain('flex-1');
+ });
+
+ it('keeps the span verdict after the multiplier', () => {
+ mount(
+ [
+ toPart({ name: 'create_file', output: 'created', runStepStatus: 'failed' }, 'first'),
+ toPart({ name: 'create_file', output: '' }, 'second'),
+ ],
+ undefined,
+ true,
+ );
+ const combo = screen.getByTestId('live-phase-combo');
+ const outcome = screen.getByTestId('live-phase-outcome');
+
+ expect(combo).toHaveTextContent('×2');
+ expect(outcome).toHaveTextContent('1 failed');
+ /** The count reads with the line; the verdict stays where the row ends. */
+ expect(combo.compareDocumentPosition(outcome) & Node.DOCUMENT_POSITION_FOLLOWING).toBeTruthy();
+ expect(combo.parentElement).not.toContainElement(outcome);
+ expect(
+ within(screen.getByTestId('activity-phase-card')).getAllByRole('button')[0],
+ ).toHaveAccessibleName(/×2 · 1 failed$/);
+ });
+
it('changes the multiplier with the throttled status line', () => {
jest.useFakeTimers();
const first = toPart(