Skip to content

fix(agent): make opencode v2 /acp status panel visible in the TUI - #880

Merged
ranxianglei merged 1 commit into
2026-09-15_opencode-native-pluginfrom
2026-09-17_opencode-v2-acp-visible-panel
Sep 17, 2026
Merged

ranxianglei merged 1 commit into
2026-09-15_opencode-native-pluginfrom
2026-09-17_opencode-v2-acp-visible-panel

Conversation

@ranxianglei

Copy link
Copy Markdown
Owner

Closes #877

Problem

Under OpenCode V2 (opencode >= 2, native plugin via v2.session.synthetic), /acp produced no visible output in the TUI whenever the panel exceeded ~1 KB. Real panels are multi-line and box-drawn, so they routinely trip the cap. Short synthetic texts render fine, which masked the bug until live-testing with a full session.

Root cause (official opencode v2.0.4 source, packages/app/src/session/timeline/message-timeline.tsx, canRenderImmediately):

(message?.type === "system" || message?.type === "synthetic") &&
(message.description ?? message.text).length <= 1024

A synthetic/notice row renders only when (description ?? text) is ≤ 1024 chars; anything longer renders nothing (not even collapsed). The panel was carried in text only.

Fix

Carry the panel in description instead (verbatim under 1024 chars; leading lines + [panel truncated] marker above — 1004 + "\n\n[panel truncated]" = 1023 ≤ 1024), and set the model-facing text to an inert one-liner (V2_SYNTHETIC_TEXT), so:

  • the TUI renders the panel (or its head + marker) as the notice row;
  • the model-facing message no longer carries the full panel content;
  • agent-side plugin code only — no wire change for any client or compression mode.

Verification

  • Live in opencode v2.0.4 TUI behind bili: short panels render fully as the notice row; a >1.5 KB panel renders its leading lines plus the [panel truncated] marker (see issue).
  • synthetic({ sessionID, text, description, resume }) is a supported API shape — the opencode v2 SDK posts description to /api/session/:id/synthetic and the Synthetic message schema carries optional text/description.
  • New unit test: 1500-char panel → description.length ≤ 1024 ending in [panel truncated], text = the inert one-liner.
  • Pre-flight on this branch: npm run typecheck clean · npm test 1659 pass / 0 fail / 2 skipped · npm run build OK.

Note: commit 304110a previously landed via #878 against the stale 2026-09-17_opencode-v2-acp-no-wake branch. This PR carries the same single commit onto the real stack (base = #850's branch, where the no-wake fix already merged via #875). Diff vs base is exactly this one commit (3 files, +48/−7).

The /acp panel was carried only in the synthetic message's text. OpenCode V2's
TUI renders a synthetic message as a Notice row only when its display text fits
the timeline cap (~1KB; message-timeline.tsx canRenderImmediately), so real
panels were silently dropped: users saw nothing after /acp.

The panel now goes to description (verbatim under 1024 chars, leading lines +
[panel truncated] above) and the model-facing body is an inert one-line note
(V2_SYNTHETIC_TEXT) so the model context never repeats panel content.

Verified live in a v2.0.4 TUI: short panels render fully as the notice row,
a >1.5KB panel renders its leading lines plus the marker; no model turn is
triggered (pairs with the no-wake fix #879).
@ranxianglei
ranxianglei merged commit 40c4970 into 2026-09-15_opencode-native-plugin Sep 17, 2026
2 checks passed
@ranxianglei
ranxianglei deleted the 2026-09-17_opencode-v2-acp-visible-panel branch October 15, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant