Skip to content

Conversation

@luxiaolei
Copy link
Contributor

@luxiaolei luxiaolei commented Oct 2, 2025

Summary

Fixes slopus/happy#143 - Happy immediately forgets context in a conversation

Problem

Happy was losing conversation context during normal usage, causing it to forget previous messages even within the same session. Users reported it behaving as if /exit was typed constantly creating new conversations.

Root Cause

The remote launcher (src/claude/claudeRemoteLauncher.ts) was calling resetParentChain on every loop iteration, which happened whenever:

  • Message queue mode changed (permission mode, model, custom prompts, tools, etc.)
  • /clear or /compact commands were used
  • Any condition triggered a new claudeRemote iteration

This broke the conversation chain and caused Claude to forget all previous context.

Solution

Modified the code to:

  1. Track the session.sessionId across loop iterations
  2. Only reset the parent chain when the session ID actually changes (new session started) or becomes null (/clear command)
  3. Preserve context when the loop continues due to mode changes within the same session

Impact

  • Normal multi-turn conversations now preserve context
  • Permission mode changes preserve context
  • Model changes preserve context
  • /compact command preserves context
  • /clear command still properly clears context (sets sessionId=null)

Testing

The fix has been verified with:

  • All 101 automated tests passing
  • Manual testing confirmed context preservation in multi-turn conversations
  • Permission mode switches preserve context
  • Model changes preserve context
  • /compact and /clear commands work correctly

Files Changed

  • src/claude/claudeRemoteLauncher.ts: Added session ID tracking logic with detailed comments (21 additions, 3 deletions)

Closes slopus/happy#143

Fixes issue where Happy was losing context during normal conversations,
causing it to forget previous messages even within the same session.

**Root Cause:**
The remote launcher was calling `resetParentChain()` on every loop
iteration, which happened whenever:
- Message queue mode changed (permission mode, model, tools, etc.)
- /clear or /compact commands were used
- Any condition triggered a new claudeRemote() iteration

This caused context loss even during normal multi-turn conversations.

**Solution:**
Track the session ID across loop iterations and only reset the parent
chain when the session ID actually changes (new session started) or
becomes null (/clear command).

**Impact:**
✅ Normal multi-turn conversations now preserve context
✅ Permission mode changes preserve context
✅ Model changes preserve context
✅ /compact command preserves context
✅ /clear command still properly clears context

Fixes #143

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@luxiaolei
Copy link
Contributor Author

@bra1nDump could u pls review this one?

@bra1nDump bra1nDump merged commit b1cfc18 into slopus:main Oct 10, 2025
jasonnoahchoi pushed a commit to jasonnoahchoi/happy-cli that referenced this pull request Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Happy immediately forgets context in a conservation.

2 participants