mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-04 00:44:05 -07:00
feat(cli): provide manual session UUID via command line arg (#26060)
This commit is contained in:
@@ -408,6 +408,36 @@ export const getSessionFiles = async (
|
||||
export class SessionSelector {
|
||||
constructor(private storage: Storage) {}
|
||||
|
||||
/**
|
||||
* Checks if a session with the given ID already exists on disk.
|
||||
*/
|
||||
async sessionExists(id: string): Promise<boolean> {
|
||||
const chatsDir = path.join(this.storage.getProjectTempDir(), 'chats');
|
||||
const files = await fs.readdir(chatsDir).catch(() => []);
|
||||
|
||||
// The filename format is `session-<TIMESTAMP>-<ID_SLICE(0,8)>.jsonl`
|
||||
const shortId = id.slice(0, 8);
|
||||
const candidateFiles = files.filter(
|
||||
(f) =>
|
||||
f.startsWith(SESSION_FILE_PREFIX) &&
|
||||
(f.endsWith(`-${shortId}.json`) || f.endsWith(`-${shortId}.jsonl`)),
|
||||
);
|
||||
|
||||
for (const fileName of candidateFiles) {
|
||||
try {
|
||||
const sessionPath = path.join(chatsDir, fileName);
|
||||
const sessionData = await loadConversationRecord(sessionPath);
|
||||
if (sessionData && sessionData.sessionId === id) {
|
||||
return true;
|
||||
}
|
||||
} catch {
|
||||
// Ignore unparseable files
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Lists all available sessions for the current project.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user