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.
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, thesubscribefunction has a logic error: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:
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.