Skip to content

feat(ui): add quick copy for package version#3056

Open
xusnitdinov wants to merge 1 commit into
npmx-dev:mainfrom
xusnitdinov:feat/copy-package-version
Open

feat(ui): add quick copy for package version#3056
xusnitdinov wants to merge 1 commit into
npmx-dev:mainfrom
xusnitdinov:feat/copy-package-version

Conversation

@xusnitdinov

Copy link
Copy Markdown

Closes #2646

What

Adds a quick way to copy the current package version, mirroring the existing Copy package name affordance.

Changes

  • Visible copy button next to the version selector in the package sub-header (icon-only ButtonBase, shows a check + accent color on success).
  • Command palette command package-copy-version (grouped under package), mirroring package-copy-name, so it is keyboard-accessible and announces Copied to clipboard.
  • New i18n key package.copy_version (Copy version) added to en.json (source of truth) and i18n/schema.json.

Notes

  • Uses the existing useClipboard pattern with resolvedVersion as the source.
  • Only renders when a resolved version is available.
  • Other locale files intentionally untouched; they fall back to English and are tracked via Lunaria, per the i18n contributing guide.

Co-authored-by: Cursor <cursoragent@cursor.com>
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
npmx.dev Ready Ready Preview, Comment Jul 17, 2026 1:27pm
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Jul 17, 2026 1:27pm
npmx-lunaria Ignored Ignored Jul 17, 2026 1:27pm

Request Review

@github-actions

Copy link
Copy Markdown

Hello! Thank you for opening your first PR to npmx, @xusnitdinov! 🚀

Here’s what will happen next:

  1. Our GitHub bots will run to check your changes.
    If they spot any issues you will see some error messages on this PR.
    Don’t hesitate to ask any questions if you’re not sure what these mean!

  2. In a few minutes, you’ll be able to see a preview of your changes on Vercel

  3. One or more of our maintainers will take a look and may ask you to make changes.
    We try to be responsive, but don’t worry if this takes a few days.

@github-actions

Copy link
Copy Markdown

Lunaria Status Overview

🌕 This pull request will trigger status changes.

Learn more

By default, every PR changing files present in the Lunaria configuration's files property will be considered and trigger status changes accordingly.

You can change this by adding one of the keywords present in the ignoreKeywords property in your Lunaria configuration file in the PR's title (ignoring all files) or by including a tracker directive in the merged commit's description.

Tracked Files

File Note
i18n/locales/en.json Source changed, localizations will be marked as outdated.
Warnings reference
Icon Description
🔄️ The source for this localization has been updated since the creation of this pull request, make sure all changes in the source have been applied.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Summary by CodeRabbit

  • New Features
    • Added a quick-copy action for resolved package versions.
    • The action is available in the command palette and package header when a resolved version exists.
    • Added visual feedback after the version has been copied.

Walkthrough

Adds resolved package version copying through the command palette and a header button, with clipboard state and package.copy_version translation schema support.

Changes

Package version copy

Layer / File(s) Summary
Resolved version clipboard state
app/components/Package/Header.vue
Derives the resolved version text and connects it to useClipboard state and copy actions.
Copy entrypoints and translation contract
app/components/Package/Header.vue, i18n/locales/en.json, i18n/schema.json
Adds conditional command-palette and header-button entrypoints, plus the English translation and typed schema field for package.copy_version.

Possibly related PRs

  • npmx-dev/npmx.dev#3044: Adds overlapping package-header version copying, clipboard wiring, command-palette support, and copy_version translations.

Suggested reviewers: alexdln

