Skip to content

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

Open
MatteoGabriele wants to merge 1 commit intonpmx-dev:mainfrom
MatteoGabriele:refactor/use-new-vueuse-useclipboard
Open

refactor(ui): use new useClipboard with async#2675
MatteoGabriele wants to merge 1 commit 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 5:43am
npmx.dev Ready Ready Preview, Comment May 4, 2026 5:43am
1 Skipped Deployment
Project Deployment Actions Updated (UTC)
npmx-lunaria Ignored Ignored May 4, 2026 5:43am

Request Review

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 4, 2026

📝 Walkthrough

Walkthrough

The PR replaces a custom useClipboardAsync composable with Vue Use's standard useClipboard, updating the README copy feature in the package page to use explicit pending state. The underlying @vueuse/core dependency is bumped to 14.3.0 to support this change.

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
Custom useClipboardAsync composable is removed entirely.
Page Migration
app/pages/package/[[org]]/[name].vue
README "copy as Markdown" logic switched from useClipboardAsync to useClipboard, introducing copyReadmePending state and conditional loader UI feedback during clipboard operations.

Possibly Related PRs

Suggested Reviewers

  • knowler
  • graphieros
🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately describes the main change: removing a custom composable and refactoring to use the updated useClipboard from vueuse.
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.
Description check ✅ Passed The pull request description clearly relates to the changeset, explaining the removal of useClipboardAsync and migration to vueuse's built-in implementation.

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

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

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.

@socket-security
Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​vueuse/​core@​14.3.0991007792100

View full report

@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/[email protected] 890.3 kB
@vueuse/[email protected] 220.4 kB
@vueuse/[email protected] 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 ✨ 🧹

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