opencode icon indicating copy to clipboard operation
opencode copied to clipboard

[FEATURE]: web review-panel copy content button

Open divinity76 opened this issue 1 month ago • 6 comments

Feature hasn't been suggested before.

  • [x] I have verified this feature I'm about to request hasn't been suggested before.

Describe the enhancement you want to request

I want a "copy file content to clipboard" button in the web review-panel. It's actually difficult to copy manually, because double-clicking opens the "add comment" panel, which cancels the double-click-select-effect.

Image

divinity76 avatar Oct 25 '26 04:10 divinity76

Thanks for the suggestion, @divinity76! You're asking for a button in the web review panel that copies a file's full content, since copying by hand is awkward when double-clicking opens the add-comment panel and cancels the selection.

Maintainers will consider it. A related request:

  • #34823: a "copy file path" action in the diff review and file viewer (closed). It asks for the path rather than the content.

opencode-agent[bot] avatar Oct 25 '26 04:10 opencode-agent[bot]

May I contribute a Copy file contents action in the review file header? It would copy the complete current text, not diff hunks, with clipboard success/error feedback. Deleted files would use complete old text when available; binary or unavailable content would not overwrite the clipboard.

I have a local implementation prepared with AI assistance, but have not opened a PR. I should have requested design review before implementing it. Is this approach approved for an implementation PR, or would you prefer a different scope?

lancy69 avatar Oct 27 '26 17:10 lancy69

@lancy69 i recommend just sending the PR asap, worst they can do is close the PR

divinity76 avatar Oct 27 '26 19:10 divinity76

Got it. I'll make a PR now :)

lancy69 avatar Oct 28 '26 00:10 lancy69

Confirming this affects the desktop app's file panel too (not just the web review panel), plus the root cause from source so the fix can be targeted.

Repro on desktop 2.2.7 (remote-SSH mode): open a plain-text file (e.g. a .sql file) in the right-hand file panel and click once on a line — the comment editor opens immediately. A single click is enough; a drag is not required.

Root cause:

  • packages/gui-plugins/src/file/view.tsx:489 passes enableLineSelection to the file viewer unconditionally — there is no setting to turn it off.
  • packages/session-ui/src/components/file.tsx:325 — handleMouseDown only checks event.button !== 0; it does not check altKey/shiftKey/metaKey/ctrlKey, so holding a modifier does not bypass the gesture.
  • packages/session-ui/src/pierre/selection-machine.ts:274-278 — a press with no movement still produces a single-line range, which is why a bare click is enough.
  • packages/session-ui/src/components/line-comment-machine.ts:71-76 — line.selection-ended with a non-null range calls openDraft, which renders the editor.
  • The code view renders with no toolbar at all (view.tsx:508), unlike the artifact view, which has a working "Copy content" button (artifact-toolbar.tsx:97) already covered by an e2e test (packages/app/e2e/regression/review.spec.ts:917).

Note on #59785: that PR adds the copy action to the review panel header, so the file panel still has no copy affordance once it lands. It would be good to either reuse the same action in the file panel, or gate enableLineSelection behind a user setting — the review panel already gates it on a prop (session-review-file-preview-v2.tsx:120,194), so the plumbing exists.

One more thing worth fixing while here: the comment editor auto-focuses its textarea on open (line-comment.tsx:326), which discards the text selection the viewer had just restored (selection-bridge.ts:88). So "drag to select, then Ctrl/Cmd+C" does not work either, even though the viewer goes to the trouble of preserving the selection.

ESwordCn avatar Nov 11 '26 12:11 ESwordCn

The file tab toolbar in #64463 adds Copy content for regular text and code files in the web review panel. That PR is open for review.

usrnk1 avatar Nov 17 '26 15:11 usrnk1