notifications: rewrite subject API URLs to their HTML form#49
Open
AntonNiklasson wants to merge 1 commit into
Open
notifications: rewrite subject API URLs to their HTML form#49AntonNiklasson wants to merge 1 commit into
AntonNiklasson wants to merge 1 commit into
Conversation
The notifications API returns subject.url as an API URL (e.g. https://api.github.com/repos/o/r/pulls/1) and doesn't include an html_url, so pressing 'o' on a notification was opening a raw JSON endpoint. Derive the HTML URL locally — no extra API calls — and fall back to a sensible repo-level page for subject types we can't resolve precisely (Release, Discussion). Fixes #47
There was a problem hiding this comment.
Pull request overview
Fixes notification “open” behavior by converting GitHub Notifications subject.url values (REST API endpoints) into their corresponding HTML URLs so the UI opens the intended issue/PR/commit page without extra API calls.
Changes:
- Added
notificationHtmlUrl()helper to rewrite GitHub API URLs to HTML equivalents (including GHES/api/v3handling and sensible fallbacks). - Updated
fetchNotifications()to use the rewritten URL instead of the raw APIsubject.url. - Expanded integration tests to validate URL rewriting and fallbacks.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/server/src/fetchers.ts | Adds URL rewrite helper and applies it to notification payload shaping. |
| packages/server/src/fetchers.integration.test.ts | Updates notification shaping test and adds unit-style coverage for URL rewrite behavior (GitHub.com + GHES). |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
523
to
526
| export async function fetchNotifications(instanceId: string) { | ||
| const client = await getClient(instanceId); | ||
| const { baseUrl } = await getInstance(instanceId); | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The notifications API returns subject.url as an API URL (e.g.
https://api.github.com/repos/o/r/pulls/1) and doesn't include an
html_url, so pressing 'o' on a notification was opening a raw JSON
endpoint. Derive the HTML URL locally — no extra API calls — and fall
back to a sensible repo-level page for subject types we can't resolve
precisely (Release, Discussion).
Fixes #47