fix: exclude empty Kimi placeholder sessions

This commit is contained in:
tommy0103
2026-08-03 00:49:37 +08:00
parent 71a80114f1
commit f3daedfbe0
2 changed files with 124 additions and 2 deletions
+7 -1
View File
@@ -56,7 +56,7 @@ interface ProjectedSession {
}
const SOURCE = 'kimi';
export const KIMI_CANONICAL_TRANSCRIPT_MARKER = '__kimi_canonical_transcript_v3__';
export const KIMI_CANONICAL_TRANSCRIPT_MARKER = '__kimi_canonical_transcript_v4__';
function defaultKimiRoot(): string {
return process.env['KIMI_CODE_HOME'] ?? join(homedir(), '.kimi-code');
@@ -679,6 +679,12 @@ export function createKimiProvider({ rootDir = defaultKimiRoot() }: { rootDir?:
if (before !== after) throw new Error(`Kimi session changed while indexing: ${meta.sessionDir}`);
yield { kind: 'delete-session', sessionId: unit.sessionId };
// Kimi persists a titled session before the first prompt; keep it retracted until user evidence exists.
const hasLastPrompt = typeof state.lastPrompt === 'string' && state.lastPrompt.length > 0;
const hasProjectedUserPrompt = projected.messages.some((message) => (
message.agent_id === null && message.role === 'user' && !message.is_meta
));
if (state.title === 'New Session' && !hasLastPrompt && !hasProjectedUserPrompt) return after;
yield {
kind: 'session',
id: unit.sessionId,