Skip to content

ADE-92: Copy user-launched chat and CLI prompts to clipboard#506

Merged
arul28 merged 1 commit into
mainfrom
ade-92-copy-user-launched-chat-and-cli-prompts-to-clipboard
Jun 2, 2026
Merged

ADE-92: Copy user-launched chat and CLI prompts to clipboard#506
arul28 merged 1 commit into
mainfrom
ade-92-copy-user-launched-chat-and-cli-prompts-to-clipboard

Conversation

@arul28
Copy link
Copy Markdown
Owner

@arul28 arul28 commented Jun 1, 2026

Fixes ADE-92

Summary

Describe the change.

What Changed

Key files and behaviors.

Validation

How you tested.

Risks

Anything to watch.

Linked Linear issues

ADE   Open in ADE  ·  ade-92-copy-user-launched-chat-and-cli-prompts-to-clipboard branch  ·  PR #506

Summary by CodeRabbit

  • New Features

    • Added "Copy launch prompts to clipboard" toggle in Chat & notifications settings
    • Launch prompts automatically copy to clipboard when sending (when enabled)
    • Chat composer displays helper message indicating clipboard copy behavior
  • Improvements

    • Enhanced Settings page navigation with hash-based smooth scrolling to target sections
  • Tests

    • Added test coverage for launch prompt clipboard functionality and copyable behavior in chat workflows

Greptile Summary

This PR implements ADE-92, adding a user-controlled toggle to copy chat, CLI, and agent launch prompts to the system clipboard before ADE sends them. The feature spans a new launchPromptClipboard.ts utility, a persisted launchPromptClipboardEnabled preference, a settings checkbox with hash-based deep-linking, and a contextual hint bar in the chat composer.

  • New utility (launchPromptClipboard.ts) writes to clipboard via the IPC bridge first, falling back to the browser Clipboard API, swallowing all errors so clipboard failures never block a launch.
  • State & UI: the toggle is persisted in user preferences (defaulting on), propagated into per-project stores, and wired to every send path in AgentChatPane and LinearQuickViewButton.
  • Settings navigation: SettingsPage is generalised to support any hash-targeted section and now clears the hash on tab change to prevent spurious re-scrolls.

Confidence Score: 5/5

Safe to merge — the clipboard write is entirely best-effort and cannot block any send path; the feature defaults on but is easily toggled off.

All changed paths have solid test coverage, the new utility defensively catches every error, and the preference is correctly round-tripped through localStorage. The one finding is a cosmetic silent no-op on the Setting link when the callback prop is omitted, which cannot occur in the current production wiring.

No files require special attention; the most complex changes are in AgentChatPane.tsx and AgentChatComposer.tsx, both of which are well-covered by the accompanying tests.

Important Files Changed

Filename Overview
apps/desktop/src/renderer/lib/launchPromptClipboard.ts New utility that wraps clipboard write with IPC-first, browser-fallback strategy; errors are intentionally swallowed as best-effort.
apps/desktop/src/renderer/state/appStore.ts Adds launchPromptClipboardEnabled to persisted user preferences with correct read/write/default (true) handling; mirrors existing boolean preference flags.
apps/desktop/src/renderer/components/chat/AgentChatComposer.tsx Adds focus-region tracking and launch-clipboard hint bar; the Setting button silently no-ops when onOpenLaunchPromptClipboardSettings is undefined.
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx Wires copyPromptForLaunch at all submit call-sites; overall plumbing is correct and tests cover key paths.
apps/desktop/src/renderer/components/app/SettingsPage.tsx Generalises hash-based scroll navigation and clears the hash on tab change to prevent re-scrolling.
apps/desktop/src/renderer/components/settings/AppearanceSection.tsx Adds the launch-prompt clipboard toggle checkbox with the scroll-anchor id on the label element.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User types prompt & clicks Send] --> B{launchPromptClipboardEnabled?}
    B -- No --> G[Normal send flow]
    B -- Yes --> C[copyLaunchPromptToClipboard]
    C --> D{window.ade.app.writeClipboardText?}
    D -- Yes --> E[IPC clipboard write]
    D -- No --> F{navigator.clipboard.writeText?}
    F -- Yes --> H[Browser clipboard write]
    F -- No --> I[Silent no-op]
    E --> G
    H --> G
    I --> G
    G --> J{New session?}
    J -- Yes --> K[Create session + send]
    J -- No --> L[Send to existing session]
Loading

Fix All in Claude Code

Prompt To Fix All With AI
Fix the following 1 code review issue. Work through them one at a time, proposing concise fixes.

---

