Skip to content

feat: add clipboard copy support and fix hint bar overlap#115

Merged
subsy merged 4 commits intomainfrom
feat/clipboard-copy
Jan 17, 2026
Merged

feat: add clipboard copy support and fix hint bar overlap#115
subsy merged 4 commits intomainfrom
feat/clipboard-copy

Conversation

@subsy
Copy link
Copy Markdown
Owner

@subsy subsy commented Jan 17, 2026

Summary

  • Add clipboard copy functionality using Cmd+C (macOS), Ctrl+Shift+C or Alt+C (Linux), Ctrl+C (Windows)
  • Cross-platform clipboard support via OS commands (pbcopy, wl-copy, xclip, xsel, clip.exe)
  • Fix hint bar overlap in ChatView by positioning it on the border line

Closes #91

Test plan

  • Test copy in create-prd mode: select text, press copy shortcut, verify clipboard contents
  • Test copy in run mode: select text in iteration output, press copy shortcut
  • Verify hint bar no longer overlaps with long input text in create-prd mode
  • Test on macOS with Cmd+C
  • Test on Linux with Ctrl+Shift+C or Alt+C

Summary by CodeRabbit

  • New Features

    • Cross-platform clipboard copy with keyboard shortcuts (Cmd/Ctrl+C) for selected text and a temporary "Copied" toast at bottom-right.
  • UI Improvements

    • Hint bar repositioned to the bottom edge with updated visual styling.
  • Tests

    • Comprehensive clipboard unit tests added to validate multi-tool fallbacks and error handling across platforms.

✏️ Tip: You can customize this high-level summary in your review settings.

AI Agent added 2 commits January 17, 2026 00:07
Add ability to copy selected text to system clipboard from the TUI.

- Add cross-platform clipboard utility (wl-copy, xclip, xsel, pbcopy, clip.exe)
- Cmd+C copies selected text on macOS
- Ctrl+Shift+C or Alt+C copies on Linux
- Ctrl+C copies on Windows
- Show feedback toast when text is copied
- Auto-dismiss feedback after 2 seconds

Closes #91
Move the hint bar in ChatView from inside the input area to an absolute
position on the bottom border line. This prevents the hints from
overlapping with long input text.
@vercel
Copy link
Copy Markdown

vercel bot commented Jan 17, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Review Updated (UTC)
ralph-tui Ignored Ignored Jan 17, 2026 0:35am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Jan 17, 2026

Walkthrough

Adds cross‑platform clipboard write support and UI feedback to the TUI: new clipboard utility, integrations in chat and run components to copy selected renderer text on copy shortcuts, repositioned ChatView hint bar.

Changes

Cohort / File(s) Summary
Chat view layout
src/tui/components/ChatView.tsx
Repositions hint bar using absolute positioning (bottom: 0, left: 2, right: 2) and adds a background colour.
Clipboard integration — UI
src/tui/components/PrdChatApp.tsx, src/tui/components/RunApp.tsx
Adds renderer usage and platform/clipboard wiring, detects cross‑platform copy shortcuts, reads selected text via renderer.selection?.getSelectedText(), writes to clipboard, and shows a 2s auto‑dismiss "Copied" toast rendered bottom‑right.
Clipboard utility
src/utils/clipboard.ts
New module exporting writeToClipboard(text) and ClipboardResult. Executes OS‑specific commands (pbcopy, wl-copy/xclip/xsel fallbacks, clip) via child_process.spawn, pipes stdin, validates input, and returns structured success/error results with charCount.
Public utils export
src/utils/index.ts
Re‑exports clipboard utilities (export * from './clipboard.js').
Tests
tests/utils/clipboard.test.ts
New comprehensive tests mocking child_process.spawn and node:os.platform to validate macOS, Windows, Linux tool fallbacks, error cases, and empty input handling.

Sequence Diagram

sequenceDiagram
    participant User
    participant KeyHandler as KeyboardHandler
    participant Renderer
    participant Clipboard as Clipboard Utility
    participant OS as OS Clipboard
    participant Toast

    User->>KeyHandler: Press Cmd+C / Ctrl+C
    KeyHandler->>Renderer: Is copy shortcut? / getSelectedText()
    alt Selection exists
        Renderer-->>KeyHandler: Selected text
        KeyHandler->>Clipboard: writeToClipboard(selectedText)
        Clipboard->>OS: Run platform command (pbcopy / wl-copy / xclip / clip)
        OS-->>Clipboard: Command result
        Clipboard-->>KeyHandler: ClipboardResult {success, error?, charCount?}
        KeyHandler->>Toast: Show "Copied" feedback (2s)
        Toast->>User: Display and auto-dismiss
    else No selection
        KeyHandler-->>User: No action
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I nibble keys and copy with glee,
Piping selections to clipboard tree,
From pbcopy to clip, through xclip's maze,
A twinkle, a toast, two seconds of praise. ✨

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the two main changes: adding clipboard copy support and fixing the hint bar overlap issue.
Linked Issues check ✅ Passed The pull request implements all coding requirements from issue #91: clipboard copy shortcuts across platforms, OS-specific command invocation, renderer.selection integration, and mouse tracking preservation.
Out of Scope Changes check ✅ Passed All changes directly align with the objectives: clipboard utility and cross-platform shortcuts in PrdChatApp and RunApp, ChatView hint bar positioning fix, and comprehensive clipboard tests.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link
Copy Markdown

codecov bot commented Jan 17, 2026

Codecov Report

❌ Patch coverage is 94.93671% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 41.95%. Comparing base (8a5b30a) to head (738f662).
⚠️ Report is 5 commits behind head on main.

Files with missing lines Patch % Lines
src/utils/clipboard.ts 94.87% 4 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #115      +/-   ##
==========================================
+ Coverage   41.61%   41.95%   +0.33%     
==========================================
  Files          57       59       +2     
  Lines       12606    12690      +84     
==========================================
+ Hits         5246     5324      +78     
- Misses       7360     7366       +6     
Files with missing lines Coverage Δ
src/utils/index.ts 100.00% <100.00%> (ø)
src/utils/clipboard.ts 94.87% <94.87%> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

AI Agent and others added 2 commits January 17, 2026 00:31
- Test platform-specific command selection (pbcopy, wl-copy, xclip, clip)
- Test Linux fallback chain (wl-copy -> xclip -> xsel)
- Test error handling (ENOENT, other errors, non-zero exit codes)
- Test BSD support (FreeBSD, OpenBSD use Linux clipboard tools)
- Achieves 94.87% line coverage on clipboard.ts
@subsy subsy merged commit f9829c5 into main Jan 17, 2026
9 checks passed
sakaman pushed a commit to sakaman/ralph-tui that referenced this pull request Feb 15, 2026
feat: add clipboard copy support and fix hint bar overlap
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.

Cannot copy text from TUI with Cmd+C

1 participant