mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 13:00:55 +00:00
👋 feat: Optional Greeting Heading and Footer-Free Welcome Screen (#17055)
This commit is contained in:
parent
b7d096f991
commit
5cb396e85c
21 changed files with 438 additions and 33 deletions
|
|
@ -543,6 +543,7 @@ if (cluster.isMaster) {
|
|||
so the answer is the deployment's base configuration, like index.js. */
|
||||
indexHTML = injectConfiguredFooterBootstrap(indexHTML, {
|
||||
customFooter: process.env.CUSTOM_FOOTER,
|
||||
landingFooter: baseAppConfig?.interfaceConfig?.landingFooter,
|
||||
});
|
||||
|
||||
indexHTML = injectColorModeHandoff(indexHTML, baseAppConfig?.interfaceConfig?.colorModeFromUrl);
|
||||
|
|
|
|||
|
|
@ -301,6 +301,7 @@ const startServer = async () => {
|
|||
caller's and the client prefers it. */
|
||||
indexHTML = injectConfiguredFooterBootstrap(indexHTML, {
|
||||
customFooter: process.env.CUSTOM_FOOTER,
|
||||
landingFooter: appConfig?.interfaceConfig?.landingFooter,
|
||||
});
|
||||
|
||||
indexHTML = injectColorModeHandoff(indexHTML, appConfig.interfaceConfig?.colorModeFromUrl);
|
||||
|
|
|
|||
|
|
@ -692,6 +692,9 @@ declare global {
|
|||
/** Whether this deployment configured footer content of its own, so the
|
||||
* composer reserves the footer bar's band on its first frame. */
|
||||
hasConfiguredFooter?: boolean;
|
||||
/** The deployment's `interface.landingFooter`, so the welcome screen does
|
||||
* not paint a footer the config is about to remove. */
|
||||
landingFooter?: boolean;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,6 +24,7 @@ import {
|
|||
useFileMapContext,
|
||||
ComposerRestoreProvider,
|
||||
} from '~/Providers';
|
||||
import Footer, { useLandingFooter, useConfiguredFooter } from './Footer';
|
||||
import { QueuedTurnPortalProvider } from './Steering/QueuedTurnPortal';
|
||||
import { useChatSettings } from '~/Providers/ChatSettingsContext';
|
||||
import ApprovalProvider from './Messages/Content/ApprovalContext';
|
||||
|
|
@ -33,7 +34,6 @@ import ProjectBadge from '~/components/Projects/ProjectBadge';
|
|||
import { composerLiftFamily } from './Input/Composer/state';
|
||||
import { OwnerTextProvider } from './Messages/PrivateText';
|
||||
import { useGetMessagesByConvoId } from '~/data-provider';
|
||||
import Footer, { useConfiguredFooter } from './Footer';
|
||||
import { AskAnswerHostProvider } from './ask/state';
|
||||
import MessagesView from './Messages/MessagesView';
|
||||
import Presentation from './Presentation';
|
||||
|
|
@ -86,6 +86,7 @@ function ChatView({
|
|||
* composer's clearance has to account for the bar when it does — including
|
||||
* before the config answers, so a cold load does not jump. */
|
||||
const configuredFooter = useConfiguredFooter();
|
||||
const landingFooter = useLandingFooter();
|
||||
|
||||
/** Room an open composer popover needs below the composer; see the atom. */
|
||||
const composerLift = useAtomValue(composerLiftFamily(index));
|
||||
|
|
@ -149,11 +150,10 @@ function ChatView({
|
|||
(!messagesTree || messagesTree.length === 0) &&
|
||||
(conversationId === Constants.NEW_CONVO || !conversationId);
|
||||
|
||||
/** A footer bar renders beneath the composer on the welcome screen always, and
|
||||
* in a conversation when the deployment configured one. The shell already
|
||||
* carried that answer, so this is the same value before and after the config
|
||||
* resolves. */
|
||||
const footerBelow = isLandingPage || configuredFooter;
|
||||
/** The welcome screen carries the full footer unless the deployment turned it
|
||||
* off; otherwise a footer bar renders only for configured content. */
|
||||
const fullFooter = isLandingPage && landingFooter;
|
||||
const footerBelow = fullFooter || configuredFooter;
|
||||
const isNavigating = (!messagesTree || messagesTree.length === 0) && conversationId != null;
|
||||
const isProjectLandingPage = isLandingPage && project != null;
|
||||
|
||||
|
|
@ -280,7 +280,7 @@ function ChatView({
|
|||
{/* The generic disclaimer and the policy links are the
|
||||
welcome screen's; a deployment's own footer stays
|
||||
with the conversation that always showed it. */}
|
||||
{!isLandingPage && configuredFooter && <Footer configuredOnly />}
|
||||
{!fullFooter && configuredFooter && <Footer configuredOnly />}
|
||||
</div>
|
||||
<Lia
|
||||
bandRef={composerBandRef}
|
||||
|
|
@ -288,7 +288,7 @@ function ChatView({
|
|||
submission={rootSubmission}
|
||||
/>
|
||||
</div>
|
||||
{isLandingPage && <Footer />}
|
||||
{fullFooter && <Footer />}
|
||||
</>
|
||||
</TraceSurface>
|
||||
</Presentation>
|
||||
|
|
|
|||
|
|
@ -53,6 +53,21 @@ export function useConfiguredFooter(): boolean {
|
|||
return isSuccess ? hasConfiguredFooter(config) : shellHasConfiguredFooter;
|
||||
}
|
||||
|
||||
/** The deployment's `interface.landingFooter`, as the server said when it served
|
||||
* this document. A shell that carries no answer reads as the default: on. */
|
||||
const shellLandingFooter =
|
||||
typeof window === 'undefined' || window.__LIBRECHAT_CONFIG__?.landingFooter !== false;
|
||||
|
||||
/** Whether the welcome screen carries the generic disclaimer and policy links.
|
||||
* Off, it keeps only a configured footer, the same as a conversation. Until
|
||||
* `/api/config` answers, the shell's answer holds, so a cold load lays the
|
||||
* welcome screen out once instead of dropping a footer it painted. */
|
||||
export function useLandingFooter(): boolean {
|
||||
const { data: config, isSuccess } = useGetStartupConfig();
|
||||
|
||||
return isSuccess ? config?.interface?.landingFooter !== false : shellLandingFooter;
|
||||
}
|
||||
|
||||
function Footer({ className, startupConfig, configuredOnly = false }: FooterProps) {
|
||||
const shouldFetchConfig = startupConfig === undefined;
|
||||
const { data: fetchedConfig } = useGetStartupConfig({ enabled: shouldFetchConfig });
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ import PromptsCommand from './PromptsCommand';
|
|||
import { submitFromComposer } from './submit';
|
||||
import SkillsCommand from './SkillsCommand';
|
||||
import AutoPlayAudio from './AutoPlayAudio';
|
||||
import composerClearance from './clearance';
|
||||
import Waveform from './Composer/Waveform';
|
||||
import { mainTextareaId } from '~/common';
|
||||
import CollapseChat from './CollapseChat';
|
||||
|
|
@ -712,22 +713,11 @@ const ChatForm = memo(function ChatForm({
|
|||
[isCollapsed],
|
||||
);
|
||||
|
||||
/* From `sm` up the band leaves room under itself for the disclaimer, which only
|
||||
the landing page carries — doubled while the centred landing composer floats,
|
||||
and dropped back the moment a submission starts the thread. A started
|
||||
conversation has nothing beneath it, so it keeps only enough to clear the
|
||||
surface's own shadow. Below `sm` the composer runs to the viewport floor in
|
||||
every state. */
|
||||
const landingClearance =
|
||||
centerFormOnLanding && !isSubmitting ? 'transition-all duration-200 sm:mb-28' : 'sm:mb-10';
|
||||
let bottomClearance = 'sm:mb-4';
|
||||
if (isLandingPage) {
|
||||
bottomClearance = landingClearance;
|
||||
} else if (footerBelow) {
|
||||
/* A conversation that carries a configured footer keeps the band that bar
|
||||
needs, exactly as the welcome screen does. */
|
||||
bottomClearance = 'sm:mb-10';
|
||||
}
|
||||
const bottomClearance = composerClearance({
|
||||
isLandingPage,
|
||||
footerBelow,
|
||||
floating: centerFormOnLanding && !isSubmitting,
|
||||
});
|
||||
|
||||
/** Answer mode, then during-run steering or queueing (a run in flight, or a
|
||||
* queued follow-up about to start), then an ordinary send: the same route
|
||||
|
|
|
|||
30
client/src/components/Chat/Input/__tests__/clearance.spec.ts
Normal file
30
client/src/components/Chat/Input/__tests__/clearance.spec.ts
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
import composerClearance from '../clearance';
|
||||
|
||||
describe('composerClearance', () => {
|
||||
test('reserves the footer band on the welcome screen, doubled while the composer floats', () => {
|
||||
expect(composerClearance({ isLandingPage: true, footerBelow: true, floating: true })).toBe(
|
||||
'transition-all duration-200 sm:mb-28',
|
||||
);
|
||||
expect(composerClearance({ isLandingPage: true, footerBelow: true, floating: false })).toBe(
|
||||
'sm:mb-10',
|
||||
);
|
||||
});
|
||||
|
||||
test('drops the footer band on a welcome screen with no footer beneath it', () => {
|
||||
expect(composerClearance({ isLandingPage: true, footerBelow: false, floating: true })).toBe(
|
||||
'sm:mb-4',
|
||||
);
|
||||
expect(composerClearance({ isLandingPage: true, footerBelow: false, floating: false })).toBe(
|
||||
'sm:mb-4',
|
||||
);
|
||||
});
|
||||
|
||||
test('reserves the band in a conversation only for a configured footer', () => {
|
||||
expect(composerClearance({ isLandingPage: false, footerBelow: true, floating: false })).toBe(
|
||||
'sm:mb-10',
|
||||
);
|
||||
expect(composerClearance({ isLandingPage: false, footerBelow: false, floating: false })).toBe(
|
||||
'sm:mb-4',
|
||||
);
|
||||
});
|
||||
});
|
||||
25
client/src/components/Chat/Input/clearance.ts
Normal file
25
client/src/components/Chat/Input/clearance.ts
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/**
|
||||
* Room the composer band leaves beneath itself from `sm` up. A footer bar sits
|
||||
* there whenever `footerBelow` holds, and the band reserves it: doubled while
|
||||
* the centred landing composer floats, dropped back the moment a submission
|
||||
* starts the thread. With no bar beneath it, the band keeps only enough to
|
||||
* clear the surface's own shadow, on the welcome screen as in a conversation.
|
||||
* Below `sm` the composer runs to the viewport floor in every state.
|
||||
*/
|
||||
export default function composerClearance({
|
||||
isLandingPage,
|
||||
footerBelow,
|
||||
floating,
|
||||
}: {
|
||||
isLandingPage: boolean;
|
||||
footerBelow: boolean;
|
||||
floating: boolean;
|
||||
}): string {
|
||||
if (!footerBelow) {
|
||||
return 'sm:mb-4';
|
||||
}
|
||||
if (isLandingPage && floating) {
|
||||
return 'transition-all duration-200 sm:mb-28';
|
||||
}
|
||||
return 'sm:mb-10';
|
||||
}
|
||||
|
|
@ -64,7 +64,7 @@ export default function Landing({ centerFormOnLanding }: { centerFormOnLanding:
|
|||
});
|
||||
}, [conversation?.endpoint, conversation?.iconURL, endpointsConfig]);
|
||||
|
||||
const { entity, isAgent, isAssistant } = getEntity({
|
||||
const { entity, isAgent } = getEntity({
|
||||
endpoint: endpointType,
|
||||
agentsMap,
|
||||
assistantMap,
|
||||
|
|
@ -79,7 +79,10 @@ export default function Landing({ centerFormOnLanding }: { centerFormOnLanding:
|
|||
|
||||
const brandedSpecLabel = modelSpec?.showOnLanding ? modelSpec.label : '';
|
||||
const brandedSpecDescription = (modelSpec?.showOnLanding && modelSpec.description) || '';
|
||||
const name = isTemporary ? '' : (entity?.name ?? brandedSpecLabel);
|
||||
const name =
|
||||
isTemporary || startupConfig?.interface?.landingHeading === 'greeting'
|
||||
? ''
|
||||
: (entity?.name ?? brandedSpecLabel);
|
||||
const description = isTemporary
|
||||
? localize('com_ui_temporary_description')
|
||||
: ((entity?.description || brandedSpecDescription || conversation?.greeting) ?? '');
|
||||
|
|
@ -171,7 +174,7 @@ export default function Landing({ centerFormOnLanding }: { centerFormOnLanding:
|
|||
</TooltipAnchor>
|
||||
)}
|
||||
</div>
|
||||
{((isAgent || isAssistant) && name) || name ? (
|
||||
{name ? (
|
||||
<div className="flex flex-col items-center gap-0 p-2">
|
||||
<SplitText
|
||||
key={`split-text-${name}`}
|
||||
|
|
|
|||
|
|
@ -46,10 +46,15 @@ jest.mock('../Presentation', () => ({
|
|||
default: ({ children }: { children: React.ReactNode }) => <div>{children}</div>,
|
||||
}));
|
||||
jest.mock('../Header', () => ({ __esModule: true, default: () => <div /> }));
|
||||
let mockConfiguredFooter = false;
|
||||
let mockLandingFooter = true;
|
||||
jest.mock('../Footer', () => ({
|
||||
__esModule: true,
|
||||
default: () => <div />,
|
||||
useConfiguredFooter: () => false,
|
||||
default: ({ configuredOnly }: { configuredOnly?: boolean }) => (
|
||||
<div data-testid={configuredOnly ? 'configured-footer' : 'landing-footer'} />
|
||||
),
|
||||
useConfiguredFooter: () => mockConfiguredFooter,
|
||||
useLandingFooter: () => mockLandingFooter,
|
||||
}));
|
||||
jest.mock('../Landing', () => ({ __esModule: true, default: () => <div /> }));
|
||||
jest.mock('~/components/Lia', () => ({ __esModule: true, default: () => null }));
|
||||
|
|
@ -213,3 +218,48 @@ describe('ChatView draft saving', () => {
|
|||
expect(mockAskHostSaveDrafts).toHaveBeenLastCalledWith(saveDrafts);
|
||||
});
|
||||
});
|
||||
|
||||
describe('ChatView landing footer', () => {
|
||||
beforeEach(() => {
|
||||
mockParams.mockReturnValue({});
|
||||
mockConversation.mockReturnValue(null);
|
||||
mockConfiguredFooter = false;
|
||||
mockLandingFooter = true;
|
||||
mockChatFormProps.mockClear();
|
||||
});
|
||||
|
||||
test('renders the full footer beneath the welcome screen by default', () => {
|
||||
render(<ChatView />);
|
||||
|
||||
expect(screen.getByTestId('landing-footer')).toBeInTheDocument();
|
||||
expect(screen.queryByTestId('configured-footer')).not.toBeInTheDocument();
|
||||
expect(mockChatFormProps).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ footerBelow: true }),
|
||||
);
|
||||
});
|
||||
|
||||
test('drops the welcome screen footer when the deployment turns it off', () => {
|
||||
mockLandingFooter = false;
|
||||
|
||||
render(<ChatView />);
|
||||
|
||||
expect(screen.queryByTestId('landing-footer')).not.toBeInTheDocument();
|
||||
expect(screen.queryByTestId('configured-footer')).not.toBeInTheDocument();
|
||||
expect(mockChatFormProps).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ footerBelow: false }),
|
||||
);
|
||||
});
|
||||
|
||||
test('keeps a configured footer on the welcome screen when the full footer is off', () => {
|
||||
mockLandingFooter = false;
|
||||
mockConfiguredFooter = true;
|
||||
|
||||
render(<ChatView />);
|
||||
|
||||
expect(screen.queryByTestId('landing-footer')).not.toBeInTheDocument();
|
||||
expect(screen.getByTestId('configured-footer')).toBeInTheDocument();
|
||||
expect(mockChatFormProps).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ footerBelow: true }),
|
||||
);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -78,6 +78,7 @@ jest.mock('../Footer', () => ({
|
|||
__esModule: true,
|
||||
default: () => <div data-testid="footer" />,
|
||||
useConfiguredFooter: () => false,
|
||||
useLandingFooter: () => true,
|
||||
}));
|
||||
jest.mock('../Header', () => ({ readOnly }: { readOnly?: boolean }) => (
|
||||
<div data-read-only={String(readOnly)} data-testid="header" />
|
||||
|
|
|
|||
|
|
@ -1,7 +1,8 @@
|
|||
import React from 'react';
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import { render, screen, renderHook } from '@testing-library/react';
|
||||
import '@testing-library/jest-dom/extend-expect';
|
||||
import Footer from '../Footer';
|
||||
import { useGetStartupConfig } from '~/data-provider';
|
||||
import Footer, { useLandingFooter } from '../Footer';
|
||||
|
||||
jest.mock('~/data-provider', () => ({
|
||||
useGetStartupConfig: jest.fn(() => ({ data: undefined, isFetching: false, error: null })),
|
||||
|
|
@ -103,3 +104,69 @@ describe('Footer', () => {
|
|||
expect(container).toBeEmptyDOMElement();
|
||||
});
|
||||
});
|
||||
|
||||
describe('useLandingFooter', () => {
|
||||
const mockUseGetStartupConfig = useGetStartupConfig as jest.Mock;
|
||||
|
||||
afterEach(() => {
|
||||
mockUseGetStartupConfig.mockImplementation(() => ({ data: undefined }));
|
||||
delete window.__LIBRECHAT_CONFIG__;
|
||||
});
|
||||
|
||||
/** The shell's answer is read once at module load, so each case loads Footer
|
||||
* fresh against the document it is given. */
|
||||
const loadHook = (shell?: { landingFooter?: boolean }): typeof useLandingFooter => {
|
||||
if (shell) {
|
||||
window.__LIBRECHAT_CONFIG__ = shell;
|
||||
}
|
||||
let hook: typeof useLandingFooter = useLandingFooter;
|
||||
jest.isolateModules(() => {
|
||||
hook = (jest.requireActual('../Footer') as typeof import('../Footer')).useLandingFooter;
|
||||
});
|
||||
return hook;
|
||||
};
|
||||
|
||||
test('keeps the welcome screen footer unless the resolved config turns it off', () => {
|
||||
mockUseGetStartupConfig.mockImplementation(() => ({ data: {}, isSuccess: true }));
|
||||
expect(renderHook(() => useLandingFooter()).result.current).toBe(true);
|
||||
|
||||
mockUseGetStartupConfig.mockImplementation(() => ({
|
||||
data: { interface: {} },
|
||||
isSuccess: true,
|
||||
}));
|
||||
expect(renderHook(() => useLandingFooter()).result.current).toBe(true);
|
||||
|
||||
mockUseGetStartupConfig.mockImplementation(() => ({
|
||||
data: { interface: { landingFooter: false } },
|
||||
isSuccess: true,
|
||||
}));
|
||||
expect(renderHook(() => useLandingFooter()).result.current).toBe(false);
|
||||
});
|
||||
|
||||
test('holds the shell answer while the config is unresolved', () => {
|
||||
mockUseGetStartupConfig.mockImplementation(() => ({ data: undefined, isSuccess: false }));
|
||||
|
||||
const off = loadHook({ landingFooter: false });
|
||||
expect(renderHook(() => off()).result.current).toBe(false);
|
||||
|
||||
const on = loadHook({ landingFooter: true });
|
||||
expect(renderHook(() => on()).result.current).toBe(true);
|
||||
});
|
||||
|
||||
test('reads a shell that carries no answer as the default', () => {
|
||||
mockUseGetStartupConfig.mockImplementation(() => ({ data: undefined, isSuccess: false }));
|
||||
|
||||
const hook = loadHook();
|
||||
expect(renderHook(() => hook()).result.current).toBe(true);
|
||||
});
|
||||
|
||||
test('prefers the resolved config over the shell', () => {
|
||||
mockUseGetStartupConfig.mockImplementation(() => ({
|
||||
data: { interface: { landingFooter: true } },
|
||||
isSuccess: true,
|
||||
}));
|
||||
|
||||
const hook = loadHook({ landingFooter: false });
|
||||
expect(renderHook(() => hook()).result.current).toBe(true);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ import Landing from '../Landing';
|
|||
let mockConversation: Record<string, unknown> | null = null;
|
||||
let mockAgentsMap: Record<string, any> | undefined;
|
||||
let mockAssistantMap: Record<string, any> | undefined;
|
||||
let mockInterfaceConfig: Record<string, unknown> = {};
|
||||
|
||||
jest.mock('@react-spring/web', () => ({
|
||||
easings: {
|
||||
|
|
@ -36,7 +37,7 @@ jest.mock('~/Providers', () => ({
|
|||
}));
|
||||
|
||||
jest.mock('~/data-provider', () => ({
|
||||
useGetStartupConfig: () => ({ data: { interface: {} } }),
|
||||
useGetStartupConfig: () => ({ data: { interface: mockInterfaceConfig } }),
|
||||
useGetEndpointsQuery: () => ({ data: {} }),
|
||||
}));
|
||||
|
||||
|
|
@ -232,3 +233,41 @@ describe('Landing temporary chat empty state', () => {
|
|||
expect(screen.getByTestId('convo-icon')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
||||
describe('Landing heading', () => {
|
||||
beforeEach(() => {
|
||||
mockInterfaceConfig = {};
|
||||
mockConversation = { endpoint: 'agents', agent_id: 'agent-1' };
|
||||
mockAgentsMap = {
|
||||
'agent-1': { id: 'agent-1', name: 'Data Analyst', description: 'Answers SQL questions' },
|
||||
};
|
||||
mockAssistantMap = undefined;
|
||||
});
|
||||
|
||||
it('heads the welcome screen with the selected agent name by default', () => {
|
||||
renderLanding();
|
||||
|
||||
expect(screen.getByText('Data Analyst')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Welcome')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('greets the user instead when the deployment opts into the greeting heading', () => {
|
||||
mockInterfaceConfig = { landingHeading: 'greeting' };
|
||||
|
||||
renderLanding();
|
||||
|
||||
expect(screen.getByText('Welcome')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Data Analyst')).not.toBeInTheDocument();
|
||||
expect(screen.getByText('Answers SQL questions')).toBeInTheDocument();
|
||||
expect(screen.getByTestId('convo-icon')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('uses the configured welcome as the greeting heading', () => {
|
||||
mockInterfaceConfig = { landingHeading: 'greeting', customWelcome: 'Hello there' };
|
||||
|
||||
renderLanding();
|
||||
|
||||
expect(screen.getByText('Hello there')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Data Analyst')).not.toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
115
e2e/specs/mock/scenarios/landing-greeting.spec.ts
Normal file
115
e2e/specs/mock/scenarios/landing-greeting.spec.ts
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
import { expect, test } from '@playwright/test';
|
||||
import type { Page } from '@playwright/test';
|
||||
import type { AgentDetail } from '../agents.helpers';
|
||||
import { MOCK_ENDPOINTS, NEW_CHAT_PATH, getAccessToken, requestJson } from '../helpers';
|
||||
import { cleanupAgent, uniqueAgentName } from '../agents.helpers';
|
||||
|
||||
/**
|
||||
* 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
|
||||
* below `sm`, so this runs on the desktop viewport it describes.
|
||||
*/
|
||||
|
||||
const DESCRIPTION = 'Landing heading acceptance fixture.';
|
||||
const DISCLAIMER = 'Every AI for Everyone.';
|
||||
|
||||
test.use({ viewport: { width: 1280, height: 800 } });
|
||||
|
||||
async function createAgent(page: Page, name: string) {
|
||||
await page.goto(NEW_CHAT_PATH, { timeout: 15000 });
|
||||
const token = await getAccessToken(page);
|
||||
return requestJson<AgentDetail>(page, {
|
||||
path: '/api/agents',
|
||||
token,
|
||||
method: 'POST',
|
||||
body: {
|
||||
name,
|
||||
description: DESCRIPTION,
|
||||
instructions: 'Keep this fixture deterministic.',
|
||||
provider: MOCK_ENDPOINTS[0].label,
|
||||
model: MOCK_ENDPOINTS[0].model,
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/** Answers the startup config with the deployment's welcome screen settings. */
|
||||
async function serveInterface(page: Page, overrides: 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 } },
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
async function openAgentLanding(page: Page, agentId: string) {
|
||||
await page.goto(`${NEW_CHAT_PATH}?agent_id=${encodeURIComponent(agentId)}`, {
|
||||
timeout: 15000,
|
||||
});
|
||||
const main = page.locator('main');
|
||||
await expect(main.getByText(DESCRIPTION)).toBeVisible({ timeout: 30000 });
|
||||
return main;
|
||||
}
|
||||
|
||||
/** The room the composer leaves beneath itself for a footer bar, in pixels. */
|
||||
function composerClearance(page: Page) {
|
||||
return page
|
||||
.locator('form:has(#prompt-textarea)')
|
||||
.evaluate((form) => parseFloat(getComputedStyle(form).marginBottom));
|
||||
}
|
||||
|
||||
test.describe('welcome screen heading and footer', () => {
|
||||
test('the agent name heads the welcome screen above the footer by default @scenario:landing-names-the-agent-by-default', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(90000);
|
||||
const name = uniqueAgentName('E2E Landing Default');
|
||||
let agentId: string | undefined;
|
||||
|
||||
try {
|
||||
agentId = (await createAgent(page, name)).id;
|
||||
const main = await openAgentLanding(page, agentId);
|
||||
|
||||
await expect(main.getByText(name, { exact: true }).last()).toBeVisible();
|
||||
await expect(page.getByText(DISCLAIMER)).toBeVisible();
|
||||
await expect.poll(() => composerClearance(page)).toBeGreaterThan(16);
|
||||
} finally {
|
||||
await cleanupAgent(page, agentId);
|
||||
}
|
||||
});
|
||||
|
||||
test('an opted-in deployment greets the user and drops the footer @scenario:landing-greets-the-user-without-a-footer', async ({
|
||||
page,
|
||||
}) => {
|
||||
test.setTimeout(90000);
|
||||
const name = uniqueAgentName('E2E Landing Greeting');
|
||||
const welcome = 'Hello from the welcome screen';
|
||||
let agentId: string | undefined;
|
||||
|
||||
try {
|
||||
agentId = (await createAgent(page, name)).id;
|
||||
await serveInterface(page, {
|
||||
landingHeading: 'greeting',
|
||||
landingFooter: false,
|
||||
customWelcome: welcome,
|
||||
});
|
||||
const main = await openAgentLanding(page, agentId);
|
||||
|
||||
await expect(main.getByText(welcome)).toBeVisible();
|
||||
await expect(page.getByText(DISCLAIMER)).toHaveCount(0);
|
||||
/** No footer beneath it, so the composer keeps only its shadow clearance. */
|
||||
await expect.poll(() => composerClearance(page)).toBe(16);
|
||||
/** The header selector still names the agent; the welcome screen does not repeat it. */
|
||||
const inSelector = await page
|
||||
.locator('button, [role="combobox"]')
|
||||
.getByText(name, { exact: true })
|
||||
.count();
|
||||
await expect(main.getByText(name, { exact: true })).toHaveCount(inSelector);
|
||||
} finally {
|
||||
await cleanupAgent(page, agentId);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
@ -175,6 +175,13 @@ projects:
|
|||
# Custom interface configuration
|
||||
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.
|
||||
# landingHeading: entity
|
||||
# Show the generic disclaimer and policy links beneath the welcome screen's composer (default: true).
|
||||
# When false, a CUSTOM_FOOTER still renders there, as it does in conversations.
|
||||
# landingFooter: true
|
||||
# Allow renaming a running chat or one with a placeholder title (default: true).
|
||||
# Set to false during a rolling upgrade, until ALL API replicas are upgraded and old
|
||||
# title-generation jobs have drained. While false, rename is disabled for running chats
|
||||
|
|
|
|||
|
|
@ -27,6 +27,18 @@ describe('injectConfiguredFooterBootstrap', () => {
|
|||
expect(flagOf(injectConfiguredFooterBootstrap(SHELL, { customFooter: ' ' }))).toBe(false);
|
||||
});
|
||||
|
||||
it('carries the welcome screen footer setting, on unless the deployment turned it off', () => {
|
||||
const landingOf = (html: string): boolean | undefined => {
|
||||
const match = /"landingFooter":(true|false)/.exec(html);
|
||||
return match == null ? undefined : match[1] === 'true';
|
||||
};
|
||||
|
||||
expect(landingOf(injectConfiguredFooterBootstrap(SHELL))).toBe(true);
|
||||
expect(landingOf(injectConfiguredFooterBootstrap(SHELL, { landingFooter: null }))).toBe(true);
|
||||
expect(landingOf(injectConfiguredFooterBootstrap(SHELL, { landingFooter: true }))).toBe(true);
|
||||
expect(landingOf(injectConfiguredFooterBootstrap(SHELL, { landingFooter: false }))).toBe(false);
|
||||
});
|
||||
|
||||
it('places the answer ahead of the app that reads it', () => {
|
||||
const html = injectConfiguredFooterBootstrap(SHELL, { customFooter: 'Operator' });
|
||||
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@ import { injectBootstrapConfig } from './bootstrap';
|
|||
|
||||
const CONFIGURED_FOOTER_SENTINEL = 'data-librechat-configured-footer="true"';
|
||||
|
||||
/** What the deployment configured, as the server holds it: the footer env var. */
|
||||
/** What the deployment configured, as the server holds it: the footer env var
|
||||
* and the base config's `interface.landingFooter`. */
|
||||
export interface ConfiguredFooterSource {
|
||||
customFooter?: string | null;
|
||||
landingFooter?: boolean | null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -20,6 +22,9 @@ export interface ConfiguredFooterSource {
|
|||
* served before there is a caller whose config overrides could be resolved; the
|
||||
* client prefers `/api/config`'s resolved answer once it has it.
|
||||
*
|
||||
* The welcome screen's own footer is answered the same way: a deployment that
|
||||
* turned it off would otherwise paint it until `/api/config` removed it.
|
||||
*
|
||||
* Always injected, including the negative answer, so an absent flag means "no
|
||||
* server said" (the Vite dev server) rather than "no footer".
|
||||
*/
|
||||
|
|
@ -33,5 +38,6 @@ export const injectConfiguredFooterBootstrap = (
|
|||
hasConfiguredFooter: hasConfiguredFooter({
|
||||
customFooter: source?.customFooter ?? undefined,
|
||||
}),
|
||||
landingFooter: source?.landingFooter !== false,
|
||||
},
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1575,6 +1575,15 @@ describe('interfaceSchema', () => {
|
|||
},
|
||||
);
|
||||
|
||||
it('accepts the welcome screen heading and footer settings', () => {
|
||||
expect(
|
||||
interfaceSchema.parse({ landingHeading: 'greeting', landingFooter: false }),
|
||||
).toMatchObject({ landingHeading: 'greeting', landingFooter: false });
|
||||
expect(interfaceSchema.parse({})).not.toHaveProperty('landingHeading');
|
||||
expect(interfaceSchema.safeParse({ landingHeading: 'name' }).success).toBe(false);
|
||||
expect(interfaceSchema.safeParse({ landingFooter: 'false' }).success).toBe(false);
|
||||
});
|
||||
|
||||
it('silently strips removed legacy fields', () => {
|
||||
const result = interfaceSchema.parse({
|
||||
endpointsMenu: true,
|
||||
|
|
|
|||
|
|
@ -2788,6 +2788,13 @@ export const interfaceSchema = z
|
|||
.optional(),
|
||||
termsOfService: termsOfServiceSchema.optional(),
|
||||
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. */
|
||||
landingHeading: z.enum(['entity', 'greeting']).optional(),
|
||||
/** Shows the generic disclaimer and policy links beneath the welcome screen's
|
||||
* composer. A configured `customFooter` still renders when this is false. */
|
||||
landingFooter: z.boolean().optional(),
|
||||
mcpServers: mcpServersSchema.optional(),
|
||||
modelSelect: z.boolean().optional(),
|
||||
/** Set to false during a rolling upgrade, until every API replica supports title ownership and old title jobs drain. */
|
||||
|
|
@ -3095,6 +3102,8 @@ export const interfaceSchema = z
|
|||
fileCitations: true,
|
||||
buildInfo: true,
|
||||
mascot: true,
|
||||
landingHeading: 'entity',
|
||||
landingFooter: true,
|
||||
remoteAgents: {
|
||||
use: false,
|
||||
create: false,
|
||||
|
|
|
|||
|
|
@ -485,3 +485,23 @@ describe('running chat rename deployment fence', () => {
|
|||
expect(interfaceConfig?.runningChatRename).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('welcome screen heading and footer', () => {
|
||||
it('keeps the entity heading and the full footer by default', async () => {
|
||||
const interfaceConfig = await loadDefaultInterface({
|
||||
config: {},
|
||||
configDefaults: getConfigDefaults(),
|
||||
});
|
||||
expect(interfaceConfig?.landingHeading).toBe('entity');
|
||||
expect(interfaceConfig?.landingFooter).toBe(true);
|
||||
});
|
||||
|
||||
it('copies the configured settings through', async () => {
|
||||
const interfaceConfig = await loadDefaultInterface({
|
||||
config: { interface: { landingHeading: 'greeting', landingFooter: false } },
|
||||
configDefaults: getConfigDefaults(),
|
||||
});
|
||||
expect(interfaceConfig?.landingHeading).toBe('greeting');
|
||||
expect(interfaceConfig?.landingFooter).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -42,6 +42,8 @@ export async function loadDefaultInterface({
|
|||
termsOfService: interfaceConfig?.termsOfService ?? defaults.termsOfService,
|
||||
mcpServers: interfaceConfig?.mcpServers ?? defaults.mcpServers,
|
||||
customWelcome: interfaceConfig?.customWelcome ?? defaults.customWelcome,
|
||||
landingHeading: interfaceConfig?.landingHeading ?? defaults.landingHeading,
|
||||
landingFooter: interfaceConfig?.landingFooter ?? defaults.landingFooter,
|
||||
autoSubmitFromUrl: interfaceConfig?.autoSubmitFromUrl ?? defaults.autoSubmitFromUrl,
|
||||
colorModeFromUrl: interfaceConfig?.colorModeFromUrl ?? defaults.colorModeFromUrl,
|
||||
buildInfo: interfaceConfig?.buildInfo ?? defaults.buildInfo,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue