Skip to content

Conversation

@MichaelC001
Copy link

Use Case

Many users primarily work with TUI at their desk, but occasionally need to continue working from a mobile device or browser when away from the computer.

Current behavior: When you send messages from Web UI while away, returning to TUI shows no updates - you need to restart TUI to see the messages sent from Web.

Expected behavior: TUI should receive and display messages sent from Web UI in real-time, allowing seamless transition between TUI and Web workflows.

This is a practical scenario:

  1. Work on TUI at desk
  2. Step away, continue conversation via Web UI on phone/tablet
  3. Return to desk, TUI immediately shows all messages from Web session
  4. Continue working on TUI without missing any context

Problem

  • TUI → Web: ✅ syncs in real-time
  • Web → TUI: ❌ requires TUI restart to see messages

Root Cause

TUI subscribes to /event endpoint (instance-level Bus), while Web UI publishes events to GlobalBus via /global/event.

Solution

Change TUI to subscribe to /global/event endpoint instead of /event.

Trade-off

TUI will receive events from all directories (if server manages multiple projects). However:

  1. TUI only renders matching sessionID - no incorrect data displayed
  2. Single-project usage (most common) has no impact
  3. Directory filtering can be added client-side if needed

Changes

Minimal change - only 1 file, ~10 lines:

  • packages/opencode/src/cli/cmd/tui/context/sdk.tsx
    • Import GlobalEvent type
    • Change sdk.event.subscribe() to sdk.global.event()
    • Extract payload from GlobalEvent.payload

Testing

Verified bidirectional sync works:

  1. Start TUI with opencode
  2. Open Web UI at http://localhost:<port>
  3. Send message from Web UI → TUI shows it ✅
  4. Send message from TUI → Web UI shows it ✅

Change TUI to subscribe to /global/event instead of /event endpoint.
This allows TUI to receive events from Web UI, enabling seamless
bidirectional real-time sync between TUI and Web clients.

Use case: Users who primarily work with TUI at their desk can now
continue working from Web UI when away, and return to TUI with all
messages synced in real-time - no restart needed.
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.

1 participant