Skip to content

Local-first AI coding agent desktop: Electron + Rust host core + pi Agent Harness + user-installable plugins

fix(chat): keep user-message URLs selectable and copyable

LiYaoad49c93c8b0f
diff --git a/.github/pr-assets/user-message-link-selection/01-before-url-not-selectable.png b/.github/pr-assets/user-message-link-selection/01-before-url-not-selectable.png
new file mode 100644
index 000000000..147a7c5fc
Binary files /dev/null and b/.github/pr-assets/user-message-link-selection/01-before-url-not-selectable.png differ
diff --git a/.github/pr-assets/user-message-link-selection/02-chromium-before-drag.png b/.github/pr-assets/user-message-link-selection/02-chromium-before-drag.png
new file mode 100644
index 000000000..ed3b94ef9
Binary files /dev/null and b/.github/pr-assets/user-message-link-selection/02-chromium-before-drag.png differ
diff --git a/.github/pr-assets/user-message-link-selection/03-chromium-after-drag.png b/.github/pr-assets/user-message-link-selection/03-chromium-after-drag.png
new file mode 100644
index 000000000..e8348d318
Binary files /dev/null and b/.github/pr-assets/user-message-link-selection/03-chromium-after-drag.png differ
diff --git a/apps/desktop/src/styles/chat-links.css b/apps/desktop/src/styles/chat-links.css
index 6d4d11a69..b822626bf 100644
--- a/apps/desktop/src/styles/chat-links.css
+++ b/apps/desktop/src/styles/chat-links.css
@@ -56,6 +56,10 @@
text-decoration: underline dotted;
text-underline-offset: 2px;
overflow-wrap: anywhere;
+ /* The link is message text: override the inert `button` baseline so a drag
+ across the message selects and copies the URL too. */
+ -webkit-user-select: text;
+ user-select: text;
}
.chat-text-link:hover,
.chat-text-link:focus-visible {
diff --git a/apps/desktop/test/transcript-style.test.mjs b/apps/desktop/test/transcript-style.test.mjs
index ba69fb064..8e9079aab 100644
--- a/apps/desktop/test/transcript-style.test.mjs
+++ b/apps/desktop/test/transcript-style.test.mjs
@@ -297,6 +297,20 @@ test("wrapped user links keep plaintext alignment", () => {
assert.match(userLinkStyles, /overflow-wrap:\s*anywhere;/);
});
+test("user-message links stay selectable inside the inert button baseline", () => {
+ // base.css makes every <button> unselectable, and a class selector outranks
+ // that type rule. Without this opt-in a drag across the message skips the
+ // URL and copying drops it.
+ assert.match(
+ stylesSource,
+ /button,\s*\[role="button"\],[\s\S]*?\{\s*-webkit-user-select:\s*none;\s*user-select:\s*none;/,
+ );
+ const userLinkStyles = stylesSource.match(/\.chat-text-link \{([^}]*)\}/)?.[1];
+ assert.ok(userLinkStyles);
+ assert.match(userLinkStyles, /-webkit-user-select:\s*text;/);
+ assert.match(userLinkStyles, /(?<!-webkit-)user-select:\s*text;/);
+});
+
test("user-message file chips reuse the composer chip node", () => {
assert.match(transcriptSource, /className=\"composer-chip chat-file-chip\"/);
assert.match(transcriptSource, /composer-chip-name/);
diff --git a/docs/spec/04-ux/08-component-spec.md b/docs/spec/04-ux/08-component-spec.md
index b4a2c57c4..e01df056a 100644
--- a/docs/spec/04-ux/08-component-spec.md
+++ b/docs/spec/04-ux/08-component-spec.md
@@ -1755,7 +1755,10 @@ Single message render — either user (plaintext) or assistant (markdown streami
link address. Modifier clicks (Ctrl/Cmd/Shift/Alt) continue to open
externally. Long URL links wrap
within the plate and keep logical-start alignment instead of inheriting the
- browser's centered button text.
+ browser's centered button text. They stay part of the selectable message
+ text: a drag across the plate selects the URL with its surrounding prose,
+ and copying that selection keeps the URL, even though the link is a button
+ and chrome buttons are otherwise unselectable.
- Assistant: transparent surface, left-aligned, markdown rendered at full
content width. Workspace file paths in that markdown are previewable:
inline code, markdown links, and bare path tokens (with a known
diff --git a/docs/spec/06-delivery/04-e2e-test-plan.md b/docs/spec/06-delivery/04-e2e-test-plan.md
index f62ab3c99..d1a3fc9c9 100644
--- a/docs/spec/06-delivery/04-e2e-test-plan.md
+++ b/docs/spec/06-delivery/04-e2e-test-plan.md
@@ -15619,6 +15619,13 @@ the latest destination. These assertions measure work counts, not device FPS.
- **Coverage**: `chat-links.test.mjs`; native desktop click-through with the normal browser destination.
- **Specs linked**: `04-ux/08-component-spec.md` §8.3.
+#### E2E-CHAT-user-link-selection: URLs in user messages are selectable text
+
+- **Steps**: Send `介绍一下这个项目:https://github.com/vastsa/PI-Desktop` in a user message. Drag from the start of the message past the end of the URL, then copy. Click the URL once afterwards.
+- **Expected**: The selection highlights the prose and the URL together, and the copied text is the whole message including the URL. A plain click on the URL still opens it through the Link open destination.
+- **Coverage**: `transcript-style.test.mjs` asserts `.chat-text-link` opts back into text selection over the unselectable `button` baseline; drag-and-copy checked in Chromium against the full renderer stylesheet (issue #1243).
+- **Specs linked**: `04-ux/08-component-spec.md` §8.3.
+
#### E2E-IME-escape: Composition cancellation preserves drafts
- **Steps**: Edit a user message; type a draft; dispatch composing Escape and Cmd/Ctrl+Enter. Open global search and dispatch composing Escape from its input. Repeat with legacy keyCode 229, then ordinary Escape and retry shortcuts.