Skip to content

fix(cli): send messages added outside happy when resuming a session - #1862

Open
rophy wants to merge 2 commits into
slopus:mainfrom
rophy:fix/resume-outside-messages
Open

rophy wants to merge 2 commits into
slopus:mainfrom
rophy:fix/resume-outside-messages

Conversation

@rophy

@rophy rophy commented Oct 4, 2026 •

Copy link
Copy Markdown

Summary. When a conversation is continued outside happy (plain claude --resume) and the session is then resumed with happy resume, the messages added outside never reach the app, although Claude remembers them: on start, happy marks every entry already in Claude's conversation file as sent. This PR adds a reconnect backfill: while skipping the session's existing history on reattach, the CLI records which Claude entries the history holds (claudeUuid), then sends the entries after the last known one before the scanners start. It also keeps the SDK's message uuid in remote mode instead of generating a random one, so claudeUuid matches the conversation file (rewind/fork already treat the file as the source of truth for it). Fixes #1861.

Changes

  • claude/utils/sdkToLogConverter.ts: use the SDK message's uuid (the entry's uuid in Claude's JSONL); fall back to a random one only when it is missing.
  • api/apiSession.ts: on reconnect (skipExistingMessages), decrypt the skipped history and expose what it holds of the conversation (syncedTranscript()).
  • claude/utils/transcriptResync.ts (new): finds the entries after the last one the history knows (app-typed messages that never got a reply are not sent twice) and sends them; sends nothing if the history cannot be read within 10 s or matches none of the entries.
  • claude/runClaude.ts: runs the backfill on reconnect when resuming a Claude session (--resume <id>), next to the existing fork backfill.
  • Tests: transcriptResync.test.ts (8), sdkToLogConverter.test.ts (+2), apiSession.test.ts (+1).

Proof — local pnpm env:up:authenticated, same steps on main and on this branch: start happy, send a message from the web app, stop the session process, send two messages with claude --resume <id>, then happy resume <session id>.

Before:
proof-before

After:
proof-after

CLI log on this branch:

[RECONNECT BACKFILL] Sent 4 of 6 entries missing from the session history

CLI test suite: no new failures (claude_version_utils "falls back to --version…" and the daemon "stress test: spawn / stop" fail on main as well).

rophy added 2 commits October 4, 2026 15:42
On reattach, record which conversation entries the session history holds and send the ones after the last known entry before the scanners start.

This branch has not been deployed

No deployments
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.

Messages added with "claude --resume" don't appear in the app after "happy resume"

1 participant