mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-11-16 13:00:55 +00:00
🚿 fix: Strip Code Approval Modes From Imported Chats (#16542)
Co-authored-by: Lia <lia@librechat.ai>
This commit is contained in:
parent
14f7b28656
commit
f03ecb741d
2 changed files with 74 additions and 0 deletions
|
|
@ -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' };
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue