⛵ fix: Resolve Agent Provider Endpoint Type for File Upload Support (#12117)
* chore: Remove unused setValueOnChange prop from MCPServerMenuItem component
* fix: Resolve agent provider endpoint type for file upload support
When using the agents endpoint with a custom provider (e.g., Moonshot),
the endpointType was resolving to "agents" instead of the provider's
actual type ("custom"), causing "Upload to Provider" to not appear in
the file attach menu.
Adds `resolveEndpointType` utility in data-provider that follows the
chain: endpoint (if not agents) → agent.provider → agents. Applied
consistently across AttachFileChat, DragDropContext, useDragHelpers,
and AgentPanel file components (FileContext, FileSearch, Code/Files).
* refactor: Extract useAgentFileConfig hook, restore deleted tests, fix review findings
- Extract shared provider resolution logic into useAgentFileConfig hook
(Finding #2: DRY violation across FileContext, FileSearch, Code/Files)
- Restore 18 deleted test cases in AttachFileMenu.spec.tsx covering
agent capabilities, SharePoint, edge cases, and button state
(Finding #1: accidental test deletion)
- Wrap fileConfigEndpoint in useMemo in AttachFileChat (Finding #3)
- Fix misleading test name in AgentFileConfig.spec.tsx (Finding #4)
- Fix import order in FileSearch.tsx, FileContext.tsx, Code/Files.tsx (Finding #5)
- Add comment about cache gap in useDragHelpers (Finding #6)
- Clarify resolveEndpointType JSDoc (Finding #7)
* refactor: Memoize Footer component for performance optimization
- Converted Footer component to a memoized version to prevent unnecessary re-renders.
- Improved import structure by adding memo to the React import statement for clarity.
* chore: Fix remaining review nits
- Widen useAgentFileConfig return type to EModelEndpoint | string
- Fix import order in FileContext.tsx and FileSearch.tsx
- Remove dead endpointType param from setupMocks in AttachFileMenu test
* fix: Pass resolved provider endpoint to file upload validation
AgentPanel file components (FileContext, FileSearch, Code/Files) were
hardcoding endpointOverride to "agents", causing both client-side
validation (file limits, MIME types) and server-side validation to
use the agents config instead of the provider-specific config.
Adds endpointTypeOverride to UseFileHandling params so endpoint and
endpointType can be set independently. Components now pass the
resolved provider name and type from useAgentFileConfig, so the full
fallback chain (provider → custom → agents → default) applies to
file upload validation on both client and server.
* test: Verify any custom endpoint is document-supported regardless of name
Adds parameterized tests with arbitrary endpoint names (spaces, hyphens,
colons, etc.) confirming that all custom endpoints resolve to
document-supported through resolveEndpointType, both as direct
endpoints and as agent providers.
* fix: Use || for provider fallback, test endpointOverride wiring
- Change providerValue ?? to providerValue || so empty string is
treated as "no provider" consistently with resolveEndpointType
- Add wiring tests to CodeFiles, FileContext, FileSearch verifying
endpointOverride and endpointTypeOverride are passed correctly
- Update endpointOverride JSDoc to document endpointType fallback
2026-03-07 10:45:43 -05:00
|
|
|
import React from 'react';
|
|
|
|
|
import { render, screen } from '@testing-library/react';
|
|
|
|
|
import { useForm, FormProvider } from 'react-hook-form';
|
|
|
|
|
import { EModelEndpoint, mergeFileConfig, resolveEndpointType } from 'librechat-data-provider';
|
|
|
|
|
import type { TEndpointsConfig } from 'librechat-data-provider';
|
|
|
|
|
import type { AgentForm } from '~/common';
|
|
|
|
|
import useAgentFileConfig from '~/hooks/Agents/useAgentFileConfig';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Tests the useAgentFileConfig hook used by FileContext, FileSearch, and Code/Files.
|
|
|
|
|
* Uses the real hook with mocked data-fetching layer.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
const mockEndpointsConfig: TEndpointsConfig = {
|
|
|
|
|
[EModelEndpoint.openAI]: { userProvide: false, order: 0 },
|
|
|
|
|
[EModelEndpoint.agents]: { userProvide: false, order: 1 },
|
|
|
|
|
Moonshot: { type: EModelEndpoint.custom, userProvide: false, order: 9999 },
|
|
|
|
|
'Some Endpoint': { type: EModelEndpoint.custom, userProvide: false, order: 9999 },
|
|
|
|
|
};
|
|
|
|
|
|
2026-03-15 10:35:44 -04:00
|
|
|
const defaultFileConfig = mergeFileConfig({
|
⛵ fix: Resolve Agent Provider Endpoint Type for File Upload Support (#12117)
* chore: Remove unused setValueOnChange prop from MCPServerMenuItem component
* fix: Resolve agent provider endpoint type for file upload support
When using the agents endpoint with a custom provider (e.g., Moonshot),
the endpointType was resolving to "agents" instead of the provider's
actual type ("custom"), causing "Upload to Provider" to not appear in
the file attach menu.
Adds `resolveEndpointType` utility in data-provider that follows the
chain: endpoint (if not agents) → agent.provider → agents. Applied
consistently across AttachFileChat, DragDropContext, useDragHelpers,
and AgentPanel file components (FileContext, FileSearch, Code/Files).
* refactor: Extract useAgentFileConfig hook, restore deleted tests, fix review findings
- Extract shared provider resolution logic into useAgentFileConfig hook
(Finding #2: DRY violation across FileContext, FileSearch, Code/Files)
- Restore 18 deleted test cases in AttachFileMenu.spec.tsx covering
agent capabilities, SharePoint, edge cases, and button state
(Finding #1: accidental test deletion)
- Wrap fileConfigEndpoint in useMemo in AttachFileChat (Finding #3)
- Fix misleading test name in AgentFileConfig.spec.tsx (Finding #4)
- Fix import order in FileSearch.tsx, FileContext.tsx, Code/Files.tsx (Finding #5)
- Add comment about cache gap in useDragHelpers (Finding #6)
- Clarify resolveEndpointType JSDoc (Finding #7)
* refactor: Memoize Footer component for performance optimization
- Converted Footer component to a memoized version to prevent unnecessary re-renders.
- Improved import structure by adding memo to the React import statement for clarity.
* chore: Fix remaining review nits
- Widen useAgentFileConfig return type to EModelEndpoint | string
- Fix import order in FileContext.tsx and FileSearch.tsx
- Remove dead endpointType param from setupMocks in AttachFileMenu test
* fix: Pass resolved provider endpoint to file upload validation
AgentPanel file components (FileContext, FileSearch, Code/Files) were
hardcoding endpointOverride to "agents", causing both client-side
validation (file limits, MIME types) and server-side validation to
use the agents config instead of the provider-specific config.
Adds endpointTypeOverride to UseFileHandling params so endpoint and
endpointType can be set independently. Components now pass the
resolved provider name and type from useAgentFileConfig, so the full
fallback chain (provider → custom → agents → default) applies to
file upload validation on both client and server.
* test: Verify any custom endpoint is document-supported regardless of name
Adds parameterized tests with arbitrary endpoint names (spaces, hyphens,
colons, etc.) confirming that all custom endpoints resolve to
document-supported through resolveEndpointType, both as direct
endpoints and as agent providers.
* fix: Use || for provider fallback, test endpointOverride wiring
- Change providerValue ?? to providerValue || so empty string is
treated as "no provider" consistently with resolveEndpointType
- Add wiring tests to CodeFiles, FileContext, FileSearch verifying
endpointOverride and endpointTypeOverride are passed correctly
- Update endpointOverride JSDoc to document endpointType fallback
2026-03-07 10:45:43 -05:00
|
|
|
endpoints: {
|
|
|
|
|
Moonshot: { fileLimit: 5 },
|
|
|
|
|
[EModelEndpoint.agents]: { fileLimit: 20 },
|
|
|
|
|
default: { fileLimit: 10 },
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
2026-03-15 10:35:44 -04:00
|
|
|
let mockFileConfig = defaultFileConfig;
|
|
|
|
|
|
⛵ fix: Resolve Agent Provider Endpoint Type for File Upload Support (#12117)
* chore: Remove unused setValueOnChange prop from MCPServerMenuItem component
* fix: Resolve agent provider endpoint type for file upload support
When using the agents endpoint with a custom provider (e.g., Moonshot),
the endpointType was resolving to "agents" instead of the provider's
actual type ("custom"), causing "Upload to Provider" to not appear in
the file attach menu.
Adds `resolveEndpointType` utility in data-provider that follows the
chain: endpoint (if not agents) → agent.provider → agents. Applied
consistently across AttachFileChat, DragDropContext, useDragHelpers,
and AgentPanel file components (FileContext, FileSearch, Code/Files).
* refactor: Extract useAgentFileConfig hook, restore deleted tests, fix review findings
- Extract shared provider resolution logic into useAgentFileConfig hook
(Finding #2: DRY violation across FileContext, FileSearch, Code/Files)
- Restore 18 deleted test cases in AttachFileMenu.spec.tsx covering
agent capabilities, SharePoint, edge cases, and button state
(Finding #1: accidental test deletion)
- Wrap fileConfigEndpoint in useMemo in AttachFileChat (Finding #3)
- Fix misleading test name in AgentFileConfig.spec.tsx (Finding #4)
- Fix import order in FileSearch.tsx, FileContext.tsx, Code/Files.tsx (Finding #5)
- Add comment about cache gap in useDragHelpers (Finding #6)
- Clarify resolveEndpointType JSDoc (Finding #7)
* refactor: Memoize Footer component for performance optimization
- Converted Footer component to a memoized version to prevent unnecessary re-renders.
- Improved import structure by adding memo to the React import statement for clarity.
* chore: Fix remaining review nits
- Widen useAgentFileConfig return type to EModelEndpoint | string
- Fix import order in FileContext.tsx and FileSearch.tsx
- Remove dead endpointType param from setupMocks in AttachFileMenu test
* fix: Pass resolved provider endpoint to file upload validation
AgentPanel file components (FileContext, FileSearch, Code/Files) were
hardcoding endpointOverride to "agents", causing both client-side
validation (file limits, MIME types) and server-side validation to
use the agents config instead of the provider-specific config.
Adds endpointTypeOverride to UseFileHandling params so endpoint and
endpointType can be set independently. Components now pass the
resolved provider name and type from useAgentFileConfig, so the full
fallback chain (provider → custom → agents → default) applies to
file upload validation on both client and server.
* test: Verify any custom endpoint is document-supported regardless of name
Adds parameterized tests with arbitrary endpoint names (spaces, hyphens,
colons, etc.) confirming that all custom endpoints resolve to
document-supported through resolveEndpointType, both as direct
endpoints and as agent providers.
* fix: Use || for provider fallback, test endpointOverride wiring
- Change providerValue ?? to providerValue || so empty string is
treated as "no provider" consistently with resolveEndpointType
- Add wiring tests to CodeFiles, FileContext, FileSearch verifying
endpointOverride and endpointTypeOverride are passed correctly
- Update endpointOverride JSDoc to document endpointType fallback
2026-03-07 10:45:43 -05:00
|
|
|
jest.mock('~/data-provider', () => ({
|
|
|
|
|
useGetEndpointsQuery: () => ({ data: mockEndpointsConfig }),
|
|
|
|
|
useGetFileConfig: ({ select }: { select?: (data: unknown) => unknown }) => ({
|
|
|
|
|
data: select != null ? select(mockFileConfig) : mockFileConfig,
|
|
|
|
|
}),
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
function FileConfigProbe() {
|
|
|
|
|
const { endpointType, endpointFileConfig } = useAgentFileConfig();
|
|
|
|
|
return (
|
|
|
|
|
<div>
|
|
|
|
|
<span data-testid="endpointType">{String(endpointType)}</span>
|
|
|
|
|
<span data-testid="fileLimit">{endpointFileConfig.fileLimit}</span>
|
|
|
|
|
<span data-testid="disabled">{String(endpointFileConfig.disabled ?? false)}</span>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function TestWrapper({ provider }: { provider?: string | { label: string; value: string } }) {
|
|
|
|
|
const methods = useForm<AgentForm>({
|
|
|
|
|
defaultValues: { provider: provider as AgentForm['provider'] },
|
|
|
|
|
});
|
|
|
|
|
return (
|
|
|
|
|
<FormProvider {...methods}>
|
|
|
|
|
<FileConfigProbe />
|
|
|
|
|
</FormProvider>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('AgentPanel file config resolution (useAgentFileConfig)', () => {
|
|
|
|
|
describe('endpointType resolution from form provider', () => {
|
|
|
|
|
it('resolves to custom when provider is a custom endpoint string', () => {
|
|
|
|
|
render(<TestWrapper provider="Moonshot" />);
|
|
|
|
|
expect(screen.getByTestId('endpointType').textContent).toBe(EModelEndpoint.custom);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('resolves to custom when provider is a custom endpoint with spaces', () => {
|
|
|
|
|
render(<TestWrapper provider="Some Endpoint" />);
|
|
|
|
|
expect(screen.getByTestId('endpointType').textContent).toBe(EModelEndpoint.custom);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('resolves to openAI when provider is openAI', () => {
|
|
|
|
|
render(<TestWrapper provider={EModelEndpoint.openAI} />);
|
|
|
|
|
expect(screen.getByTestId('endpointType').textContent).toBe(EModelEndpoint.openAI);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('falls back to agents when provider is undefined', () => {
|
|
|
|
|
render(<TestWrapper />);
|
|
|
|
|
expect(screen.getByTestId('endpointType').textContent).toBe(EModelEndpoint.agents);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('falls back to agents when provider is empty string', () => {
|
|
|
|
|
render(<TestWrapper provider="" />);
|
|
|
|
|
expect(screen.getByTestId('endpointType').textContent).toBe(EModelEndpoint.agents);
|
|
|
|
|
expect(screen.getByTestId('fileLimit').textContent).toBe('20');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('falls back to agents when provider option has empty value', () => {
|
|
|
|
|
render(<TestWrapper provider={{ label: '', value: '' }} />);
|
|
|
|
|
expect(screen.getByTestId('endpointType').textContent).toBe(EModelEndpoint.agents);
|
|
|
|
|
expect(screen.getByTestId('fileLimit').textContent).toBe('20');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('resolves correctly when provider is an option object', () => {
|
|
|
|
|
render(<TestWrapper provider={{ label: 'Moonshot', value: 'Moonshot' }} />);
|
|
|
|
|
expect(screen.getByTestId('endpointType').textContent).toBe(EModelEndpoint.custom);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('file config fallback chain', () => {
|
|
|
|
|
it('uses Moonshot-specific file config when provider is Moonshot', () => {
|
|
|
|
|
render(<TestWrapper provider="Moonshot" />);
|
|
|
|
|
expect(screen.getByTestId('fileLimit').textContent).toBe('5');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('falls back to agents file config when provider has no specific config', () => {
|
|
|
|
|
render(<TestWrapper provider="Some Endpoint" />);
|
|
|
|
|
expect(screen.getByTestId('fileLimit').textContent).toBe('20');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('uses agents file config when no provider is set', () => {
|
|
|
|
|
render(<TestWrapper />);
|
|
|
|
|
expect(screen.getByTestId('fileLimit').textContent).toBe('20');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('falls back to default config for openAI provider (no openAI-specific config)', () => {
|
|
|
|
|
render(<TestWrapper provider={EModelEndpoint.openAI} />);
|
|
|
|
|
expect(screen.getByTestId('fileLimit').textContent).toBe('10');
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('disabled state', () => {
|
2026-03-15 10:35:44 -04:00
|
|
|
beforeEach(() => {
|
|
|
|
|
mockFileConfig = defaultFileConfig;
|
|
|
|
|
});
|
|
|
|
|
|
⛵ fix: Resolve Agent Provider Endpoint Type for File Upload Support (#12117)
* chore: Remove unused setValueOnChange prop from MCPServerMenuItem component
* fix: Resolve agent provider endpoint type for file upload support
When using the agents endpoint with a custom provider (e.g., Moonshot),
the endpointType was resolving to "agents" instead of the provider's
actual type ("custom"), causing "Upload to Provider" to not appear in
the file attach menu.
Adds `resolveEndpointType` utility in data-provider that follows the
chain: endpoint (if not agents) → agent.provider → agents. Applied
consistently across AttachFileChat, DragDropContext, useDragHelpers,
and AgentPanel file components (FileContext, FileSearch, Code/Files).
* refactor: Extract useAgentFileConfig hook, restore deleted tests, fix review findings
- Extract shared provider resolution logic into useAgentFileConfig hook
(Finding #2: DRY violation across FileContext, FileSearch, Code/Files)
- Restore 18 deleted test cases in AttachFileMenu.spec.tsx covering
agent capabilities, SharePoint, edge cases, and button state
(Finding #1: accidental test deletion)
- Wrap fileConfigEndpoint in useMemo in AttachFileChat (Finding #3)
- Fix misleading test name in AgentFileConfig.spec.tsx (Finding #4)
- Fix import order in FileSearch.tsx, FileContext.tsx, Code/Files.tsx (Finding #5)
- Add comment about cache gap in useDragHelpers (Finding #6)
- Clarify resolveEndpointType JSDoc (Finding #7)
* refactor: Memoize Footer component for performance optimization
- Converted Footer component to a memoized version to prevent unnecessary re-renders.
- Improved import structure by adding memo to the React import statement for clarity.
* chore: Fix remaining review nits
- Widen useAgentFileConfig return type to EModelEndpoint | string
- Fix import order in FileContext.tsx and FileSearch.tsx
- Remove dead endpointType param from setupMocks in AttachFileMenu test
* fix: Pass resolved provider endpoint to file upload validation
AgentPanel file components (FileContext, FileSearch, Code/Files) were
hardcoding endpointOverride to "agents", causing both client-side
validation (file limits, MIME types) and server-side validation to
use the agents config instead of the provider-specific config.
Adds endpointTypeOverride to UseFileHandling params so endpoint and
endpointType can be set independently. Components now pass the
resolved provider name and type from useAgentFileConfig, so the full
fallback chain (provider → custom → agents → default) applies to
file upload validation on both client and server.
* test: Verify any custom endpoint is document-supported regardless of name
Adds parameterized tests with arbitrary endpoint names (spaces, hyphens,
colons, etc.) confirming that all custom endpoints resolve to
document-supported through resolveEndpointType, both as direct
endpoints and as agent providers.
* fix: Use || for provider fallback, test endpointOverride wiring
- Change providerValue ?? to providerValue || so empty string is
treated as "no provider" consistently with resolveEndpointType
- Add wiring tests to CodeFiles, FileContext, FileSearch verifying
endpointOverride and endpointTypeOverride are passed correctly
- Update endpointOverride JSDoc to document endpointType fallback
2026-03-07 10:45:43 -05:00
|
|
|
it('reports not disabled for standard config', () => {
|
|
|
|
|
render(<TestWrapper provider="Moonshot" />);
|
|
|
|
|
expect(screen.getByTestId('disabled').textContent).toBe('false');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('reports disabled when provider-specific config is disabled', () => {
|
|
|
|
|
mockFileConfig = mergeFileConfig({
|
|
|
|
|
endpoints: {
|
|
|
|
|
Moonshot: { disabled: true },
|
|
|
|
|
[EModelEndpoint.agents]: { fileLimit: 20 },
|
|
|
|
|
default: { fileLimit: 10 },
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
render(<TestWrapper provider="Moonshot" />);
|
|
|
|
|
expect(screen.getByTestId('disabled').textContent).toBe('true');
|
2026-03-15 10:35:44 -04:00
|
|
|
});
|
⛵ fix: Resolve Agent Provider Endpoint Type for File Upload Support (#12117)
* chore: Remove unused setValueOnChange prop from MCPServerMenuItem component
* fix: Resolve agent provider endpoint type for file upload support
When using the agents endpoint with a custom provider (e.g., Moonshot),
the endpointType was resolving to "agents" instead of the provider's
actual type ("custom"), causing "Upload to Provider" to not appear in
the file attach menu.
Adds `resolveEndpointType` utility in data-provider that follows the
chain: endpoint (if not agents) → agent.provider → agents. Applied
consistently across AttachFileChat, DragDropContext, useDragHelpers,
and AgentPanel file components (FileContext, FileSearch, Code/Files).
* refactor: Extract useAgentFileConfig hook, restore deleted tests, fix review findings
- Extract shared provider resolution logic into useAgentFileConfig hook
(Finding #2: DRY violation across FileContext, FileSearch, Code/Files)
- Restore 18 deleted test cases in AttachFileMenu.spec.tsx covering
agent capabilities, SharePoint, edge cases, and button state
(Finding #1: accidental test deletion)
- Wrap fileConfigEndpoint in useMemo in AttachFileChat (Finding #3)
- Fix misleading test name in AgentFileConfig.spec.tsx (Finding #4)
- Fix import order in FileSearch.tsx, FileContext.tsx, Code/Files.tsx (Finding #5)
- Add comment about cache gap in useDragHelpers (Finding #6)
- Clarify resolveEndpointType JSDoc (Finding #7)
* refactor: Memoize Footer component for performance optimization
- Converted Footer component to a memoized version to prevent unnecessary re-renders.
- Improved import structure by adding memo to the React import statement for clarity.
* chore: Fix remaining review nits
- Widen useAgentFileConfig return type to EModelEndpoint | string
- Fix import order in FileContext.tsx and FileSearch.tsx
- Remove dead endpointType param from setupMocks in AttachFileMenu test
* fix: Pass resolved provider endpoint to file upload validation
AgentPanel file components (FileContext, FileSearch, Code/Files) were
hardcoding endpointOverride to "agents", causing both client-side
validation (file limits, MIME types) and server-side validation to
use the agents config instead of the provider-specific config.
Adds endpointTypeOverride to UseFileHandling params so endpoint and
endpointType can be set independently. Components now pass the
resolved provider name and type from useAgentFileConfig, so the full
fallback chain (provider → custom → agents → default) applies to
file upload validation on both client and server.
* test: Verify any custom endpoint is document-supported regardless of name
Adds parameterized tests with arbitrary endpoint names (spaces, hyphens,
colons, etc.) confirming that all custom endpoints resolve to
document-supported through resolveEndpointType, both as direct
endpoints and as agent providers.
* fix: Use || for provider fallback, test endpointOverride wiring
- Change providerValue ?? to providerValue || so empty string is
treated as "no provider" consistently with resolveEndpointType
- Add wiring tests to CodeFiles, FileContext, FileSearch verifying
endpointOverride and endpointTypeOverride are passed correctly
- Update endpointOverride JSDoc to document endpointType fallback
2026-03-07 10:45:43 -05:00
|
|
|
|
2026-03-15 10:35:44 -04:00
|
|
|
it('reports disabled when agents config is disabled and no provider set', () => {
|
|
|
|
|
mockFileConfig = mergeFileConfig({
|
|
|
|
|
endpoints: {
|
|
|
|
|
[EModelEndpoint.agents]: { disabled: true },
|
|
|
|
|
default: { fileLimit: 10 },
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
render(<TestWrapper />);
|
|
|
|
|
expect(screen.getByTestId('disabled').textContent).toBe('true');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('reports disabled when agents is disabled and provider has no specific config', () => {
|
|
|
|
|
mockFileConfig = mergeFileConfig({
|
|
|
|
|
endpoints: {
|
|
|
|
|
[EModelEndpoint.agents]: { disabled: true },
|
|
|
|
|
default: { fileLimit: 10 },
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
render(<TestWrapper provider="Some Endpoint" />);
|
|
|
|
|
expect(screen.getByTestId('disabled').textContent).toBe('true');
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('provider-specific enabled overrides agents disabled', () => {
|
|
|
|
|
mockFileConfig = mergeFileConfig({
|
|
|
|
|
endpoints: {
|
|
|
|
|
Moonshot: { disabled: false, fileLimit: 5 },
|
|
|
|
|
[EModelEndpoint.agents]: { disabled: true },
|
|
|
|
|
default: { fileLimit: 10 },
|
|
|
|
|
},
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
render(<TestWrapper provider="Moonshot" />);
|
|
|
|
|
expect(screen.getByTestId('disabled').textContent).toBe('false');
|
|
|
|
|
expect(screen.getByTestId('fileLimit').textContent).toBe('5');
|
⛵ fix: Resolve Agent Provider Endpoint Type for File Upload Support (#12117)
* chore: Remove unused setValueOnChange prop from MCPServerMenuItem component
* fix: Resolve agent provider endpoint type for file upload support
When using the agents endpoint with a custom provider (e.g., Moonshot),
the endpointType was resolving to "agents" instead of the provider's
actual type ("custom"), causing "Upload to Provider" to not appear in
the file attach menu.
Adds `resolveEndpointType` utility in data-provider that follows the
chain: endpoint (if not agents) → agent.provider → agents. Applied
consistently across AttachFileChat, DragDropContext, useDragHelpers,
and AgentPanel file components (FileContext, FileSearch, Code/Files).
* refactor: Extract useAgentFileConfig hook, restore deleted tests, fix review findings
- Extract shared provider resolution logic into useAgentFileConfig hook
(Finding #2: DRY violation across FileContext, FileSearch, Code/Files)
- Restore 18 deleted test cases in AttachFileMenu.spec.tsx covering
agent capabilities, SharePoint, edge cases, and button state
(Finding #1: accidental test deletion)
- Wrap fileConfigEndpoint in useMemo in AttachFileChat (Finding #3)
- Fix misleading test name in AgentFileConfig.spec.tsx (Finding #4)
- Fix import order in FileSearch.tsx, FileContext.tsx, Code/Files.tsx (Finding #5)
- Add comment about cache gap in useDragHelpers (Finding #6)
- Clarify resolveEndpointType JSDoc (Finding #7)
* refactor: Memoize Footer component for performance optimization
- Converted Footer component to a memoized version to prevent unnecessary re-renders.
- Improved import structure by adding memo to the React import statement for clarity.
* chore: Fix remaining review nits
- Widen useAgentFileConfig return type to EModelEndpoint | string
- Fix import order in FileContext.tsx and FileSearch.tsx
- Remove dead endpointType param from setupMocks in AttachFileMenu test
* fix: Pass resolved provider endpoint to file upload validation
AgentPanel file components (FileContext, FileSearch, Code/Files) were
hardcoding endpointOverride to "agents", causing both client-side
validation (file limits, MIME types) and server-side validation to
use the agents config instead of the provider-specific config.
Adds endpointTypeOverride to UseFileHandling params so endpoint and
endpointType can be set independently. Components now pass the
resolved provider name and type from useAgentFileConfig, so the full
fallback chain (provider → custom → agents → default) applies to
file upload validation on both client and server.
* test: Verify any custom endpoint is document-supported regardless of name
Adds parameterized tests with arbitrary endpoint names (spaces, hyphens,
colons, etc.) confirming that all custom endpoints resolve to
document-supported through resolveEndpointType, both as direct
endpoints and as agent providers.
* fix: Use || for provider fallback, test endpointOverride wiring
- Change providerValue ?? to providerValue || so empty string is
treated as "no provider" consistently with resolveEndpointType
- Add wiring tests to CodeFiles, FileContext, FileSearch verifying
endpointOverride and endpointTypeOverride are passed correctly
- Update endpointOverride JSDoc to document endpointType fallback
2026-03-07 10:45:43 -05:00
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
describe('consistency with direct custom endpoint', () => {
|
|
|
|
|
it('resolves to the same type as a direct custom endpoint would', () => {
|
|
|
|
|
render(<TestWrapper provider="Moonshot" />);
|
|
|
|
|
const agentEndpointType = screen.getByTestId('endpointType').textContent;
|
|
|
|
|
const directEndpointType = resolveEndpointType(mockEndpointsConfig, 'Moonshot');
|
|
|
|
|
expect(agentEndpointType).toBe(directEndpointType);
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
});
|