Skip to content

fix(happy-cli): unblock SDK messages while waiting for user input#843

Open
EricSeastrand wants to merge 1 commit intoslopus:mainfrom
EricSeastrand:fix/clauderemote-nonblocking-nextmessage
Open

fix(happy-cli): unblock SDK messages while waiting for user input#843
EricSeastrand wants to merge 1 commit intoslopus:mainfrom
EricSeastrand:fix/clauderemote-nonblocking-nextmessage

Conversation

@EricSeastrand
Copy link
Contributor

Summary

  • The for await loop in claudeRemote() synchronously awaits nextMessage() after receiving a result message, which blocks the entire loop from iterating
  • Any SDK messages emitted while waiting for user input (background task completions, system notifications) pile up unsent until the user types something
  • This causes the "one behind" symptom: background task results don't appear until the user sends another message
  • Fix: switch nextMessage() to a non-blocking .then() pattern so the loop keeps forwarding SDK events while waiting

This is a complementary fix to PR #699 — that PR fixes head-of-line blocking in OutgoingMessageQueue, this one fixes a separate blocking point upstream in the claudeRemote message loop. Both contribute to the same symptom.

Fixes #639

Test plan

  • Reproduced the "one behind" bug using background tasks (sleep 12 && echo "BACKGROUND DONE" with parallel file writes)
  • Verified fix: background task notification arrives promptly ~12s after launch, no longer blocked behind the nextMessage() await
  • Verify no regressions with normal sequential message flow

🤖 Generated with Claude Code
via Happy

The for-await loop in claudeRemote awaited nextMessage() synchronously,
which blocked all SDK messages (background task completions, system
notifications) from being forwarded to the phone until the user sent
their next message. Switch to a non-blocking .then() pattern so the
loop keeps iterating and forwarding events while waiting for input.

Fixes head-of-line blocking reported in GitHub slopus#639.

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
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.

OutgoingMessageQueue head-of-line blocking causes 'one behind' responses with background tasks

1 participant