Skip to content

Conversation

@illia1f
Copy link
Contributor

@illia1f illia1f commented Dec 23, 2025

Description

Fix project picker highlight to match current selection. Resolves issue #224.

How it works

When the dropdown opens (isProjectPickerOpen becomes true), we search filteredProjects for the project matching currentProject.id and set selectedProjectIndex to that position. If not found (e.g., filtered out by search), we keep the default index.

Test plan

  1. Open the project picker with a non-first project selected
  2. Verify the highlighted item matches the checkmarked item
  3. Use arrow keys to navigate and confirm behavior is correct
  4. Type in search box and verify filtering still works
  5. Close and reopen dropdown to verify highlight resets correctly

Summary by CodeRabbit

  • Bug Fixes
    • Project picker now reliably highlights the currently selected project when opened.
    • Selection index resets on close and is restored to the active project when reopened.
    • Search/filter behavior improved so the active project is preserved and reflected correctly in filtered results.
    • Opening the picker focuses the search input to streamline re-selection.

✏️ Tip: You can customize this high-level summary in your review settings.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @illia1f, 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 addresses an issue where the project picker dropdown would incorrectly highlight the first item by default, rather than the currently selected project. The changes ensure that when the dropdown is opened, the active project is automatically highlighted, significantly improving the user experience and navigation within the project selection interface.

Highlights

  • Propagate currentProject: The currentProject is now passed as a prop to the useProjectPicker hook, enabling the hook to be aware of the currently selected project.
  • Dynamic Highlight on Dropdown Open: The useProjectPicker hook has been updated to automatically highlight the currentProject within the dropdown list when the project picker is opened. If the currentProject is not found (e.g., due to filtering), the highlight defaults to the first item.

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

@coderabbitai
Copy link

coderabbitai bot commented Dec 23, 2025

Walkthrough

Passes the currently selected project into the project-picker hook; the hook uses it to find and set the selected index within filtered results when the picker opens, and continues to reset search and selection when the picker closes.

Changes

