cc-haha/desktop/src/components/chat/UserMessage.tsx
程序员阿江(Relakkes) 3c5290eec1 fix: reduce copy ambiguity in chat sessions
The session view exposed copy affordances in a way that implied the
whole conversation would be copied, while user prompts had no copy
path at all. This changes copy to a per-message footer action so the
scope is explicit for both prompts and assistant replies, and reuses
the shared clipboard helper instead of maintaining a second copy path.

Constraint: The worktree contains unrelated in-progress changes that must stay uncommitted
Rejected: Keep a floating action above each message | it interrupted reading order and still looked session-scoped
Confidence: high
Scope-risk: narrow
Reversibility: clean
Directive: Keep copy affordances attached to individual message blocks so the copied scope stays obvious
Tested: bun run test src/components/chat/MessageList.test.tsx; bun run lint
Not-tested: Manual desktop visual QA across dense multi-message sessions
2026-04-08 23:19:31 +08:00

39 lines
1.1 KiB
TypeScript

import type { UIAttachment } from '../../types/chat'
import { AttachmentGallery } from './AttachmentGallery'
import { MessageActionBar } from './MessageActionBar'
type Props = {
content: string
attachments?: UIAttachment[]
}
export function UserMessage({ content, attachments }: Props) {
const hasText = content.trim().length > 0
return (
<div className="mb-5 flex justify-end">
<div className="max-w-[82%] space-y-2">
{attachments && attachments.length > 0 && (
<AttachmentGallery attachments={attachments} variant="message" />
)}
{hasText && (
<>
<div
className="bg-[var(--color-surface-user-msg)] px-4 py-3 text-sm leading-relaxed text-[var(--color-text-primary)] whitespace-pre-wrap break-words"
style={{ borderRadius: '18px 4px 18px 18px' }}
>
{content}
</div>
<MessageActionBar
copyText={content}
copyLabel="Copy prompt"
align="end"
/>
</>
)}
</div>
</div>
)
}