Problem
When resuming a Claude session with --resume <session_id>, Claude may return a different session ID in its JSON output than the one requested. Currently, warelay doesn't track this, so subsequent messages may fail to continue the conversation properly.
Proposed solution
- Extract
session_id from Claude's JSON output in command-reply.ts
- Compare returned session ID with the requested one
- If different, update the session store with the new ID
Affected files
src/auto-reply/command-reply.ts - add extractClaudeSessionId() and include sessionId in CommandReplyMeta
src/auto-reply/reply.ts - update session store when Claude returns a different session ID
Implementation
// command-reply.ts
export function extractClaudeSessionId(payload: unknown): string | undefined {
if (!payload || typeof payload !== "object") return undefined;
const obj = payload as Record<string, unknown>;
return typeof obj.session_id === "string" ? obj.session_id : undefined;
}
// reply.ts - after getting response
if (meta.sessionId && sessionStore && sessionKey && meta.sessionId !== sessionId) {
sessionStore[sessionKey] = {
sessionId: meta.sessionId,
updatedAt: Date.now(),
systemSent,
};
await saveSessionStore(storePath, sessionStore);
}
Problem
When resuming a Claude session with
--resume <session_id>, Claude may return a different session ID in its JSON output than the one requested. Currently, warelay doesn't track this, so subsequent messages may fail to continue the conversation properly.Proposed solution
session_idfrom Claude's JSON output incommand-reply.tsAffected files
src/auto-reply/command-reply.ts- addextractClaudeSessionId()and includesessionIdinCommandReplyMetasrc/auto-reply/reply.ts- update session store when Claude returns a different session IDImplementation