Skip to content
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

Tooltip collision fix #1098

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft

Conversation

rishyym0927
Copy link
Contributor

Resolves #1065

The previous implementation was working but in certain cases it has the possibility of having a collision. Thus added one more variable that is the repo info to make it prone to the collisions!

Copy link
Contributor

coderabbitai bot commented Mar 13, 2025

Summary by CodeRabbit

  • New Features
    • Enhanced contributor avatar tooltips to gracefully handle missing project affiliation details by providing a reliable default message.

Walkthrough

This pull request updates the ContributorAvatar component by introducing a new variable, projectName, which is used to modify the id property of the Tooltip component. The new format for the id includes the projectName, ensuring that if it is not available, a fallback value of 'unknown-project' is used. This change aims to enhance the uniqueness of tooltip identifiers for contributors across multiple projects.

Changes

File Change Summary
frontend/.../ContributorAvatar.tsx Introduced projectName variable in ContributorAvatar and updated id property of Tooltip to include it, using 'unknown-project' as a fallback.

Assessment against linked issues

Objective Addressed Explanation
Extend unique key to include the project identifier (1065)

Possibly related PRs

Suggested reviewers

  • arkid15r
  • kasya

Tip

⚡🧪 Multi-step agentic review comment chat (experimental)
  • We're introducing multi-step agentic chat in review comments. This experimental feature enhances review discussions with the CodeRabbit agentic chat by enabling advanced interactions, including the ability to create pull requests directly from comments.
    - To enable this feature, set early_access to true under in the settings.

📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between af33ac2 and a1cdf39.

📒 Files selected for processing (1)
  • frontend/src/components/ContributorAvatar.tsx (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • frontend/src/components/ContributorAvatar.tsx
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: CodeQL (python)
  • GitHub Check: CodeQL (javascript-typescript)
  • GitHub Check: Run frontend unit tests
  • GitHub Check: Run frontend e2e tests
  • GitHub Check: Run backend tests

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

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

🧹 Nitpick comments (1)
frontend/src/components/ContributorAvatar.tsx (1)

43-43: Good fix, but consider further improvements for ID formatting.

The change appropriately enhances the tooltip ID's uniqueness by incorporating the repository information, which should effectively prevent collisions as mentioned in the PR description. The tooltip can now distinguish between contributors with the same login but from different repositories.

However, note that the repositoryInfo variable (defined on lines 36-39) includes spaces and potentially special characters (e.g., in Project Name). While this works, consider using a more ID-friendly format for better HTML practices:

- id={`avatar-tooltip-${login}-${uniqueKey}-${repositoryInfo}`}
+ id={`avatar-tooltip-${login}-${uniqueKey}${repositoryInfo ? `-${(contributor as TopContributorsTypeGraphql).projectName?.replace(/\s+/g, '-')}` : ''}`}

This would format project names by replacing spaces with hyphens for cleaner IDs.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 77fb340 and af33ac2.

📒 Files selected for processing (1)
  • frontend/src/components/ContributorAvatar.tsx (1 hunks)

Copy link
Collaborator

Choose a reason for hiding this comment

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

@rishyym0927 thanks for updating this. I'm checking it locally and for all the cases that I saw repositoryInfo is actually an empty string.
So I'm thinking what if we pass in something else to this component from the Card to differentiate the project? Could be something connected to the project or to the card itself, like index for example 🤔

Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

As @kasya mentioned the project related uniqueness is not always guaranteed. It seems the code tries to cover multiple cases and the data is not properly populated for Algolia case.

@rishyym0927
Copy link
Contributor Author

Hey Im looking for more better and viable solution for this

@rishyym0927
Copy link
Contributor Author

Hey @arkid15r , @kasya

I updated the tooltip id generation to ensure uniqueness when the same contributor appears in multiple projects. Previously, it relied on repositoryInfo, which was often empty, leading to potential duplicate IDs.

  • Included projectName in the tooltip id to differentiate contributors across projects.
  • If projectName is missing, it falls back to 'unknown-project' to avoid empty values.
  • Ensured correct extraction of projectName for GraphQL contributors.

This should prevent conflicts where contributors in the same position across projects could end up with duplicate tooltip IDs.

@rishyym0927 rishyym0927 requested review from arkid15r and kasya March 17, 2025 10:31
@arkid15r arkid15r marked this pull request as draft March 17, 2025 21:25
@rishyym0927 rishyym0927 marked this pull request as ready for review March 18, 2025 07:19
Copy link

Copy link
Collaborator

@arkid15r arkid15r left a comment

Choose a reason for hiding this comment

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

I suggest look into our backend internals to understand how to fix this properly on the frontend.

@arkid15r arkid15r marked this pull request as draft March 18, 2025 18:27
@arkid15r
Copy link
Collaborator

@rishyym0927 any updates on this? Are you going to complete it or we can close it?

@rishyym0927
Copy link
Contributor Author

@rishyym0927 any updates on this? Are you going to complete it or we can close it?

Yes im working on it!!

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.

Tooltip Collision for Contributors Across Multiple Projects
3 participants