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

🚿 fix: Strip Code Approval Modes From Imported Chats (#16542)

lia-by-librechat[bot]f03ecb741dae
diff --git a/packages/data-schemas/src/methods/conversation.spec.ts b/packages/data-schemas/src/methods/conversation.spec.ts
index f3069b7e1a..a465c769dd 100644
--- a/packages/data-schemas/src/methods/conversation.spec.ts
+++ b/packages/data-schemas/src/methods/conversation.spec.ts
@@ -1079,6 +1079,79 @@ describe('Conversation Operations', () => {
});
});
+ describe('code approval persistence', () => {
+ it.each(['ask', 'acceptEdits', 'fullAccess', null, undefined] as const)(
+ 'bulkSaveConvos ignores imported approval mode %s on insert',
+ async (codeApprovalMode) => {
+ const imported = {
+ ...mockConversationData,
+ user: mockCtx.userId,
+ endpoint: EModelEndpoint.agents,
+ agent_id: 'imported-agent',
+ codeApprovalMode,
+ };
+
+ await methods.bulkSaveConvos([imported]);
+
+ const stored = await getConvo(mockCtx.userId, imported.conversationId);
+ expect(stored).not.toBeNull();
+ expect(stored).not.toHaveProperty('codeApprovalMode');
+ expect(stored).toMatchObject({
+ title: imported.title,
+ endpoint: EModelEndpoint.agents,
+ agent_id: imported.agent_id,
+ });
+ expect(imported.codeApprovalMode).toBe(codeApprovalMode);
+ },
+ );
+
+ it.each(['ask', 'acceptEdits', 'fullAccess', undefined] as const)(
+ 'bulkSaveConvos preserves existing approval mode %s on update',
+ async (codeApprovalMode) => {
+ const conversationId = uuidv4();
+ await saveConvo(mockCtx, {
+ conversationId,
+ endpoint: EModelEndpoint.agents,
+ ...(codeApprovalMode != null && { codeApprovalMode }),
+ });
+
+ await methods.bulkSaveConvos([
+ {
+ conversationId,
+ user: mockCtx.userId,
+ title: 'Imported update',
+ codeApprovalMode: 'fullAccess',
+ },
+ ]);
+
+ const stored = await getConvo(mockCtx.userId, conversationId);
+ expect(stored).not.toBeNull();
+ expect(stored?.codeApprovalMode).toBe(codeApprovalMode);
+ expect(stored?.title).toBe('Imported update');
+ },
+ );
+
+ it('persists explicit user choices through ordinary saves after an import', async () => {
+ const conversationId = uuidv4();
+ await methods.bulkSaveConvos([
+ {
+ conversationId,
+ user: mockCtx.userId,
+ endpoint: EModelEndpoint.agents,
+ codeApprovalMode: 'fullAccess',
+ },
+ ]);
+
+ for (const codeApprovalMode of ['ask', 'acceptEdits', 'fullAccess'] as const) {
+ await saveConvo(mockCtx, { conversationId, codeApprovalMode });
+ await saveConvo(mockCtx, { conversationId, title: 'Ordinary save' });
+ expect((await getConvo(mockCtx.userId, conversationId))?.codeApprovalMode).toBe(
+ codeApprovalMode,
+ );
+ }
+ });
+ });
+
describe('code environment persistence during ordinary saves', () => {
const mac = { environmentId: 'code-mac', workspaceId: 'primary' };
const vm = { environmentId: 'code-vm', workspaceId: 'primary' };
diff --git a/packages/data-schemas/src/methods/conversation.ts b/packages/data-schemas/src/methods/conversation.ts
index 9c2534d670..70139b1a9a 100644
--- a/packages/data-schemas/src/methods/conversation.ts
+++ b/packages/data-schemas/src/methods/conversation.ts
@@ -2813,6 +2813,7 @@ export function createConversationMethods(
const affectedProjectStats = new Map<string, { user: string; projectId: string }>();
const bulkOps = conversations.map((convo) => {
const { codeEnvironmentMode, codeWorkspaces, ...sanitized } = convo;
+ delete sanitized.codeApprovalMode;
delete sanitized.initial_agent_id;
delete sanitized.codeEnvironmentRevision;
stripActorCheckpointFields(sanitized);