feat(web): tap-to-copy button on every chat message

Each user and assistant message gets a copy button (⧉ → ✓) that puts the whole
message on the clipboard. Assistant copies the raw markdown (its dataset.raw);
user copies its text.

- copyToClipboard uses the async Clipboard API when available and falls back to a
  hidden-textarea + execCommand with an explicit iOS selection range, so it works
  on the iPhone PWA over plain-HTTP LAN (no secure context).
- Copy sits in the assistant rate-bar and in a right-aligned bar on user bubbles;
  tools stay visible on touch (@media hover:none) since there's no hover on iOS.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-20 01:09:27 +00:00
parent e1e89c07e4
commit cebb87205c
2 changed files with 79 additions and 0 deletions
+16
View File
@@ -1182,6 +1182,22 @@ select:hover {
.rate-btn:hover { filter: none; background: var(--accent-soft); }
.rate-btn.rated { filter: none; background: rgba(255,122,0,0.22); opacity: 1; }
/* Per-message copy button (lives in the rate-bar for assistant, its own bar for user). */
.copy-btn {
background: none; border: none; cursor: pointer; font-size: 0.85rem;
padding: 2px 6px; border-radius: 5px; line-height: 1; color: var(--text-fade);
-webkit-tap-highlight-color: transparent;
}
.copy-btn:hover { background: var(--accent-soft); color: var(--accent); }
.copy-btn.copied { color: var(--good); }
/* User bubbles are right-aligned, so right-align their copy bar too. */
.msg.user .rate-bar { justify-content: flex-end; opacity: 0.4; }
.msg.user:hover .rate-bar { opacity: 0.85; }
/* Touch devices have no hover — keep the tools tappable/visible. */
@media (hover: none) {
.rate-bar, .msg.user .rate-bar { opacity: 0.65; }
}
/* Quality floor: honor reduced-motion preference. */
@media (prefers-reduced-motion: reduce) {
*, *::before, *::after {