### Issue 1 of 1
apps/desktop/src/renderer/components/chat/AgentChatComposer.tsx:4101-4116
**Silent no-op "Setting" link when callback is not provided**

`onOpenLaunchPromptClipboardSettings` is an optional prop that defaults to `undefined`. When `launchPromptClipboardEnabled` is `true` but the callback is omitted, the "Setting" button renders and is visually interactive (underline, hover state) but `onClick={undefined}` means clicking it silently does nothing. The two props should be treated as a logical pair — the helper bar should either not render the link or disable it when the callback is absent.

Reviews (4): Last reviewed commit: "ADE-92 copy launch prompts to clipboard" | Re-trigger Greptile

@vercel
Copy link
Copy Markdown

vercel Bot commented Jun 1, 2026

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

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
ade Ignored Ignored Preview Jun 2, 2026 1:47am

@linear-code
Copy link
Copy Markdown

linear-code Bot commented Jun 1, 2026

ADE-92

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 1, 2026

Review Change Stack

📝 Walkthrough

Walkthrough

This PR adds a complete "copy launch prompts to clipboard" feature to the desktop app. It introduces a persisted user preference, a clipboard utility, settings UI, a visual helper in the chat composer, and integrates clipboard copying across multiple send and launch paths including draft launches, parallel launches, Cursor Cloud submissions, and Linear batch operations.

Changes

Launch Prompt Clipboard Feature

Layer / File(s) Summary
State management and persistence
apps/desktop/src/renderer/state/appStore.ts, apps/desktop/src/renderer/state/appStore.test.ts
Added launchPromptClipboardEnabled boolean preference with schema updates, localStorage persistence, default initialization, and setter that writes changes to ade.userPreferences.v1.
Clipboard copy utility
apps/desktop/src/renderer/lib/launchPromptClipboard.ts
Implemented copyLaunchPromptToClipboard(promptText) that attempts ADE clipboard API with browser Clipboard API fallback, handles empty text, and silently catches errors.
Settings UI and navigation
apps/desktop/src/renderer/components/settings/AppearanceSection.tsx, apps/desktop/src/renderer/components/app/SettingsPage.tsx
Added checkbox in AppearanceSection to toggle the clipboard setting and generalized SettingsPage hash-to-section scrolling with HASH_TARGET_SECTIONS mapping and useNavigate integration.
Chat composer helper UI
apps/desktop/src/renderer/components/chat/AgentChatComposer.tsx, apps/desktop/src/renderer/components/chat/AgentChatComposer.test.tsx
Added props launchPromptClipboardEnabled and onOpenLaunchPromptClipboardSettings, tracks composerFocused state on rich editor and textarea focus/blur, and conditionally renders footer helper message when feature is enabled, composer is focused, and draft has non-whitespace content.
Chat pane clipboard integration
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx, apps/desktop/src/renderer/components/chat/AgentChatPane.test.tsx
Wires clipboard copying in multiple send/launch paths: draft session creation, plan approval, parallel launch, regular send, and Cursor Cloud submission; passes clipboard props to AgentChatComposer; comprehensive test coverage validates clipboard writes and respects the feature flag.
Linear batch launch and store hydration
apps/desktop/src/renderer/components/app/LinearQuickViewButton.tsx, apps/desktop/src/renderer/components/app/App.tsx
Updated LinearQuickViewButton to derive and copy kickoff prompt before batch launch, and updated App.tsx to pass launchPromptClipboardEnabled to project-scoped stores during hydration.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related issues

Suggested labels

desktop

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately reflects the main feature being implemented: copying user-launched chat and CLI prompts to clipboard, which aligns with the substantial changes across multiple components.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch ade-92-copy-user-launched-chat-and-cli-prompts-to-clipboard

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.

@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented Jun 1, 2026

@copilot review but do not make fixes

Comment thread apps/desktop/src/renderer/components/app/SettingsPage.tsx
Comment thread apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
@arul28 arul28 force-pushed the ade-92-copy-user-launched-chat-and-cli-prompts-to-clipboard branch from a0d8ef0 to 36424ce Compare June 2, 2026 01:18
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented Jun 2, 2026

Review follow-up:

  • Fixed the SettingsPage hash-scroll issue in 36424ce by mapping settings anchors to their owning tab and clearing stale hashes on manual tab switches.
  • Kept clipboard copy on plan-approval revision sends intentionally: ADE-92 explicitly includes chat sends that launch or continue a session, and revision text is a user-submitted continuation prompt. Narrowing this to initial session creation would miss the ticket scope.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/desktop/src/renderer/components/chat/AgentChatPane.tsx (1)

