Skip to content

feat(ui): add pkg.pr.new preview releases link - #3157

Open
AmirSa12 wants to merge 5 commits into
npmx-dev:mainfrom
AmirSa12:feat/preview-releases
Open

feat(ui): add pkg.pr.new preview releases link#3157
AmirSa12 wants to merge 5 commits into
npmx-dev:mainfrom
AmirSa12:feat/preview-releases

Conversation

@AmirSa12

@AmirSa12 AmirSa12 commented Aug 7, 2026

Copy link
Copy Markdown

🔗 Linked issue

related to #3140

🧭 Context

https://discord.com/channels/1464542801676206113/1508756434937188372

📚 Description

I added the necessary headers to the HEAD response in pkg.pr.new so we can detect whether a package has preview releases. if a package turns to have them, we render that "preview releases" button at the bottom of the "versions" section, as shown in the below screenshot.

cleanshot

@vercel

vercel Bot commented Aug 7, 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 Aug 12, 2026 8:41am
2 Skipped Deployments
Project Deployment Actions Updated (UTC)
docs.npmx.dev Ignored Ignored Preview Aug 12, 2026 8:41am
npmx-lunaria Ignored Ignored Aug 12, 2026 8:41am

Request Review

@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 7c9bbbe0-0b8e-4924-9a3c-5a077059294b

📥 Commits

Reviewing files that changed from the base of the PR and between e6084db and b50559d.

📒 Files selected for processing (2)
  • app/pages/package/[[org]]/[name].vue
  • nuxt.config.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/pages/package/[[org]]/[name].vue

📝 Walkthrough

Summary by CodeRabbit

  • New Features

    • Added a “Preview releases” link beneath package versions when preview releases are available.
    • Automatically detects preview release availability and provides the relevant package URL.
    • Handles unavailable preview releases gracefully by hiding the link or using the repository URL where appropriate.
  • Bug Fixes

    • Improved handling of missing parameters and failed availability checks.
    • Added short-term caching to improve the speed and reliability of availability checks.

Walkthrough

The package page checks pkg.pr.new for preview releases, resolves a repository-specific URL, and passes it to PackageVersions. The component conditionally renders the link. The endpoint and component tests cover availability and rendering.

Changes

Preview release discovery

Layer / File(s) Summary
pkg.pr.new availability endpoint
server/api/registry/pkg-pr-new.get.ts, nuxt.config.ts, test/unit/server/api/registry/pkg-pr-new.get.spec.ts
The endpoint validates repository parameters, checks release availability with a HEAD request, handles failures, and caches normalised responses. Nuxt config adds 60-second ISR with restricted query forwarding. Tests cover validation, release headers, and failed requests.
Package page preview URL integration
app/pages/package/[[org]]/[name].vue
The package page derives the repository URL, queries availability, applies the fallback URL, refreshes when repository metadata changes, and passes the resolved value to PackageVersions.
Preview releases link rendering
app/components/Package/Versions.vue, test/nuxt/components/Package/Versions.spec.ts
PackageVersions accepts an optional nullable preview URL and renders the external link when a URL is provided. Tests cover both states.

Sequence Diagram(s)

sequenceDiagram
  participant PackagePage
  participant AvailabilityAPI
  participant PkgPrNew
  participant PackageVersions
  PackagePage->>AvailabilityAPI: Request repository availability
  AvailabilityAPI->>PkgPrNew: Send HEAD request
  PkgPrNew-->>AvailabilityAPI: Return release header
  AvailabilityAPI-->>PackagePage: Return availability and URL
  PackagePage->>PackageVersions: Pass preview releases URL
  PackageVersions-->>PackagePage: Render link when URL exists
Loading

Possibly related issues

  • npmx-dev/npmx.dev#3140: Requests pkg.pr.new support, which this change implements through availability detection and a package-page link.

Suggested reviewers: 43081j

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the addition of the pkg.pr.new preview releases link.
Description check ✅ Passed The description explains the preview release detection, link rendering, related issue, and supporting context.
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.
✨ 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.

@github-actions

github-actions Bot commented Aug 7, 2026

Copy link
Copy Markdown

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

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.

@AmirSa12 AmirSa12 changed the title feat(registry): add pkg.pr.new preview releases link feat(ui): add pkg.pr.new preview releases link Aug 7, 2026
@codecov

