Hide sessions that don't have user messages (#13994)

This commit is contained in:
bl-ue
2025-12-02 13:52:53 -07:00
committed by GitHub
parent c78f2574a2
commit aa544c40de
3 changed files with 267 additions and 3 deletions

View File

@@ -89,6 +89,15 @@ export interface SessionSelectionResult {
displayInfo: string;
}
/**
* Checks if a session has at least one user or assistant (gemini) message.
* Sessions with only system messages (info, error, warning) are considered empty.
* @param messages - The array of message records to check
* @returns true if the session has meaningful content
*/
export const hasUserOrAssistantMessage = (messages: MessageRecord[]): boolean =>
messages.some((msg) => msg.type === 'user' || msg.type === 'gemini');
/**
* Cleans and sanitizes message content for display by:
* - Converting newlines to spaces
@@ -215,6 +224,11 @@ export const getAllSessionFiles = async (
return { fileName: file, sessionInfo: null };
}
// Skip sessions that only contain system messages (info, error, warning)
if (!hasUserOrAssistantMessage(content.messages)) {
return { fileName: file, sessionInfo: null };
}
const firstUserMessage = extractFirstUserMessage(content.messages);
const isCurrentSession = currentSessionId
? file.includes(currentSessionId.slice(0, 8))