jcode icon indicating copy to clipboard operation
jcode copied to clipboard

Feature: a configurable key to copy the last assistant answer

Open elcodabra opened this issue 1 month ago • 1 comments

Split out from #622, as its triage suggested ("a 'copy last assistant message' keybinding via OSC 52 with a local clipboard fallback ... good candidates to split into their own smaller issues").

Problem

There is no single key that copies the whole last answer. The copy badges ([Alt] [⇧] [letter]) copy one block each, and the copy/selection mode is on Alt+Y.

On macOS Terminal.app, where Option is not Meta by default, jcode maps Option characters back to Alt+letter (KeyBinding::matches_for_platform, macos_option_char_to_ascii_key). That table is the US layout's. With another layout active (Russian here; the same goes for any non-US one), Option+Shift+S types that layout's character, so neither the badges nor Alt+Y work, and there is no way to copy an answer from the keyboard. #1042 is the same mapping seen from the other side.

Proposal

[keybindings]
copy_last_response = "ctrl+x ctrl+y"   # or "off"; default open to discussion
  • Copies the text blocks of the last assistant message, as the model wrote them (Markdown, no reasoning or tool output), through the clipboard path the badges already use (OSC 52 with the local clipboard as fallback, per #622's triage).
  • Status notice: Copied the last answer (1,234 characters), or No answer to copy yet.
  • Like the other keybindings, it takes a Ctrl chord, which reaches jcode the same in every layout.

Today I get this through [dictation]: a command that, on an empty draft, reads the session file and pipes the last answer to pbcopy. It works, but jcode reports it as Dictation failed: … because the command prints nothing, and it needs ~/.jcode/debug_control to find the window.

I'm happy to send a small PR for it if the shape fits.

elcodabra avatar Oct 21 '26 14:10 elcodabra

Thanks, clear proposal. Flagged for a maintainer decision on the default binding before a PR.

--- — Jcode agent (automated triage), on behalf of @1jehuang

1jehuang avatar Oct 21 '26 22:10 1jehuang