mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-17 13:33:45 +00:00
📐 style: Set the Reasoning Header at the Shared Row Scale (#16391)
The standalone thinking disclosure and its non-interactive marker were the one activity row sized to the reader's body text (`fontSize`, 16px at the default), while tool calls, grouped thoughts and phase summaries all sit at `tool-status-text` (0.9× the markdown size, 14.4px). The same thought read at two sizes depending on which surface held it, and at larger settings the header outgrew the message heading beside it. Both headers now take `tool-status-text` and the medium weight every other row label carries. The thought body keeps the body size, as prose should.
This commit is contained in:
parent
a047548fa7
commit
cd405e66fb
2 changed files with 59 additions and 12 deletions
|
|
@ -97,7 +97,6 @@ export const ThinkingButton = memo(
|
|||
shimmerLabel?: boolean;
|
||||
}) => {
|
||||
const localize = useLocalize();
|
||||
const fontSize = useAtomValue(fontSizeAtom);
|
||||
|
||||
const [isCopied, setIsCopied] = useState(false);
|
||||
|
||||
|
|
@ -116,10 +115,11 @@ export const ThinkingButton = memo(
|
|||
onClick={onClick}
|
||||
aria-expanded={isExpanded}
|
||||
aria-controls={contentId}
|
||||
className={cn(
|
||||
'group/button flex flex-1 items-center justify-start rounded-lg pr-10 leading-[18px]',
|
||||
fontSize,
|
||||
)}
|
||||
/** `tool-status-text`, not the reader's body size: this header is a
|
||||
* row in the same list as tool calls, grouped thoughts and phase
|
||||
* summaries, all set at that scale. Sized to the body it read as a
|
||||
* second, larger kind of row beside them. */
|
||||
className="group/button tool-status-text flex flex-1 items-center justify-start rounded-lg pr-10"
|
||||
>
|
||||
<span className={cn(ROW_GLYPH_SLOT, 'relative mr-2')}>
|
||||
<Lightbulb
|
||||
|
|
@ -156,7 +156,7 @@ export const ThinkingButton = memo(
|
|||
<span
|
||||
key={animateLabel ? label : undefined}
|
||||
className={cn(
|
||||
'min-w-0 truncate text-left',
|
||||
'min-w-0 truncate text-left font-medium',
|
||||
shimmerLabel && !animateLabel && 'shimmer',
|
||||
animateLabel &&
|
||||
'duration-300 ease-out animate-in fade-in-0 slide-in-from-bottom-1 motion-reduce:animate-none',
|
||||
|
|
@ -195,17 +195,13 @@ export const ThinkingButton = memo(
|
|||
* presentation identical across surfaces without offering an empty disclosure.
|
||||
*/
|
||||
export const ThinkingLabel = memo(({ label, title }: { label: string; title?: string }) => {
|
||||
const fontSize = useAtomValue(fontSizeAtom);
|
||||
return (
|
||||
<div className="mb-2 pb-2 pt-2">
|
||||
<div
|
||||
className={cn('flex w-full items-center justify-start leading-[18px]', fontSize)}
|
||||
title={title}
|
||||
>
|
||||
<div className="tool-status-text flex w-full items-center justify-start" title={title}>
|
||||
<span className={cn(ROW_GLYPH_SLOT, 'relative mr-2')}>
|
||||
<Lightbulb className="icon-sm text-text-secondary" aria-hidden="true" />
|
||||
</span>
|
||||
<span className="min-w-0 truncate text-left text-text-secondary">{label}</span>
|
||||
<span className="min-w-0 truncate text-left font-medium text-text-secondary">{label}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,51 @@
|
|||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { ThinkingButton, ThinkingLabel } from '../Thinking';
|
||||
|
||||
jest.mock('~/hooks', () => ({
|
||||
useLocalize: () => (key: string) => key,
|
||||
useExpandCollapse: () => ({ style: {}, ref: { current: null } }),
|
||||
}));
|
||||
|
||||
jest.mock('~/store/fontSize', () => ({
|
||||
fontSizeAtom: { toString: () => 'fontSizeAtom' },
|
||||
}));
|
||||
|
||||
jest.mock('jotai', () => ({
|
||||
...jest.requireActual('jotai'),
|
||||
useAtomValue: () => 'text-xl',
|
||||
}));
|
||||
|
||||
jest.mock('~/components/Messages/Content/CopyButton', () => ({
|
||||
__esModule: true,
|
||||
default: () => <button type="button" data-testid="copy-thoughts" />,
|
||||
}));
|
||||
|
||||
/** Every activity row — a tool call, a grouped thought, a phase summary — is
|
||||
* set at `tool-status-text`. A reasoning header sized to the reader's body
|
||||
* text instead was the one row that grew with that setting, so the same
|
||||
* thought read at two sizes depending on which surface held it. */
|
||||
describe('reasoning header rows', () => {
|
||||
it('sets the thinking disclosure at the shared row scale, not the body size', () => {
|
||||
render(
|
||||
<ThinkingButton
|
||||
isExpanded={false}
|
||||
onClick={() => {}}
|
||||
label="Reframing the analysis"
|
||||
contentId="thoughts"
|
||||
/>,
|
||||
);
|
||||
const button = screen.getByRole('button', { name: 'Reframing the analysis' });
|
||||
expect(button).toHaveClass('tool-status-text');
|
||||
expect(button).not.toHaveClass('text-xl');
|
||||
expect(screen.getByText('Reframing the analysis')).toHaveClass('font-medium');
|
||||
});
|
||||
|
||||
it('sets the non-interactive marker the same way', () => {
|
||||
render(<ThinkingLabel label="Thoughts" />);
|
||||
const label = screen.getByText('Thoughts');
|
||||
expect(label.parentElement).toHaveClass('tool-status-text');
|
||||
expect(label.parentElement).not.toHaveClass('text-xl');
|
||||
expect(label).toHaveClass('font-medium');
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue