Skip to content

refactor(ui): use new useClipboard with async#2675

Merged
ghostdevv merged 2 commits intonpmx-dev:mainfrom
MatteoGabriele:refactor/use-new-vueuse-useclipboard
May 4, 2026
Merged

refactor(ui): use new useClipboard with async#2675
ghostdevv merged 2 commits intonpmx-dev:mainfrom
MatteoGabriele:refactor/use-new-vueuse-useclipboard

Conversation

@MatteoGabriele
Copy link
Copy Markdown
Member

@MatteoGabriele MatteoGabriele commented May 4, 2026

The fix for #2151 has been incorporated into vueuse, and with the release of v14.3.0, we can now remove the additional code and rely on the version included in the library.

see vueuse/vueuse#5368

@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented May 4, 2026

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

Project Deployment Actions Updated (UTC)
docs.npmx.dev Ready Ready Preview, Comment May 4, 2026 10:22pm
npmx.dev Ready Ready Preview, Comment May 4, 2026 10:22pm
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
npmx-lunaria Ignored Ignored May 4, 2026 10:22pm

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 14f1dc77-0f17-49e2-80a6-e87900402dc3

📥 Commits

Reviewing files that changed from the base of the PR and between 13fb947 and 058614a.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (1)
  • package.json
✅ Files skipped from review due to trivial changes (1)
  • package.json

📝 Walkthrough

Summary by CodeRabbit

Release Notes

  • Refactor

    • Enhanced the package details page README copy feature with improved user experience. The interface now displays a loading spinner whilst the copy operation is in progress, and the button label dynamically updates to clearly indicate when the content has been successfully copied.
  • Chores

    • Updated package dependencies to the latest stable versions.

Walkthrough

The PR removes a custom useClipboardAsync composable, replaces its usage in the package README "copy as Markdown" flow with VueUse's useClipboard (adding explicit pending state and loader UI), and bumps @vueuse/core from 14.2.1 to 14.3.0.

Changes

Clipboard API Migration

Layer / File(s) Summary
Dependency Update
package.json
@vueuse/core upgraded from 14.2.1 to 14.3.0.
Composable Removal
app/composables/useClipboardAsync.ts
Removed custom useClipboardAsync that exposed copy() and a copied ShallowRef boolean and wrote async text to the clipboard.
Page Migration — wiring & behaviour
app/pages/package/[[org]]/[name].vue
Replaced useClipboardAsync usage with useClipboard, destructuring copied, copy, and copyPending; copyReadme() now calls copy(async () => ...) to fetch README markdown.
Page Migration — UI
app/pages/package/[[org]]/[name].vue
README copy button updated to reflect copyReadmePending by showing a spinner during pending state and toggling label between “copy” and “copied”.

Possibly Related PRs

  • npmx-dev/npmx.dev#2554: Introduced useClipboardAsync and wired it into the package page; directly related as this PR removes that custom composable and switches back to useClipboard.

Suggested Reviewers

  • knowler
  • graphieros
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly describes the main change: refactoring the clipboard handling to use vueuse's new async useClipboard functionality instead of custom code.
Description check ✅ Passed The description is related to the changeset, explaining that vueuse v14.3.0 now includes the fix for the issue, allowing removal of local custom code.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

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

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 4, 2026

📊 Dependency Size Changes

Warning

This PR adds 1.3 MB of new dependencies, which exceeds the threshold of 200 kB.

📦 Package 📏 Size
@vueuse/core@14.3.0 890.3 kB
@vueuse/shared@14.3.0 220.4 kB
@vueuse/metadata@14.3.0 165.6 kB

Total size change: 1.3 MB

@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

❌ Patch coverage is 0% with 6 lines in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
app/pages/package/[[org]]/[name].vue 0.00% 5 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@app/pages/package/`[[org]]/[name].vue:
- Around line 119-124: The copyReadme helper currently calls copy with an empty
string when fetchReadmeMarkdown fails; change copyReadme so it awaits
fetchReadmeMarkdown, checks readmeMarkdownData.value?.markdown and if it's falsy
returns early (or surfaces an error/toast) instead of calling copy with ''—use
fetchReadmeMarkdown(), inspect readmeMarkdownData (or its Markdown field) and
only call copy(async () => ...) when markdown is non-empty, otherwise bail out
or raise a user-visible error.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 81213369-668c-43bc-b6d3-2faddd6afa3e

📥 Commits

Reviewing files that changed from the base of the PR and between c26421f and 13fb947.

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml
📒 Files selected for processing (3)
  • app/composables/useClipboardAsync.ts
  • app/pages/package/[[org]]/[name].vue
  • package.json
💤 Files with no reviewable changes (1)
  • app/composables/useClipboardAsync.ts

Comment on lines +119 to +124
function copyReadme() {
copy(async () => {
await fetchReadmeMarkdown()
return readmeMarkdownData.value?.markdown ?? ''
},
{
copiedDuring: 2000,
},
)
})
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Don't copy an empty README on fetch failure.

The helper currently falls back to '' when the markdown ref is empty, so a failed fetch can still look like a successful copy. Return early or surface an error instead of treating missing markdown as valid content.

🛠 Suggested fix
 async function copyReadme() {
   copy(async () => {
     await fetchReadmeMarkdown()
-    return readmeMarkdownData.value?.markdown ?? ''
+    const markdown = readmeMarkdownData.value?.markdown
+    if (!markdown) throw new Error('README Markdown is unavailable')
+    return markdown
   })
 }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@app/pages/package/`[[org]]/[name].vue around lines 119 - 124, The copyReadme
helper currently calls copy with an empty string when fetchReadmeMarkdown fails;
change copyReadme so it awaits fetchReadmeMarkdown, checks
readmeMarkdownData.value?.markdown and if it's falsy returns early (or surfaces
an error/toast) instead of calling copy with ''—use fetchReadmeMarkdown(),
inspect readmeMarkdownData (or its Markdown field) and only call copy(async ()
=> ...) when markdown is non-empty, otherwise bail out or raise a user-visible
error.

Copy link
Copy Markdown
Contributor

@graphieros graphieros left a comment

Choose a reason for hiding this comment

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

Works on my Safari 🌿

Copy link
Copy Markdown
Contributor

@ghostdevv ghostdevv left a comment

Choose a reason for hiding this comment

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

assuming the code rabbit comment is valid, we can fix it here or create an issue? otherwise LGTM

@MatteoGabriele
Copy link
Copy Markdown
Member Author

MatteoGabriele commented May 4, 2026

assuming the code rabbit comment is valid, we can fix it here or create an issue? otherwise LGTM

@ghostdevv the copying action "never fails", even if it does.
We might need a different UX for failure. 🤔 I suppose we could add a small "x" icon when it fails, but I'd like to check with some a11y people what the best strategy is for that too.
If it's fine with you, I would prefer to create a separate PR so we can get this out of the way faster.

Copy link
Copy Markdown
Member

@shuuji3 shuuji3 left a comment

Choose a reason for hiding this comment

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

Works as expected on Firefox/Google Chrome on Linux/macOS/Android ✨ 🧹

@ghostdevv ghostdevv enabled auto-merge May 4, 2026 22:20
@ghostdevv ghostdevv added this pull request to the merge queue May 4, 2026
Merged via the queue into npmx-dev:main with commit 50997b7 May 4, 2026
23 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.

4 participants