The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): drag-select and ⌘C work on user bubbles again
Brooklyn Nicholson1d97c035ef10
diff --git a/apps/desktop/src/components/assistant-ui/thread/user-message-selection.test.ts b/apps/desktop/src/components/assistant-ui/thread/user-message-selection.test.tsnew file mode 100644index 00000000000..0b766c062a9--- /dev/null+++ b/apps/desktop/src/components/assistant-ui/thread/user-message-selection.test.ts@@ -0,0 +1,28 @@+import { afterEach, describe, expect, it } from 'vitest'++import { hasTextSelection } from './user-message'++afterEach(() => {+ window.getSelection()?.removeAllRanges()+ document.body.replaceChildren()+})++describe('hasTextSelection', () => {+ it('is false with nothing highlighted', () => {+ expect(hasTextSelection()).toBe(false)+ })++ it('is true once the user has a live range', () => {+ const node = document.createElement('span')+ node.textContent = 'copy me'+ document.body.appendChild(node)++ const range = document.createRange()+ range.selectNodeContents(node)+ const selection = window.getSelection()!+ selection.removeAllRanges()+ selection.addRange(range)++ expect(hasTextSelection()).toBe(true)+ })+})diff --git a/apps/desktop/src/components/assistant-ui/thread/user-message.tsx b/apps/desktop/src/components/assistant-ui/thread/user-message.tsxindex 16c6963e248..2ea43309df9 100644--- a/apps/desktop/src/components/assistant-ui/thread/user-message.tsx+++ b/apps/desktop/src/components/assistant-ui/thread/user-message.tsx@@ -16,6 +16,13 @@ import { cn } from '@/lib/utils'import { notifyThreadEditOpen } from '@/store/thread-scroll'import { isWatchWindow } from '@/store/windows'+/** True when the user has a live text highlight (drag-select / triple-click). */+export function hasTextSelection(): boolean {+ const selection = window.getSelection()++ return Boolean(selection && !selection.isCollapsed && selection.toString().length > 0)+}+export function StickyHumanMessageContainer({attachments,children,@@ -279,10 +286,16 @@ export const UserMessage: FC<{<divclassName="relative w-full"onContextMenu={- // Right-click is the desktop stand-in for iOS touch-and-hold.+ // Right-click is the desktop stand-in for iOS touch-and-hold —+ // but only when there's nothing selected. A live highlight+ // keeps the native Copy menu (and ⌘C) instead of the picker.readOnly || !reactionsEnabled? undefined: event => {+ if (hasTextSelection()) {+ return+ }+event.preventDefault()setPickerOpen(true)}@@ -295,7 +308,9 @@ export const UserMessage: FC<{aria-expanded={bodyClamped ? expanded : undefined}className={cn(bubbleClassName, !bodyClamped && 'cursor-default')}onClick={() => {- if (!bodyClamped) {+ // Drag-select ends on mouseup→click; don't collapse the+ // clamp just because the highlight finished.+ if (hasTextSelection() || !bodyClamped) {return}@@ -310,12 +325,29 @@ export const UserMessage: FC<{) : (// Always editable — clicking opens the edit composer even while a// turn streams; sending the edit reverts (interrupt + rewind).+ // A live text highlight wins: finishing a drag-select must not+ // open the editor and throw the selection away.<ActionBarPrimitive.Edit asChild><buttonaria-label={copy.editMessage}className={bubbleClassName}- onClick={() => triggerHaptic('selection')}- onPointerDown={() => notifyThreadEditOpen()}+ onClick={event => {+ if (hasTextSelection()) {+ event.preventDefault()+ event.stopPropagation()++ return+ }++ triggerHaptic('selection')+ }}+ onPointerDown={() => {+ if (hasTextSelection()) {+ return+ }++ notifyThreadEditOpen()+ }}title={copy.editMessage}type="button">diff --git a/apps/desktop/src/styles.css b/apps/desktop/src/styles.cssindex 065f5bd562d..09aa77a6d13 100644--- a/apps/desktop/src/styles.css+++ b/apps/desktop/src/styles.css@@ -1008,6 +1008,15 @@ button,user-select: none;}+/* User bubbles are <button>s (click → edit), so the rule above would kill+ drag-to-select and leave ⌘C with nothing to grab. Message text stays+ selectable; chrome controls outside the bubble keep user-select: none. */+[data-slot='aui_user-message-root'] button,+[data-slot='aui_user-message-root'] [role='button'] {+ -webkit-user-select: text;+ user-select: text;+}+img,picture,video,