feat: include page URL in copied context#272
Conversation
Appends the current page URL to clipboard text when grabbing elements, giving AI tools and collaborators immediate context about where the element was found. The URL appears as a footer in text/plain and text/html clipboard output, while structured metadata exposes it via a dedicated `url` field on the `application/x-react-grab` payload. - Primary grab copies append `URL: <href>` after the snippet - Comment re-copy and plugin copies (styles, HTML) omit the text footer but still record the URL in metadata - `metadata.content` stays clean (no URL text); consumers use `metadata.url` for structured access
|
@sour4bh is attempting to deploy a commit to the Million Team on Vercel. A member of the Team first needs to authorize it. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 34c963349f
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| didCopy = copyContent(copiedContent, { | ||
| componentName: options.componentName, | ||
| entries, | ||
| url, |
There was a problem hiding this comment.
Keep onCopySuccess content aligned with clipboard payload
Passing url into copyContent here makes the actual clipboard text include a URL: ... footer, but tryCopyWithFallback still reports copiedContent (without that footer) to onCopySuccess later in the same function. In environments where plugins use onCopySuccess to forward or diff what was copied, this creates a behavior mismatch and drops the new URL context from hook consumers even though users copied it to the clipboard.
Useful? React with 👍 / 👎.
|
@aidenybai commented throughout my app across multiple pages, when i dropped in the copied context, the comments lost localized context especially when you have composite components across multiple pages. |
Summary
URL: <href>footer intext/plainandtext/htmlclipboard output when grabbing elements, giving AI tools immediate context about where the element was foundurlfield to theapplication/x-react-grabclipboard metadata for programmatic accessDesign decisions
copyContent()options — only callers that passurlget the text footer appended. This keeps copy-styles (CSS) and copy-html (raw HTML) output clean.metadata.contentstays clean — no URL text embedded. Consumers usemetadata.urlfor structured access, avoiding redundancy.copy.tsand passed through tocopyContent(), with awindow.location.hreffallback incopyContent()for paths that don't pass it explicitly (ensuringmetadata.urlis always populated).Test plan
copy-url.spec.tswith 5 tests: single element, URL ordering, metadata structure, copy with comment, multi-element dragelement-context.spec.tstruncation test to assert on snippet portion only (before URL footer)Summary by cubic
Include the current page URL in copied content so snippets carry their source. Adds a structured URL field to clipboard metadata and appends a text footer for primary and comment copies.
New Features
text/plainandtext/htmlfor primary and comment copies; plugin copies (styles, HTML) omit the footer.urltoapplication/x-react-grabmetadata;metadata.contentstays unchanged.copyContent({ url }); metadata always includes a URL viawindow.location.hreffallback.Bug Fixes
onCopySuccessto pass the actual clipboard text (including the URL footer) to plugins.Written for commit ed1ed8f. Summary will update on new commits.