Skip to content

Idea: use Turso/ZeroMQ/WebSockets for shared event bus, synchronize multiple opencode TUIs and servers #2783

Closed

Description

@remorses

Currently opencode uses an in memory event notification system, this means that you cannot have 2 opencode sessions open at the same time or use opencode serve and opencode tui at the same time.

This is a problem for kimaki: if you try to write messages in Discord and also the tui the opencode chat will hang, probably because it is in a broken state, because state is not synchronized between the 2 processes

If instead opencode uses ZeroMQ for the process notification bus

Unfortunately ZeroMQ does not seem to work in Bun right now so we would need to create a port form Zig bindings using ffi or NAPI

Activity

  1. changed the title [-]Idea: use ZeroMQ for shared event bus for `client.event.subscribe`[/-] [+]Idea: use ZeroMQ for shared event bus for `/event`[/+] on Sep 25, 2025
  2. github-actions commented on Sep 25, 2025

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if none of these address your specific case.

  3. changed the title [-]Idea: use ZeroMQ for shared event bus for `/event`[/-] [+]Idea: use ZeroMQ for shared event bus, synchronize multiple opencode TUIs and servers[/+] on Sep 25, 2025
  4. changed the title [-]Idea: use ZeroMQ for shared event bus, synchronize multiple opencode TUIs and servers[/-] [+]Idea: use ZeroMQ or WebSockets for shared event bus, synchronize multiple opencode TUIs and servers[/+] on Sep 26, 2025
  5. taqtiqa-mark commented on Sep 28, 2025

    @taqtiqa-mark

    this means that you cannot have 2 opencode sessions open at the same time or use opencode serve and opencode tui at the same time.

    @remorses I believe that the new opencode attach <prot://host:port> resolves this?

    #2635 (comment) see 40c206c

  6. remorses commented on Sep 29, 2025

    @remorses
    ContributorAuthor

    it's not a great DX. I don't know the port the server is listening to, i want to use /sessions command instead

    Also doesn't work if i have an already open tui and want to start a server for the same project

    This behavior needs to be baked in

  7. taqtiqa-mark commented on Sep 29, 2025

    @taqtiqa-mark

    Some of this isn't documented, or the docs are wip:

    I don't know the port the server is listening to

    That is either the default port 4096, or the port you nominated with opencode serve --port 1234 --hostname 127.0.0.1
    Note that opencode starts a server with default port and hostname, and connects the TUI client to that.

    Also doesn't work if i have an already open tui and want to start a server for the same project.

    As above, when you started the TUI, it started a server (with defaults) for you.

    Test:

    opencode &
    
    # Step 3: Wait briefly for server to start (adjust sleep if needed)
    sleep 5
    
    # Step 4: Check if port 4096 is listening (using ss; install net-tools if using netstat)
    ss -tuln | grep 4096  # If output shows LISTEN on :::4096 or 0.0.0.0:4096, it's running
    
    # Alternative: Use curl to verify the API docs endpoint (should return HTML if server is up)
    curl -f http://127.0.0.1:4096/doc || echo "Server not responding"
    
    # Step 5: Clean up (stop the server and any processes)
    pkill -f opencode  
    

    i want to use /sessions command instead

    Maybe that can be a separate issue, given this one concerns "multiple opencode TUIs and servers)"?

  8. athal7 commented on Jan 2, 2026

    @athal7
    Contributor

    Still encountering this - opening multiple TUI instances for the same directory doesn't sync the session list. Would love to see this addressed. Happy to help test any solutions.

  9. changed the title [-]Idea: use ZeroMQ or WebSockets for shared event bus, synchronize multiple opencode TUIs and servers[/-] [+]Idea: use Turso/ZeroMQ/WebSockets for shared event bus, synchronize multiple opencode TUIs and servers[/+] on Jan 24, 2026
  10. github-actions commented on Mar 27, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 90 days of no activity. If the issue is still relevant please open a new one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions