Skip to content

feat(tui): copy-on-select, configurable copy key, clearer Select label#510

Open
saada wants to merge 1 commit into
F1bonacc1:mainfrom
saada:tui-log-copy-ergonomics
Open

feat(tui): copy-on-select, configurable copy key, clearer Select label#510
saada wants to merge 1 commit into
F1bonacc1:mainfrom
saada:tui-log-copy-ergonomics

Conversation

@saada

@saada saada commented Jun 17, 2026

Copy link
Copy Markdown

What

Makes copying logs out of the TUI ergonomic and configurable:

  1. Copy-on-select (mouse): releasing a mouse drag in selection mode copies the highlight to the clipboard automatically — no Enter needed.
  2. Configurable keyboard copy key: new log_copy shortcut, default Enter (fully backward compatible), so it can be rebound — e.g. y for a Vim-style yank.
  3. Clearer footer label: the selection toggle now reads Enable Select / Disable Select (the action) instead of Select On / Select Off (which read as current state).
  4. Docs: new "Copying Logs to the Clipboard" section in www/docs/tui.md, including the OSC 52 fallback — previously undocumented.
# $XDG_CONFIG_HOME/process-compose/shortcuts.yaml
shortcuts:
  log_copy:
    shortcut: y   # Vim-style yank instead of Enter

Why

The copy key (Enter) and exit key (Esc) in selection mode were the only TUI bindings not covered by the configurable shortcuts system, and "turn Select on → highlight → nothing's in my clipboard until I press Enter" is a recurring point of confusion. Ctrl+C can't simply be adopted for copy because it's already the global quit binding (and forwards SIGINT to a focused interactive process), so copy-on-select plus a configurable copy key is the pragmatic fix.

How

  • src/tui/actions.go — new ActionLogCopy (log_copy), default tcell.KeyCR in defaultShortcuts, and a ShortCutKeys entry. Relabels ActionLogSelection's ToggleDescription. log_copy is intentionally left out of the footer/help order arrays, so the footer layout is unchanged.
  • src/tui/log-operations.go — copy logic extracted into copyLogSelection(collapse bool) (ignores empty selections so a stray click/press never clobbers the clipboard). The keyboard path matches the configured key via isLogCopyEvent (special key or rune); the title hint uses logCopyShortcut. A SetMouseCapture on the text area copies on MouseLeftUp. Esc still exits.
  • src/tui/actions_test.go — unit tests for the default (Enter) and overrides (y rune, Ctrl-Y key).
  • www/docs/tui.md — new docs section.

Behavior notes

  • Default keyboard behavior is unchanged: Enter still copies, Esc still exits.
  • Copy-on-select fires only on a deliberate mouse drag release with a non-empty selection, in selection mode. If you'd prefer it gated behind a config flag, easy to add.
  • The mouse path keeps the highlight visible after copying; the keyboard path collapses it (as before).

Testing

  • go build ./... — clean
  • go test ./... — pass (incl. new tests)
  • gofmt -l / go vet ./src/tui/ — clean

Closes #509

- Copy a mouse selection to the clipboard automatically on drag release
  (copy-on-select), no Enter required.
- Add a configurable `log_copy` shortcut (default Enter) so the keyboard
  copy key can be remapped (e.g. `y` for a Vim-style yank). It was the only
  TUI binding not covered by shortcuts.yaml.
- Relabel the selection toggle from 'Select On'/'Select Off' to the action
  it performs: 'Enable Select'/'Disable Select'.
- Document the copy-to-clipboard flow (incl. the OSC 52 fallback) in
  www/docs/tui.md.
- Ignore empty selections so a stray click/key press never clobbers the
  clipboard.
@sonarqubecloud

Copy link
Copy Markdown

@F1bonacc1 F1bonacc1 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @saada,

Thank you for the PR!
I accept that log copy should be a configurable shortcut.
And this is exactly what this PR provides, which is great.
I think "copy on selection" to the main clipboard is unexpected and should be behind a configuration or not at all.

There are also a 2 critical issues that should be addressed.

  1. nil dereference
    func (s *ShortCuts) setAction(actName ActionName, actionFn func()) {

    is not wired. Setting a custom shortcut, I reproduced it with y panics here:
    act.actionFn()

    Since actionFn is nil.

Since it was missed, it's worth adding a test to catch this before fixing.

  1. ActionLogCopy is missing from the help screen
    The ActionLogCopy action should be added here:
    var logActionsOrder = []ActionName{

Comment thread www/docs/tui.md
Toggle **selection mode** with `Ctrl+S` (`Enable Select` in the footer). The log pane then becomes selectable and there are two ways to copy:

- **Mouse:** drag to highlight — releasing the mouse copies the selection automatically (copy-on-select), no key press required.
- **Keyboard:** highlight with `Shift`+arrows and press `Enter` to copy.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keyboard selection doesn't work.
Sounds like a documentation fix, not a bug.

Comment thread www/docs/tui.md

Press `Esc` to leave selection mode.

Process Compose copies through your system clipboard when available and falls back to the [OSC 52](https://www.reddit.com/r/vim/comments/k1ydpn/a_guide_on_how_to_copy_text_from_anywhere/) terminal escape sequence otherwise (your terminal must allow OSC 52). A status message confirms which method was used.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The OSC 52 fallback is documented in my other repo: https://github.com/F1bonacc1/glippy#osc-52-fallback
I wouldn't add it, especially with a Reddit link.

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.

TUI: make copying logs ergonomic & configurable (copy-on-select, configurable copy key, clearer Select label)

2 participants