mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-07-01 13:46:46 -07:00
fix(cli): restore resume for legacy sessions (#26577)
Co-authored-by: Tommaso Sciortino <sciortino@gmail.com>
This commit is contained in:
@@ -270,15 +270,23 @@ export const getAllSessionFiles = async (
|
||||
}
|
||||
|
||||
// Validate required fields
|
||||
if (
|
||||
!content.sessionId ||
|
||||
!content.startTime ||
|
||||
!content.lastUpdated
|
||||
) {
|
||||
if (!content.sessionId) {
|
||||
// Missing required fields - treat as corrupted
|
||||
return { fileName: file, sessionInfo: null };
|
||||
}
|
||||
|
||||
const fileTimestamp =
|
||||
!content.startTime || !content.lastUpdated
|
||||
? (
|
||||
await fs.stat(filePath).catch(() => undefined)
|
||||
)?.mtime.toISOString()
|
||||
: undefined;
|
||||
const fallbackTimestamp = fileTimestamp ?? new Date().toISOString();
|
||||
const startTime =
|
||||
content.startTime || content.lastUpdated || fallbackTimestamp;
|
||||
const lastUpdated =
|
||||
content.lastUpdated || content.startTime || fallbackTimestamp;
|
||||
|
||||
// Skip sessions that only contain system messages (info, error, warning)
|
||||
if (!content.hasUserOrAssistantMessage) {
|
||||
return { fileName: file, sessionInfo: null };
|
||||
@@ -319,8 +327,8 @@ export const getAllSessionFiles = async (
|
||||
id: content.sessionId,
|
||||
file: file.replace(/\.jsonl?$/, ''),
|
||||
fileName: file,
|
||||
startTime: content.startTime,
|
||||
lastUpdated: content.lastUpdated,
|
||||
startTime,
|
||||
lastUpdated,
|
||||
messageCount: content.messageCount ?? content.messages.length,
|
||||
displayName: content.summary
|
||||
? stripUnsafeCharacters(content.summary)
|
||||
@@ -546,12 +554,17 @@ export class SessionSelector {
|
||||
if (!sessionData) {
|
||||
throw new Error('Failed to load session data');
|
||||
}
|
||||
const normalizedSessionData = {
|
||||
...sessionData,
|
||||
startTime: sessionData.startTime || sessionInfo.startTime,
|
||||
lastUpdated: sessionData.lastUpdated || sessionInfo.lastUpdated,
|
||||
};
|
||||
|
||||
const displayInfo = `Session ${sessionInfo.index}: ${sessionInfo.firstUserMessage} (${sessionInfo.messageCount} messages, ${formatRelativeTime(sessionInfo.lastUpdated)})`;
|
||||
|
||||
return {
|
||||
sessionPath,
|
||||
sessionData,
|
||||
sessionData: normalizedSessionData,
|
||||
displayInfo,
|
||||
};
|
||||
} catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user