diff --git a/client/src/components/Chat/Header.tsx b/client/src/components/Chat/Header.tsx index 41458d3dad..4451a6610a 100644 --- a/client/src/components/Chat/Header.tsx +++ b/client/src/components/Chat/Header.tsx @@ -149,6 +149,7 @@ function Header({ conversationId={routeConversationId ?? Constants.NEW_CONVO} agentId={conversation?.agent_id} isSubmitting={isSubmitting} + autoOpen={interfaceConfig.sessionRailAutoOpen !== false} /> )} {startupConfig != null && !sessionRail && !isNewChat && parentConversationId == null && ( diff --git a/client/src/components/Chat/Session/Session.tsx b/client/src/components/Chat/Session/Session.tsx index f89e842f5e..ff8752e551 100644 --- a/client/src/components/Chat/Session/Session.tsx +++ b/client/src/components/Chat/Session/Session.tsx @@ -1,9 +1,18 @@ -import { memo, useCallback, useState } from 'react'; +import { memo, useCallback, useEffect, useRef, useState } from 'react'; import { ListTodo } from 'lucide-react'; import { createPortal } from 'react-dom'; import { useAtom, useAtomValue } from 'jotai'; import { TooltipAnchor } from '@librechat/client'; -import { SESSION_RAIL_ID, SESSION_TOGGLE_ID, sessionRailOpen, sessionRailSlot } from './state'; +import { Constants } from 'librechat-data-provider'; +import { + SESSION_RAIL_ID, + sessionRailOpen, + sessionRailSlot, + SESSION_TOGGLE_ID, + sessionRailAutoOpen, + sessionRailDismissed, + SESSION_RAIL_DISMISSED_LIMIT, +} from './state'; import { ARTIFACTS_SHEET_MAX_WIDTH } from '~/utils/breakpoints'; import useBackgroundTasks from '../BackgroundTasks/useTasks'; import useScaledMaxWidth from '~/hooks/useScaledMaxWidth'; @@ -16,15 +25,21 @@ import { cn } from '~/utils'; * The chat header's session control and the rail it opens. It is always offered, so a reader * learns one place to look, and it is the single reader of the conversation's tasks: the dot on * the control and the rows in the rail cannot disagree. + * + * With `autoOpen`, work that starts running shows the rail without being asked. That costs the + * thread one re-wrap and no render: the rail's column narrows it, and nothing outside this + * component and the rail reads whether the rail is open. */ function Session({ conversationId, agentId, isSubmitting, + autoOpen = true, }: { conversationId: string; agentId?: string | null; isSubmitting: boolean; + autoOpen?: boolean; }) { const localize = useLocalize(); const slot = useAtomValue(sessionRailSlot); @@ -32,15 +47,55 @@ function Session({ const [docked, setDocked] = useAtom(sessionRailOpen); /** A sheet covers the conversation, so it never reopens itself from a remembered choice. */ const [sheetOpen, setSheetOpen] = useState(false); - const open = sheet ? sheetOpen : docked; + /** + * Shown for this conversation because work started in it. That is not the reader's standing + * choice, so it is not remembered as one and it ends with the conversation. Closing the rail + * is an answer: it is not shown again for the same conversation, whatever starts later and + * however often the reader comes back to it. An unsaved chat has no identity to remember + * that under, so its answer lasts as long as this control does. + */ + const [summoned, setSummoned] = useState(false); + const wanted = useAtomValue(sessionRailAutoOpen); + const [dismissedIds, setDismissedIds] = useAtom(sessionRailDismissed); + const dismissedUnsaved = useRef(false); + const saved = conversationId !== '' && conversationId !== Constants.NEW_CONVO; + const dismissed = saved && dismissedIds.includes(conversationId); + const open = sheet ? sheetOpen : docked || summoned; const [now, setNow] = useState(() => Date.now()); const view = useBackgroundTasks({ conversationId, isSubmitting, now, details: open }); const { activeCount, awaitingCount, failedCount, incomplete } = view; useTaskExpiry(view.rows, setNow); + /** Never as a sheet: that would cover the conversation the reader is in the middle of. */ + const working = activeCount > 0; + useEffect(() => { + if (autoOpen && wanted && working && !sheet && !dismissed && !dismissedUnsaved.current) { + setSummoned(true); + } + }, [autoOpen, wanted, working, sheet, dismissed]); + const setOpen = useCallback( - (next: boolean) => (sheet ? setSheetOpen(next) : setDocked(next)), - [sheet, setDocked], + (next: boolean) => { + if (sheet) { + setSheetOpen(next); + return; + } + setSummoned(false); + setDocked(next); + if (!saved) { + dismissedUnsaved.current = !next; + return; + } + /** Closing is remembered for this conversation; opening it by hand takes that back. */ + setDismissedIds((ids) => { + const others = ids.filter((id) => id !== conversationId); + if (next) { + return others.length === ids.length ? ids : others; + } + return [...others, conversationId].slice(-SESSION_RAIL_DISMISSED_LIMIT); + }); + }, + [conversationId, saved, sheet, setDismissedIds, setDocked], ); const close = useCallback( (restoreFocus = true) => { diff --git a/client/src/components/Chat/Session/__tests__/Session.test.tsx b/client/src/components/Chat/Session/__tests__/Session.test.tsx index dfaa9605ab..a4ab322e69 100644 --- a/client/src/components/Chat/Session/__tests__/Session.test.tsx +++ b/client/src/components/Chat/Session/__tests__/Session.test.tsx @@ -7,10 +7,15 @@ import { ContentTypes, QueryKeys, dataService } from 'librechat-data-provider'; import { activeSubagentPanel, ParentSubagentsProvider } from '@librechat/chat/react'; import type { ParentSubagentSummary, BackgroundTaskIndex, TMessage } from 'librechat-data-provider'; import type { JotaiStore } from 'test/harness'; +import { + sessionRailOpen, + sessionRailAutoOpen, + sessionRailDismissed, + SESSION_RAIL_DISMISSED_LIMIT, +} from '../state'; import { AgentsMapContext } from '~/Providers/AgentsMapContext'; import { SubagentIndexHostProvider } from 'test/streamHost'; import { ChatSurfaceHarness } from 'test/harness'; -import { sessionRailOpen } from '../state'; import SessionRailSlot from '../Slot'; import Session from '../Session'; @@ -122,11 +127,20 @@ const renderSession = ({ children = [], remembered, id = conversationId, + autoOpen = false, + wanted, + dismissed, }: { children?: ParentSubagentSummary[]; /** The reader's stored choice for the docked rail. */ remembered?: boolean; id?: string; + /** Off unless a test is about the rail showing itself, so the others open it by hand. */ + autoOpen?: boolean; + /** The reader's own setting for the rail showing itself. */ + wanted?: boolean; + /** Conversations the reader has already closed the rail in. */ + dismissed?: string[]; } = {}) => { jest.spyOn(dataService, 'getSubagentThread').mockImplementation(() => new Promise(() => {})); const queryClient = new QueryClient({ defaultOptions: { queries: { retry: false } } }); @@ -142,6 +156,8 @@ const renderSession = ({ seed={(store) => { atoms = store; if (remembered != null) store.set(sessionRailOpen, remembered); + if (wanted != null) store.set(sessionRailAutoOpen, wanted); + if (dismissed != null) store.set(sessionRailDismissed, dismissed); }} > @@ -150,7 +166,7 @@ const renderSession = ({
- +
@@ -165,6 +181,7 @@ const renderSession = ({ queryClient, getSelection: () => atoms.get(activeSubagentPanel), isRemembered: () => atoms.get(sessionRailOpen), + dismissedIn: () => atoms.get(sessionRailDismissed), }; }; @@ -471,6 +488,125 @@ describe('Session', () => { expect(rail).not.toContainElement(document.activeElement as HTMLElement); }); + describe('showing itself when work starts', () => { + it('opens for running work without being asked, and without that becoming the remembered choice', async () => { + jest.spyOn(dataService, 'getBackgroundTasks').mockResolvedValue(index()); + const { isRemembered } = renderSession({ autoOpen: true }); + const rail = await screen.findByTestId('session-rail'); + await waitFor(() => expect(within(rail).getAllByTestId('session-row')).toHaveLength(2)); + expect(toggle()).toHaveAttribute('aria-expanded', 'true'); + /** Focus stays where the reader had it. */ + expect(rail).not.toContainElement(document.activeElement as HTMLElement); + expect(isRemembered()).toBe(false); + }); + + it('stays closed for a conversation that only has finished work to list', async () => { + jest + .spyOn(dataService, 'getBackgroundTasks') + .mockResolvedValue(index({ tasks: [index().tasks[1]] })); + renderSession({ autoOpen: true }); + await waitFor(() => expect(toggle()).toHaveAccessibleName('com_ui_session_label_pending')); + expect(screen.queryByTestId('session-rail')).toBeNull(); + }); + + it('takes closing as an answer for the conversation, whatever starts next', async () => { + const running = index(); + const getTasks = jest.spyOn(dataService, 'getBackgroundTasks').mockResolvedValue(running); + const { queryClient, isRemembered } = renderSession({ autoOpen: true }); + const rail = await screen.findByTestId('session-rail'); + await userEvent.click(within(rail).getByRole('button', { name: 'com_ui_session_close' })); + expect(screen.queryByTestId('session-rail')).toBeNull(); + expect(isRemembered()).toBe(false); + + /** Everything finishes, then something new starts running. */ + getTasks.mockResolvedValue(index({ tasks: [running.tasks[1]] })); + await queryClient.refetchQueries([QueryKeys.backgroundTasks, conversationId]); + await waitFor(() => expect(toggle()).toHaveAccessibleName('com_ui_session_label_pending')); + getTasks.mockResolvedValue( + index({ tasks: [{ ...running.tasks[0], taskId: 'task-later', toolCallId: 'call-later' }] }), + ); + await queryClient.refetchQueries([QueryKeys.backgroundTasks, conversationId]); + await waitFor(() => expect(toggle()).toHaveAccessibleName('com_ui_session_label_running')); + expect(screen.queryByTestId('session-rail')).toBeNull(); + }); + + it('remembers that answer when the reader leaves the conversation and comes back', async () => { + jest.spyOn(dataService, 'getBackgroundTasks').mockResolvedValue(index()); + const first = renderSession({ autoOpen: true }); + const rail = await screen.findByTestId('session-rail'); + await userEvent.click(within(rail).getByRole('button', { name: 'com_ui_session_close' })); + expect(first.dismissedIn()).toEqual([conversationId]); + first.unmount(); + + /** A fresh visit: nothing of the first is left but what was stored. */ + const second = renderSession({ autoOpen: true }); + await waitFor(() => + expect(toggle()).toHaveAccessibleName( + 'com_ui_session_label_running; com_ui_session_label_pending', + ), + ); + expect(screen.queryByTestId('session-rail')).toBeNull(); + second.unmount(); + + /** It was an answer for that conversation, not for every one. */ + renderSession({ autoOpen: true, id: 'convo-2' }); + expect(await screen.findByTestId('session-rail')).toBeInTheDocument(); + }); + + it('takes the answer back when the reader opens the rail by hand', async () => { + jest.spyOn(dataService, 'getBackgroundTasks').mockResolvedValue(index()); + const { dismissedIn } = renderSession({ + autoOpen: true, + dismissed: ['convo-0', conversationId], + }); + await waitFor(() => expect(toggle()).not.toHaveAccessibleName('com_ui_session')); + expect(screen.queryByTestId('session-rail')).toBeNull(); + await userEvent.click(toggle()); + expect(await screen.findByTestId('session-rail')).toBeInTheDocument(); + expect(dismissedIn()).toEqual(['convo-0']); + }); + + it('keeps a bounded memory of where it was closed, dropping the oldest', async () => { + jest.spyOn(dataService, 'getBackgroundTasks').mockResolvedValue(index()); + const earlier = Array.from( + { length: SESSION_RAIL_DISMISSED_LIMIT }, + (_, position) => `earlier-${position}`, + ); + const { dismissedIn } = renderSession({ autoOpen: true, dismissed: earlier }); + const rail = await screen.findByTestId('session-rail'); + await userEvent.click(within(rail).getByRole('button', { name: 'com_ui_session_close' })); + expect(dismissedIn()).toHaveLength(SESSION_RAIL_DISMISSED_LIMIT); + expect(dismissedIn()[0]).toBe('earlier-1'); + expect(dismissedIn()[SESSION_RAIL_DISMISSED_LIMIT - 1]).toBe(conversationId); + }); + + it('stays out of the way of a reader who turned this off in their settings', async () => { + jest.spyOn(dataService, 'getBackgroundTasks').mockResolvedValue(index()); + renderSession({ autoOpen: true, wanted: false }); + await waitFor(() => expect(toggle()).not.toHaveAccessibleName('com_ui_session')); + expect(screen.queryByTestId('session-rail')).toBeNull(); + /** The control still opens it. */ + await userEvent.click(toggle()); + expect(await screen.findByTestId('session-rail')).toBeInTheDocument(); + }); + + it('does not cover the conversation on a small screen', async () => { + mockSheet.current = true; + jest.spyOn(dataService, 'getBackgroundTasks').mockResolvedValue(index()); + renderSession({ autoOpen: true }); + await waitFor(() => expect(toggle()).not.toHaveAccessibleName('com_ui_session')); + expect(screen.queryByTestId('session-rail')).toBeNull(); + expect(screen.queryByRole('dialog')).toBeNull(); + }); + + it('leaves the rail to the control when the deployment turns this off', async () => { + jest.spyOn(dataService, 'getBackgroundTasks').mockResolvedValue(index()); + renderSession({ autoOpen: false }); + await waitFor(() => expect(toggle()).not.toHaveAccessibleName('com_ui_session')); + expect(screen.queryByTestId('session-rail')).toBeNull(); + }); + }); + describe('on a small screen', () => { beforeEach(() => { mockSheet.current = true; diff --git a/client/src/components/Chat/Session/state.ts b/client/src/components/Chat/Session/state.ts index 88bb468074..8e56bb513c 100644 --- a/client/src/components/Chat/Session/state.ts +++ b/client/src/components/Chat/Session/state.ts @@ -10,5 +10,19 @@ export const sessionRailOpen = createStorageAtom('sessionRailOpen', fal */ export const sessionRailSlot = atom(null); +/** + * The reader's own switch for the rail showing itself when work starts. The deployment's comes + * first: where it has turned this off, the reader is not offered the switch. + */ +export const sessionRailAutoOpen = createStorageAtom('sessionRailAutoOpen', true); + +/** + * The conversations whose rail the reader closed, oldest first. The rail is not shown again by + * itself for one of these, on this visit or after coming back to it, and the list is bounded so + * it cannot grow with every conversation a reader ever closes it in. + */ +export const sessionRailDismissed = createStorageAtom('sessionRailDismissed', []); +export const SESSION_RAIL_DISMISSED_LIMIT = 100; + export const SESSION_RAIL_ID = 'session-rail'; export const SESSION_TOGGLE_ID = 'session-rail-toggle'; diff --git a/client/src/components/Chat/__tests__/Header.stacking.spec.tsx b/client/src/components/Chat/__tests__/Header.stacking.spec.tsx index 1ed4553bc7..26d39b227e 100644 --- a/client/src/components/Chat/__tests__/Header.stacking.spec.tsx +++ b/client/src/components/Chat/__tests__/Header.stacking.spec.tsx @@ -139,6 +139,15 @@ describe('Header stacking', () => { expect(backgroundTasks).not.toHaveBeenCalled(); }); + test('lets the rail show itself unless the deployment says otherwise', () => { + render(
); + expect(session.mock.calls[0][0]).toMatchObject({ autoOpen: true }); + session.mockClear(); + mockStartupConfig.current = { interface: { sessionRailAutoOpen: false } }; + render(
); + expect(session.mock.calls[0][0]).toMatchObject({ autoOpen: false }); + }); + test('offers the session control on a chat that has not been saved yet', () => { mockRoute.current = undefined; render(
); diff --git a/client/src/components/Nav/Settings/__tests__/Sidebar.spec.tsx b/client/src/components/Nav/Settings/__tests__/Sidebar.spec.tsx index 300ae7eff8..a09f25cf09 100644 --- a/client/src/components/Nav/Settings/__tests__/Sidebar.spec.tsx +++ b/client/src/components/Nav/Settings/__tests__/Sidebar.spec.tsx @@ -24,6 +24,7 @@ const ctx: SettingsContextValue = { allowAccountDeletion: true, aboutEnabled: false, mascotAllowed: true, + sessionRailAutoOpenAllowed: true, engineSTT: 'browser', engineTTS: 'browser', langfuseConnectionAccess: false, diff --git a/client/src/components/Nav/Settings/__tests__/context.spec.tsx b/client/src/components/Nav/Settings/__tests__/context.spec.tsx index 08cf15a023..7d79239d53 100644 --- a/client/src/components/Nav/Settings/__tests__/context.spec.tsx +++ b/client/src/components/Nav/Settings/__tests__/context.spec.tsx @@ -117,3 +117,30 @@ describe('useSettingsContext connected accounts', () => { expect(hasConnect()).toBe(false); }); }); + +describe('useSettingsContext session rail auto-open', () => { + afterEach(() => { + mockStartup = undefined; + }); + + const allowed = (): boolean => + renderHook(() => useSettingsContext(), { wrapper }).result.current.sessionRailAutoOpenAllowed; + + it('withholds the switch until the deployment has answered', () => { + mockStartup = undefined; + expect(allowed()).toBe(false); + }); + + it('offers the switch by default', () => { + mockStartup = { interface: {} } as Partial; + expect(allowed()).toBe(true); + }); + + it.each([{ sessionRail: false }, { sessionRailAutoOpen: false }])( + 'withholds the switch when the deployment sets %o', + (ui) => { + mockStartup = { interface: ui } as Partial; + expect(allowed()).toBe(false); + }, + ); +}); diff --git a/client/src/components/Nav/Settings/__tests__/registry.spec.ts b/client/src/components/Nav/Settings/__tests__/registry.spec.ts index a62b18a53b..c70af9ed54 100644 --- a/client/src/components/Nav/Settings/__tests__/registry.spec.ts +++ b/client/src/components/Nav/Settings/__tests__/registry.spec.ts @@ -26,6 +26,7 @@ const settingsContext: SettingsContextValue = { allowAccountDeletion: true, aboutEnabled: false, mascotAllowed: true, + sessionRailAutoOpenAllowed: true, engineSTT: 'browser', engineTTS: 'browser', langfuseConnectionAccess: false, @@ -76,6 +77,12 @@ describe('settings registry', () => { expect(entry?.show?.({ ...settingsContext, analyticsConfigured: true })).toBe(true); }); + it('offers the session rail switch only where the deployment lets the rail show itself', () => { + const entry = registry.find((e) => e.id === 'sessionRailAutoOpen'); + expect(entry?.show?.(settingsContext)).toBe(true); + expect(entry?.show?.({ ...settingsContext, sessionRailAutoOpenAllowed: false })).toBe(false); + }); + describe('setting applicability', () => { it.each(['usernameDisplay', 'saveBadgesState'])( 'does not offer the obsolete %s control', diff --git a/client/src/components/Nav/Settings/context.tsx b/client/src/components/Nav/Settings/context.tsx index 05a89f5a36..2f97a1fe08 100644 --- a/client/src/components/Nav/Settings/context.tsx +++ b/client/src/components/Nav/Settings/context.tsx @@ -52,6 +52,10 @@ export function useSettingsContext(): SettingsContextValue { const aboutEnabled = startupConfig?.interface?.buildInfo !== false; /* Offered only once the deployment has answered, so an operator's opt-out never flashes the row. */ const mascotAllowed = startupConfig != null && startupConfig.interface?.mascot !== false; + const sessionRailAutoOpenAllowed = + startupConfig != null && + startupConfig.interface?.sessionRail !== false && + startupConfig.interface?.sessionRailAutoOpen !== false; /* Offered only once the deployment has answered, matching the capability hook the alerts read: before then a toggle could store a preference, or raise the browser's permission prompt, for a capability the operator turns off. */ @@ -95,6 +99,7 @@ export function useSettingsContext(): SettingsContextValue { allowAccountDeletion, aboutEnabled, mascotAllowed, + sessionRailAutoOpenAllowed, engineSTT, engineTTS, langfuseConnectionAccess, @@ -124,6 +129,7 @@ export function useSettingsContext(): SettingsContextValue { allowAccountDeletion, aboutEnabled, mascotAllowed, + sessionRailAutoOpenAllowed, engineSTT, engineTTS, langfuseConnectionAccess, diff --git a/client/src/components/Nav/Settings/registry.tsx b/client/src/components/Nav/Settings/registry.tsx index 31362b4d6d..f2fc3050b8 100644 --- a/client/src/components/Nav/Settings/registry.tsx +++ b/client/src/components/Nav/Settings/registry.tsx @@ -33,6 +33,7 @@ import { ArchiveAllChats } from '../SettingsTabs/Data/ArchiveAllChats'; import { toggleControl, ThemeSetting, LangSetting } from './controls'; import BackupCodesItem from '../SettingsTabs/Account/BackupCodesItem'; import UiScaleSelector from '../SettingsTabs/General/UiScaleSelector'; +import { sessionRailAutoOpen } from '~/components/Chat/Session/state'; import FontSizeSelector from '../SettingsTabs/Chat/FontSizeSelector'; import ChatTitleInTab from '../SettingsTabs/General/ChatTitleInTab'; import AdvancedPrompts from '../SettingsTabs/Chat/AdvancedPrompts'; @@ -184,6 +185,20 @@ export const registry: SettingEntry[] = [ switchId: 'showScrollButton', }), }, + { + id: 'sessionRailAutoOpen', + tab: GENERAL, + section: 'layout', + labelKey: 'com_nav_session_rail_auto_open', + keywords: ['session', 'rail', 'background', 'tasks', 'subagents', 'sidebar', 'panel'], + show: (ctx) => ctx.sessionRailAutoOpenAllowed, + Component: toggleControl({ + stateAtom: sessionRailAutoOpen, + localizationKey: 'com_nav_session_rail_auto_open', + switchId: 'sessionRailAutoOpen', + hoverCardText: 'com_nav_info_session_rail_auto_open', + }), + }, { id: 'mobileDrawerStrip', tab: GENERAL, diff --git a/client/src/components/Nav/Settings/types.ts b/client/src/components/Nav/Settings/types.ts index 2ba013be19..07520d9cac 100644 --- a/client/src/components/Nav/Settings/types.ts +++ b/client/src/components/Nav/Settings/types.ts @@ -58,6 +58,8 @@ export interface SettingsContextValue { allowAccountDeletion: boolean; aboutEnabled: boolean; mascotAllowed: boolean; + /** The deployment has the session rail and lets it show itself. */ + sessionRailAutoOpenAllowed: boolean; engineSTT: string; engineTTS: string; langfuseConnectionAccess: boolean; diff --git a/client/src/locales/en/translation.json b/client/src/locales/en/translation.json index 22abc7abb4..9546dffc6a 100644 --- a/client/src/locales/en/translation.json +++ b/client/src/locales/en/translation.json @@ -1207,6 +1207,8 @@ "com_nav_setting_speech": "Speech", "com_nav_settings": "Settings", "com_nav_shared_links": "Shared chats", + "com_nav_session_rail_auto_open": "Open the session rail when work starts", + "com_nav_info_session_rail_auto_open": "Shows the session rail beside the chat when a subagent or background task starts running. If you close it, it stays closed for that chat.", "com_nav_show_lia": "Show Lia on the Welcome Screen", "com_nav_show_thinking": "Open Thinking Dropdowns by Default", "com_nav_slash_command": "/-Command", diff --git a/e2e/specs/mock/subagent-activity.spec.ts b/e2e/specs/mock/subagent-activity.spec.ts index 1241cb944f..88117f1ca2 100644 --- a/e2e/specs/mock/subagent-activity.spec.ts +++ b/e2e/specs/mock/subagent-activity.spec.ts @@ -284,9 +284,11 @@ test.describe('detached subagent activity', () => { ); expect(response.ok()).toBeTruthy(); - /** The children outlive the parent's turn, and the control counts them from the header. */ + /** The children outlive the parent's turn. The control counts them from the header, and + * the rail shows itself for them: it was closed above, but for the unsaved chat. */ await expect(toggle).toHaveAccessibleName(/^Session, 2 running/, { timeout: 30_000 }); - await toggle.click(); + await expect(rail).toBeVisible(); + await expect(toggle).toHaveAttribute('aria-expanded', 'true'); const rows = rail.getByTestId('session-row'); await expect(rows).toHaveCount(2); for (const childName of childNames) { @@ -324,9 +326,16 @@ test.describe('detached subagent activity', () => { await expect(rail.getByRole('button', { name: /^Stop/ })).toHaveCount(0); await expect(rail.getByTestId('session-row-now')).toHaveCount(0); - /** The docked rail is a layout choice: it is still there after a reload. */ + /** Showing itself for running work is not a remembered choice: after a reload nothing + * is running, and the rail is closed. Opened by hand it is a layout choice, and it is + * still there after the next one. */ await panel.getByRole('button', { name: 'Close' }).click(); await page.reload(); + await expect(toggle).toHaveAccessibleName('Session'); + await expect(rail).toHaveCount(0); + await toggle.click(); + await expect(rows).toHaveCount(2); + await page.reload(); await expect(rail).toBeVisible(); await expect(rows).toHaveCount(2); await rail.getByRole('button', { name: 'Close session' }).click(); diff --git a/librechat.example.yaml b/librechat.example.yaml index d95a748f5d..0e9df64372 100644 --- a/librechat.example.yaml +++ b/librechat.example.yaml @@ -334,6 +334,9 @@ interface: # List a conversation's subagents and background tasks in a rail beside the chat, opened # from the chat header. Set false to list them in a header popover instead. Default: true. sessionRail: true + # Show the session rail by itself when work starts running in a conversation (desktop only; + # closing it keeps it closed for that conversation). Default: true. + sessionRailAutoOpen: true # Ask each viewer before loading Google Tag Manager (ANALYTICS_GTM_ID). # Set false when the deployment settles consent itself, e.g. internal use. Default: true. # analyticsConsent: true diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts index 49cb900b5b..c2be4b0cbd 100644 --- a/packages/data-provider/src/config.ts +++ b/packages/data-provider/src/config.ts @@ -3572,6 +3572,11 @@ export const interfaceSchema = z * background tasks, opened from the chat header. Enabled by default; false restores * the header button that lists them in a popover and appears only once there are any. */ sessionRail: z.boolean().optional(), + /** Shows the session rail by itself when work starts running in a conversation, on + * screens wide enough to dock it. Enabled by default; false leaves the rail to the + * header control, as it was. A reader who closes it is not shown it again for that + * conversation either way. */ + sessionRailAutoOpen: z.boolean().optional(), /** Asks each viewer for consent before Google Tag Manager (`ANALYTICS_GTM_ID`) * loads. A deployment that settles consent itself, such as an internal one * covered by its own policy, can set false to load the container without the @@ -3817,6 +3822,7 @@ export const interfaceSchema = z artifactUndocking: true, sideChat: true, sessionRail: true, + sessionRailAutoOpen: true, feedback: true, peoplePicker: { users: true, diff --git a/packages/data-schemas/src/app/interface.spec.ts b/packages/data-schemas/src/app/interface.spec.ts index 92c91212c2..cd655465f4 100644 --- a/packages/data-schemas/src/app/interface.spec.ts +++ b/packages/data-schemas/src/app/interface.spec.ts @@ -272,6 +272,24 @@ describe('loadDefaultInterface', () => { expect(interfaceConfig?.sessionRail).toBe(true); }); + it('carries a disabled session rail auto-open flag to the clients', async () => { + const interfaceConfig = await loadDefaultInterface({ + config: { interface: { sessionRailAutoOpen: false } }, + configDefaults: getConfigDefaults(), + }); + + expect(interfaceConfig?.sessionRailAutoOpen).toBe(false); + }); + + it('opens the session rail by itself by default', async () => { + const interfaceConfig = await loadDefaultInterface({ + config: {}, + configDefaults: getConfigDefaults(), + }); + + expect(interfaceConfig?.sessionRailAutoOpen).toBe(true); + }); + it('carries a disabled analytics consent prompt to the clients', async () => { const interfaceConfig = await loadDefaultInterface({ config: { interface: { analyticsConsent: false } }, diff --git a/packages/data-schemas/src/app/interface.ts b/packages/data-schemas/src/app/interface.ts index 678118288e..e26a965b10 100644 --- a/packages/data-schemas/src/app/interface.ts +++ b/packages/data-schemas/src/app/interface.ts @@ -104,6 +104,7 @@ export async function loadDefaultInterface({ artifactUndocking: interfaceConfig?.artifactUndocking ?? defaults.artifactUndocking, sideChat: interfaceConfig?.sideChat ?? defaults.sideChat, sessionRail: interfaceConfig?.sessionRail ?? defaults.sessionRail, + sessionRailAutoOpen: interfaceConfig?.sessionRailAutoOpen ?? defaults.sessionRailAutoOpen, analyticsConsent: interfaceConfig?.analyticsConsent, contextCost: interfaceConfig?.contextCost ?? defaults.contextCost, feedback: interfaceConfig?.feedback ?? defaults.feedback,