Skip to content

Fix Recent Releases Card: Show Tag as Fallback and Correct Release URLs #1566

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: main
Choose a base branch
from

Conversation

rishyym0927
Copy link
Contributor

@rishyym0927 rishyym0927 commented Jun 8, 2025

This PR improves the Recent Releases card component with the following changes:

  • Fixes Improve recent releases card #1537

  • Ensures that each release item displays a readable name: if the release name is absent, the tagName is shown as a fallback.

  • Fixes the release link: if the url is missing or invalid, the link now correctly points to the organization's repository release page using the organization, repository, and tag.

  • No changes are required in the backend as long as all necessary fields (name, tagName, url, organizationName, repositoryName) are present in the API response.

  • These changes address issues where releases from external organizations were missing information or had incorrect links. No unrelated code was modified.

Copy link
Contributor

coderabbitai bot commented Jun 8, 2025

Summary by CodeRabbit

  • Bug Fixes

    • Improved handling of missing or empty release and author information in recent releases, ensuring more accurate fallback values and conditional rendering.
    • Release and author links now display correctly even when some data is missing.
  • New Features

    • Release URLs are now directly available and used for recent releases, providing more accurate and reliable links.

Summary by CodeRabbit

  • Bug Fixes
    • Improved handling of release dates for consistent display.
    • Enhanced fallback logic for author and release information to ensure accurate and reliable display of names, avatars, and links.
    • Refined avatar display to only show when author information is available.
  • Bug Fixes
    • Improved the logic for release links to ensure they direct to the correct release page, even when certain data is missing.
    • Updated displayed text for releases to show the release name if available, or the tag name as a fallback.

Walkthrough

The RecentReleases component's link href logic was changed from using a fallback URL '/' to directly using the release item's URL with nullish coalescing fallback. The displayed link text was updated to show the release name if available, otherwise the tag name. Author avatar and link rendering were refined with conditional checks and nullish coalescing for fallback values. The publishedAt date field is normalized to a Unix timestamp.

Changes

File(s) Change Summary
frontend/src/components/RecentReleases.tsx Normalized publishedAt date to numeric timestamp; refined author avatar rendering and link href fallbacks; updated release link href and display text to prefer item.name over item.tagName; replaced logical OR with nullish coalescing for fallback values.
frontend/src/server/queries/repositoryQueries.ts Added url field to releases in GraphQL query to fetch release URLs for proper link rendering.

Assessment against linked issues

