Skip to content

Add clipboard copy for log message and full entry (ctrl+y / y)#145

Open
soy-chrislo wants to merge 1 commit into
control-theory:mainfrom
soy-chrislo:clipboard-copy-log-entry
Open

Add clipboard copy for log message and full entry (ctrl+y / y)#145
soy-chrislo wants to merge 1 commit into
control-theory:mainfrom
soy-chrislo:clipboard-copy-log-entry

Conversation

@soy-chrislo

@soy-chrislo soy-chrislo commented Jul 5, 2026

Copy link
Copy Markdown

Fixes #9

What

In the log details modal:

  • y (or alt+y) copies just the log message to the clipboard.
  • ctrl+y copies the full entry as plain text: severity, timestamps, attributes (sorted alphabetically, same as the attributes table), and the AI analysis result if one has already been run for this entry.

Both are plain text (no ANSI/lipgloss styling), so they paste cleanly into Slack, an AI chat, or a bug report — matching the use case described in the issue.

Design

This follows what was discussed in the issue thread: atotto/clipboard (it was already an indirect dependency, now promoted to direct via go mod tidy), ctrl-y for the full log, y/alt-y for the message.

One deliberate deviation worth flagging: instead of adding a separate binding for "copy AI analysis" in the chat pane, I folded it into ctrl+y — the AI analysis already renders in the same info pane as the rest of the log details, so copying "everything visible here" felt like the more natural fit. Happy to split it into its own key if you'd rather keep it separate.

I intentionally left the chat pane untouched — it captures every keystroke while focused for typing, and scoping this to the info pane kept the change small and avoided fighting that input-focus behavior.

Testing

  • Added internal/tui/clipboard_test.go (table-driven, matching the only existing test file's style) covering the plain-text formatting (attribute sorting, optional Log Time/Attributes/AI Analysis sections, and skipping the transient "Analyzing..." placeholder).
  • make fmt, make vet, make test, make build all pass locally.
  • Manually verified end-to-end on Linux/Wayland: copied from the running app and confirmed the exact content lands in the clipboard via wl-paste.

Known limitation: atotto/clipboard needs xclip/xsel/wl-copy on Linux (no OSC52 fallback) — on failure, the status bar shows "Copy failed: ..." instead of silently doing nothing.

In the log details modal, "y" (or "alt+y") copies just the log
message, and "ctrl+y" copies the full entry as plain text (severity,
timestamps, attributes, and the AI analysis if one has been run),
suitable for pasting into Slack or an AI chat.

This follows the design agreed on in the issue thread (atotto/clipboard,
ctrl-y for the full log, y/alt-y for the message). Copying the AI
analysis is folded into ctrl+y instead of a separate binding, since
the analysis result already lives in the same info pane as the log
details - happy to split it into its own key if maintainers prefer.

Fixes control-theory#9
@soy-chrislo

Copy link
Copy Markdown
Author

Hope this resolves the issue! Happy to make any changes needed to get it merged — just let me know and I'll get on it.

One small heads-up from testing: on my machine, pasting into Kate (KDE) specifically doesn't pick up the multi-line ctrl+y copy, though the single-line y copy works fine there, and other apps read the multi-line one correctly. Seems like a Kate/Wayland clipboard quirk unrelated to this PR — just flagging it in case it's useful, not something I think needs fixing here.

@rbg

rbg commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Thanks for the PR and heads up - we'll take a look !

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.

Support for copy and paste

2 participants