Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions app/components/Package/Header.vue
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ const { y: scrollY } = useScroll(window)
const showScrollToTop = computed(() => scrollY.value > SCROLL_TO_TOP_THRESHOLD)

const packageName = computed(() => props.pkg?.name ?? '')
const resolvedVersionText = computed(() => props.resolvedVersion ?? '')
const fundingUrl = computed(() => {
let funding = props.displayVersion?.funding
if (Array.isArray(funding)) funding = funding[0]
Expand All @@ -75,6 +76,11 @@ const { copied: copiedPkgName, copy: copyPkgName } = useClipboard({
copiedDuring: 2000,
})

const { copied: copiedVersion, copy: copyVersion } = useClipboard({
source: resolvedVersionText,
copiedDuring: 2000,
})

function hasProvenance(version: PackumentVersion | null): boolean {
if (!version?.dist) return false
return !!(version.dist as { attestations?: unknown }).attestations
Expand All @@ -100,6 +106,20 @@ useCommandPaletteContextCommands(
},
]

if (resolvedVersionText.value) {
commands.push({
id: 'package-copy-version',
group: 'package',
label: $t('package.copy_version'),
keywords: [resolvedVersionText.value],
iconClass: 'i-lucide:copy',
action: () => {
copyVersion()
announce($t('command_palette.announcements.copied_to_clipboard'))
},
})
}

if (fundingUrl.value) {
commands.push({
id: 'package-link-funding',
Expand Down Expand Up @@ -313,6 +333,16 @@ useShortcuts({
:url-pattern="versionUrlPattern"
position-class="max-md:inset-is-0 md:inset-ie-0"
/>
<!-- 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()"
/>
Comment on lines +336 to +345

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

</div>
</div>
<!-- Docs + Code — inline on desktop, floating bottom bar on mobile -->
Expand Down
1 change: 1 addition & 0 deletions i18n/locales/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@
"verified_provenance": "Verified provenance",
"navigation": "Package",
"copy_name": "Copy package name",
"copy_version": "Copy version",
"deprecation": {
"package": "This package has been deprecated.",
"version": "This version has been deprecated.",
Expand Down
3 changes: 3 additions & 0 deletions i18n/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1237,6 +1237,9 @@
"copy_name": {
"type": "string"
},
"copy_version": {
"type": "string"
},
"deprecation": {
"type": "object",
"properties": {
Expand Down
Loading