-
Notifications
You must be signed in to change notification settings - Fork 24
added copy for ai button #142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
@dqnamo is attempting to deploy a commit to the cossistant Team on Vercel. A member of the Team first needs to authorize it. |
Greptile OverviewGreptile SummaryThis PR adds a small CTA to the Facehash landing page: a client-side button that copies a pre-written “AI prompt” (installation + usage notes) to the clipboard, and wires it into the hero section of The change is isolated to the landing app UI: Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant U as User
participant P as Home page (page.tsx)
participant B as CopyAiPromptButton
participant C as navigator.clipboard
U->>P: Render landing page
P->>B: Render <CopyAiPromptButton />
U->>B: Click "copy ai prompt" button
B->>C: writeText(MARKDOWN)
alt writeText succeeds
C-->>B: Promise resolves
B->>B: setCopied(true)
B->>B: setTimeout(2s) -> setCopied(false)
else writeText fails
C-->>B: Promise rejects
B-->>U: Unhandled rejection (current)
end
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 2 comments
| const handleCopy = async () => { | ||
| await navigator.clipboard.writeText(MARKDOWN); | ||
| setCopied(true); | ||
| setTimeout(() => setCopied(false), 2000); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unhandled clipboard failure
navigator.clipboard.writeText can throw (e.g., non-secure context, denied permission, unsupported API). Since the handler doesn’t catch errors, clicking the button can produce an unhandled promise rejection and still schedules state changes. Consider wrapping the copy in a try/catch and only toggling copied on success (optionally provide a fallback message).
| const handleCopy = async () => { | ||
| await navigator.clipboard.writeText(MARKDOWN); | ||
| setCopied(true); | ||
| setTimeout(() => setCopied(false), 2000); | ||
| }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Timeout set after unmount
The setTimeout(() => setCopied(false), 2000) isn’t cleared if the component unmounts within 2s, which can trigger React warnings about state updates on unmounted components. Store the timeout id and clear it in an effect cleanup.
Have been looking for a quick way to add facehash to projects. Not sure on the best place to put this on the page tho tbh

