Skip to content

Auto-selection of full hash matches and dropdown visibility improvements - #1

Open
moijes12 wants to merge 2 commits into
bug1986319-julesfrom
fix-hash-auto-select-1986319-244443538767991578
Open

Auto-selection of full hash matches and dropdown visibility improvements#1
moijes12 wants to merge 2 commits into
bug1986319-julesfrom
fix-hash-auto-select-1986319-244443538767991578

Conversation

@moijes12

@moijes12 moijes12 commented Jul 6, 2026

Copy link
Copy Markdown
Owner

This PR implements auto-selection for full and partial hash matches in the Search view, as requested in bug 1986319.

Key changes:

  • Auto-selection: If a search term is a hex hash (length >= 4) and matches exactly one result, or matches the full revision of a result, it is automatically selected.
  • Dropdown Visibility:
    • For full 40-character hashes, the dropdown now remains open after auto-selection to allow the user to see or change the selection.
    • When a user removes a selected revision from the view, the dropdown is automatically opened.
  • New Tests: A comprehensive test suite SearchAutoSelect.test.tsx was added to ensure correct behavior and prevent regressions.
  • Robustness: Prevents unintended auto-selections during initial page load when a revision is already provided in the URL.

Verified via npm run test-all and visual inspection using Playwright scripts.


PR created automatically by Jules for task 244443538767991578 started by @moijes12

- Automatically select a revision when a full 40-character hash or a partial hex hash (length >= 4) matches exactly one result or matches a result's revision hash.
- Ensure the revision dropdown remains open after auto-selecting a full 40-character hash.
- Automatically open the revision dropdown when a selected revision is removed from the view.
- Added a new test suite `src/__tests__/Search/SearchAutoSelect.test.tsx` to verify these behaviors.
- Updated existing snapshots in `src/__tests__/Search/__snapshots__`.

Co-authored-by: moijes12 <4566851+moijes12@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@moijes12
moijes12 changed the base branch from main to bug1986319-jules July 6, 2026 16:11
useEffect(() => {
if (displayedRevisions.length < prevDisplayedRevisionsCount.current) {
setIsDropdownOpen(true);
}

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@jules so this behavior is unwanted in the app. When a selected revision is removed from view, we don't want to open the revision dropdown. This also conflicts with closing the revision dropdown when the user clicks outside the component. We'll also have to remove the test for this behavior too.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I have removed the logic that programmatically opens the revision dropdown when a selected revision is removed from view. I have also removed the corresponding test case for this behavior to avoid any conflicts with standard dropdown interactions (like clicking outside).

const isPartialHash =
searchTerm.length >= 4 && /^[0-9a-fA-F]+$/.test(searchTerm);

if (

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@jules We want to select the revision after pasting the hash on the Results page too, so I'd remove this condition: !urlParams.has('newRev')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I have removed the !urlParams.has('newRev') condition. This ensures that the hash auto-selection works seamlessly on the Results page after a paste as well.

} else if (
results.length > 1 &&
(isPartialHash || isFullHash) &&
!urlParams.has('newRev')

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

@jules Same here. I'd remove this condition: !urlParams.has('newRev')

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I have removed the !urlParams.has('newRev') condition from this logic block as well.

@moijes12

Copy link
Copy Markdown
Owner Author

@jules Please see the comments I have raised and act accordingly

- Removed the logic that opens the dropdown when a selected revision is removed from the view, resolving conflicts with standard clicking outside interactions.
- Removed the test case for the dropdown opening upon revision removal.
- Removed the `!urlParams.has('newRev')` condition to allow hash auto-selection to work on the Results page after pasting a hash.
- Ran all tests successfully and updated snapshots.
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.

1 participant