herdr-core: OpenCode Chat shows "Conversation unavailable" when another session has the same title (paneSession)
What happened
On the herdr-core runtime, Chat for an OpenCode pane shows "Conversation unavailable". The pane's terminal works. This happens whenever the pane's terminal title (OC | <title>) matches more than one OpenCode session in opencode.db, even when only one of those sessions is the pane's own. A common case: every session opened with "hi" gets the title "Greeting".
- Run Ovis with
OVIS_RUNTIME=herdr-coreand open an OpenCode pane. - Start a session whose title OpenCode already gave another session (for example, send "hi" so it is titled "Greeting" again).
- Open the pane's Chat.
Expected: Chat shows the pane's session. The pane reported it: the terminal's ovis.opencode label holds exactly that one session id.
Actual: Chat shows "Conversation unavailable". GET /api/pane/conversation?pane_id=<pane> returns:
{"source":"scrollback","turns":[],"unavailable":"not_found"}
The plugin's server.log logs conversation.failed with operation: conversation.no_session_id on every attempt.
State observed (facts)
hc get <terminal>:title: "OC | Greeting",status: {"app":"opencode","state":"idle"},labels["ovis.opencode"]: "ses_e1ca…"(one id).session_v2in~/.local/share/opencode/opencode.db: 14 rows withtitle = 'Greeting', one of themses_e1ca…. None archived, none child sessions, in 5 different directories, created over 7 weeks./api/session: the pane hasagent: "opencode"andagent_session: null.- On the same setup, a second OpenCode pane whose title matches only one session opens in Chat normally.
Cause (from reading the code at 9d17bcd)
server/agent-identity.ts:141 (paneSession):
return titled.length === 1 && (facts.named ?? []).includes(titled[0]!) ? { … value: titled[0]! } : null;
titled comes from opencodeSessionsTitled (server/opencode.ts:645). It is every session in the whole store with the terminal's title, whatever terminal or directory it belongs to. So one other session with the same title makes titled.length 2+. paneSession then returns null even though named (the pane's own sessions, from adapter.ts:192) holds only one of them. With agent_session null, opencodeSessionId returns null and resolveTranscript throws ConversationUnavailable("no_session_id").
Proposed scope
Narrow the title match to the pane's own named sessions before asking for a single one:
const matches = (facts.titled ?? []).filter((id) => (facts.named ?? []).includes(id));
return matches.length === 1 ? { agent: "opencode", source: "herdr:opencode", kind: "id", value: matches[0]! } : null;
Hypothesis, not verified: the global uniqueness check may be deliberate. It guards against the OpenCode TUI being switched to an older session with the same title that this pane never ran a turn in. With the change above, Chat would then show the pane's last named session instead of the one on screen. If that case matters, another tie-breaker could be used instead of giving up (session directory against the pane's cwd, or the most recently updated). Today the strict check makes Chat unusable for any recurring title, which seems the larger cost.
Non-goals: the herdr runtime (it gets the session from herdr's OpenCode integration directly) and how OpenCode titles sessions.
How often
Every time
Ovis version
0.5.4 (b9d0798)
How it runs
herdr plugin
Server PC
Ubuntu 26.04.1 LTS x86_64, herdr 0.9.5, herdr-core (hc) 0.1.21
Device and browser
Phone, browser tab
How the device reaches the server
tailscale serve
Agent and PC
OpenCode v2.3.0 (session_v2 store), on the server PC
Screenshots or logs
server.log (plugin state dir):
{"event":"conversation.failed","operation":"conversation.no_session_id","code":"conversation_unavailable","failures":1,…}
{"event":"conversation.failed","operation":"conversation.no_session_id","code":"conversation_unavailable","failures":5,"suppressed":3,…}
same issue
Thank you @Ploppy3 for the careful report and code reading, and @alex93133 for confirming.
Reproduced on current main (192f55e97). With a test OpenCode store holding two sessions titled "Greeting" and a pane that reported one of them, paneSession returns null, so Chat shows "Conversation unavailable". With a title only one session has, the same pane opens normally. So the trigger is exactly what you describe.
Why we are not narrowing the title match to the pane's own reported sessions. The sessions a pane "reported" are only the ones OpenCode was busy with in that pane: its TUI sends a status record for a session only while it works or waits for input, never for a resting one. OpenCode's session list (<leader>l) also shows sessions from all projects by default, and the open dialog accepts any session id. So a pane can be showing a resting "Greeting" session from another folder that it never reported. With the narrowed rule, Chat would then show the reported "Greeting" session, which is another conversation than the one on screen, with no sign that anything is wrong. Choosing by folder, by the newest session, or by OpenCode's "viewed" time has the same problem (that time is shared by every OpenCode client, not tied to a pane). This is the case the store-wide check was added for in #2983.
Ovis has one rule here: Chat never shows a conversation unless the evidence proves it is this pane's. When it cannot tell, it says "Conversation unavailable", and the pane's live terminal keeps working as before. That is what you see now, so we are leaving the behaviour as it is for this case rather than risk showing the wrong conversation.
What would decide it: a fact reported per pane by OpenCode itself, saying which session is on screen (herdr's own OpenCode plugin reports exactly that on the herdr runtime, which is why herdr is not affected). On herdr-core no such report reaches Ovis today. Matching screen text against sessions would still be a guess, so we won't do that either. We are working out one rule for "which conversation belongs to this pane" across agents, and this issue stays open until that gives OpenCode on herdr-core a per-pane report.
Still reproduces on main (741a7f1d2): paneSession returns the session when the pane's title matches one OpenCode session, and null when two sessions share it ("Greeting"). #4121 fixed another path and #4727 keeps the pane's ovis.opencode label across restarts, but neither proves which of two same-titled sessions the pane is showing now. A safe fix needs OpenCode's current session id for the pane, rather than guessing between titles.