Merge pull request #367 from shenlvkang-collab/pr/claude-conversation-first-hand

fix(session): learn the live Claude conversation from the CLI's own hook
This commit is contained in:
Ark0N
2026-09-06 23:02:33 +02:00
committed by GitHub
16 changed files with 540 additions and 11 deletions
+26
View File
@@ -29,6 +29,32 @@ export class MockSession extends EventEmitter {
terminalBuffer: string = '';
/** Mirrors Session.lastSubmitAt — the response viewer credits history entries by it. */
lastSubmitAt: number = 0;
/** Mirrors Session.claudeSessionId — the conversation the viewer reads. */
claudeSessionId: string | null = null;
/** Mirrors Session.claudeSessionIdIsFirstHand — set only by a hook adoption. */
claudeSessionIdIsFirstHand: boolean = false;
/** Mirrors Session.claudeSessionChain — oldest first, current last. */
claudeSessionChain: string[] = [];
/** Mirrors Session.adoptClaudeSessionId, including the first-hand chain rule. */
adoptClaudeSessionId(newId: string, options: { firstHand?: boolean } = {}): void {
if (!newId) return;
if (options.firstHand) {
this.claudeSessionIdIsFirstHand = true;
if (this.claudeSessionChain[this.claudeSessionChain.length - 1] !== newId) {
const existing = this.claudeSessionChain.indexOf(newId);
if (existing !== -1) this.claudeSessionChain.splice(existing, 1);
this.claudeSessionChain.push(newId);
}
}
if (newId === this.claudeSessionId) return;
this.claudeSessionId = newId;
}
/** Mirrors Session.markPromptSubmitted. */
markPromptSubmitted(): void {
this.lastSubmitAt = Date.now();
}
private _muxName: string | null = null;