Skip to content

fix: Fix repo carousel thrashing #294

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

Merged
merged 3 commits into from
May 6, 2025
Merged

fix: Fix repo carousel thrashing #294

merged 3 commits into from
May 6, 2025

Conversation

brendan-kellam
Copy link
Contributor

@brendan-kellam brendan-kellam commented May 6, 2025

This PR fixes repo carousel thrashing by showing repos that have ever had a zoekt index (using indexedAt !== undefined) instead of relying on the current repo indexing status. It also adds hydration server side s.t., the skeleton does not appear on first page load.

Fixes #293

Summary by CodeRabbit

  • New Features

    • Improved repository snapshot display by refining which repositories are shown as indexed.
    • Enhanced initial loading experience with more accurate loading and empty states for repositories.
  • Bug Fixes

    • Added error handling to prevent service errors from affecting repository lists.
    • Fixed issue where repositories were not visible in the homepage carousel after re-indexing.

@brendan-kellam brendan-kellam requested a review from msukkari May 6, 2025 16:53
Copy link

coderabbitai bot commented May 6, 2025

"""

Walkthrough

The RepositorySnapshot component was updated to accept initial repository data via a new prop and to refine its logic for determining indexed repositories by checking the presence of indexedAt. The Home page was modified to fetch repository data and pass it to RepositorySnapshot, with improved error handling to ensure only valid data is used.

Changes

File(s) Change Summary
packages/web/src/app/[domain]/components/repositorySnapshot.tsx Updated RepositorySnapshot to accept repos prop, use it as initial data in React Query, and refine indexed repo logic.
packages/web/src/app/[domain]/page.tsx Modified Home to fetch repositories using getRepos, handle errors, and pass repos prop to RepositorySnapshot.
CHANGELOG.md Added "Fixed" entry for repos not visible in homepage carousel after re-indexing referencing PR #294.

Sequence Diagram(s)

sequenceDiagram
    participant HomePage
    participant getRepos
    participant RepositorySnapshot

    HomePage->>getRepos: Fetch repository data for domain
    getRepos-->>HomePage: Return repos or error
    HomePage->>RepositorySnapshot: Render with repos (empty array if error)
    RepositorySnapshot->>RepositorySnapshot: Filter and display indexed repos based on indexedAt
Loading

Assessment against linked issues

Objective Addressed Explanation
Prevent "Search through X repos" UI from thrashing as repos are reindexed (#293)

Possibly related PRs

  • Display name improvements #259: Backend and schema updates adding displayName for repositories, related to frontend handling of repository data and display.

Poem

A snapshot of repos, now smarter and bright,
With data that's filtered just right.
No more UI thrashing, no more dismay—
Only indexed-at truth on display!
The bunny hops by, gives a cheerful cheer:
"Your repo count's stable, so search without fear!"
🐇✨
"""


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f2d612f and 9871195.

📒 Files selected for processing (1)
  • packages/web/src/app/[domain]/components/repositorySnapshot.tsx (3 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • packages/web/src/app/[domain]/components/repositorySnapshot.tsx
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
✨ Finishing Touches
  • 📝 Generate Docstrings

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.
    • Generate unit testing code for this file.
    • 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 generate unit testing code for this file.
    • @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 generate unit testing code.
    • @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 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.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

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

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

🧹 Nitpick comments (1)
packages/web/src/app/[domain]/components/repositorySnapshot.tsx (1)

20-28: Consider adding default value for repos prop.

While the code handles the case where repos might be a service error, consider providing a default empty array for the repos prop to handle cases where it might not be provided at all.

-    repos: RepositoryQuery[];
+    repos?: RepositoryQuery[];

-    repos: initialRepos,
+    repos: initialRepos = [],
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eb10d59 and bbbd054.

📒 Files selected for processing (2)
  • packages/web/src/app/[domain]/components/repositorySnapshot.tsx (3 hunks)
  • packages/web/src/app/[domain]/page.tsx (2 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (10)
packages/web/src/app/[domain]/page.tsx (3)

13-14: Good addition of required imports.

These imports provide the necessary functionality to fetch repositories and handle service errors.


22-23: Server-side data fetching implemented correctly.

Fetching repository data server-side will provide initial data for hydration, preventing the loading skeleton from appearing on first page load.


41-44: Good error handling and prop passing.

The code correctly handles potential service errors by passing an empty array when errors occur, preventing error propagation to the client component.

packages/web/src/app/[domain]/components/repositorySnapshot.tsx (7)

18-18: Good addition of type import.

Importing the RepositoryQuery type ensures proper type checking for the new props.


20-23: Interface correctly updated with new props.

The interface now properly includes the repos prop that will be used for initial data.


25-28: Good component parameter update with renamed prop.

Renaming repos to initialRepos in the parameters makes it clear that these are initial values that may be updated.


31-36: Query configuration properly updated for initial data.

The changes correctly:

  1. Add initialRepos to the query key so React Query will refetch if initial data changes
  2. Set initialData to the server-provided repositories

This ensures proper hydration and prevents unnecessary loading states.


46-49: Good implementation of improved filtering logic.

Changing the filter criteria to check for indexedAt !== undefined rather than the current indexing status is a good approach to prevent carousel thrashing. The comment explains the reasoning well.


50-68: Improved conditional rendering with appropriate states.

The conditional rendering logic has been improved to:

  1. Show a loading indicator when repositories are being indexed
  2. Show the empty state only when no repositories are indexed or in the indexing queue

This provides better user feedback about the system state.


78-78: Fixed pluralization for better grammar.

Good attention to detail by ensuring correct pluralization based on the number of repositories.

@brendan-kellam brendan-kellam merged commit b280e2d into main May 6, 2025
5 checks passed
@brendan-kellam brendan-kellam deleted the bkellam/fix_293 branch May 6, 2025 17:44
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.

[bug] "Search through X repos" UI thrashes as repos are being reindexed
1 participant