OpenCode: show user messages sent from another client (e.g. the TUI) in the thread#27807

opened19h agobySSidneyJob

When T3 Code is attached to an existing OpenCode server (provider settings → Server URL / Server password), the same session can also be used from another OpenCode client, e.g. the OpenCode TUI on the laptop. Replies to prompts sent from that client do show up in the T3 thread (as "Background activity updated"), but the user's own prompt does not. A long thread then reads as a list of assistant answers with no questions, which makes it hard to follow.

Steps to reproduce (t3 0.1.5, OpenCode 2.2.4):

  1. Run opencode service start and point T3's OpenCode provider at it (Server URL + Server password).
  2. Start a thread in T3 with the OpenCode provider and send "Привет". It shows normally.
  3. Open the same session in the OpenCode TUI and send "qwe!".
  4. In T3 (web or mobile), the assistant's answer to "qwe!" appears after "Background activity updated", but the "qwe!" message itself is missing.

Expected: user messages sent from another client appear in the thread like messages sent from T3, so the conversation reads in order.

Where: packages/provider-opencode/src/server/adapter.ts, handlePartUpdated. User text parts are projected only for child (subagent) turns:

ts
1if (part.type === "text" && state.messageRoles.get(part.messageID) === "user") {
2 if (!turn.isRoot) yield* projectChildUserPart(state, turn, part);
3 return;
4}

For root turns started by another client, the part is dropped. Projecting those parts as user messages (marked as coming from another client, if that's useful) would fix it. The snapshot path (readSnapshot) already keeps user messages (createdBy: info.role === "user" ? "user" : "agent").

Related: #10826 (importing OpenCode sessions started outside T3).