🚥 Pre-merge checks | ✅ 3 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning Implements quick copy for the version in [#2646], but the version itself is not made more noticeable as the issue also requested. Update the version text styling or layout so it is more prominent, or confirm that this requirement is satisfied elsewhere in the patch.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: adding quick copy for the package version.
Description check ✅ Passed The description matches the changeset and accurately describes the new copy-version button, command, and i18n updates.
Out of Scope Changes check ✅ Passed The changes stay within scope: UI copy action, command palette support, and related i18n/schema updates.
✨ 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.

Warning

⚠️ This pull request shows signs of AI-generated slop (redundant_comments). It has been flagged by CodeRabbit slop detection and should be reviewed carefully.

@codecov

codecov Bot commented Jul 17, 2026

Copy link
Copy Markdown

Codecov Report

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

Files with missing lines Patch % Lines
app/components/Package/Header.vue 57.14% 2 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@coderabbitai coderabbitai Bot added the 007 This PR *may* not follow our code of conduct regarding AI usage. label Jul 17, 2026

@coderabbitai coderabbitai Bot left a comment

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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@app/components/Package/Header.vue`:
- Around line 336-345: Update the quick-copy button’s click handling around
copyVersion() to also call the announce() method exposed by useCommandPalette(),
using the same clipboard-success feedback as the command palette action.
Preserve the existing copyVersion behavior and button state updates.
🪄 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: 45418cad-0d0e-4b59-a839-a2cb7c20f4b3

📥 Commits

Reviewing files that changed from the base of the PR and between 2df3b31 and 2647cca.

📒 Files selected for processing (3)
  • app/components/Package/Header.vue
  • i18n/locales/en.json
  • i18n/schema.json

Comment on lines +336 to +345
<!-- Quick copy version -->
<ButtonBase
v-if="resolvedVersion"
size="sm"
variant="secondary"
:aria-label="copiedVersion ? $t('common.copied') : $t('package.copy_version')"
:classicon="copiedVersion ? 'i-lucide:check' : 'i-lucide:copy'"
:class="copiedVersion ? 'text-accent' : ''"
@click="copyVersion()"
/>

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.

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Add screen-reader announcement for clipboard action.

The quick-copy button calls copyVersion() but omits the screen-reader announcement, whereas the command palette correctly announces the action. Based on learnings, clipboard copy feedback should be announced using the announce() method exposed by useCommandPalette().

♿ Proposed fix
           <!-- Quick copy version -->
           <ButtonBase
             v-if="resolvedVersion"
             size="sm"
             variant="secondary"
             :aria-label="copiedVersion ? $t('common.copied') : $t('package.copy_version')"
             :classicon="copiedVersion ? 'i-lucide:check' : 'i-lucide:copy'"
             :class="copiedVersion ? 'text-accent' : ''"
-            `@click`="copyVersion()"
+            `@click`="copyVersion(); announce($t('command_palette.announcements.copied_to_clipboard'))"
           />

(Note: You could also extract this combined copy and announce logic into a shared helper function in the <script setup> block to avoid duplication with the command palette action.)

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<!-- Quick copy version -->
<ButtonBase
v-if="resolvedVersion"
size="sm"
variant="secondary"
:aria-label="copiedVersion ? $t('common.copied') : $t('package.copy_version')"
:classicon="copiedVersion ? 'i-lucide:check' : 'i-lucide:copy'"
:class="copiedVersion ? 'text-accent' : ''"
@click="copyVersion()"
/>
<!-- Quick copy version -->
<ButtonBase
v-if="resolvedVersion"
size="sm"
variant="secondary"
:aria-label="copiedVersion ? $t('common.copied') : $t('package.copy_version')"
:classicon="copiedVersion ? 'i-lucide:check' : 'i-lucide:copy'"
:class="copiedVersion ? 'text-accent' : ''"
`@click`="copyVersion(); announce($t('command_palette.announcements.copied_to_clipboard'))"
/>
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@app/components/Package/Header.vue` around lines 336 - 345, Update the
quick-copy button’s click handling around copyVersion() to also call the
announce() method exposed by useCommandPalette(), using the same
clipboard-success feedback as the command palette action. Preserve the existing
copyVersion behavior and button state updates.

Source: Learnings

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

007 This PR *may* not follow our code of conduct regarding AI usage.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A quick way to copy package version

1 participant