6522-6536: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Avoid double-copying the prompt on foreground draft chat submits.

Line 6574 copies the draft before the branches at Lines 6522-6536 hand off to launchDraftChat(), and launchDraftSession() already copies the same text at Line 5955. Foreground draft chat sends therefore hit the clipboard twice. Keep the copy in the delegated draft-launch path, or gate the shared-path copy so it only runs for the non-draft submit flow.

Also applies to: 6574-6574

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/desktop/src/renderer/components/chat/AgentChatPane.tsx` around lines
6522 - 6536, The foreground draft-chat flow is copying the prompt twice: once in
the shared-path clipboard copy and again inside the delegated launch functions;
fix by removing or gating the redundant shared-path clipboard copy so it does
not run when delegating to launchDraftChat (and similarly launchDraftSession),
and ensure only the delegated path (launchDraftChat/launchDraftSession) performs
the clipboard copy for draft launches.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/desktop/src/renderer/components/chat/AgentChatComposer.tsx`:
- Around line 1099-1103: The helper is unmounting on input blur so keyboard
users can't tab to it; update AgentChatComposer to track focus-within the
composer region (e.g., add a boolean state like isComposerFocusWithin updated by
onFocusCapture/onBlurCapture on the composer container using event.relatedTarget
to detect leaving the region) and change the showLaunchClipboardHelper condition
to use isComposerFocusWithin (instead of only composerFocused) along with
launchPromptClipboardEnabled, composerInputLocked, and draft.trim().length > 0;
keep the helper mounted while isComposerFocusWithin is true and ensure the
helper button is keyboard-focusable (no preventDefault blocking focus events and
include proper tabIndex/role) so keyboard users can reach it.

---

Outside diff comments:
In `@apps/desktop/src/renderer/components/chat/AgentChatPane.tsx`:
- Around line 6522-6536: The foreground draft-chat flow is copying the prompt
twice: once in the shared-path clipboard copy and again inside the delegated
launch functions; fix by removing or gating the redundant shared-path clipboard
copy so it does not run when delegating to launchDraftChat (and similarly
launchDraftSession), and ensure only the delegated path
(launchDraftChat/launchDraftSession) performs the clipboard copy for draft
launches.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 5b964b81-16f6-417b-9171-1ce9f72fe36e

📥 Commits

Reviewing files that changed from the base of the PR and between 172d8f2 and 36424ce.

📒 Files selected for processing (11)
  • apps/desktop/src/renderer/components/app/App.tsx
  • apps/desktop/src/renderer/components/app/LinearQuickViewButton.tsx
  • apps/desktop/src/renderer/components/app/SettingsPage.tsx
  • apps/desktop/src/renderer/components/chat/AgentChatComposer.test.tsx
  • apps/desktop/src/renderer/components/chat/AgentChatComposer.tsx
  • apps/desktop/src/renderer/components/chat/AgentChatPane.test.tsx
  • apps/desktop/src/renderer/components/chat/AgentChatPane.tsx
  • apps/desktop/src/renderer/components/settings/AppearanceSection.tsx
  • apps/desktop/src/renderer/lib/launchPromptClipboard.ts
  • apps/desktop/src/renderer/state/appStore.test.ts
  • apps/desktop/src/renderer/state/appStore.ts

Comment thread apps/desktop/src/renderer/components/chat/AgentChatComposer.tsx
@arul28 arul28 force-pushed the ade-92-copy-user-launched-chat-and-cli-prompts-to-clipboard branch from 36424ce to 9c32204 Compare June 2, 2026 01:33
@arul28
Copy link
Copy Markdown
Owner Author

arul28 commented Jun 2, 2026

CodeRabbit follow-up:

  • Fixed the helper focus issue in 9c32204: the composer helper now tracks focus within the composer/helper region, so keyboard users can tab from the prompt into the Setting button without unmounting it.
  • Checked the reported foreground draft-chat double-copy path against current code. The delegated launchDraftChat("foreground") branches return before the shared copyPromptForLaunch(text) call, so draft launches are copied by the delegated launch path only; no code change needed there.

@arul28 arul28 force-pushed the ade-92-copy-user-launched-chat-and-cli-prompts-to-clipboard branch from 9c32204 to 3c10b46 Compare June 2, 2026 01:47
@arul28 arul28 merged commit d8f663b into main Jun 2, 2026
28 checks passed
@arul28 arul28 deleted the ade-92-copy-user-launched-chat-and-cli-prompts-to-clipboard branch June 2, 2026 03:42
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.

1 participant