Skip to content

Add a copy button to the agent prompt - #3

Open
FurkaanBoraa wants to merge 1 commit into
RectZones:mainfrom
FurkaanBoraa:copy-prompt
Open

Add a copy button to the agent prompt#3
FurkaanBoraa wants to merge 1 commit into
RectZones:mainfrom
FurkaanBoraa:copy-prompt

Conversation

@FurkaanBoraa

Copy link
Copy Markdown
Contributor

You did not ask for this one — it is a proposal, not a follow-up to anything you assigned. Close it without ceremony if you disagree; nothing else depends on it.

Why

The #agent section is the site's flagship path — it is one of the two hero CTAs and the row you win outright in the comparison table. Its entire call to action is paste this into your agent. But the block cannot be cleanly selected by hand: the you> prefixes and the two comment lines share the same text flow, so dragging across it puts this on the clipboard:

you> https://github.com/RectZones/RectZones you> install this # agent clones, builds, guides the permission, # proves it works from the log, gives you a tour.

Nobody can paste that. So the button is less a convenience than a fix for a path we actively advertise.

What it copies

Exactly the two you> lines, nothing hidden:

https://github.com/RectZones/RectZones
install this

Deliberately identical to what is on screen. A copy button that quietly copies something richer than the visible block would be a small dishonesty on a page that trades on being checkable.

Two implementation notes

It floats, it is not absolutely positioned. Absolute positioning needs padding-right on the whole block, which pushed both comment lines onto a second line each and grew the block from 7 rendered lines to 9. A float only shortens the lines it actually sits beside, so the comments keep their width. Verified the block's rendered line count is unchanged from main.

This is the site's first script — around 15 lines, no dependency, no build step, no new request. If you would rather the page stay pure HTML/CSS, that is a completely reasonable line to hold and I will close this.

Verification

Served the page and drove a real browser rather than reading the diff:

Check Result
Payload passed to navigator.clipboard.writeText https://github.com/RectZones/RectZones\ninstall this
The write actually resolves ✅ promise fulfilled, not just fired
Success state ✅ label → Copied, turns --ok green
Layout shift on state change ✅ none — min-width: 70px holds the button across Copy / Copied / Select it
[data-state="done"] vs :hover cascade ✅ green wins while hovered (equal specificity, later rule)
Keyboard ✅ real <button>, :focus-visible ring in --azure
Narrow viewport (≈300 px block) ✅ button stays inside the block, page gains no horizontal scroll

On failure the label becomes Select it in amber rather than silently doing nothing — navigator.clipboard needs a secure context, and a button that looks like it worked when it did not is worse than one that admits it.

One honest caveat: the block already scrolls horizontally on very narrow screens because https://github.com/RectZones/RectZones is a single unbreakable token. Measured scrollWidth with and without the button at the same width — 353 px both ways, so this PR does not make it worse, but the button does scroll with the content there.

Note

Opened from a fork — pull only on this repo. Independent of #2 (the security-policy footer link); either can merge first, they touch different parts of the file.

The whole section asks the reader to paste something into their agent,
but the block was not cleanly selectable: the you> prefixes and the two
comment lines sit in the same text flow, so dragging across it yields

  you> https://github.com/RectZones/RectZones you> install this # agent…

which is not what anyone wants on their clipboard. The button copies
exactly the two you> lines and nothing else.

The button floats rather than being absolutely positioned, so it only
shortens the lines it sits beside and the comment lines keep their
width. Positioning it absolutely needed padding on the whole block,
which wrapped the comments onto two extra lines.

First script on the site: ~15 lines, no dependency, no build step. It
copies only what is already visible, so the block on screen stays the
source of truth for what lands on the clipboard.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant