Skip to content

Bug fix button#137

Merged
BaseMax merged 23 commits into
john-bampton:mainfrom
NssGourav:bug_fix_button
Dec 21, 2025
Merged

Bug fix button#137
BaseMax merged 23 commits into
john-bampton:mainfrom
NssGourav:bug_fix_button

Conversation

@NssGourav

Copy link
Copy Markdown
Contributor

shihabhasan0161 and others added 3 commits December 18, 2025 22:13
* Fix the loading state by removing display: flex !important

* add display: flex

* Change style.display from block to flex

* Update docs/script.js

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

---------

Co-authored-by: Max Base <MaxBaseCode@Gmail.Com>
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @NssGourav, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request resolves an issue with the 'I'm Feeling Lucky' button, ensuring it functions as expected by accurately selecting and highlighting a random user from the currently displayed and sorted list. The changes improve the reliability of this feature by updating the underlying data source for user selection and refining the DOM manipulation for highlighting, providing a more consistent user experience.

Highlights

  • Bug Fix: Fixed a bug in the 'I'm Feeling Lucky' button where it was not correctly picking and highlighting users, especially after filtering or sorting.
  • User Selection Logic: The pickRandomUser function now utilizes a new getVisibleSortedUsers function to ensure it selects from the currently filtered and sorted list of users, rather than potentially outdated data.
  • DOM Interaction: Improved the highlighting mechanism by directly querying the DOM for the user's card using its data-login attribute and ensuring any previous highlights are removed before applying a new one.
  • New Functionality: Introduced getVisibleSortedUsers to centralize the logic for retrieving users based on the current display filters and sort order.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request successfully addresses the bug with the "I'm Feeling Lucky" button by correctly using the filtered and sorted list of users. The change to query the DOM for the user's card instead of relying on a pre-existing property makes the implementation more robust. I've identified a high-severity race condition in the new highlighting logic that could lead to multiple cards being highlighted at once and have provided a suggestion to resolve it.

Comment thread docs/script.js Outdated

@NssGourav NssGourav left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Resolved

@jbampton jbampton self-assigned this Dec 18, 2025
@jbampton jbampton added this to Turbo Dec 18, 2025
@jbampton jbampton moved this to In Progress in Turbo Dec 18, 2025
@jbampton jbampton added this to the December 2025 milestone Dec 18, 2025
@jbampton

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request successfully fixes the "I'm Feeling Lucky" button bug by correctly using the filtered and sorted user data. The changes also improve the highlighting logic by querying the DOM for the user card and clearing any previous highlights, making it more robust. I've included a couple of minor suggestions to improve code style and simplify a new helper function.

Comment thread docs/script.js Outdated
Comment thread docs/script.js Outdated
@NssGourav

Copy link
Copy Markdown
Contributor Author

@BaseMax please review

@jbampton jbampton 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.

If we are only updating JS code why do we need to delete avatars ?

@jbampton jbampton marked this pull request as draft December 19, 2025 15:00
@NssGourav

Copy link
Copy Markdown
Contributor Author

If we are only updating JS code why do we need to delete avatars ?

yeah to resolve merge conflicts that has been done else it's not req to delete

@NssGourav NssGourav marked this pull request as ready for review December 19, 2025 15:03
@jbampton

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request correctly aims to fix the "I'm Feeling Lucky" button by using the filtered and sorted list of users. The new getVisibleSortedUsers function is a good addition. However, I've found a few critical issues that will prevent this from working as intended. I've added a specific comment for a bug introduced in the diff. Additionally, there are two other issues to address:

  • The variable usersToPickFrom is used on lines 72 and 73 but is no longer defined. It should be replaced with visibleSortedUsers.
  • There seems to be a pre-existing issue where randomUser.card is always undefined because the card element is never assigned to the user object. You may need to add user.card = card; in the renderCards function for the highlighting to work.

Fixing these issues should make the feature fully functional.

Comment thread docs/script.js Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@NssGourav

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request aims to fix a bug in the "I'm Feeling Lucky" button by ensuring it uses the correctly filtered and sorted list of users. The introduction of the getVisibleSortedUsers function is a good step towards this. However, the implementation in pickRandomUser has a critical bug where a variable was renamed, but not all its usages were updated, which will lead to a runtime error. I've provided a suggestion to fix this.

Comment thread docs/script.js Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@jbampton

Copy link
Copy Markdown
Member

Did you test this locally ?

@jbampton

Copy link
Copy Markdown
Member

For me the button does not work

@jbampton

jbampton commented Dec 19, 2025

Copy link
Copy Markdown
Member

Some local testing bug. But this does not happen on live

image

