mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-20 06:51:59 +00:00
👋 fix: Drop the Agent Icon From the Greeting Welcome Heading (#18535)
* fix: Drop the Agent Icon From the Greeting Welcome Heading * docs: Describe the Greeting Heading Without Its Icon in the Example Config * test: Cover the Greeting Heading Without the Agent Icon in E2E Scenarios
This commit is contained in:
parent
f7ae4c8e10
commit
ca0f8df4fe
5 changed files with 137 additions and 40 deletions
|
|
@ -80,10 +80,10 @@ export default function Landing({ centerFormOnLanding }: { centerFormOnLanding:
|
|||
|
||||
const brandedSpecLabel = modelSpec?.showOnLanding ? modelSpec.label : '';
|
||||
const brandedSpecDescription = (modelSpec?.showOnLanding && modelSpec.description) || '';
|
||||
const name =
|
||||
isTemporary || startupConfig?.interface?.landingHeading === 'greeting'
|
||||
? ''
|
||||
: (entity?.name ?? brandedSpecLabel);
|
||||
const isGreetingHeading = startupConfig?.interface?.landingHeading === 'greeting';
|
||||
/** Greeting mode drops the entity icon: the header selector already shows it. */
|
||||
const showIcon = isTemporary || !isGreetingHeading;
|
||||
const name = isTemporary || isGreetingHeading ? '' : (entity?.name ?? brandedSpecLabel);
|
||||
const description = isTemporary
|
||||
? localize('com_ui_temporary_description')
|
||||
: ((entity?.description || brandedSpecDescription || conversation?.greeting) ?? '');
|
||||
|
|
@ -169,35 +169,39 @@ export default function Landing({ centerFormOnLanding }: { centerFormOnLanding:
|
|||
<div
|
||||
className={`flex ${textHasMultipleLines ? 'flex-col' : 'flex-col md:flex-row'} items-center justify-center gap-2`}
|
||||
>
|
||||
<div className={`relative size-10 justify-center ${textHasMultipleLines ? 'mb-2' : ''}`}>
|
||||
<div className="avatar-stroke size-full rounded-full dark:after:shadow-none">
|
||||
{isTemporary ? (
|
||||
<div className={containerClassName}>
|
||||
<HatGlasses className="text-text-primary h-2/3 w-2/3" aria-hidden="true" />
|
||||
</div>
|
||||
) : (
|
||||
<ConvoIcon
|
||||
agentsMap={agentsMap}
|
||||
assistantMap={assistantMap}
|
||||
conversation={conversation}
|
||||
endpointsConfig={endpointsConfig}
|
||||
containerClassName={containerClassName}
|
||||
context="landing"
|
||||
className="text-text-primary h-2/3 w-2/3"
|
||||
size={41}
|
||||
/>
|
||||
{showIcon && (
|
||||
<div
|
||||
className={`relative size-10 justify-center ${textHasMultipleLines ? 'mb-2' : ''}`}
|
||||
>
|
||||
<div className="avatar-stroke size-full rounded-full dark:after:shadow-none">
|
||||
{isTemporary ? (
|
||||
<div className={containerClassName}>
|
||||
<HatGlasses className="text-text-primary h-2/3 w-2/3" aria-hidden="true" />
|
||||
</div>
|
||||
) : (
|
||||
<ConvoIcon
|
||||
agentsMap={agentsMap}
|
||||
assistantMap={assistantMap}
|
||||
conversation={conversation}
|
||||
endpointsConfig={endpointsConfig}
|
||||
containerClassName={containerClassName}
|
||||
context="landing"
|
||||
className="text-text-primary h-2/3 w-2/3"
|
||||
size={41}
|
||||
/>
|
||||
)}
|
||||
</div>
|
||||
{startupConfig?.showBirthdayIcon && (
|
||||
<TooltipAnchor
|
||||
className="absolute inset-e-2 bottom-[1.6875rem]"
|
||||
description={localize('com_ui_happy_birthday')}
|
||||
aria-label={localize('com_ui_happy_birthday')}
|
||||
>
|
||||
<BirthdayIcon />
|
||||
</TooltipAnchor>
|
||||
)}
|
||||
</div>
|
||||
{startupConfig?.showBirthdayIcon && (
|
||||
<TooltipAnchor
|
||||
className="absolute inset-e-2 bottom-[1.6875rem]"
|
||||
description={localize('com_ui_happy_birthday')}
|
||||
aria-label={localize('com_ui_happy_birthday')}
|
||||
>
|
||||
<BirthdayIcon />
|
||||
</TooltipAnchor>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
{name ? (
|
||||
<div className="flex flex-col items-center gap-0 p-2">
|
||||
<SplitText
|
||||
|
|
|
|||
|
|
@ -259,9 +259,24 @@ describe('Landing heading', () => {
|
|||
expect(screen.getByText('Welcome')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Data Analyst')).not.toBeInTheDocument();
|
||||
expect(screen.getByText('Answers SQL questions')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('convo-icon')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('keeps the icon in the default entity heading', () => {
|
||||
renderLanding();
|
||||
|
||||
expect(screen.getByTestId('convo-icon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('keeps the temporary chat icon in greeting mode', () => {
|
||||
mockInterfaceConfig = { landingHeading: 'greeting' };
|
||||
|
||||
const { container } = renderLanding({ isTemporary: true });
|
||||
|
||||
expect(screen.queryByTestId('convo-icon')).not.toBeInTheDocument();
|
||||
expect(container.querySelector('.avatar-stroke')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('uses the configured welcome as the greeting heading', () => {
|
||||
mockInterfaceConfig = { landingHeading: 'greeting', customWelcome: 'Hello there' };
|
||||
|
||||
|
|
|
|||
|
|
@ -5,14 +5,19 @@ import { cleanupAgent, uniqueAgentName } from '../agents.helpers';
|
|||
import { expect, test } from '../fixtures';
|
||||
|
||||
/**
|
||||
* The welcome screen names the selected agent and carries the generic footer
|
||||
* by default. A deployment can greet the user instead and drop that footer;
|
||||
* the agent's icon and description stay either way. The footer is hidden
|
||||
* The welcome screen names the selected agent, draws its icon beside the name,
|
||||
* and carries the generic footer by default. A deployment can greet the user
|
||||
* instead and drop that footer; the greeting then stands without the icon, which
|
||||
* the header selector already shows, and the description stays either way.
|
||||
* Temporary chat keeps its own mark under both headings. The footer is hidden
|
||||
* below `sm`, so this runs on the desktop viewport it describes.
|
||||
*/
|
||||
|
||||
const DESCRIPTION = 'Landing heading acceptance fixture.';
|
||||
const DISCLAIMER = 'Every AI for Everyone.';
|
||||
/** The round mark beside the heading, and the badge anchored to it when the birthday icon is on. */
|
||||
const HEADING_ICON = '.avatar-stroke';
|
||||
const BIRTHDAY_BADGE = "It's my 1st birthday!";
|
||||
|
||||
test.use({ viewport: { width: 1280, height: 800 } });
|
||||
|
||||
|
|
@ -33,14 +38,19 @@ async function createAgent(page: Page, name: string) {
|
|||
});
|
||||
}
|
||||
|
||||
/** Answers the startup config with the deployment's welcome screen settings. */
|
||||
async function serveInterface(page: Page, overrides: Record<string, unknown>) {
|
||||
/** Answers the startup config with the deployment's welcome screen settings, and any
|
||||
* top-level setting beside them, such as the birthday icon. */
|
||||
async function serveInterface(
|
||||
page: Page,
|
||||
overrides: Record<string, unknown>,
|
||||
startup: Record<string, unknown> = {},
|
||||
) {
|
||||
await page.route('**/api/config', async (route) => {
|
||||
const response = await route.fetch();
|
||||
const config = await response.json();
|
||||
await route.fulfill({
|
||||
response,
|
||||
json: { ...config, interface: { ...config.interface, ...overrides } },
|
||||
json: { ...config, ...startup, interface: { ...config.interface, ...overrides } },
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
@ -135,4 +145,71 @@ test.describe('welcome screen heading and footer', () => {
|
|||
await cleanupAgent(page, agentId);
|
||||
}
|
||||
});
|
||||
|
||||
test('the default heading keeps the agent icon and its birthday badge beside the name @scenario:landing-default-heading-keeps-the-agent-icon', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(90000);
|
||||
const name = uniqueAgentName('E2E Landing Icon Default');
|
||||
let agentId: string | undefined;
|
||||
|
||||
try {
|
||||
agentId = (await createAgent(page, name)).id;
|
||||
await serveInterface(page, {}, { showBirthdayIcon: true });
|
||||
const main = await openAgentLanding(page, agentId);
|
||||
|
||||
await expect(main.getByText(name, { exact: true }).last()).toBeVisible();
|
||||
await expect(main.locator(HEADING_ICON)).toHaveCount(1);
|
||||
await expect(main.getByLabel(BIRTHDAY_BADGE)).toBeVisible();
|
||||
} finally {
|
||||
await cleanupAgent(page, agentId);
|
||||
}
|
||||
});
|
||||
|
||||
test('an opted-in deployment greets the user without the agent icon or its birthday badge @scenario:landing-greeting-drops-the-agent-icon', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(90000);
|
||||
const name = uniqueAgentName('E2E Landing Icon Greeting');
|
||||
const welcome = 'Hello without the icon';
|
||||
let agentId: string | undefined;
|
||||
|
||||
try {
|
||||
agentId = (await createAgent(page, name)).id;
|
||||
await serveInterface(
|
||||
page,
|
||||
{ landingHeading: 'greeting', customWelcome: welcome },
|
||||
{ showBirthdayIcon: true },
|
||||
);
|
||||
const main = await openAgentLanding(page, agentId);
|
||||
|
||||
/** The description is already up and the greeting beside it, so the absences below are
|
||||
* not a screen that has yet to draw. */
|
||||
await expect(main.getByText(welcome)).toBeVisible();
|
||||
await expect(main.locator(HEADING_ICON)).toHaveCount(0);
|
||||
await expect(main.getByLabel(BIRTHDAY_BADGE)).toHaveCount(0);
|
||||
} finally {
|
||||
await cleanupAgent(page, agentId);
|
||||
}
|
||||
});
|
||||
|
||||
test('temporary chat keeps its incognito icon under the greeting heading @scenario:landing-greeting-keeps-the-temporary-chat-icon', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(90000);
|
||||
const welcome = 'Hello before the mode changes';
|
||||
await serveInterface(page, { landingHeading: 'greeting', customWelcome: welcome });
|
||||
await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
|
||||
const main = page.locator('main');
|
||||
await expect(main.getByText(welcome)).toBeVisible({ timeout: 30000 });
|
||||
await expect(main.locator(HEADING_ICON)).toHaveCount(0);
|
||||
|
||||
/** The chat route resets temporary mode on load, so it is turned on the way a user does. */
|
||||
const toggle = page.locator('button[aria-label="Temporary Chat"]');
|
||||
await toggle.click();
|
||||
await expect(toggle).toHaveAttribute('aria-pressed', 'true');
|
||||
|
||||
await expect(main.getByText('Temporary Chat', { exact: true }).first()).toBeVisible();
|
||||
await expect(main.locator(`${HEADING_ICON} svg.lucide-hat-glasses`)).toBeVisible();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -218,8 +218,8 @@ projects:
|
|||
interface:
|
||||
customWelcome: 'Welcome to LibreChat! Enjoy your experience.'
|
||||
# What heads the welcome screen when an agent, assistant or model spec is selected (default: entity).
|
||||
# 'entity' shows its name; 'greeting' shows the time-of-day greeting (or customWelcome) with the
|
||||
# user's name, for deployments where the header selector already names the agent.
|
||||
# 'entity' shows its name and icon; 'greeting' shows the time-of-day greeting (or customWelcome) with
|
||||
# the user's name and no icon, for deployments where the header selector already shows the agent.
|
||||
# landingHeading: entity
|
||||
# Show the generic disclaimer and policy links on the welcome screen (default: true).
|
||||
# true places them at the bottom of the page, 'composer' directly under the composer, and false
|
||||
|
|
|
|||
|
|
@ -3487,7 +3487,8 @@ export const interfaceSchema = z
|
|||
customWelcome: z.string().optional(),
|
||||
/** What heads the welcome screen when an agent, assistant or branded spec is
|
||||
* selected: its name (`entity`), or the time-of-day greeting with the user's
|
||||
* name (`greeting`) for deployments whose header selector already names it. */
|
||||
* name (`greeting`) for deployments whose header selector already names it.
|
||||
* Greeting mode also drops the agent or endpoint icon beside the heading. */
|
||||
landingHeading: z.enum(['entity', 'greeting']).optional(),
|
||||
/** Shows the generic disclaimer and policy links on the welcome screen: at the bottom of the
|
||||
* page (`true`), directly under the composer (`composer`), or not at all (`false`). A
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue