fix(landing): instant feedback on copy markdown button#121
Conversation
Optimistically show "Copied" state on click instead of waiting for the fetch to complete. Shows an error toast if the copy fails.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@landing/src/components/docs/copy-markdown-button.tsx`:
- Around line 16-22: The promise chain starting with fetch(markdownUrl) in the
click handler is not awaited or explicitly voided; update the handler (in
copy-markdown-button.tsx, e.g. the CopyMarkdownButton click handler where
fetch(markdownUrl) is invoked) to explicitly void the promise by prefixing the
chain with "void" (or alternatively make the handler async and await the
fetch/... chain) so the returned Promise is intentionally ignored and the lint
rule is satisfied; keep the existing then/catch behavior intact when applying
this change.
- Around line 16-18: The fetch flow in copy-markdown-button.tsx uses
fetch(markdownUrl).then(res => res.text()).then(text =>
navigator.clipboard.writeText(text)) and does not check HTTP status, so 4xx/5xx
bodies can be copied; change the chain to verify response.ok after the fetch
(e.g., in the first then for the response returned by fetch), throw an error
when !res.ok so the failure path runs, and only call
navigator.clipboard.writeText(text) after res.text() on a successful response;
update any surrounding UI/notification logic in the component to handle the
thrown error (show failure feedback) instead of optimistically reporting
success.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 6e7a51f0-78ca-42b1-b650-ba0a74191c87
📒 Files selected for processing (1)
landing/src/components/docs/copy-markdown-button.tsx
Summary
Test plan
Summary by CodeRabbit