Skip to content

fix(desktop): preserve selected message copy#3942

Merged
esengine merged 1 commit into
esengine:main-v2from
GTC2080:fix/desktop-selection-copy
Jun 11, 2026
Merged

fix(desktop): preserve selected message copy#3942
esengine merged 1 commit into
esengine:main-v2from
GTC2080:fix/desktop-selection-copy

Conversation

@GTC2080

@GTC2080 GTC2080 commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

Fixes desktop message-fragment copying on macOS by adding an explicit copy-event fallback for selected chat text.

Changes

  • Adds a focused message selection copy handler that writes the exact selected text to text/plain when a non-empty selection intersects rendered message content.
  • Leaves native copy behavior untouched for text inputs, editable fields, collapsed selections, whitespace-only selections, and selections outside message content.
  • Marks message bubbles as selectable/non-draggable so macOS/Wails drag regions do not interfere with text selection.
  • Adds regression coverage for the copy decision boundaries and includes it in the frontend test scripts.

Verification

  • git diff --check
  • gofmt -l .
  • npm run test:all
  • npm run build
  • go test ./...
  • (cd desktop && go test ./...)
  • Vite preview smoke test: loaded the desktop frontend, sent a mock message, and checked for console errors.

Closes #3861

@github-actions github-actions Bot added v2 Go rewrite (1.x) — main-v2 branch, active development desktop Wails desktop app (desktop/**) labels Jun 11, 2026

@esengine esengine left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed. The pure decision function with the DOM glue kept thin is exactly how I want this factored — the six boundary cases (editable targets, collapsed/whitespace selections, non-message scope, no clipboardData) are all pinned in the repo's tsx test convention and wired into both test scripts. The user-select + --wails-draggable: no-drag on .msg also kills the drag-region interference that made selection flaky in the first place.

One accepted trade-off worth recording: claiming the copy event replaces the native payload with text/plain only, so pasting into rich editors loses the HTML flavor. For chat-bubble content that's almost always what the user wanted anyway, and it's what makes the WKWebView fragment-copy bug (#3861) unhittable.

Merging, thanks!

@esengine esengine merged commit 6b37bd5 into esengine:main-v2 Jun 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

desktop Wails desktop app (desktop/**) v2 Go rewrite (1.x) — main-v2 branch, active development

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: mac选中ai回复内容片段,cmd c 无法正确复制内容

2 participants