Skip to content

fix(landing): instant feedback on copy markdown button#121

Merged
maxktz merged 2 commits into
mainfrom
maxktz/add-turbo-ignore
Apr 13, 2026
Merged

fix(landing): instant feedback on copy markdown button#121
maxktz merged 2 commits into
mainfrom
maxktz/add-turbo-ignore

Conversation

@maxktz

@maxktz maxktz commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Show "Copied" state instantly on click instead of waiting for the markdown fetch to complete
  • If the fetch or clipboard write fails, revert the state and show an error toast via sonner

Test plan

  • Click "Copy Markdown" on a docs page — should show "Copied" immediately
  • Paste content — should contain the correct markdown
  • Simulate network failure — should show error toast and revert button state

Summary by CodeRabbit

  • Bug Fixes
    • Enhanced error handling for the copy markdown button: users now see an error toast if fetching or copying fails.
    • Improved copy feedback: the success state is applied immediately and reliably resets after 2 seconds.

Optimistically show "Copied" state on click instead of waiting for
the fetch to complete. Shows an error toast if the copy fails.
@vercel

vercel Bot commented Apr 13, 2026

Copy link
Copy Markdown
Contributor

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
paykit Ready Ready Preview, Comment Apr 13, 2026 4:17am

@coderabbitai

coderabbitai Bot commented Apr 13, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: dfa6d496-f330-4cfe-96c1-3f1b2c90a231

📥 Commits

Reviewing files that changed from the base of the PR and between 12c6446 and 4f4b44b.

📒 Files selected for processing (1)
  • landing/src/components/docs/copy-markdown-button.tsx

📝 Walkthrough

Walkthrough

The CopyMarkdownButton click handler was changed from an async/await implementation to a promise-chain style. It now sets copied optimistically, schedules a 2s revert, and reports fetch/text/clipboard errors via toast.error("Failed to copy markdown") while resetting copied to false on failure.

Changes

Cohort / File(s) Summary
Copy button logic
landing/src/components/docs/copy-markdown-button.tsx
Replaced async/await click handler with a promise chain. Added centralized .catch() error handling that calls toast.error("Failed to copy markdown") and resets copied to false. Keeps immediate copied = true UI and 2000ms revert.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Poem

I hopped in with paws so bright,
Swapped async for chains in the night,
When markdown refuses to fly,
A toast will tell you why,
— signed, the rabbit with a clipboard 🐇✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: converting from a sequential async/await pattern to an optimistic UI pattern that provides instant feedback on the copy markdown button click.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch maxktz/add-turbo-ignore

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 95d7147 and 12c6446.

📒 Files selected for processing (1)
  • landing/src/components/docs/copy-markdown-button.tsx

Comment thread landing/src/components/docs/copy-markdown-button.tsx Outdated
Comment thread landing/src/components/docs/copy-markdown-button.tsx Outdated
@maxktz maxktz merged commit fb3ae0d into main Apr 13, 2026
1 of 3 checks passed
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