Skip to content

fix(tui): TUI message list doesn't update for cross-instance agent messages #22588

@ailearningguy

Description

@ailearningguy

Bug Description

When using agent-comms plugin to send messages between opencode instances, the TUI message list doesn't update in real-time. The agent processes messages and replies correctly, but the conversation view only shows the first message until TUI is restarted.

Root Cause

In packages/opencode/src/cli/cmd/tui/context/event.ts, the subscribe function has a logic error:

if (project.workspace.current()) {
  if (event.workspace === project.workspace.current()) {
    handler(event.payload)
  }
  return  // <-- BUG: always returns, even when workspace mismatch
}
// Directory fallback never reached for workspace mismatches
if (event.directory === project.instance.directory()) {
  handler(event.payload)
}

When TUI is in a workspace but the incoming event has a different workspace ID (or none), the function returns without falling back to directory matching. Events are silently dropped.

Fix

Replace the double-if with proper else-if so directory fallback runs when workspace doesn't match:

if (project.workspace.current()) {
  if (event.workspace === project.workspace.current()) {
    handler(event.payload)
  }
} else if (event.directory === project.instance.directory()) {
  handler(event.payload)
}

Verification

Tested with agent-comms plugin sending messages between two opencode instances in different directories. Before fix: message list stuck on first message. After fix: message list updates in real-time.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions