Skip to content

Agent Mode: add copy buttons to chat log - #630

Merged
AnthonyRonning merged 1 commit into
masterfrom
codex/agent-chat-copy-buttons
Jul 14, 2026
Merged

Agent Mode: add copy buttons to chat log#630
AnthonyRonning merged 1 commit into
masterfrom
codex/agent-chat-copy-buttons

Conversation

@marksftw

@marksftw marksftw commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add copy actions below Agent Mode user prompts and assistant responses
  • extract the existing standard-chat copy control into one shared ChatCopyButton
  • copy raw message text while excluding thinking, tool activity, permission prompts, system events, and errors
  • centralize user-action visibility in the shared chat-turn layout

Why

Agent Mode already reused the standard chat turn layout, but it did not wire actions into those shared turn shells. The existing clipboard control was private to UnifiedChat, so Agent Mode could not reuse it without first extracting the component.

Validation

  • bun test — 93 passed
  • bun run lint — 0 errors (12 pre-existing warnings)
  • bun run build
  • bun run format

Closes #629

Summary by CodeRabbit

  • New Features

    • Added a shared message copy button across standard and unified chat views.
    • Enabled per-turn copy controls in agent timelines, with assistant turn text derived from the relevant assistant message.
    • Copy actions are suppressed for the currently active final assistant turn.
  • Bug Fixes

    • Improved copy-control behavior and visibility consistency across different layouts.
  • Tests

    • Expanded coverage for agent timeline copy-text generation and user-message “locked” detection.

@coderabbitai

coderabbitai Bot commented Jul 14, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a shared ChatCopyButton, integrates copy actions into Unified Chat and Agent Mode turns, extracts copyable Agent timeline text, and updates ChatUserTurn styling and timeline tests.

Changes

Chat copy controls

Layer / File(s) Summary
Copy contract and shared button
frontend/src/components/chat/ChatCopyButton.tsx, frontend/src/components/chat/ChatTurn.tsx
Adds clipboard copying with transient success feedback and updates ChatUserTurn action styling and props.
Agent turn copy text
frontend/src/services/agentTimeline.ts, frontend/src/services/agentTimeline.test.ts
Extracts user text and the latest assistant message text, with tests covering filtering and turn detection.
Chat rendering integration
frontend/src/components/AgentMode.tsx, frontend/src/components/UnifiedChat.tsx
Renders the shared copy control for Agent Mode and standard chat turns, removing the local copy implementation.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant AgentTimeline
  participant AgentMode
  participant ChatCopyButton
  participant Clipboard
  AgentTimeline->>AgentMode: derive copy text for grouped turn
  AgentMode->>ChatCopyButton: render copy action
  ChatCopyButton->>Clipboard: write turn text
  Clipboard-->>ChatCopyButton: report copy result
Loading

Possibly related PRs

Suggested reviewers: anthonyronning

Poem

I’m a bunny with buttons, a copy-ready trail,
User words and answers hop into the mail.
Click once—little check marks gleam,
Agent turns now share the same beam.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The PR adds copy buttons for user and assistant turns in Agent Mode and copies the intended message text, matching issue #629.
Out of Scope Changes check ✅ Passed The changes stay focused on shared copy controls, copy-text extraction, and related tests, with no clear unrelated additions.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding copy buttons to the Agent Mode chat log.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/agent-chat-copy-buttons

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

@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jul 14, 2026

Copy link
Copy Markdown

Deploying maple with  Cloudflare Pages  Cloudflare Pages

Latest commit: 295602b
Status: ✅  Deploy successful!
Preview URL: https://3ed15003.maple-ca8.pages.dev
Branch Preview URL: https://codex-agent-chat-copy-button.maple-ca8.pages.dev

View logs

@marksftw
marksftw force-pushed the codex/agent-chat-copy-buttons branch from 275bc29 to b21eced Compare July 14, 2026 20:19
@marksftw
marksftw marked this pull request as ready for review July 14, 2026 20:25

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no bugs or issues to report.

Open in Devin Review

@marksftw
marksftw requested a review from AnthonyRonning July 14, 2026 21:25
@AnthonyRonning

Copy link
Copy Markdown
Contributor

Agent Mode should copy only the final assistant content message in a turn, rather than concatenating every assistant message around tool calls.

For a turn like:

assistant preamble → tool → tool result → assistant update → tool → tool result → final assistant

please have the copy action copy only the final assistant message. The earlier assistant messages, thinking, tools, tool results, permissions, system events, and errors should not be included.

Please also suppress the copy action on the currently active assistant turn until the run finishes, since otherwise an intermediate assistant message temporarily becomes copyable. Copy actions on earlier completed turns should remain available.

A focused test should cover assistant preamble → tool/result → final assistant and assert that only the final assistant text is copied.

@marksftw
marksftw force-pushed the codex/agent-chat-copy-buttons branch from b21eced to 295602b Compare July 14, 2026 22:02
@marksftw

Copy link
Copy Markdown
Contributor Author

Addressed in 295602b.

  • Agent Mode now copies only the final assistant content message in each turn; preambles, intermediate assistant updates, thinking, tools/results, permissions, system events, and errors are excluded.
  • The copy action is suppressed on the currently active assistant turn until the run finishes, while earlier completed turns remain copyable.
  • The focused timeline test now covers assistant preamble → tool/result → final assistant and asserts that only the final text is selected.

Validation: 93 tests pass, production build passes, and lint completes with 0 errors (12 existing warnings).

@marksftw
marksftw marked this pull request as draft July 14, 2026 22:24

@AnthonyRonning AnthonyRonning left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Reviewed the updated implementation at 295602b. The final-message-only copy behavior and active-turn suppression match the requested Agent Mode behavior, with focused test coverage. Local validation passed; approving pending completion of the remaining required CI builds.

@marksftw
marksftw marked this pull request as ready for review July 14, 2026 22:25
@AnthonyRonning
AnthonyRonning merged commit 47128a8 into master Jul 14, 2026
17 checks passed
@AnthonyRonning
AnthonyRonning deleted the codex/agent-chat-copy-buttons branch July 14, 2026 22:29
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.

Agent Mode: Add buttons to chat log for copying text

2 participants