@NssGourav

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request successfully fixes the 'I'm Feeling Lucky' button by ensuring it selects a random user from the correctly filtered and sorted list. The added fallback logic for finding user cards and caching them on creation are great improvements for robustness and performance. I've included a couple of suggestions to further improve the code by refactoring duplicated logic and removing a potentially problematic try...catch block. Overall, this is a solid contribution that addresses the bug effectively.

Comment thread docs/script.js Outdated
Comment thread docs/script.js Outdated
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
@NssGourav

Copy link
Copy Markdown
Contributor Author

/gemini review

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request fixes the 'I'm Feeling Lucky' button by correctly using the filtered and sorted user data, which is a great improvement. The logic is now much more robust.

I have a couple of suggestions to further improve the code:

  • I've pointed out a potential issue with stale DOM references that could lead to a silent failure. A small addition can make the feature even more robust.
  • I also noticed some code duplication for showing toast notifications, and I've suggested refactoring it into a helper function to improve maintainability.

Overall, these are solid changes that fix the reported bug. Addressing my comments will make the code even better.

Comment thread docs/script.js Outdated
Comment thread docs/script.js Outdated
NssGourav and others added 3 commits December 20, 2025 00:15
Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>

@BaseMax BaseMax 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.

ok

@BaseMax

BaseMax commented Dec 21, 2025

Copy link
Copy Markdown
Member

Can you please run pre-commit on your branch and push?

@BaseMax

BaseMax commented Dec 21, 2025

Copy link
Copy Markdown
Member

@BaseMax

BaseMax commented Dec 21, 2025

Copy link
Copy Markdown
Member

/gemini review

@gemini-code-assist gemini-code-assist 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.

Code Review

This pull request refactors the user selection logic in docs/script.js to enhance robustness and maintainability. The pickRandomUser function now utilizes a new getVisibleSortedUsers helper to ensure it selects from the currently filtered and sorted list of users. A significant improvement was added to pickRandomUser to handle scenarios where a user's card might not be directly available or connected to the DOM; it now includes a fallback search by data-login and displays a toast notification if the card remains unlocatable. Furthermore, the buildCardElement function was updated to store the created card directly on the user object for more efficient access. A review comment highlighted code duplication in docs/script.js regarding the toast notification logic, suggesting its extraction into a reusable helper function. Additionally, across fetch.py and render.py, all f-string logging statements were converted to use standard string formatting for consistency.

Comment thread docs/script.js Outdated
Comment on lines +84 to +89
const msg = document.createElement('div');
msg.className = 'toast-notification';
msg.textContent = '🎲 Could not locate the selected developer card. Try again.';
document.body.appendChild(msg);
setTimeout(() => msg.remove(), 3000);
return;

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.

medium

This block of code for creating a toast notification is very similar to the one on lines 62-66. To avoid code duplication and improve maintainability, you could extract this logic into a helper function. For example:

function showToast(message) {
    const msg = document.createElement('div');
    msg.className = 'toast-notification';
    msg.textContent = message;
    document.body.appendChild(msg);
    setTimeout(() => msg.remove(), 3000);
}

You could then call showToast('🎲 Could not locate the selected developer card. Try again.'); here and showToast('🎲 No developers found! Try adjusting your filters.'); on line 64.

@BaseMax

BaseMax commented Dec 21, 2025

Copy link
Copy Markdown
Member

It's long time we missed the functionality while we have the "random" button on the production site. it's not good.

@BaseMax

BaseMax commented Dec 21, 2025

Copy link
Copy Markdown
Member

Where message variable has been defined?

image

- Created showToast() helper function to avoid code duplication
- Replaced duplicate toast notification code in pickRandomUser()
- Improves maintainability and follows DRY principle
@NssGourav

Copy link
Copy Markdown
Contributor Author

Where message variable has been defined?

image

Oops 😬 missed defining message.That one’s on me thanks for the sharp eyes , pushing a fix

@NssGourav

Copy link
Copy Markdown
Contributor Author

It's long time we missed the functionality while we have the "random" button on the production site. it's not good.

Agreed this has been broken too long. I’ll prioritize and ship a fix for the random button right now

@BaseMax

BaseMax commented Dec 21, 2025

Copy link
Copy Markdown
Member

Yes I am checking, but please double check everything on your end and give me your final feedback here. I want to merge it sooner, so I can continue developing the project tonight.

Best and Happy Yalda night.

@NssGourav

Copy link
Copy Markdown
Contributor Author

Yes I am checking, but please double check everything on your end and give me your final feedback here. I want to merge it sooner, so I can continue developing the project tonight.

Best and Happy Yalda night.

All pre-commit checks pass on my end and I’ve incorporated the Gemini suggestions. Ready to merge

@BaseMax BaseMax merged commit 639992d into john-bampton:main Dec 21, 2025
5 of 6 checks passed
@github-project-automation github-project-automation Bot moved this from In Progress to Done in Turbo Dec 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

4 participants