opencove icon indicating copy to clipboard operation
opencove copied to clipboard

[BUG] Copy-last-agent-message toolbar button copies wrong content (small fragment from older message)

Open domijin opened this issue 6 months ago • 1 comments

Build

  • OpenCove.app CFBundleVersion = 0.2.0-nightly.20260509.1
  • macOS (Apple Silicon)

Where

The agent-node toolbar that shows the Standby chip and four icons (undo / history / copy / X). The third icon is the affected one.

Expected

Clicking the copy button copies the full text of the most recent assistant message in the conversation to the system clipboard.

Actual

Click registers (focus ring fires, no console errors), and the system clipboard does mutate — but the content that lands is a small fragment from an older message, not the most recent one.

Concrete repro from a real session:

  • The most recent assistant message at click time was a multi-paragraph runbook (~30 lines, headers, numbered steps, no inline code spans in its early paragraphs).
  • The clipboard after the click contained only the literal string mp-skill-issues — a kebab-case slug that was wrapped in backticks (inline code span) inside an earlier assistant message ~2 turns back, not the latest one.

Captured diagnostics

Signal Result
Click registers (focus ring) yes
DevTools Console errors during click none (empty)
System clipboard mutated yes
Clipboard content matches "most recent message" no — contains a fragment from an older message

So the IPC clipboard-write path is firing fine. The bug is in what the click handler decides to copy, not whether the copy executes.

Candidate root causes

  1. Message-index off-by-N. The handler resolves "last assistant message" against a stale or wrong-index source (e.g., last complete message excluding the current streaming one, or simply pointing at the wrong array slot).
  2. Inline-code-span scope. The handler walks the rendered DOM for the last <code> element across all messages and copies its textContent, instead of resolving the most-recent message's full body. This would explain why mp-skill-issues (an inline code span in an earlier message) landed instead of the runbook (which had no inline code spans in its first paragraph).

Hypothesis 2 fits the observed fragment best, but a maintainer will know which selection logic the button uses.

Repro for the maintainer

  1. In any agent thread, send a long assistant turn that contains no inline code spans (e.g., a multi-paragraph plain-prose response).
  2. Earlier in the same thread, ensure there is at least one assistant message containing a backtick-wrapped inline code span.
  3. Click the copy button on the agent toolbar.
  4. Paste somewhere external. Expect: full text of the latest message. Observe: probably just the inline-code-span text from the older message.

Notes

  • This is a different bug class from #144 (xterm WebGL renderer) and #231 (frame-budget scheduler) — both confirmed working in this build. This is in the agent-node toolbar's copy-handler logic.

domijin avatar May 12 '26 08:05 domijin

这种问题一般发生于在进行了 resume 或者 undo 回撤的情况下,因为现在的 agent 状态追踪原理是追踪 session,但是如果在 TUI 里切回了 session 就会丢失目标,导致无法确定状态,也就无法找到session对应的 last message。目前对于 TUI 还没有特别好的解决办法,只有实现 ACP + 自定义 UI 交互才能规避这个问题(但是又可能会出现指令功能不完全继承兼容的问题),目前还在思考解决方案。

DeadWaveWave avatar May 20 '26 07:05 DeadWaveWave