Skip to content

feat: add auto copy on select#1194

Merged
arnestrickmann merged 1 commit intogeneralaction:mainfrom
liamhess:liam/terminal-auto-copy-8c1
Mar 1, 2026
Merged

feat: add auto copy on select#1194
arnestrickmann merged 1 commit intogeneralaction:mainfrom
liamhess:liam/terminal-auto-copy-8c1

Conversation

@liamhess
Copy link
Contributor

@liamhess liamhess commented Mar 1, 2026

Fixes #1193 by adding auto copy on selection.

@vercel
Copy link

vercel bot commented Mar 1, 2026

@liamhess is attempting to deploy a commit to the General Action Team on Vercel.

A member of the Team first needs to authorize it.

@greptile-apps
Copy link

greptile-apps bot commented Mar 1, 2026

Greptile Summary

Adds optional auto-copy on selection feature to the terminal, allowing users to automatically copy selected text to clipboard. The implementation includes:

  • New autoCopyOnSelection boolean setting (defaults to false for opt-in behavior)
  • Settings UI with toggle switch in Terminal Settings Card
  • Event-based communication between settings and terminal manager
  • 150ms debounce to prevent excessive clipboard operations during text selection
  • Reuses existing copySelectionToClipboard() method which handles ANSI code cleanup and fallback strategies
  • Proper cleanup of debounce timers and event listeners in disposables

The feature is well-isolated, properly initialized from settings, and updates immediately when toggled.

Confidence Score: 5/5

  • This PR is safe to merge with no issues identified
  • Clean implementation following established patterns, proper error handling, memory-safe with timer cleanup, opt-in behavior, reuses existing clipboard methods, no breaking changes
  • No files require special attention

Important Files Changed

Filename Overview
src/main/settings.ts Added autoCopyOnSelection boolean field to terminal settings with proper defaults and normalization
src/renderer/components/TerminalSettingsCard.tsx Added Switch UI component for auto-copy setting with proper state management and event dispatching
src/renderer/terminal/TerminalSessionManager.ts Implemented auto-copy functionality with 150ms debounce, proper event handling, and cleanup in disposables
src/renderer/types/electron-api.d.ts Updated TypeScript definitions to include autoCopyOnSelection field in terminal settings types

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User selects text in terminal] --> B{Auto-copy enabled?}
    B -->|No| Z[End - no action]
    B -->|Yes| C{Has selection?}
    C -->|No| Z
    C -->|Yes| D[Clear existing debounce timer]
    D --> E[Start 150ms debounce timer]
    E --> F{Timer expires}
    F --> G{Terminal disposed?}
    G -->|Yes| Z
    G -->|No| H{Still has selection?}
    H -->|No| Z
    H -->|Yes| I[Get selected text]
    I --> J[Clean terminal text<br/>remove ANSI codes]
    J --> K{navigator.clipboard available?}
    K -->|Yes| L[Copy via navigator.clipboard]
    K -->|No| M[Copy via electronAPI fallback]
    L --> N[Success]
    M --> N
    L -.->|Error| M
    N --> Z
Loading

Last reviewed commit: 00fae83

@arnestrickmann
Copy link
Contributor

Hi @liamhess,

Thanks for opening the PR - the addition makes sense.

LGTM, merging.

@arnestrickmann arnestrickmann merged commit 5e1a8cf into generalaction:main Mar 1, 2026
3 of 4 checks passed
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.

[feat]: auto copy on terminal selection

2 participants