From 102920da813a9868f9c03fc4576ba7710fcaaec7 Mon Sep 17 00:00:00 2001 From: Fahleen1 Date: Wed, 18 Feb 2026 14:12:07 +0500 Subject: [PATCH] feat: Add configuration option to enable/disable Attach Files sidebar panel --- client/src/hooks/Nav/useSideNavLinks.ts | 17 ++++--- librechat.example.yaml | 4 ++ .../api/src/app/AppService.interface.spec.ts | 51 +++++++++++++++++++ packages/data-provider/src/config.ts | 2 + packages/data-schemas/src/app/interface.ts | 1 + 5 files changed, 68 insertions(+), 7 deletions(-) diff --git a/client/src/hooks/Nav/useSideNavLinks.ts b/client/src/hooks/Nav/useSideNavLinks.ts index 142784b517..51305dc7a3 100644 --- a/client/src/hooks/Nav/useSideNavLinks.ts +++ b/client/src/hooks/Nav/useSideNavLinks.ts @@ -141,13 +141,15 @@ export default function useSideNavLinks({ }); } - links.push({ - title: 'com_sidepanel_attach_files', - label: '', - icon: AttachmentIcon, - id: 'files', - Component: FilesPanel, - }); + if (interfaceConfig.attachFiles !== false) { + links.push({ + title: 'com_sidepanel_attach_files', + label: '', + icon: AttachmentIcon, + id: 'files', + Component: FilesPanel, + }); + } if (hasAccessToBookmarks) { links.push({ @@ -191,6 +193,7 @@ export default function useSideNavLinks({ hasAccessToMemories, hasAccessToReadMemories, interfaceConfig.parameters, + interfaceConfig.attachFiles, endpointType, hasAccessToBookmarks, availableMCPServers, diff --git a/librechat.example.yaml b/librechat.example.yaml index aa5b4e8cd8..63d0d7393b 100644 --- a/librechat.example.yaml +++ b/librechat.example.yaml @@ -85,6 +85,10 @@ interface: parameters: true sidePanel: true presets: true + # Enable/disable the Attach Files sidebar panel (default: true) + # When set to false, hides the sidebar's file management panel + # but users can still upload files directly in chats + attachFiles: true prompts: use: true share: false diff --git a/packages/api/src/app/AppService.interface.spec.ts b/packages/api/src/app/AppService.interface.spec.ts index e15d57e329..96ae1b24f4 100644 --- a/packages/api/src/app/AppService.interface.spec.ts +++ b/packages/api/src/app/AppService.interface.spec.ts @@ -154,4 +154,55 @@ describe('AppService interface configuration', () => { // Verify that peoplePicker is undefined when not provided expect(result.interfaceConfig?.peoplePicker).toBeUndefined(); }); + + it('should set attachFiles to true when config specifies attachFiles as true', async () => { + const config = { + interface: { + attachFiles: true, + }, + }; + + const result = await AppService({ config }); + + expect(result).toEqual( + expect.objectContaining({ + interfaceConfig: expect.objectContaining({ + attachFiles: true, + }), + }), + ); + }); + + it('should set attachFiles to false when config specifies attachFiles as false', async () => { + const config = { + interface: { + attachFiles: false, + }, + }; + + const result = await AppService({ config }); + + expect(result).toEqual( + expect.objectContaining({ + interfaceConfig: expect.objectContaining({ + attachFiles: false, + }), + }), + ); + }); + + it('should not set attachFiles when not provided in config', async () => { + const config = {}; + + const result = await AppService({ config }); + + expect(result).toEqual( + expect.objectContaining({ + interfaceConfig: expect.anything(), + }), + ); + + // Verify that attachFiles is undefined when not provided + expect(result.interfaceConfig?.attachFiles).toBeUndefined(); + }); }); diff --git a/packages/data-provider/src/config.ts b/packages/data-provider/src/config.ts index 02174b6496..7753c50942 100644 --- a/packages/data-provider/src/config.ts +++ b/packages/data-provider/src/config.ts @@ -623,6 +623,7 @@ export const interfaceSchema = z bookmarks: z.boolean().optional(), memories: z.boolean().optional(), presets: z.boolean().optional(), + attachFiles: z.boolean().optional(), prompts: z .union([ z.boolean(), @@ -681,6 +682,7 @@ export const interfaceSchema = z multiConvo: true, bookmarks: true, memories: true, + attachFiles: true, prompts: { use: true, create: true, diff --git a/packages/data-schemas/src/app/interface.ts b/packages/data-schemas/src/app/interface.ts index f8afdefd33..66945ba083 100644 --- a/packages/data-schemas/src/app/interface.ts +++ b/packages/data-schemas/src/app/interface.ts @@ -43,6 +43,7 @@ export async function loadDefaultInterface({ customWelcome: interfaceConfig?.customWelcome ?? defaults.customWelcome, // Permissions - only include if explicitly configured + attachFiles: interfaceConfig?.attachFiles, bookmarks: interfaceConfig?.bookmarks, memories: shouldDisableMemories ? false : interfaceConfig?.memories, prompts: interfaceConfig?.prompts,