Skip to content

Add assistant message copy action and harden related test/storage fallbacks#1211

Open
shivamhwp wants to merge 4 commits intopingdotgg:mainfrom
shivamhwp:feature/assistant-copy-state
Open

Add assistant message copy action and harden related test/storage fallbacks#1211
shivamhwp wants to merge 4 commits intopingdotgg:mainfrom
shivamhwp:feature/assistant-copy-state

Conversation

@shivamhwp
Copy link
Collaborator

@shivamhwp shivamhwp commented Mar 19, 2026

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
image
After
image

Fixes #1164

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • I included before/after screenshots for any UI changes
  • I included a video for animation/interaction changes

Note

Add copy action to assistant messages and harden storage/SSR fallbacks

  • Adds a MessageCopyButton to assistant message rows in MessagesTimeline.tsx: visible and enabled for completed messages, visible but disabled while streaming, hidden when the response is empty; success/error toasts are shown on copy.
  • Introduces resolveAssistantMessageCopyState in MessagesTimeline.logic.ts to centralize copy visibility, disabled state, and text resolution for assistant messages.
  • Extends MessageCopyButton with disabled, label, size, variant, onCopy, and onError props.
  • Hardens useTheme.ts and terminalStateStore.ts against SSR and non-browser environments by gating window/document/localStorage access and falling back to in-memory storage or stable defaults.

Macroscope summarized 928a793.

- 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
@coderabbitai
Copy link

coderabbitai bot commented Mar 19, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 8ea3b819-be84-47f9-99e1-8f2dcc3601eb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
📝 Coding Plan
  • Generate coding plan for human review comments

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.

Tip

You can customize the tone of the review comments and chat replies.

Configure the tone_instructions setting to customize the tone of the review comments and chat replies. For example, you can set the tone to Act like a strict teacher, Act like a pirate and more.

@github-actions github-actions bot added size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list. labels Mar 19, 2026
@shivamhwp shivamhwp changed the title Refine assistant message copy button state and UX Add muted assistant message copy action and harden related test/storage fallbacks Mar 19, 2026
- 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
@shivamhwp shivamhwp changed the title Add muted assistant message copy action and harden related test/storage fallbacks Add assistant message copy action and harden related test/storage fallbacks Mar 19, 2026
- Reference `globalThis.localStorage` in `beforeEach`
- Keep storage cleanup logic consistent across test environments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature]: Add one-click copy action for assistant responses

1 participant