Skip to content

Add copy-paste mode with cp: prefix for web UI interaction#276

Merged
dwash96 merged 16 commits intocecli-dev:v0.90.4from
chrisnestrud:copy-paste-no-api
Dec 19, 2025
Merged

Add copy-paste mode with cp: prefix for web UI interaction#276
dwash96 merged 16 commits intocecli-dev:v0.90.4from
chrisnestrud:copy-paste-no-api

Conversation

@chrisnestrud
Copy link
Copy Markdown

Add copy-paste mode with cp: prefix for web UI interaction, based on the copy-paste-no-api branch of https://github.com/ther0bster/aider.git

See also Aider-AI#3479

@dwash96
Copy link
Copy Markdown
Collaborator

dwash96 commented Dec 19, 2025

Oh man, I am not anti this concept at all but could you actually refactor it such that it's a coder class in aider/coders and add the relevant overriding logic on when to call the relevant model perhaps. I'm also super curious as to how this integrates with the TUI mode

@chrisnestrud
Copy link
Copy Markdown
Author

Thanks, I appreciate the feedback. I've made changes as you suggested.

Here’s how CopyPasteCoder behaves in the TUI, and how it differs from the --copy-paste CLI option.

Using a cp: model (e.g., cp:openai/gpt-5.2)

  • What happens when you press Enter in the TUI:
    • CopyPasteCoder flattens the current chat (system/user/assistant messages) into plain text with role headers (e.g., “USER: …”, “ASSISTANT: …”).
    • It copies that text to your system clipboard (via pyperclip) and prints messages like:
      • “Request copied to clipboard.”
      • “Paste it into your LLM interface, then copy the reply back.”
      • “Waiting for clipboard updates (Ctrl+C to cancel)…”
    • It blocks and waits for the clipboard to change. As soon as you copy the LLM’s reply from your browser (or any external interface) into the clipboard, that text is treated as the assistant’s response and shown in the TUI.
  • Important details/limitations:
    • Tool calls and function calls are ignored in this mode; it’s plain text in/out only.
    • Requires a working system clipboard (pyperclip). If clipboard access fails, you get a tool error in the TUI.
    • It is per-request blocking: the TUI waits until you copy a new clipboard value or you interrupt with Ctrl+C.

Using the --copy-paste CLI option (clipboard watcher for input)

  • What it does in the TUI:
    • It starts a background clipboard watcher that continuously monitors your clipboard.
    • Whenever the clipboard changes, it interrupts the current input and pre-fills the TUI input box (io.placeholder) with the clipboard content. If it’s multi-line, it’s wrapped with leading/trailing newlines for nicer editing.
  • What it does not do:
    • It does not change how model calls are made. If you’re using a normal API model (e.g., openai/gpt-4o), the app still calls the API as usual.
    • It does not automatically perform the “copy request, wait for reply in clipboard” round trip. That is specific to cp: models.
  • It’s purely a UX aid for getting text into the TUI input quickly by just copying it.

How they differ and how they combine

  • cp:openai/gpt-5.2 (or any cp:* model) switches the send path to clipboard-driven “transport” for model replies: request is copied out; the reply is read from clipboard; no API call happens; tools/functions are ignored.
  • --copy-paste only affects the input experience in the TUI by pre-filling your next prompt from the clipboard; it does not alter the send path or API usage.
  • You can combine them:
    • The cp: model will still do its request→clipboard→wait→clipboard flow.
    • The CLI watcher will continue to pre-fill the next input field when your clipboard changes (helpful for quickly turning copied snippets into prompts), but it doesn’t change the cp mode’s blocking wait behavior.

@dwash96
Copy link
Copy Markdown
Collaborator

dwash96 commented Dec 19, 2025

Alright nice, my 2 last (very minor!) requests since I appreciate you separating most of the effects of this out from the rest of the code base:

  • can we move aider/copypaste.py to aider/helpers/copypaste.py (I'm trying to keep highly specific functionalities sequestered as helpers files)
  • Can we shorten copy_paste_instead_of_api to either copy_paste_mode or clipboard_mode

These 2 changes and I'm fine with this for 0.90.4

@ErichBSchulz
Copy link
Copy Markdown

This is useful for in what situations? What would this be documented?

@chrisnestrud
Copy link
Copy Markdown
Author

Thanks, I've made these changes.

The use case is when your only LLM access is via a web browser frontend.

@dwash96 dwash96 changed the base branch from main to v0.90.4 December 19, 2025 23:27
@dwash96 dwash96 merged commit 175db1a into cecli-dev:v0.90.4 Dec 19, 2025
@dwash96 dwash96 mentioned this pull request Dec 19, 2025
@ErichBSchulz
Copy link
Copy Markdown

ErichBSchulz commented Dec 20, 2025

The use case is when your only LLM access is via a web browser frontend.

Oh nice!! Sorry I'm very good at impersonating a dumb noob (ask @dwash96)... this is a bit of project wide soft spot. It would be great to say when you would use this feature and a bit more on what to expect.

Don't need "War and Peace", but is it possible to expand on "Enable automatic copy/paste of chat between aider and web UI".

eg "Enable automatic copy/paste of chat between aider and web UI (Useful when your LLM access is via a browser)".

But what does "automatic" mean exactly?

I feel like cecli has a growing number of awesome features that won't get the use they deserve for want of a few explanatory words.

@Konfekt
Copy link
Copy Markdown

Konfekt commented Dec 20, 2025

I feel like cecli has a growing number of awesome features that won't get the use they deserve for want of a few explanatory words.

This mirrors my feelings at #256 (comment)

@chrisnestrud chrisnestrud deleted the copy-paste-no-api branch December 21, 2025 03:38
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.

4 participants