Add assistant message copy action and harden related test/storage fallbacks#1211
Conversation
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
|
no need for this |
- make `MessageCopyButton` configurable with disabled state, titles, style props, and copy/error callbacks - show assistant copy action in timeline metadata, disable it while streaming, and add toast feedback - extract and test copy-visibility logic for streaming/empty assistant messages
- guard theme hook against missing window/document/localStorage and add server snapshot - add in-memory fallback storage for persisted terminal state when localStorage is unavailable - simplify brittle platform/global test setup to match new runtime-safe behavior
928a793 to
741eb41
Compare
ApprovabilityVerdict: Needs human review This PR introduces a new user-facing feature (copy button for assistant messages) with new UI components, state derivation logic, and prop threading, plus SSR hardening changes. While each individual change is straightforward, the aggregate introduces meaningful new capability. The open review comment about an incorrect aria-label also needs addressing. You can customize Macroscope's approvability policy. Learn more. |
- Remove the optional label prop from the copy button - Show only the icon while preserving copied state feedback
- Gate assistant copy button to the final assistant message in each turn - Update copy-state logic and tests for streaming and non-terminal messages
- Reorder the assistant message footer so metadata appears before the copy actions - Preserve the existing timestamp and elapsed-time display
- simplify assistant copy state to only track text and visibility - stop passing always-false disabled props to the copy button - update tests to match the narrower state shape
- Simplify `MessageCopyButton` to always be enabled - Keep copy feedback limited to the copied state
Dismissing prior approval to re-evaluate 1d34730
- Add assistant message hover group styling - Move copy button beside footer metadata with hover reveal
486c004 to
5ee8129
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 90a1b7a. Configure here.
| <TooltipTrigger | ||
| render={ | ||
| <Button | ||
| aria-label="Copy link" |
There was a problem hiding this comment.
Incorrect aria-label says "Copy link" instead of message
Medium Severity
The aria-label on the copy button is "Copy link" but the button actually copies message text to the clipboard. The old code correctly used title="Copy message". This mislabels the action for screen reader users and is inconsistent with the tooltip text "Copy to clipboard".
Reviewed by Cursor Bugbot for commit 90a1b7a. Configure here.


What Changed
Added a copy action for assistant messages in the chat timeline. The control lives in the assistant footer, copies only the assistant response text, stays visible but disabled while the message is still streaming, and becomes clickable once the response is complete.
The shared message copy button was also extended so it can be rendered as a compact muted button for this footer treatment. Tests were updated to cover the assistant copy visibility and streaming-disabled behavior.
Why
The app already supported copying code blocks and user messages, but not full assistant responses.
This approach keeps the behavior predictable by sourcing the copied content directly from the assistant message text already stored in the timeline, so it does not include work-log entries, command metadata, timestamps, or diff UI. Keeping the button disabled during streaming also avoids partial-copy behavior and makes the interaction state explicit.
UI Changes
This adds a small muted copy button next to the assistant message timestamp in the footer. It is disabled while the assistant is streaming and enabled after the response completes.
Before


After
Fixes #1164
Checklist
Note
Add copy button to terminal assistant messages in MessagesTimeline
resolveAssistantMessageCopyStateandderiveTerminalAssistantMessageIdsin MessagesTimeline.logic.ts to determine which messages show the copy button; active/streaming turns are excluded.size,variant, andclassNameprops.window/localStorageare unavailable.Macroscope summarized 90a1b7a.
Note
Medium Risk
Moderate risk due to changes in chat timeline rendering/state (new assistant-copy eligibility logic and streaming/turn handling) and
useThemeinitialization/SSR guards that affect app-wide theming behavior.Overview
Adds a hover-revealed copy-to-clipboard action for assistant responses in
MessagesTimeline, shown only for the terminal assistant message of each turn and suppressed while the turn/message is still streaming.Extends
MessageCopyButtonto support compact icon styling with tooltip and anchored success/error toasts, and updates timeline row derivation/tests to track copy eligibility.Improves virtualized timeline height estimation for assistant/system messages by accounting for inline code width, and hardens
useThemewith SSR/non-browser fallbacks (safelocalStorage/windowaccess plususeSyncExternalStoreserver snapshot).Reviewed by Cursor Bugbot for commit 90a1b7a. Bugbot is set up for automated code reviews on this repo. Configure here.