Skip to content

fix: Preserve URL scheme when typed or pasted into PromptField - #10565

Open
tiffany-sy-lin wants to merge 1 commit into
adobe:mainfrom
tiffany-sy-lin:fix/link-display
Open

fix: Preserve URL scheme when typed or pasted into PromptField#10565
tiffany-sy-lin wants to merge 1 commit into
adobe:mainfrom
tiffany-sy-lin:fix/link-display

Conversation

@tiffany-sy-lin

Copy link
Copy Markdown
Collaborator

Summary

  • tokenizeURLs in PromptField.tsx was stripping the scheme/www. from a typed or inserted URL's token text, even though it was retained in the token's value.url — so both the visible pill and the serialized outgoing message lost the scheme. Now the token's text matches the full match, i.e. exactly what was typed/inserted.
  • Pasting a rendered link (e.g. copied from Slack, where the visible label omits the scheme but the href has it) also dropped the scheme, since useTokenField's paste handling fell back to the browser's text/plain clipboard data. It now inspects text/html and substitutes an anchor's href for its display text when they represent the same URL, while leaving all other paste content (non-link HTML, links whose label differs from their href) unchanged.

Test plan

  • Added a PromptField unit test confirming a typed https://www.test.com keeps its scheme in both the token text and serialized value
  • Added TokenField browser tests (Chromium/Firefox; skipped on WebKit, which doesn't support synthetic dataTransfer on constructed InputEvents) covering: scheme recovery from a pasted rendered link, leaving unrelated link labels alone, and pasting non-link HTML unchanged
  • Verified the fix also applies to programmatic insertion (autocomplete popover, "+" insert menu), since both share the same tokenize/replaceRangeWithSegments path

🤖 Generated with Claude Code

   tokenizeURLs was stripping the scheme from token text/serialized output. Paste handling in useTokenField now also recovers a link's href when the pasted plain text is just its scheme-less display label.
@dannify

dannify commented Sep 3, 2026

Copy link
Copy Markdown
Member

We want it to look pretty. Why do we need all the url visible?

@tiffany-sy-lin

Copy link
Copy Markdown
Collaborator Author

We want it to look pretty. Why do we need all the url visible?

We got a report that they were expecting to see the full url after pasting and sending it and that their mcp had some checks/validation related to seeing the full url. I'm currently looking into overriding it in our own application, but it feels a bit hack-y b/c we have to intercept the message with the url and prevent the promptfield from stripping the protocol

@tiffany-sy-lin

Copy link
Copy Markdown
Collaborator Author

Another thing the reporter brought up that I also agree with is that it's odd that something we pasted/typed is changed w/o the user's consent (in this case the protocol is removed). I think it's fine to leave the display text without the https (keep it pretty), but the underlying text value to should contain the full url.

@devongovett

Copy link
Copy Markdown
Member

We could change PromptFieldValue's toString method to this:

this.segments.map(s => s.type === 'token' && s.value?.type === 'url' ? s.value.url : s.text).join('');

that way it includes the full URL when submitted but displays the pretty url.

@devongovett

Copy link
Copy Markdown
Member

FYI we merged and released #10575 which applies my comment above. Leaving this open in case we want to discuss the other parts of it (e.g. pasting).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants