mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-20 15:02:02 +00:00
🕓 style: Move the Queued-Message Hint Into a Hover Tooltip on the Clock Icon (#15706)
* 🕓 style: Move the Queued-Message Hint Into a Hover Tooltip on the Clock Icon "Sends when this response finishes" rendered as a caption row under the queued chips for as long as a run was pending, costing composer height for a single reassurance. The clock icon of each queued row now carries that sentence as a hover tooltip and as its accessible name, and the caption row is gone. Nothing else about the row changes: warning states keep their triangle, and the hint disappears with the run as before. * ⌨️ fix: Give the Queued-Hint Clock an Explicit Tab Stop and Focus Ring The tooltip anchor was already focusable through Ariakit's Focusable default, and opens on focus-visible, but nothing said so and no ring showed where focus was. Make the tab stop explicit, add the same focus-visible ring the row's buttons use, and prove the keyboard path with a test. The hover test now allows for Ariakit's show timer on a loaded CI shard, which is what failed the first run. Codex round 1 (P2) on #15706. * 🧪 test: Move the Pointer Between Coordinates Before Expecting the Queued Hint Tooltip Ariakit's hover detector treats a pointer as moving only when consecutive mousemove events differ in screen coordinates; its NODE_ENV=test shortcut does not apply under the CI runner's NODE_ENV, which is why the hover test passed locally and failed in the shard. Two moves at distinct coordinates make the test environment-independent; the keyboard test was already deterministic.
This commit is contained in:
parent
4b3a6eaf0e
commit
21c03b7c92
2 changed files with 68 additions and 30 deletions
|
|
@ -1,7 +1,7 @@
|
|||
import { memo, useMemo, useRef, useState, useCallback } from 'react';
|
||||
import { useAtomValue } from 'jotai';
|
||||
import { useRecoilValue } from 'recoil';
|
||||
import { useToastContext } from '@librechat/client';
|
||||
import { TooltipAnchor, useToastContext } from '@librechat/client';
|
||||
import {
|
||||
X,
|
||||
Zap,
|
||||
|
|
@ -77,6 +77,33 @@ function QuoteCount({ count, label }: { count: number; label: string }) {
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* The one fact a queued row needs to convey ("did my message vanish?" it did
|
||||
* not) rides the clock as a hover hint and its accessible name while a run is
|
||||
* pending, instead of a caption row that costs composer height at rest. The
|
||||
* anchor is a tab stop with a visible ring so keyboard users reach the same
|
||||
* hint: the tooltip opens on focus-visible as well as on hover.
|
||||
*/
|
||||
function QueuedIcon({ warning, hint }: { warning: boolean; hint?: string }) {
|
||||
if (warning) {
|
||||
return <TriangleAlert className="h-4 w-4 shrink-0 text-text-warning" aria-hidden="true" />;
|
||||
}
|
||||
if (!hint) {
|
||||
return <Clock className={cn('h-4 w-4 shrink-0', QUEUE_ICON)} aria-hidden="true" />;
|
||||
}
|
||||
return (
|
||||
<TooltipAnchor
|
||||
description={hint}
|
||||
role="img"
|
||||
aria-label={hint}
|
||||
tabIndex={0}
|
||||
className="flex shrink-0 cursor-help rounded-full focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-xheavy"
|
||||
>
|
||||
<Clock className={cn('h-4 w-4', QUEUE_ICON)} aria-hidden="true" />
|
||||
</TooltipAnchor>
|
||||
);
|
||||
}
|
||||
|
||||
function QueuedRow({
|
||||
message,
|
||||
steering,
|
||||
|
|
@ -209,11 +236,10 @@ function QueuedRow({
|
|||
|
||||
return (
|
||||
<div role="listitem" className={ROW_CLASS} data-testid="queued-message-row">
|
||||
{isRejected || isUnconfirmed || isIndeterminate ? (
|
||||
<TriangleAlert className="h-4 w-4 shrink-0 text-text-warning" aria-hidden="true" />
|
||||
) : (
|
||||
<Clock className={cn('h-4 w-4 shrink-0', QUEUE_ICON)} aria-hidden="true" />
|
||||
)}
|
||||
<QueuedIcon
|
||||
warning={isRejected || isUnconfirmed || isIndeterminate}
|
||||
hint={steering.duringRunActive ? localize('com_ui_steer_queued_info') : undefined}
|
||||
/>
|
||||
<span className="min-w-0 flex-1 truncate" title={message.text}>
|
||||
{message.text}
|
||||
</span>
|
||||
|
|
@ -463,8 +489,6 @@ function PendingSteerChips({
|
|||
|
||||
return (
|
||||
<div className="flex flex-col gap-1.5 px-2 pt-2" data-testid="pending-steer-chips">
|
||||
{/* The list owns only listitem rows; the caption lives beside it so the
|
||||
* ARIA list structure stays valid for assistive tech. */}
|
||||
<div
|
||||
className="flex flex-col gap-1.5"
|
||||
role="list"
|
||||
|
|
@ -490,14 +514,6 @@ function PendingSteerChips({
|
|||
/>
|
||||
))}
|
||||
</div>
|
||||
{/* One caption for the whole queued group: the single fact users need
|
||||
* ("did my message vanish?" it did not), shown only while a run is
|
||||
* actually pending — after it, rows drain or convert on their own. */}
|
||||
{queued.length > 0 && steering.duringRunActive && (
|
||||
<div className="px-3 text-xs text-text-secondary" data-testid="queued-caption">
|
||||
{localize('com_ui_steer_queued_info')}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ jest.mock('@librechat/client', () => {
|
|||
const { createSteerMorphIconMock } = jest.requireActual('~/../test/mockMorphIcon');
|
||||
return {
|
||||
useToastContext: () => ({ showToast: mockShowToast }),
|
||||
TooltipAnchor: jest.requireActual('@librechat/client').TooltipAnchor,
|
||||
MorphIcon: createSteerMorphIconMock(),
|
||||
};
|
||||
});
|
||||
|
|
@ -653,34 +654,55 @@ describe('PendingSteerChips — queued interrupt-now', () => {
|
|||
);
|
||||
});
|
||||
|
||||
describe('PendingSteerChips — queued caption', () => {
|
||||
describe('PendingSteerChips — queued hint', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
});
|
||||
|
||||
const queuedItem = { id: 'q1', text: 'follow up later', createdAt: 1 };
|
||||
const hintName = 'com_ui_steer_queued_info';
|
||||
|
||||
it('explains when queued messages will send while a run is active', () => {
|
||||
it('explains when a queued message will send as a hover hint on its clock icon', async () => {
|
||||
renderChips([queuedItem], { steering: { duringRunActive: true } });
|
||||
expect(screen.getByTestId('queued-caption')).toHaveTextContent('com_ui_steer_queued_info');
|
||||
const clock = screen.getByRole('img', { name: hintName });
|
||||
fireEvent.mouseEnter(clock);
|
||||
/** Ariakit only counts a pointer as moving when consecutive events differ
|
||||
* in screen coordinates (its NODE_ENV=test shortcut is off under CI's
|
||||
* NODE_ENV), and it opens the tooltip on a timer after that. */
|
||||
fireEvent.mouseMove(clock, { screenX: 10, screenY: 10 });
|
||||
fireEvent.mouseMove(clock, { screenX: 20, screenY: 20 });
|
||||
const tooltip = await screen.findByRole('tooltip', {}, { timeout: 3000 });
|
||||
expect(tooltip).toHaveTextContent(hintName);
|
||||
});
|
||||
|
||||
it('renders one caption for the whole group, not one per row', () => {
|
||||
it('reaches the same hint from the keyboard: the clock is a tab stop and opens on focus', async () => {
|
||||
const user = userEvent.setup();
|
||||
renderChips([queuedItem], { steering: { duringRunActive: true } });
|
||||
const clock = screen.getByRole('img', { name: hintName });
|
||||
await user.tab();
|
||||
expect(clock).toHaveFocus();
|
||||
const tooltip = await screen.findByRole('tooltip');
|
||||
expect(tooltip).toHaveTextContent(hintName);
|
||||
});
|
||||
|
||||
it('renders no always-visible caption, so the hint costs no composer height at rest', () => {
|
||||
renderChips([queuedItem], { steering: { duringRunActive: true } });
|
||||
expect(screen.queryByText(hintName)).toBeNull();
|
||||
expect(screen.queryByRole('tooltip')).toBeNull();
|
||||
});
|
||||
|
||||
it('keeps the hint inside each queued row as its icon, never as a stray child of the list', () => {
|
||||
renderChips([queuedItem, { id: 'q2', text: 'and another', createdAt: 2 }], {
|
||||
steering: { duringRunActive: true },
|
||||
});
|
||||
expect(screen.getAllByTestId('queued-caption')).toHaveLength(1);
|
||||
const rows = screen.getAllByTestId('queued-message-row');
|
||||
const clocks = screen.getAllByRole('img', { name: hintName });
|
||||
expect(clocks).toHaveLength(2);
|
||||
rows.forEach((row, index) => expect(row).toContainElement(clocks[index]));
|
||||
});
|
||||
|
||||
it('keeps the caption beside the ARIA list, never as a non-listitem child of it', () => {
|
||||
renderChips([queuedItem], { steering: { duringRunActive: true } });
|
||||
const list = screen.getByRole('list', { name: 'com_ui_queued_messages' });
|
||||
expect(list).not.toContainElement(screen.getByTestId('queued-caption'));
|
||||
expect(list).toContainElement(screen.getByTestId('queued-message-row'));
|
||||
});
|
||||
|
||||
it('omits the caption once the run is over, when rows drain on their own terms', () => {
|
||||
it('omits the hint once the run is over, when rows drain on their own terms', () => {
|
||||
renderChips([queuedItem], { steering: { duringRunActive: false } });
|
||||
expect(screen.queryByTestId('queued-caption')).toBeNull();
|
||||
expect(screen.queryByRole('img', { name: hintName })).toBeNull();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue