fix(docs): fix copy page button and header hook#2284
Merged
waleedlatif1 merged 1 commit intostagingfrom Dec 10, 2025
Merged
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile OverviewGreptile SummaryThis PR refactors the documentation page copy functionality and adds heading anchor link features:
The changes improve user experience by making it easier to share both full page content and specific heading links. Confidence Score: 4/5
Important Files ChangedFile Analysis
Sequence DiagramsequenceDiagram
participant User
participant Page as Page Component
participant Heading as Heading Component
participant LLMCopy as LLMCopyButton
participant Browser as Browser API
User->>Page: Renders documentation page
Page->>Page: Overrides h1-h6 components with Heading
Page->>Heading: Renders heading with id
Heading->>Heading: Shows Link icon on hover
alt User clicks heading anchor
User->>Heading: Clicks anchor link
Heading->>Browser: navigator.clipboard.writeText(url)
Heading->>Browser: window.history.pushState()
Heading->>Heading: Shows Check icon (2s)
end
alt User clicks Copy Page button
User->>LLMCopy: Clicks copy button
LLMCopy->>LLMCopy: Check cache for markdown
alt Cache hit
LLMCopy->>Browser: navigator.clipboard.writeText(cached)
else Cache miss
LLMCopy->>Browser: fetch(markdownUrl)
Browser-->>LLMCopy: Markdown content
LLMCopy->>LLMCopy: Store in cache
LLMCopy->>Browser: navigator.clipboard.write()
end
LLMCopy->>LLMCopy: Shows "Copied" state
end
|
Comment on lines
22
to
37
| setLoading(true) | ||
|
|
||
| try { | ||
| await navigator.clipboard.write([ | ||
| new ClipboardItem({ | ||
| 'text/plain': fetch(markdownUrl).then(async (res) => { | ||
| const content = await res.text() | ||
| cache.set(markdownUrl, content) | ||
|
|
||
| return content | ||
| }), | ||
| }), | ||
| ]) | ||
| setCopied(true) | ||
| setTimeout(() => setCopied(false), 2000) | ||
| } catch (err) { | ||
| console.error('Failed to copy:', err) | ||
| } finally { | ||
| setLoading(false) | ||
| } |
Contributor
There was a problem hiding this comment.
logic: setLoading(true) is called but never reset to false when using cached content (line 20). This could leave the button in a loading state indefinitely if cache is hit.
Suggested change
| setLoading(true) | |
| try { | |
| await navigator.clipboard.write([ | |
| new ClipboardItem({ | |
| 'text/plain': fetch(markdownUrl).then(async (res) => { | |
| const content = await res.text() | |
| cache.set(markdownUrl, content) | |
| return content | |
| }), | |
| }), | |
| ]) | |
| setCopied(true) | |
| setTimeout(() => setCopied(false), 2000) | |
| } catch (err) { | |
| console.error('Failed to copy:', err) | |
| } finally { | |
| setLoading(false) | |
| } | |
| const [checked, onClick] = useCopyButton(async () => { | |
| const cached = cache.get(markdownUrl) | |
| if (cached) return navigator.clipboard.writeText(cached) | |
| setLoading(true) | |
| try { | |
| await navigator.clipboard.write([ | |
| new ClipboardItem({ | |
| 'text/plain': fetch(markdownUrl).then(async (res) => { | |
| const content = await res.text() | |
| cache.set(markdownUrl, content) | |
| return content | |
| }), | |
| }), | |
| ]) | |
| } finally { | |
| setLoading(false) | |
| } | |
| }) |
Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/docs/components/page-actions.tsx
Line: 22:37
Comment:
**logic:** `setLoading(true)` is called but never reset to `false` when using cached content (line 20). This could leave the button in a loading state indefinitely if cache is hit.
```suggestion
const [checked, onClick] = useCopyButton(async () => {
const cached = cache.get(markdownUrl)
if (cached) return navigator.clipboard.writeText(cached)
setLoading(true)
try {
await navigator.clipboard.write([
new ClipboardItem({
'text/plain': fetch(markdownUrl).then(async (res) => {
const content = await res.text()
cache.set(markdownUrl, content)
return content
}),
}),
])
} finally {
setLoading(false)
}
})
```
How can I resolve this? If you propose a fix, please make it concise.
waleedlatif1
added a commit
that referenced
this pull request
Dec 10, 2025
… docs, mcp, autolayout improvements (#2286) * fix(mcp): prevent redundant MCP server discovery calls at runtime, use cached tool schema instead (#2273) * fix(mcp): prevent redundant MCP server discovery calls at runtime, use cached tool schema instead * added backfill, added loading state for tools in settings > mcp * fix tool inp * feat(rate-limiter): token bucket algorithm (#2270) * fix(ratelimit): make deployed chat rate limited * improvement(rate-limiter): use token bucket algo * update docs * fix * fix type * fix db rate limiter * address greptile comments * feat(i18n): update translations (#2275) Co-authored-by: icecrasher321 <[email protected]> * fix(tools): updated kalshi and polymarket tools to accurately reflect outputs (#2274) * feat(i18n): update translations (#2276) Co-authored-by: waleedlatif1 <[email protected]> * fix(autolayout): align by handle (#2277) * fix(autolayout): align by handle * use shared constants everywhere * cleanup * fix(copilot): fix custom tools (#2278) * Fix title custom tool * Checkpoitn (broken) * Fix custom tool flash * Edit workflow returns null fix * Works * Fix lint * fix(ime): prevent form submission during IME composition steps (#2279) * fix(ui): prevent form submission during IME composition steps * chore(gitignore): add IntelliJ IDE files to .gitignore --------- Co-authored-by: Vikhyath Mondreti <[email protected]> Co-authored-by: Waleed <[email protected]> Co-authored-by: waleedlatif1 <[email protected]> * feat(ui): logs, kb, emcn (#2207) * feat(kb): emcn alignment; sidebar: popover primary; settings-modal: expand * feat: EMCN breadcrumb; improvement(KB): UI * fix: hydration error * improvement(KB): UI * feat: emcn modal sizing, KB tags; refactor: deleted old sidebar * feat(logs): UI * fix: add documents modal name * feat: logs, emcn, cursorrules; refactor: logs * feat: dashboard * feat: notifications; improvement: logs details * fixed random rectangle on canvas * fixed the name of the file to align * fix build --------- Co-authored-by: waleed <[email protected]> * fix(creds): glitch allowing multiple credentials in an integration (#2282) * improvement: custom tools modal, logs-details (#2283) * fix(docs): fix copy page button and header hook (#2284) * improvement(chat): add the ability to download files from the deployed chat (#2280) * added teams download and chat download file * Removed comments * removed comments * component structure and download all * removed comments * cleanup code * fix empty files case * small fix * fix(container): resize heuristic improvement (#2285) * estimate block height for resize based on subblocks * fix hydration error * make more conservative --------- Co-authored-by: Vikhyath Mondreti <[email protected]> Co-authored-by: icecrasher321 <[email protected]> Co-authored-by: waleedlatif1 <[email protected]> Co-authored-by: Siddharth Ganesan <[email protected]> Co-authored-by: mosa <[email protected]> Co-authored-by: Emir Karabeg <[email protected]> Co-authored-by: Adam Gough <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Type of Change
Testing
Tested manually
Checklist