Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

🧰 feat: Move Code Settings Into Run Code (#15722)

Danny Avilaf50c40e2f583
diff --git a/client/src/components/SidePanel/Agents/Advanced/AdvancedPanel.tsx b/client/src/components/SidePanel/Agents/Advanced/AdvancedPanel.tsx
index 227dc96403..1c84ddee0b 100644
--- a/client/src/components/SidePanel/Agents/Advanced/AdvancedPanel.tsx
+++ b/client/src/components/SidePanel/Agents/Advanced/AdvancedPanel.tsx
@@ -1,11 +1,9 @@
-import { useMemo, useState } from 'react';
+import { useState } from 'react';
import { useFormContext } from 'react-hook-form';
import { ChevronLeft, Check, Copy } from 'lucide-react';
-import { AgentCapabilities } from 'librechat-data-provider';
import { Button, TooltipAnchor, labelVariants, useToastContext } from '@librechat/client';
import type { AgentForm } from '~/common';
import { useAgentPanelContext } from '~/Providers';
-import StatefulSessions from './StatefulSessions';
import OrchestrationHub from './OrchestrationHub';
import MaxAgentSteps from './MaxAgentSteps';
import { groupHeadingClass } from './ui';
@@ -19,11 +17,7 @@ export default function AdvancedPanel() {
const currentAgentId = watch('id');
const [copied, setCopied] = useState(false);
- const { agentsConfig, setActivePanel } = useAgentPanelContext();
- const statefulSessionsEnabled = useMemo(
- () => agentsConfig?.capabilities.includes(AgentCapabilities.stateful_code_sessions) ?? false,
- [agentsConfig],
- );
+ const { setActivePanel } = useAgentPanelContext();
const handleCopyAgentId = async () => {
if (!currentAgentId) return;
@@ -59,7 +53,6 @@ export default function AdvancedPanel() {
<section className="flex flex-col gap-3">
<span className={groupHeadingClass}>{localize('com_ui_essentials')}</span>
<MaxAgentSteps />
- {statefulSessionsEnabled && <StatefulSessions />}
</section>
<OrchestrationHub currentAgentId={currentAgentId} />
diff --git a/client/src/components/SidePanel/Agents/Advanced/StatefulSessions.tsx b/client/src/components/SidePanel/Agents/Code/Settings.tsx
similarity index 96%
rename from client/src/components/SidePanel/Agents/Advanced/StatefulSessions.tsx
rename to client/src/components/SidePanel/Agents/Code/Settings.tsx
index 4e21a57880..c70a9014b5 100644
--- a/client/src/components/SidePanel/Agents/Advanced/StatefulSessions.tsx
+++ b/client/src/components/SidePanel/Agents/Code/Settings.tsx
@@ -34,7 +34,7 @@ const ENVIRONMENT_LABELS = {
const DEPLOYMENT_DEFAULT_ENVIRONMENT = '__deployment_default__';
-export default function StatefulSessions() {
+export default function CodeSettings() {
const localize = useLocalize();
const { user } = useAuthContext();
const { agentsConfig } = useGetAgentsConfig();
@@ -54,12 +54,17 @@ export default function StatefulSessions() {
const codeEnvironmentId = watch('code_environment_id');
const configuredEnvironments = agentsConfig?.statefulCodeSessions?.allowedEnvironments;
const executionEnvironments = agentsConfig?.statefulCodeSessions?.environments ?? [];
+ const statefulSessionsAvailable =
+ agentsConfig?.capabilities.includes(AgentCapabilities.stateful_code_sessions) ?? false;
const allowedEnvironments = resolveAllowedStatefulCodeEnvironments(configuredEnvironments);
const effectiveExecutionEnvironment = codeEnvironmentId
? executionEnvironments.find((candidate) => candidate.id === codeEnvironmentId)
: executionEnvironments.find((candidate) => candidate.default === true);
const showGitIdentity =
- codeEnabled && enabled && effectiveExecutionEnvironment?.type === 'attached';
+ statefulSessionsAvailable &&
+ codeEnabled &&
+ enabled &&
+ effectiveExecutionEnvironment?.type === 'attached';
const releaseIdentity = useCallback(() => {
const identity = getValues('git_identity');
const empty = !identity?.name?.trim() && !identity?.email?.trim();
@@ -97,6 +102,10 @@ export default function StatefulSessions() {
}
};
+ if (!statefulSessionsAvailable) {
+ return null;
+ }
+
return (
<div className="space-y-3">
<HoverCard openDelay={50}>
diff --git a/client/src/components/SidePanel/Agents/Tools/ItemDialog/__tests__/BuiltinSection.spec.tsx b/client/src/components/SidePanel/Agents/Tools/ItemDialog/__tests__/BuiltinSection.spec.tsx
index f7b6d8f48b..9058626025 100644
--- a/client/src/components/SidePanel/Agents/Tools/ItemDialog/__tests__/BuiltinSection.spec.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/ItemDialog/__tests__/BuiltinSection.spec.tsx
@@ -8,7 +8,15 @@ import BuiltinSection from '../sections/BuiltinSection';
jest.mock('~/hooks', () => ({
useLocalize: () => (key: string) => key,
- useGetAgentsConfig: () => ({ agentsConfig: undefined }),
+ useAuthContext: () => ({ user: {} }),
+ useGetAgentsConfig: () => ({
+ agentsConfig: {
+ capabilities: ['stateful_code_sessions'],
+ statefulCodeSessions: {
+ environments: [{ id: 'byom', name: 'My machine', type: 'attached', default: true }],
+ },
+ },
+ }),
useAgentCapabilities: () => ({ backgroundToolsEnabled: false }),
}));
jest.mock('~/data-provider', () => ({ useVerifyAgentToolAuth: () => ({ data: undefined }) }));
@@ -82,3 +90,19 @@ describe('BuiltinSection memory scope', () => {
expect(screen.queryByRole('checkbox', { name: 'com_agents_memory_scope' })).toBeNull();
});
});
+
+describe('BuiltinSection Run Code settings', () => {
+ test('exposes stateful code configuration with the Run Code tool', () => {
+ renderSection('execute_code', {
+ execute_code: true,
+ stateful_code_sessions: true,
+ stateful_code_environment: 'user',
+ });
+
+ expect(screen.getByRole('switch', { name: 'com_ui_stateful_sessions' })).toBeChecked();
+ expect(screen.getByTestId('code-environment-id')).toBeInTheDocument();
+ expect(screen.getByTestId('stateful-code-environment')).toBeInTheDocument();
+ expect(screen.getByLabelText('com_ui_agent_git_name')).toBeInTheDocument();
+ expect(screen.getByLabelText('com_ui_agent_git_email')).toBeInTheDocument();
+ });
+});
diff --git a/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsx b/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsx
index 16fc9be55b..05a0c24554 100644
--- a/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsx
+++ b/client/src/components/SidePanel/Agents/Tools/ItemDialog/sections/BuiltinSection.tsx
@@ -6,6 +6,7 @@ import type { AgentForm, ExtendedFile } from '~/common';
import type { BuiltinId } from '../../items/types';
import { useVerifyAgentToolAuth } from '~/data-provider';
import CodeBackground from '../../../Code/Background';
+import CodeSettings from '../../../Code/Settings';
import SearchAction from '../../../Search/Action';
import FileContext from '../../../FileContext';
import FileSearch from '../../../FileSearch';
@@ -144,6 +145,7 @@ export default function BuiltinSection({
if (builtinId === 'execute_code') {
body = (
<div className="flex flex-col gap-4">
+ <CodeSettings />
<CodeBackground />
<CodeFiles agent_id={agentId} files={codeFiles} />
</div>
diff --git a/client/src/components/SidePanel/Agents/Tools/items/__tests__/configurable.spec.ts b/client/src/components/SidePanel/Agents/Tools/items/__tests__/configurable.spec.ts
index 741071890f..5268252687 100644
--- a/client/src/components/SidePanel/Agents/Tools/items/__tests__/configurable.spec.ts
+++ b/client/src/components/SidePanel/Agents/Tools/items/__tests__/configurable.spec.ts
@@ -6,17 +6,14 @@ const builtin = (id: string, extra: Record<string, unknown> = {}): AgentItem =>
({ kind: 'builtin', id, name: '', description: '', iconKey: id, ...extra }) as AgentItem;
describe('hasConfigurableSettings', () => {
- test('artifacts, file_search, context, and memory builtins are configurable', () => {
+ test('builtins with settings are configurable', () => {
expect(hasConfigurableSettings(builtin('artifacts'))).toBe(true);
+ expect(hasConfigurableSettings(builtin('execute_code'))).toBe(true);
expect(hasConfigurableSettings(builtin('file_search'))).toBe(true);
expect(hasConfigurableSettings(builtin('context'))).toBe(true);
expect(hasConfigurableSettings(builtin('memory'))).toBe(true);
});
- test('execute_code builtin is not configurable', () => {
- expect(hasConfigurableSettings(builtin('execute_code'))).toBe(false);
- });
-
test('web_search is configurable only when auth is user-provided', () => {
expect(hasConfigurableSettings(builtin('web_search'))).toBe(false);
expect(hasConfigurableSettings(builtin('web_search', { userProvidedAuth: false }))).toBe(false);
diff --git a/client/src/components/SidePanel/Agents/Tools/items/configurable.ts b/client/src/components/SidePanel/Agents/Tools/items/configurable.ts
index 8063c497d0..cc63ac7f80 100644
--- a/client/src/components/SidePanel/Agents/Tools/items/configurable.ts
+++ b/client/src/components/SidePanel/Agents/Tools/items/configurable.ts
@@ -12,6 +12,7 @@ export function hasConfigurableSettings(item: AgentItem): boolean {
case 'builtin':
return (
item.id === 'artifacts' ||
+ item.id === 'execute_code' ||
item.id === 'file_search' ||
item.id === 'context' ||
item.id === 'memory' ||
diff --git a/client/src/components/SidePanel/Agents/__tests__/StatefulSessions.spec.tsx b/client/src/components/SidePanel/Agents/__tests__/CodeSettings.spec.tsx
similarity index 91%
rename from client/src/components/SidePanel/Agents/__tests__/StatefulSessions.spec.tsx
rename to client/src/components/SidePanel/Agents/__tests__/CodeSettings.spec.tsx
index fc4f5bf991..4df0676a84 100644
--- a/client/src/components/SidePanel/Agents/__tests__/StatefulSessions.spec.tsx
+++ b/client/src/components/SidePanel/Agents/__tests__/CodeSettings.spec.tsx
@@ -5,13 +5,14 @@ import { FormProvider, useForm } from 'react-hook-form';
import { AgentCapabilities } from 'librechat-data-provider';
import { render, screen, fireEvent, waitFor } from '@testing-library/react';
import type { AgentForm } from '~/common';
-import StatefulSessions from '../Advanced/StatefulSessions';
+import CodeSettings from '../Code/Settings';
jest.mock('~/hooks', () => ({
useLocalize: () => (key: string) => key,
useAuthContext: () => ({ user: {} }),
useGetAgentsConfig: () => ({
agentsConfig: {
+ capabilities: ['stateful_code_sessions'],
statefulCodeSessions: {
environments: [{ id: 'byom', name: 'My machine', type: 'attached', default: true }],
},
@@ -20,7 +21,7 @@ jest.mock('~/hooks', () => ({
}));
function IdentityForm({ savedIdentity }: { savedIdentity?: AgentForm['git_identity'] }) {
- const [advanced, setAdvanced] = useState(true);
+ const [dialogOpen, setDialogOpen] = useState(true);
const methods = useForm<AgentForm>({
mode: 'onChange',
defaultValues: {
@@ -31,8 +32,8 @@ function IdentityForm({ savedIdentity }: { savedIdentity?: AgentForm['git_identi
});
return (
<FormProvider {...methods}>
- {advanced && <StatefulSessions />}
- <button onClick={() => setAdvanced(!advanced)}>Toggle Advanced</button>
+ {dialogOpen && <CodeSettings />}
+ <button onClick={() => setDialogOpen(!dialogOpen)}>Toggle Dialog</button>
<button onClick={() => methods.setValue(AgentCapabilities.execute_code, false)}>
Disable code
</button>
@@ -55,8 +56,8 @@ test.each(['', 'not-an-email'])(
target: { value: email },
});
expect(await screen.findByRole('alert')).toBeInTheDocument();
- fireEvent.click(screen.getByText('Toggle Advanced'));
- fireEvent.click(screen.getByText('Toggle Advanced'));
+ fireEvent.click(screen.getByText('Toggle Dialog'));
+ fireEvent.click(screen.getByText('Toggle Dialog'));
expect(screen.getByLabelText('com_ui_agent_git_name')).toHaveValue('Saved Agent');
expect(screen.getByLabelText('com_ui_agent_git_email')).toHaveValue('[email protected]');
expect(screen.queryByRole('alert')).not.toBeInTheDocument();
@@ -77,7 +78,7 @@ test('clears cross-field errors when completing or clearing a Git identity', asy
await waitFor(() => expect(screen.queryByRole('alert')).not.toBeInTheDocument());
});
-test.each(['Disable code', 'Use managed', 'Disable sessions', 'Toggle Advanced'])(
+test.each(['Disable code', 'Use managed', 'Disable sessions', 'Toggle Dialog'])(
'discards a partial identity when its controls disappear: %s',
async (action) => {
render(<IdentityForm />);
@@ -91,7 +92,7 @@ test.each(['Disable code', 'Use managed', 'Disable sessions', 'Toggle Advanced']
},
);
-test.each(['Disable code', 'Use managed', 'Disable sessions', 'Toggle Advanced'])(
+test.each(['Disable code', 'Use managed', 'Disable sessions', 'Toggle Dialog'])(
'discards an invalid email when its controls disappear: %s',
async (action) => {
render(<IdentityForm />);
@@ -118,9 +119,9 @@ test.each([
fireEvent.change(screen.getByLabelText('com_ui_agent_git_email'), {
target: { value: identity.email },
});
- fireEvent.click(screen.getByText('Toggle Advanced'));
+ fireEvent.click(screen.getByText('Toggle Dialog'));
expect(screen.getByTestId('identity')).toHaveTextContent(JSON.stringify(identity));
- fireEvent.click(screen.getByText('Toggle Advanced'));
+ fireEvent.click(screen.getByText('Toggle Dialog'));
expect(screen.getByLabelText('com_ui_agent_git_name')).toHaveValue(identity.name);
expect(screen.getByLabelText('com_ui_agent_git_email')).toHaveValue(identity.email);
fireEvent.change(screen.getByLabelText('com_ui_agent_git_email'), {