Skip to content

fix: re-fetch messages when control returns to mobile#263

Merged
bra1nDump merged 1 commit intoslopus:mainfrom
kmizzi:fix/resync-messages-on-control-return
Dec 6, 2025
Merged

fix: re-fetch messages when control returns to mobile#263
bra1nDump merged 1 commit intoslopus:mainfrom
kmizzi:fix/resync-messages-on-control-return

Conversation

@kmizzi
Copy link
Copy Markdown
Contributor

@kmizzi kmizzi commented Dec 3, 2025

Summary

When a session is started from mobile and the user continues from desktop (by pressing a key), the CLI switches to local mode and stops syncing messages. This PR ensures that when control returns to mobile, messages are automatically re-fetched to catch up.

The Problem

  1. User starts session from mobile (remote mode, controlledByUser: true)
  2. User presses key on desktop → CLI switches to local mode (controlledByUser: false)
  3. Messages exchanged during local mode are not synced to mobile
  4. When user switches back to mobile, they're missing the messages

The Fix

Detects when controlledByUser transitions from falsetrue in the update-session handler, and triggers a message re-fetch via onSessionVisible().

const wasControlledByUser = session.agentState?.controlledByUser;
const isNowControlledByUser = agentState?.controlledByUser;
if (!wasControlledByUser && isNowControlledByUser) {
    log.log(`🔄 Control returned to mobile for session ${updateData.body.id}, re-fetching messages`);
    this.onSessionVisible(updateData.body.id);
}

Limitations

This only helps when the CLI syncs the messages to the server before switching back to remote mode. If messages were never synced during local mode, they won't appear on mobile. That would require a CLI-side change to sync message history on mode switch.

Test plan

  • TypeScript type checking passes (yarn typecheck)
  • Existing sync-related tests pass
  • Manual test: Start session from mobile → continue on desktop → switch back to mobile → messages should sync

Fixes #261

🤖 Generated with Claude Code

When a session switches from local mode (desktop control) back to remote
mode (mobile control), automatically re-fetch messages to catch up on any
messages that were exchanged while the desktop had control.

This addresses the issue where starting a session from mobile, then
continuing from desktop, would leave mobile without the new messages.
When the user switches back to mobile control, messages are now synced.

Fixes slopus#261

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

Co-Authored-By: Claude <noreply@anthropic.com>
@bra1nDump bra1nDump merged commit 4c77971 into slopus:main Dec 6, 2025
JoeLuker pushed a commit to JoeLuker/happy that referenced this pull request Feb 1, 2026
When a session switches from local mode (desktop control) back to remote
mode (mobile control), automatically re-fetch messages to catch up on any
messages that were exchanged while the desktop had control.

This addresses the issue where starting a session from mobile, then
continuing from desktop, would leave mobile without the new messages.
When the user switches back to mobile control, messages are now synced.

Fixes slopus#261

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

Co-authored-by: Claude <noreply@anthropic.com>
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.

Mobile stops receiving updates when desktop takes control

2 participants