Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@
"@types/minimatch": "^5.1.2",
"@types/mock-fs": "^4.13.4",
"@types/prompts": "^2.4.9",
"@types/proper-lockfile": "^4.1.4",
"@types/react": "^19.2.0",
"@types/react-dom": "^19.2.0",
"@types/shell-quote": "^1.7.5",
Expand Down Expand Up @@ -126,6 +127,7 @@
"dependencies": {
"ink": "npm:@jrichman/ink@6.4.8",
"latest-version": "^9.0.0",
"proper-lockfile": "^4.1.2",
"simple-git": "^3.28.0"
},
"optionalDependencies": {
Expand Down
4 changes: 4 additions & 0 deletions packages/cli/src/gemini_cleanup.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
disableMouseEvents: vi.fn(),
enterAlternateScreen: vi.fn(),
disableLineWrapping: vi.fn(),
ProjectRegistry: vi.fn().mockImplementation(() => ({
initialize: vi.fn(),
getShortId: vi.fn().mockReturnValue('project-slug'),
})),
};
});

Expand Down
3 changes: 3 additions & 0 deletions packages/cli/src/ui/hooks/useShellHistory.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
'shell_history',
);
}
initialize(): Promise<undefined> {
return Promise.resolve(undefined);
}
}
return {
...actual,
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/ui/hooks/useShellHistory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async function getHistoryFilePath(
configStorage?: Storage,
): Promise<string> {
const storage = configStorage ?? new Storage(projectRoot);
await storage.initialize();
return storage.getHistoryFilePath();
}

Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/ui/utils/clipboardUtils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
},
Storage: class {
getProjectTempDir = vi.fn(() => '/tmp/global');
initialize = vi.fn(() => Promise.resolve(undefined));
},
};
});
Expand Down
9 changes: 6 additions & 3 deletions packages/cli/src/ui/utils/clipboardUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,8 +256,11 @@ const saveFileWithXclip = async (tempFilePath: string) => {
* @param targetDir The root directory of the current project.
* @returns The absolute path to the images directory.
*/
function getProjectClipboardImagesDir(targetDir: string): string {
async function getProjectClipboardImagesDir(
targetDir: string,
): Promise<string> {
const storage = new Storage(targetDir);
await storage.initialize();
const baseDir = storage.getProjectTempDir();
return path.join(baseDir, 'images');
}
Expand All @@ -271,7 +274,7 @@ export async function saveClipboardImage(
targetDir: string,
): Promise<string | null> {
try {
const tempDir = getProjectClipboardImagesDir(targetDir);
const tempDir = await getProjectClipboardImagesDir(targetDir);
await fs.mkdir(tempDir, { recursive: true });

// Generate a unique filename with timestamp
Expand Down Expand Up @@ -396,7 +399,7 @@ export async function cleanupOldClipboardImages(
targetDir: string,
): Promise<void> {
try {
const tempDir = getProjectClipboardImagesDir(targetDir);
const tempDir = await getProjectClipboardImagesDir(targetDir);
const files = await fs.readdir(tempDir);
const oneHourAgo = Date.now() - 60 * 60 * 1000;

Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/ui/utils/clipboardUtils.windows.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
spawnAsync: vi.fn(),
Storage: class {
getProjectTempDir = vi.fn(() => "C:\\User's Files");
initialize = vi.fn(() => Promise.resolve(undefined));
},
};
});
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/utils/cleanup.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import * as path from 'node:path';
vi.mock('@google/gemini-cli-core', () => ({
Storage: vi.fn().mockImplementation(() => ({
getProjectTempDir: vi.fn().mockReturnValue('/tmp/project'),
initialize: vi.fn().mockResolvedValue(undefined),
})),
shutdownTelemetry: vi.fn(),
isTelemetrySdkInitialized: vi.fn().mockReturnValue(false),
Expand Down
1 change: 1 addition & 0 deletions packages/cli/src/utils/cleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ async function drainStdin() {

export async function cleanupCheckpoints() {
const storage = new Storage(process.cwd());
await storage.initialize();
const tempDir = storage.getProjectTempDir();
const checkpointsDir = join(tempDir, 'checkpoints');
try {
Expand Down
8 changes: 6 additions & 2 deletions packages/cli/src/utils/sessionCleanup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,12 @@ export async function cleanupToolOutputFiles(
}

const retentionConfig = settings.general.sessionRetention;
const tempDir =
projectTempDir ?? new Storage(process.cwd()).getProjectTempDir();
let tempDir = projectTempDir;
if (!tempDir) {
const storage = new Storage(process.cwd());
await storage.initialize();
tempDir = storage.getProjectTempDir();
}
const toolOutputDir = path.join(tempDir, TOOL_OUTPUTS_DIR);

// Check if directory exists
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/config/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -895,6 +895,8 @@ export class Config {
}
this.initialized = true;

await this.storage.initialize();

// Add pending directories to workspace context
for (const dir of this.pendingIncludeDirectories) {
this.workspaceContext.addDirectory(dir);
Expand Down
Loading
Loading