fix: Unify execution IDs between broadcast events and session storage

- Pass generated executionId to cliExecutorTool.execute as id parameter
- Ensures CLI_EXECUTION_STARTED broadcast uses same ID as saved session
- Fixes "Conversation not found" errors when querying by broadcast ID
- Add DEBUG logging for executionId tracking

This resolves the mismatch where:
  - Broadcast event used ID from Date.now() at broadcast time
  - Session saved used different ID from Date.now() at completion time
  - Now all use the same ID generated at cli.ts:868

Changes:
- cli.ts:868 - executionId generated once
- cli.ts:1001 - pass executionId to execute() as id parameter
- cli-executor-core.ts automatically uses passed id as conversationId
This commit is contained in:
catlog22
2026-01-29 16:59:00 +08:00
parent 113dce55c5
commit 860dbdab56

View File

@@ -929,6 +929,10 @@ async function execAction(positionalPrompt: string | undefined, options: CliExec
mode
});
if (process.env.DEBUG) {
console.error(`[CLI] Generated executionId: ${executionId}`);
}
// Buffer to accumulate output when both --stream and --to-file are specified
let streamBuffer = '';
@@ -994,7 +998,7 @@ async function execAction(positionalPrompt: string | undefined, options: CliExec
includeDirs,
// timeout removed - controlled by external caller (bash timeout)
resume,
id, // custom execution ID
id: executionId, // unified execution ID (matches broadcast events)
noNative,
stream: !!stream, // stream=true → streaming enabled (no cache), stream=false → cache output (default)
outputFormat, // Enable JSONL parsing for tools that support it