Objective Addressed Explanation
Show a readable name for all release items, using tag if title is absent (#1537)
Ensure URLs lead to the organization's repository release page, not the main Nest page (#1537)

Assessment against linked issues: Out-of-scope changes

No out-of-scope changes found.

Possibly related PRs

Suggested reviewers

  • arkid15r

📜 Recent review details

Configuration used: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between efb1558 and b6888ac.

📒 Files selected for processing (2)
  • frontend/src/components/RecentReleases.tsx (3 hunks)
  • frontend/src/server/queries/repositoryQueries.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
frontend/src/components/RecentReleases.tsx (2)
frontend/src/types/link.ts (1)
  • Link (1-6)
frontend/src/components/TruncatedText.tsx (1)
  • TruncatedText (3-45)
🔇 Additional comments (5)
frontend/src/server/queries/repositoryQueries.ts (1)

36-36: LGTM! Essential field addition for release URL handling.

Adding the url field to the releases query enables the frontend component to access the release URL directly, supporting the improved fallback logic in RecentReleases.tsx.

frontend/src/components/RecentReleases.tsx (4)

44-66: Excellent improvements to null safety and fallback handling.

The changes enhance the avatar rendering logic with:

  • Optional chaining to prevent runtime errors
  • Nullish coalescing (??) for more precise fallback behavior
  • Improved conditional logic for the author link href

These changes make the code more robust when dealing with missing author data.


77-77: Appropriate use of logical OR for release name fallback.

Using logical OR (||) here is correct because we want to fall back to tagName when name is any falsy value (empty string, null, undefined), not just null/undefined. This provides better user experience by ensuring a readable name is always displayed.


92-92: Good consistency with nullish coalescing usage.

The change to nullish coalescing is consistent with the other improvements in this component and provides more precise fallback behavior.


70-73: Validate GitHub URL fallback parameters

The fallback URL may include literal “undefined” if any of these fields are missing at runtime. Please confirm in your GraphQL schema that organizationName, repositoryName, and tagName are non-nullable. If they can ever be null or undefined, add guards to prevent malformed links.

Affected code:

  • frontend/src/components/RecentReleases.tsx (around lines 70–73)

Suggested diff:

href={
  item.url ??
- `https://github.com/${item.organizationName}/${item.repositoryName}/releases/tag/${item.tagName}`
+ (item.organizationName && item.repositoryName && item.tagName
+   ? `https://github.com/${encodeURIComponent(item.organizationName)}/${encodeURIComponent(item.repositoryName)}/releases/tag/${encodeURIComponent(item.tagName)}`
+   : '#')
}

• Verify whether these fields are non-nullable in the GraphQL schema.
• If not, add runtime checks or default behavior to avoid invalid URLs.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate Unit Tests
  • Create PR with Unit Tests
  • Post Copyable Unit Tests in Comment

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai auto-generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 6b0757a and a7f3bc7.

📒 Files selected for processing (1)
  • frontend/src/components/RecentReleases.tsx (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
frontend/src/components/RecentReleases.tsx (1)
frontend/src/components/TruncatedText.tsx (1)
  • TruncatedText (3-45)
🔇 Additional comments (1)
frontend/src/components/RecentReleases.tsx (1)

78-78: LGTM! Proper fallback implementation.

The fallback logic correctly displays the tag name when the release name is missing, which aligns perfectly with the PR objectives. The use of optional chaining ensures safe property access.

Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

Thanks for working on this.
One big issue I found ⬇️

@kasya
Copy link
Collaborator

kasya commented Jun 14, 2025

@rishyym0927 Hi! Any updates on this one?

@rishyym0927
Copy link
Contributor Author

@kasya can you clarify one thing, that if the url is not present then what should I use in replacement of that or how to deal with it? Also what if the tag name or title name both are missing how can we deal with it then? shouldn't we make these fields mandatory at the backend part ?

@rishyym0927 rishyym0927 requested a review from kasya June 14, 2025 12:49
@kasya
Copy link
Collaborator

kasya commented Jun 15, 2025

@kasya can you clarify one thing, that if the url is not present then what should I use in replacement of that or how to deal with it? Also what if the tag name or title name both are missing how can we deal with it then? shouldn't we make these fields mandatory at the backend part ?

@rishyym0927 the item you work with doesn't have a url property on it. You need to update the backend to pass it in.

I would recommend you to check how links for releases work on the organization page. It's the same component.
Also, maybe look at GraphQL to check what data is available on the backend

@kasya
Copy link
Collaborator

kasya commented Jun 15, 2025

Also, tests are failing now. Please run make check and make test after addressing this and before pushing changes 👌🏼

@rishyym0927
Copy link
Contributor Author

image

Hey @kasya as I can see that the graphql query return the url in recentReleases, so it does have the url property in it. What goes wrong is I gues that sometimes the when url link is not received then it basically redirect to home page of the nest where as we shoudl redirect it not found page. IF im correct then can I mplement this solution cause I dont think there is any need of making changes in hte backend as of now

@rishyym0927 the item you work with doesn't have a url property on it. You need to update the backend to pass it in.

I would recommend you to check how links for releases work on the organization page. It's the same component. Also, maybe look at GraphQL to check what data is available on the backend

Hey @kasya,
Thanks for the suggestion!

I checked the GraphQL query, and it looks like the recentReleases does return the url property. From what I observed, the issue seems to occur when the url is not present for a particular release — in such cases, it redirects to the home page of Nest. Ideally, we should redirect to a 404 or a "Not Found" page instead.

If my understanding is correct, would it make sense for me to implement this behavior on the frontend? I believe this might be sufficient for now, without requiring changes on the backend — but happy to discuss further if you think otherwise.

Let me know what you think!

@rishyym0927
Copy link
Contributor Author

I implemented a new solution which works pretty well, even if the url fiield is missing @kasya

@kasya
Copy link
Collaborator

kasya commented Jun 15, 2025

Hey @kasya, Thanks for the suggestion!

I checked the GraphQL query, and it looks like the recentReleases does return the url property. From what I observed, the issue seems to occur when the url is not present for a particular release — in such cases, it redirects to the home page of Nest. Ideally, we should redirect to a 404 or a "Not Found" page instead.

Let me know what you think!

@rishyym0927 have you compared the data on those 2 pages? The data that is sent to the project page releases does have the url property on it.
Screenshot 2025-06-15 at 12 52 19 PM

But you don't have it in the objects you work with on the repo page.
Screenshot 2025-06-15 at 12 52 29 PM

GraphQL only shows you what's available - not necessarily all of it was sent to the frontend. And that's exactly the case for this page.

@rishyym0927
Copy link
Contributor Author

Hey @kasya, Thanks for the suggestion!
I checked the GraphQL query, and it looks like the recentReleases does return the url property. From what I observed, the issue seems to occur when the url is not present for a particular release — in such cases, it redirects to the home page of Nest. Ideally, we should redirect to a 404 or a "Not Found" page instead.
Let me know what you think!

@rishyym0927 have you compared the data on those 2 pages? The data that is sent to the project page releases does have the url property on it. Screenshot 2025-06-15 at 12 52 19 PM

But you don't have it in the objects you work with on the repo page. Screenshot 2025-06-15 at 12 52 29 PM

GraphQL only shows you what's available - not necessarily all of it was sent to the frontend. And that's exactly the case for this page.

Hey @kasya,
Thank you so much for the clarification and the screenshots — that really helped me understand the gap better.

You're absolutely right — I hadn’t compared the data between the project page and the repo page closely enough. I now see that while the GraphQL query can return the url, it isn’t being passed to the frontend in the repo page context, which is likely why the redirection issue occurs there.

Apologies for the oversight on my part. I’ll dig into this further

Copy link

Copy link
Collaborator

@kasya kasya left a comment

Choose a reason for hiding this comment

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

I cleaned this up a bit (removed prev.added logic for working with dates that was not needed, we have a formatDate() util that takes care of that).

Also pushed missing part with getting url for a release in repository query.
This works fine now! 👌🏼

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve recent releases card
2 participants