codecov Bot commented Aug 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 32.35294% with 23 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% 11 Missing and 5 partials ⚠️
server/api/registry/pkg-pr-new.get.ts 64.70% 4 Missing and 2 partials ⚠️
app/components/Package/Versions.vue 0.00% 0 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@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: 2

🧹 Nitpick comments (1)
test/unit/server/api/registry/pkg-pr-new.get.spec.ts (1)

6-6: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace the broad Function type.

Function does not describe the event-handler contract. Use a handler type with H3Event so this mock remains type-safe.

Proposed fix
-vi.stubGlobal('defineCachedEventHandler', (fn: Function) => fn)
+vi.stubGlobal(
+  'defineCachedEventHandler',
+  (fn: (event: H3Event) => unknown) => fn,
+)
🤖 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 `@test/unit/server/api/registry/pkg-pr-new.get.spec.ts` at line 6, Replace the
broad Function annotation in the defineCachedEventHandler stub with an
event-handler type that accepts H3Event, preserving the existing passthrough
behavior while making the mock type-safe.

Source: Coding guidelines

🤖 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/pages/package/`[[org]]/[name].vue:
- Around line 427-474: Restrict the pkg.pr.new preview flow to GitHub
repositories by requiring repoRef.value?.provider === 'github' alongside owner
and repo checks in rawPreviewReleasesUrl, the useAsyncData cache key and fetch
callback, and previewReleasesUrl. Return the existing null/hasReleases-false
defaults for non-GitHub refs so no request or unrelated URL is produced.

In `@server/api/registry/pkg-pr-new.get.ts`:
- Line 28: Update the upstream request in the handler around $fetch.raw to use a
short finite timeout and disable retries with retry: 0, while preserving the
HEAD method. Update the corresponding assertion in pkg-pr-new.get.spec.ts to
expect both request options.

---

Nitpick comments:
In `@test/unit/server/api/registry/pkg-pr-new.get.spec.ts`:
- Line 6: Replace the broad Function annotation in the defineCachedEventHandler
stub with an event-handler type that accepts H3Event, preserving the existing
passthrough behavior while making the mock type-safe.
🪄 Autofix

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 Plus

Run ID: 4d74ceba-5e50-470a-8601-a66a6b063767

📥 Commits

Reviewing files that changed from the base of the PR and between 5be120b and 8f8a746.

📒 Files selected for processing (5)
  • app/components/Package/Versions.vue
  • app/pages/package/[[org]]/[name].vue
  • server/api/registry/pkg-pr-new.get.ts
  • test/nuxt/components/Package/Versions.spec.ts
  • test/unit/server/api/registry/pkg-pr-new.get.spec.ts

Comment thread app/pages/package/[[org]]/[name].vue Outdated
Comment thread server/api/registry/pkg-pr-new.get.ts Outdated

@gameroman gameroman left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was thinking more of adding a new route similar to /pacakage/... which would allow to view all the info about a published preview package on npmx

@AmirSa12

AmirSa12 commented Aug 7, 2026

Copy link
Copy Markdown
Author

I was thinking more of adding a new route similar to /pacakage/... which would allow to view all the info about a published preview package on npmx

That also sounds great! but apparently its been discussed before with Daniel (https://discord.com/channels/1464542801676206113/1508756434937188372/1518531069190738040)

I think we could have a 'preview releases' or something like that, which displays at the bottom of the 'Versions' tab

IDK if that has changed or not.

@gameroman

Copy link
Copy Markdown
Member

I'd say these are 2 related features but different and could be both implemented

One for just detecting and linking to pkg.pr.new, which is what the Discord discussion was bout

And later we could add an actual route on npmx to view them, where this would later link instead of to pkg.pr.new directly, which is what my issue is about

@ghostdevv

Copy link
Copy Markdown
Member

How can I test this? I tried going to the page for knip but I can't see something like in the screenshot

@AmirSa12

Copy link
Copy Markdown
Author

How can I test this? I tried going to the page for knip but I can't see something like in the screenshot

Hey @ghostdevv, thanks for reviewing.
Can you try again now? it was a caching matter.

@gameroman

Copy link
Copy Markdown
Member

How can I test this? I tried going to the page for knip but I can't see something like in the screenshot

Hey @ghostdevv, thanks for reviewing. Can you try again now? it was a caching matter.

Thank you! I see it now

image image

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.

3 participants