mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-18 18:11:02 -07:00
fix(plan): isolate plan files per session (#18757)
This commit is contained in:
@@ -823,7 +823,7 @@ export class Config {
|
||||
(params.shellToolInactivityTimeout ?? 300) * 1000; // 5 minutes
|
||||
this.extensionManagement = params.extensionManagement ?? true;
|
||||
this.enableExtensionReloading = params.enableExtensionReloading ?? false;
|
||||
this.storage = new Storage(this.targetDir);
|
||||
this.storage = new Storage(this.targetDir, this.sessionId);
|
||||
|
||||
this.fakeResponses = params.fakeResponses;
|
||||
this.recordResponses = params.recordResponses;
|
||||
|
||||
@@ -154,12 +154,24 @@ describe('Storage – additional helpers', () => {
|
||||
expect(Storage.getGlobalBinDir()).toBe(expected);
|
||||
});
|
||||
|
||||
it('getProjectTempPlansDir returns ~/.gemini/tmp/<identifier>/plans', async () => {
|
||||
it('getProjectTempPlansDir returns ~/.gemini/tmp/<identifier>/plans when no sessionId is provided', async () => {
|
||||
await storage.initialize();
|
||||
const tempDir = storage.getProjectTempDir();
|
||||
const expected = path.join(tempDir, 'plans');
|
||||
expect(storage.getProjectTempPlansDir()).toBe(expected);
|
||||
});
|
||||
|
||||
it('getProjectTempPlansDir returns ~/.gemini/tmp/<identifier>/<sessionId>/plans when sessionId is provided', async () => {
|
||||
const sessionId = 'test-session-id';
|
||||
const storageWithSession = new Storage(projectRoot, sessionId);
|
||||
ProjectRegistry.prototype.getShortId = vi
|
||||
.fn()
|
||||
.mockReturnValue(PROJECT_SLUG);
|
||||
await storageWithSession.initialize();
|
||||
const tempDir = storageWithSession.getProjectTempDir();
|
||||
const expected = path.join(tempDir, sessionId, 'plans');
|
||||
expect(storageWithSession.getProjectTempPlansDir()).toBe(expected);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Storage - System Paths', () => {
|
||||
|
||||
@@ -20,11 +20,13 @@ const AGENTS_DIR_NAME = '.agents';
|
||||
|
||||
export class Storage {
|
||||
private readonly targetDir: string;
|
||||
private readonly sessionId: string | undefined;
|
||||
private projectIdentifier: string | undefined;
|
||||
private initPromise: Promise<void> | undefined;
|
||||
|
||||
constructor(targetDir: string) {
|
||||
constructor(targetDir: string, sessionId?: string) {
|
||||
this.targetDir = targetDir;
|
||||
this.sessionId = sessionId;
|
||||
}
|
||||
|
||||
static getGlobalGeminiDir(): string {
|
||||
@@ -242,9 +244,19 @@ export class Storage {
|
||||
}
|
||||
|
||||
getProjectTempPlansDir(): string {
|
||||
if (this.sessionId) {
|
||||
return path.join(this.getProjectTempDir(), this.sessionId, 'plans');
|
||||
}
|
||||
return path.join(this.getProjectTempDir(), 'plans');
|
||||
}
|
||||
|
||||
getProjectTempTasksDir(): string {
|
||||
if (this.sessionId) {
|
||||
return path.join(this.getProjectTempDir(), this.sessionId, 'tasks');
|
||||
}
|
||||
return path.join(this.getProjectTempDir(), 'tasks');
|
||||
}
|
||||
|
||||
getExtensionsDir(): string {
|
||||
return path.join(this.getGeminiDir(), 'extensions');
|
||||
}
|
||||
|
||||
@@ -53,4 +53,4 @@ toolName = ["write_file", "replace"]
|
||||
decision = "allow"
|
||||
priority = 70
|
||||
modes = ["plan"]
|
||||
argsPattern = "\"file_path\":\"[^\"]+/\\.gemini/tmp/[a-zA-Z0-9_-]+/plans/[a-zA-Z0-9_-]+\\.md\""
|
||||
argsPattern = "\"file_path\":\"[^\"]+/\\.gemini/tmp/[a-zA-Z0-9_-]+/[a-zA-Z0-9_-]+/plans/[a-zA-Z0-9_-]+\\.md\""
|
||||
|
||||
Reference in New Issue
Block a user