Skip to content

Commit 89a1add

Browse files
committed
Address feedback
1 parent 1d11db8 commit 89a1add

26 files changed

+320
-229
lines changed

package-lock.json

Lines changed: 45 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
"@types/minimatch": "^5.1.2",
8787
"@types/mock-fs": "^4.13.4",
8888
"@types/prompts": "^2.4.9",
89+
"@types/proper-lockfile": "^4.1.4",
8990
"@types/react": "^19.2.0",
9091
"@types/react-dom": "^19.2.0",
9192
"@types/shell-quote": "^1.7.5",
@@ -126,6 +127,7 @@
126127
"dependencies": {
127128
"ink": "npm:@jrichman/[email protected]",
128129
"latest-version": "^9.0.0",
130+
"proper-lockfile": "^4.1.2",
129131
"simple-git": "^3.28.0"
130132
},
131133
"optionalDependencies": {

packages/cli/src/ui/hooks/useShellHistory.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
5555
'shell_history',
5656
);
5757
}
58+
initialize(): Promise<undefined> {
59+
return Promise.resolve(undefined);
60+
}
5861
}
5962
return {
6063
...actual,

packages/cli/src/ui/hooks/useShellHistory.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ async function getHistoryFilePath(
2424
configStorage?: Storage,
2525
): Promise<string> {
2626
const storage = configStorage ?? new Storage(projectRoot);
27+
await storage.initialize();
2728
return storage.getHistoryFilePath();
2829
}
2930

packages/cli/src/ui/utils/clipboardUtils.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
4545
},
4646
Storage: class {
4747
getProjectTempDir = vi.fn(() => '/tmp/global');
48+
initialize = vi.fn(() => Promise.resolve(undefined));
4849
},
4950
};
5051
});

packages/cli/src/ui/utils/clipboardUtils.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -256,8 +256,11 @@ const saveFileWithXclip = async (tempFilePath: string) => {
256256
* @param targetDir The root directory of the current project.
257257
* @returns The absolute path to the images directory.
258258
*/
259-
function getProjectClipboardImagesDir(targetDir: string): string {
259+
async function getProjectClipboardImagesDir(
260+
targetDir: string,
261+
): Promise<string> {
260262
const storage = new Storage(targetDir);
263+
await storage.initialize();
261264
const baseDir = storage.getProjectTempDir();
262265
return path.join(baseDir, 'images');
263266
}
@@ -271,7 +274,7 @@ export async function saveClipboardImage(
271274
targetDir: string,
272275
): Promise<string | null> {
273276
try {
274-
const tempDir = getProjectClipboardImagesDir(targetDir);
277+
const tempDir = await getProjectClipboardImagesDir(targetDir);
275278
await fs.mkdir(tempDir, { recursive: true });
276279

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

packages/cli/src/ui/utils/clipboardUtils.windows.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ vi.mock('@google/gemini-cli-core', async (importOriginal) => {
1818
spawnAsync: vi.fn(),
1919
Storage: class {
2020
getProjectTempDir = vi.fn(() => "C:\\User's Files");
21+
initialize = vi.fn(() => Promise.resolve(undefined));
2122
},
2223
};
2324
});

packages/cli/src/utils/cleanup.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import * as path from 'node:path';
1111
vi.mock('@google/gemini-cli-core', () => ({
1212
Storage: vi.fn().mockImplementation(() => ({
1313
getProjectTempDir: vi.fn().mockReturnValue('/tmp/project'),
14+
initialize: vi.fn().mockResolvedValue(undefined),
1415
})),
1516
shutdownTelemetry: vi.fn(),
1617
isTelemetrySdkInitialized: vi.fn().mockReturnValue(false),

packages/cli/src/utils/cleanup.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ async function drainStdin() {
102102

103103
export async function cleanupCheckpoints() {
104104
const storage = new Storage(process.cwd());
105+
await storage.initialize();
105106
const tempDir = storage.getProjectTempDir();
106107
const checkpointsDir = join(tempDir, 'checkpoints');
107108
try {

packages/cli/src/utils/sessionCleanup.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,8 +348,12 @@ export async function cleanupToolOutputFiles(
348348
}
349349

350350
const retentionConfig = settings.general.sessionRetention;
351-
const tempDir =
352-
projectTempDir ?? new Storage(process.cwd()).getProjectTempDir();
351+
let tempDir = projectTempDir;
352+
if (!tempDir) {
353+
const storage = new Storage(process.cwd());
354+
await storage.initialize();
355+
tempDir = storage.getProjectTempDir();
356+
}
353357
const toolOutputDir = path.join(tempDir, TOOL_OUTPUT_DIR);
354358

355359
// Check if directory exists

0 commit comments

Comments
 (0)