Skip to content
This repository was archived by the owner on Feb 14, 2026. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 21 additions & 3 deletions src/claude/claudeRemoteLauncher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -294,15 +294,33 @@ export async function claudeRemoteLauncher(session: Session): Promise<'switch' |
message: string;
mode: EnhancedMode;
} | null = null;

// Track session ID to detect when it actually changes
// This prevents context loss when mode changes (permission mode, model, etc.)
// without starting a new session. Only reset parent chain when session ID
// actually changes (e.g., new session started or /clear command used).
// See: https://github.com/anthropics/happy-cli/issues/143
let previousSessionId: string | null = null;
while (!exitReason) {
logger.debug('[remote]: launch');
messageBuffer.addMessage('═'.repeat(40), 'status');
messageBuffer.addMessage('Starting new Claude session...', 'status');

// Only reset parent chain and show "new session" message when session ID actually changes
const isNewSession = session.sessionId !== previousSessionId;
if (isNewSession) {
messageBuffer.addMessage('Starting new Claude session...', 'status');
permissionHandler.reset(); // Reset permissions before starting new session
sdkToLogConverter.resetParentChain(); // Reset parent chain for new conversation
logger.debug(`[remote]: New session detected (previous: ${previousSessionId}, current: ${session.sessionId})`);
} else {
messageBuffer.addMessage('Continuing Claude session...', 'status');
logger.debug(`[remote]: Continuing existing session: ${session.sessionId}`);
}

previousSessionId = session.sessionId;
const controller = new AbortController();
abortController = controller;
abortFuture = new Future<void>();
permissionHandler.reset(); // Reset permissions before starting new session
sdkToLogConverter.resetParentChain(); // Reset parent chain for new conversation
let modeHash: string | null = null;
let mode: EnhancedMode | null = null;
try {
Expand Down