[PR #6736] fix(tui): subscribe to global events for bidirectional Web sync #12077

Open
opened 2026-02-16 18:17:00 -05:00 by yindo · 0 comments
Owner

Original Pull Request: https://github.com/anomalyco/opencode/pull/6736

State: open
Merged: No


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
**Original Pull Request:** https://github.com/anomalyco/opencode/pull/6736 **State:** open **Merged:** No --- ## 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 ✅
yindo added the pull-request label 2026-02-16 18:17:00 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#12077