Cohort / File(s) Change Summary
Project picker hook & consumer
apps/ui/src/components/layout/sidebar/components/project-selector-with-options.tsx, apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts
Added `currentProject: Project

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related issues

  • Issue #224: Fixes selection behavior by passing currentProject to useProjectPicker and selecting it when the dropdown opens.

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: fixing the project picker dropdown to highlight the current project instead of the first item, which matches the file changes and PR objectives.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between a398367 and 50a595a.

📒 Files selected for processing (1)
  • apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

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 an issue where the project picker dropdown didn't highlight the currently selected project upon opening. The changes correctly pass the currentProject to the useProjectPicker hook and add logic to find and set the selected index when the dropdown is opened. My review includes a suggestion to refactor two related useEffect hooks into a single, more maintainable hook to simplify state management.

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

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 524a973 and e70c3b7.

📒 Files selected for processing (2)
  • apps/ui/src/components/layout/sidebar/components/project-selector-with-options.tsx
  • apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts
🧰 Additional context used
🧬 Code graph analysis (1)
apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts (1)
apps/ui/src/components/layout/sidebar/hooks/index.ts (1)
  • useProjectPicker (6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e
🔇 Additional comments (2)
apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts (1)

4-18: LGTM! Interface and parameters correctly updated.

The addition of currentProject to the interface and hook parameters is well-typed and properly integrated.

apps/ui/src/components/layout/sidebar/components/project-selector-with-options.tsx (1)

64-76: LGTM! Hook call correctly updated.

The currentProject parameter is properly passed to useProjectPicker, matching the updated hook signature.

@illia1f
Copy link
Contributor Author

illia1f commented Dec 23, 2025

Now, when the dropdown opens, it finds the currently selected project in the list and highlights that item.
image

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

🧹 Nitpick comments (1)
apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts (1)

32-34: Remove unnecessary useCallback wrapper.

The getCurrentProjectIndex function is a simple operation that's only called inside effects (not passed as a prop or returned). Using useCallback here:

  1. Adds unnecessary overhead
  2. Creates dependency management issues with the effects that use it
  3. Will trigger ESLint exhaustive-deps warnings
🔎 Proposed refactor
-  const getCurrentProjectIndex = useCallback(() => {
+  const getCurrentProjectIndex = () => {
     return currentProject ? filteredProjects.findIndex((p) => p.id === currentProject.id) : -1;
-  }, [currentProject, filteredProjects]);
+  };
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e70c3b7 and 38f2e0b.

📒 Files selected for processing (1)
  • apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts
🧰 Additional context used
🧬 Code graph analysis (1)
apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts (1)
apps/ui/src/components/layout/sidebar/hooks/index.ts (1)
  • useProjectPicker (6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e
🔇 Additional comments (2)
apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts (2)

4-10: LGTM: Props and parameters updated correctly.

The addition of currentProject to the props and parameters is the necessary foundation for fixing the highlight behavior. The nullable type correctly handles the case where no project is selected.

Also applies to: 12-18


1-123: Overall: Excellent fix that achieves the PR objectives.

The implementation correctly addresses issue #224 by ensuring the dropdown highlights the currently selected project when opened. The core logic flows are sound:

  1. ✅ Dropdown opens → highlights current project
  2. ✅ User searches → resets to first filtered item
  3. ✅ Search cleared → returns to current project
  4. ✅ Dropdown closes → resets state

The refactoring suggestions above are about improving code quality and following React best practices, but the current implementation will work correctly for the documented test cases.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts (1)

50-67: Edge case: highlight won't update if currentProject changes while dropdown is open.

The current dependency array [isProjectPickerOpen] is intentionally minimal to prevent the effect from re-running on every keystroke (which would happen if filteredProjects were included). However, this creates a minor edge case:

Scenario: If currentProject changes externally (e.g., via sync) while the dropdown is open and there's no active search, the highlight won't update to reflect the new current project until the dropdown is closed and reopened.

Trade-off analysis:

  • Current approach: Prevents unwanted re-runs during search
  • ⚠️ Edge case: Stale highlight if current project changes while dropdown is open
  • Severity: Minor UX inconsistency in a rare scenario

Note: The ESLint exhaustive-deps rule will warn about getCurrentProjectIndex not being in dependencies. This is safe because the function is recreated each render with the latest closure values, so when the effect runs (on isProjectPickerOpen change), it always uses current values.

🔎 Options to address

Option 1: Accept the trade-off and document it (recommended for "Chill" review mode)

Add an ESLint disable comment with explanation:

+  // Note: getCurrentProjectIndex uses currentProject and filteredProjects but they're intentionally
+  // not in dependencies to avoid re-running on every keystroke. The effect correctly uses current
+  // values when isProjectPickerOpen changes.
+  // eslint-disable-next-line react-hooks/exhaustive-deps
   }, [isProjectPickerOpen]);

Option 2: Handle the edge case with a separate effect (if real-time sync is important)

Add after this effect:

// Update highlight if current project changes while dropdown is open (no search)
useEffect(() => {
  if (isProjectPickerOpen && !projectSearchQuery.trim()) {
    const currentIndex = getCurrentProjectIndex();
    if (currentIndex !== -1) {
      setSelectedProjectIndex(currentIndex);
    }
  }
  // eslint-disable-next-line react-hooks/exhaustive-deps
}, [isProjectPickerOpen, currentProject]);
🧹 Nitpick comments (1)
apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts (1)

32-34: Consider memoizing with useCallback for consistency.

While the current implementation works correctly, wrapping getCurrentProjectIndex in useCallback would:

  1. Satisfy React's exhaustive-deps lint rule without false warnings
  2. Make the dependency relationships explicit
  3. Avoid recreating the function on every render
🔎 Proposed refactor
-  const getCurrentProjectIndex = () => {
+  const getCurrentProjectIndex = useCallback(() => {
     return currentProject ? filteredProjects.findIndex((p) => p.id === currentProject.id) : -1;
-  };
+  }, [currentProject, filteredProjects]);
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 38f2e0b and a398367.

📒 Files selected for processing (1)
  • apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts
🧰 Additional context used
🧬 Code graph analysis (1)
apps/ui/src/components/layout/sidebar/hooks/use-project-picker.ts (1)
apps/ui/src/components/layout/sidebar/hooks/index.ts (1)
  • useProjectPicker (6-6)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: e2e

@webdevcody webdevcody merged commit 870df88 into AutoMaker-Org:main Dec 23, 2025
5 of 6 checks passed
@illia1f illia1f deleted the fix/project-picker-dropdown branch December 23, 2025 08:06
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.

2 participants