feat: replace Code conversation archive with deletion

This commit is contained in:
鲨鱼辣椒 committed 2026-10-14 11:09:51 +08:00
1 parent 140f6be8db
commit bf101c1e52
19 files changed
+1001 -292

No files matched your search

+37
View File
@@ -7,6 +7,7 @@ import { CodingCapabilityRegistryImpl } from '@electron/coding-plugins/registry'
import type { PiProviderSelection } from '@electron/coding-runtime/pi/provider-config';
import {
buildPiManagedInputArgs,
deletePiConversationSession,
getPiManagedPaths,
MAKELORE_DEFAULT_LANGUAGE_PROMPT,
materializePiAgentResources,
@@ -62,6 +63,42 @@ async function fixtureRoot(): Promise<{
}
describe('Pi managed resource loader', () => {
it('permanently deletes only the selected session, including timestamped files and trash copies', async () => {
const { userDataDir } = await fixtureRoot();
const paths = getPiManagedPaths(userDataDir);
const deletedPaths: string[] = [];
const retainedPaths: string[] = [];
for (const root of [paths.sessionsDir, paths.trashDir]) {
for (const projectId of ['project-a', 'project-b']) {
const directory = path.join(root, projectId);
await mkdir(directory, { recursive: true });
for (const filename of [
'session-a.jsonl',
'2026-10-14T12-34-56-789Z_session-a.jsonl',
'session-b.jsonl',
'2026-10-14T12-34-56-789Z_session-b.jsonl',
'another_session-a.jsonl',
]) {
const target = path.join(directory, filename);
await writeFile(target, 'session-data');
(projectId === 'project-a' && ['session-a.jsonl', '2026-10-14T12-34-56-789Z_session-a.jsonl'].includes(filename)
? deletedPaths : retainedPaths).push(target);
}
}
}
await deletePiConversationSession({ userDataDir, projectId: 'project-a', sessionKey: 'session-a' });
for (const filename of deletedPaths) await expect(readFile(filename)).rejects.toMatchObject({ code: 'ENOENT' });
for (const filename of retainedPaths) await expect(readFile(filename, 'utf8')).resolves.toBe('session-data');
await expect(deletePiConversationSession({ userDataDir, projectId: 'project-a', sessionKey: 'session-a' })).resolves.toBeUndefined();
await expect(deletePiConversationSession({ userDataDir, projectId: 'missing-project', sessionKey: 'session-a' })).resolves.toBeUndefined();
});
it('rejects paths outside a selected project session during deletion', async () => {
const { userDataDir } = await fixtureRoot();
await expect(deletePiConversationSession({ userDataDir, projectId: '../outside', sessionKey: 'session-a' })).rejects.toThrow();
await expect(deletePiConversationSession({ userDataDir, projectId: 'project-a', sessionKey: '../outside' })).rejects.toThrow();
});
it('materializes only managed prompt and explicitly paired package Skills', async () => {
const fixture = await fixtureRoot();
const prompt = 'PRIVATE PARTNER PROMPT CONTENT';