Skip to content

Conversation

onesounds
Copy link
Contributor

@onesounds onesounds commented Apr 21, 2025

Improve SelectedIndex Retention on Query Updates and Context Menu Return

Summary

This PR improves the behavior of SelectedIndex to prevent it from resetting to 0 in the following scenarios:

By avoiding unnecessary index resets, the user experience becomes more consistent and intuitive.


Details

Main Changes

  • Retain SelectedIndex on context menu return:
    Previously, returning from a context menu caused the query to be re-applied, which reset the index to 0.
    A new logic now updates the QueryText without refreshing the result list, preventing index reset in this case.

  • Handle null QueryText:
    When QueryText becomes null, the stored index is now properly cleared.

  • Changed behavior for users with "retain query" mode enabled:
    Previously, the index would reset even if the query remained the same.
    Now, the index is preserved as long as the query is not cleared.
    This is considered more intuitive, so no setting toggle was added.


Additional Fixes

  • Prevent simultaneous display of context menu and result list during loading:
    A bug was discovered where opening the context menu before loading completed could result in both the context menu and results being shown at the same time.
    The update logic now checks for open context menus and skips result updates if one is active.

Test Cases

  • On initial launch, typing a query should place the index at 0.
  • There should never be a case where no result is selected (i.e., index must always be valid).
  • Opening and closing the context menu should not reset the selection.
  • Loading during search should no longer reset the index on completion.

During testing, there were a few instances where no index was selected, so further testing is needed.

@prlabeler prlabeler bot added the bug Something isn't working label Apr 21, 2025
Copy link

gitstream-cm bot commented Apr 21, 2025

🚨 Warning: Approaching Monthly Automation Limit

Monthly PRs automated: 249/250

Your organization has used over 90% of its monthly quota for gitStream automations. Once the quota is reached, new pull requests for this month will not trigger gitStream automations and will be marked as “Skipped”.

To avoid interruptions, consider optimizing your automation usage or upgrading your plan by contacting LinearB.

This comment has been minimized.

Copy link

gitstream-cm bot commented Apr 21, 2025

🥷 Code experts: Jack251970

Jack251970, onesounds have most 👩‍💻 activity in the files.
onesounds, Jack251970 have most 🧠 knowledge in the files.

See details

Flow.Launcher/MainWindow.xaml.cs

Activity based on git-commit:

Jack251970 onesounds
APR 19 additions & 8 deletions
MAR 1141 additions & 1076 deletions 327 additions & 141 deletions
FEB 1 additions & 1 deletions 8 additions & 4 deletions
JAN
DEC 5 additions & 10 deletions
NOV

Knowledge based on git-blame:
Jack251970: 63%
onesounds: 16%

Flow.Launcher/ViewModel/MainViewModel.cs

Activity based on git-commit:

Jack251970 onesounds
APR 35 additions & 28 deletions
MAR 695 additions & 628 deletions 293 additions & 201 deletions
FEB 63 additions & 21 deletions 23 additions & 25 deletions
JAN 17 additions & 21 deletions
DEC 59 additions & 63 deletions
NOV 39 additions & 15 deletions

Knowledge based on git-blame:
Jack251970: 30%
onesounds: 10%

Flow.Launcher/ViewModel/ResultsViewModel.cs

Activity based on git-commit:

Jack251970 onesounds
APR 4 additions & 5 deletions
MAR 8 additions & 6 deletions
FEB
JAN
DEC
NOV

Knowledge based on git-blame:
onesounds: 5%
Jack251970: 3%

To learn more about /:\ gitStream - Visit our Docs

Copy link

gitstream-cm bot commented Apr 21, 2025

Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX.

@onesounds
Copy link
Contributor Author

@coderabbitai Review it please.

Copy link
Contributor

coderabbitai bot commented Apr 21, 2025

Tip

For best results, initiate chat on the files or code changes.

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Get PR details (title, description, etc.)
gh pr view 3480 --json title,body,additions,deletions,changedFiles,commits,statusCheckRollup

# List files changed in the PR
gh pr view 3480 --json files --jq '.files[].path'

# Fetch the PR diff to see the changes
gh pr diff 3480

Length of output: 21322


🏁 Script executed:

#!/bin/bash
# Get the content of the changed files
echo "### MainWindow.xaml.cs"
cat Flow.Launcher/MainWindow.xaml.cs

echo -e "\n\n### MainViewModel.cs"
cat Flow.Launcher/ViewModel/MainViewModel.cs

echo -e "\n\n### ResultsViewModel.cs"
cat Flow.Launcher/ViewModel/ResultsViewModel.cs

Length of output: 105307


@onesounds I've reviewed PR #3480 "Remember selected position" and it looks like a solid implementation.

The PR addresses an important UX improvement by preventing the selected index from resetting to 0 in two key scenarios:

  1. When query results finish loading during a search
  2. When returning to the results after using a context menu

The implementation uses a comprehensive approach to track and restore the selection:

  • Storing both the selected item and index before navigation
  • Attempting to restore the exact same item if it still exists after updates
  • Falling back to the same index position if the item isn't found
  • Ensuring a valid selection is always maintained

The code is well-structured with proper validation and edge case handling. The use of a flag to suppress query execution when returning from context menus is an elegant solution to prevent index reset.

This change will definitely improve the user experience by making the selection behavior more predictable and preventing frustrating position resets.

Copy link
Contributor

coderabbitai bot commented Apr 21, 2025

📝 Walkthrough

"""

Walkthrough

This update introduces mechanisms to better manage the selection state and query execution flow in the application's main window and view models. It adds logic to reset the selected result index when the query text is cleared, enhances the ability to suppress query execution during certain UI state changes, and improves the restoration of previously selected items when switching between query results and context menus. The update also simplifies result update logic and refines visibility management based on the presence of results.

Changes

File(s) Change Summary
Flow.Launcher/MainWindow.xaml.cs Added logic to reset the selected index of results when the query text is cleared or empty in the QueryTextBox_TextChanged1 event handler.
Flow.Launcher/ViewModel/MainViewModel.cs Introduced _blockQueryExecution to control query execution, updated ChangeQueryText and ChangeQueryTextAsync to allow suppressing query execution, improved selected item restoration when switching result views, and simplified result update logic.
Flow.Launcher/ViewModel/ResultsViewModel.cs Added fields to track last selected item and index, implemented ResetSelectedIndex, improved logic for preserving/restoring selection during result updates, and refactored visibility management based on results.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant MainWindow
    participant MainViewModel
    participant ResultsViewModel

    User->>MainWindow: Changes query text
    MainWindow->>MainViewModel: Update QueryText
    alt Query text is empty
        MainWindow->>ResultsViewModel: ResetSelectedIndex
    end
    MainWindow->>MainViewModel: Query (with delay)
    MainViewModel->>MainViewModel: Check _blockQueryExecution
    alt Not blocked
        MainViewModel->>ResultsViewModel: AddResults
        ResultsViewModel->>ResultsViewModel: Restore selection if possible
    end
Loading

Assessment against linked issues

Objective Addressed Explanation
Preserve current selection when loading completes during global search, preventing reset to first item (#3464) Selection preservation and restoration logic added in ResultsViewModel prevents unwanted resets.

Possibly related PRs

  • Flow-Launcher/Flow.Launcher#3240: Modifies MainViewModel methods for query text changes and execution control, focusing on handling query and selection state transitions between query results and context menus.

Suggested labels

kind/ui

Poem

In the warren of code where queries hop,
Selection now remembers where you stop.
When results are refreshed or queries are new,
The right item is waiting—no need to redo!
With index resets and logic refined,
This bunny’s delighted with what you’ll find.
🐇✨
"""


📜 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 a97561e and ab35149.

📒 Files selected for processing (2)
  • Flow.Launcher/MainWindow.xaml.cs (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (9 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • Flow.Launcher/MainWindow.xaml.cs
  • Flow.Launcher/ViewModel/MainViewModel.cs
⏰ 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
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: 2

🧹 Nitpick comments (5)
Flow.Launcher/MainWindow.xaml.cs (1)

1128-1134: Avoid duplicating selection‑reset logic – delegate to ViewModel only

QueryTextBox_TextChanged1 now resets the selected index every time the box becomes empty.
The same action is already performed in MainViewModel.ChangeQueryTextAsync (lines 663‑667) and – thanks to the new ResultsViewModel.ResetSelectedIndex – can be triggered from there alone. Executing it twice is harmless but unnecessary work and increases the risk of future divergence.

-            // Reset Index when query null
-            if (string.IsNullOrEmpty(textBox.Text))
-            {
-                _viewModel.Results.ResetSelectedIndex();
-            }
+            // Index is reset by MainViewModel when needed
Flow.Launcher/ViewModel/ResultsViewModel.cs (1)

220-279: Potential performance hot‑spot – lock granularity

UpdateResults holds _collectionLock while updating the whole collection and while running the reselection algorithm (lines 229‑249).
The collection update already executes in Results.Update, which internally locks again; keeping the outer lock around additional work unnecessarily blocks other producer threads (e.g., concurrent plugin result updates).

Moving the reselection logic after the update call – once the collection is in a stable state – will shorten the critical section:

 lock (_collectionLock)
 {
-    Results.Update(newResults, token);
-    // reselection logic …
+    Results.Update(newResults, token);
 }
+// reselection logic …
Flow.Launcher/ViewModel/MainViewModel.cs (3)

663-667: Duplicate index reset – keep logic in one place

ChangeQueryTextAsync resets the index when the new text is empty.
Because MainWindow.QueryTextBox_TextChanged1 already does (or will after refactor) and ResultsViewModel.ResetSelectedIndex can be invoked from outside, consider removing one of the two to avoid maintenance overhead.

No code diff provided because you may decide which layer should own this responsibility.


708-748: Persisting selection across views – guard against collection shrink

When returning from the context menu you restore the previous item or index (👍).
However, if plugins updated the results while the menu was open, _lastSelectedIndex may now be out of bounds. You already check its upper bound but not that the list still contains at least one element (could be zero).

-else if (_lastSelectedResultIndex >= 0 && _lastSelectedResultIndex < Results.Results.Count)
+else if (Results.Results.Count > 0 &&
+         _lastSelectedResultIndex >= 0 &&
+         _lastSelectedResultIndex < Results.Results.Count)

1088-1100: Early return controlled by _blockQueryExecution may drop legitimate user queries

_blockQueryExecution is a single Boolean shared by several code paths.
If a long‑running async method schedules QueryAsync after you set _blockQueryExecution = true, there is a chance the flag is reset before the delayed call executes, letting the query through unexpectedly. Conversely, if it remains true longer than intended, it may discard a user‑typed query.

Consider using a more scoped mechanism, e.g. a SemaphoreSlim or an incrementing token, so you can reliably detect “my suppression period” instead of a global flag.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 09723c2 and 675581f.

📒 Files selected for processing (3)
  • Flow.Launcher/MainWindow.xaml.cs (1 hunks)
  • Flow.Launcher/ViewModel/MainViewModel.cs (7 hunks)
  • Flow.Launcher/ViewModel/ResultsViewModel.cs (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Flow.Launcher/MainWindow.xaml.cs (1)
Flow.Launcher/ViewModel/ResultsViewModel.cs (1)
  • ResetSelectedIndex (176-184)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: build

This comment has been minimized.

@onesounds
Copy link
Contributor Author

@copilot Review it

@onesounds onesounds requested a review from Copilot April 22, 2025 01:13
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR improves how the application retains the selected result index when a query is updated or when returning from the context menu, aiming to create a more consistent user experience.

  • Introduces a ResetSelectedIndex method and uses internal properties (_lastSelectedItem, _lastSelectedIndex) to cache and restore selections.
  • Updates ChangeQueryText and related asynchronous query logic to optionally suppress execution and preserve selection state on context menu returns.
  • Ensures that empty query strings trigger a reset of the selected index in both the view model and view layer.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
Flow.Launcher/ViewModel/ResultsViewModel.cs Adds selection retention logic and a ResetSelectedIndex method to avoid index resets.
Flow.Launcher/ViewModel/MainViewModel.cs Updates query text change handling with a new suppressQueryExecution flag and restores previous selection on context menu returns.
Flow.Launcher/MainWindow.xaml.cs Calls ResetSelectedIndex when the query becomes empty to ensure proper selection state.

This comment has been minimized.

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

🧹 Nitpick comments (2)
Flow.Launcher/ViewModel/ResultsViewModel.cs (2)

264-269: Redundant selection logic outside the lock.

This selection fallback logic is already implemented within the lock section above (lines 256-260). Having it both inside and outside the lock creates redundancy and potential race conditions where the selection could be set twice.

- // If no item is selected, select the first one
- if (Results.Count > 0 && (SelectedIndex == -1 || SelectedItem == null))
- {
-     SelectedIndex = 0;
-     SelectedItem = Results[0];
- }

271-290: Consider simplifying visibility management.

The visibility management logic has nested conditions that could be simplified. Additionally, there's more redundant selection logic that's already handled above.

 // Visibility update - fix for related issue
 if (Results.Count > 0)
 {
-    // 1. Always ensure index is valid when there are results
-    if (SelectedIndex == -1 || SelectedItem == null)
-    {
-        SelectedIndex = 0;
-        SelectedItem = Results[0];
-    }
-
-    // 2. Update visibility
     if (Visibility == Visibility.Collapsed)
     {
         Visibility = Visibility.Visible;
     }
 }
 else if (Visibility == Visibility.Visible && Results.Count == 0)
 {
     Visibility = Visibility.Collapsed;
 }
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between cc8b9e6 and 4d6dba4.

📒 Files selected for processing (1)
  • Flow.Launcher/ViewModel/ResultsViewModel.cs (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
Flow.Launcher/ViewModel/ResultsViewModel.cs (1)
Flow.Launcher/ViewModel/ResultViewModel.cs (2)
  • ResultViewModel (14-328)
  • ResultViewModel (21-63)
⏰ Context from checks skipped due to timeout of 90000ms (4)
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: gitStream.cm
  • GitHub Check: build
🔇 Additional comments (4)
Flow.Launcher/ViewModel/ResultsViewModel.cs (4)

26-27: Well-designed selection tracking system.

Adding these private fields to track the last selected item and index serves as the foundation for preserving selection state when navigating between views or during result updates. The default value of -1 for _lastSelectedIndex is appropriate as it indicates no selection.


176-187: Good implementation of ResetSelectedIndex method.

This method properly:

  1. Resets cached selection state
  2. Sets selection to the first item when results exist
  3. Raises property change notifications to update UI bindings

The addition of _lastSelectedItem = null addresses the previous review comment about preventing accidental reselection of stale items.


203-221: Thread-safe selection capture implemented correctly.

This code properly captures the current selection on the UI thread using Dispatcher.Invoke(), addressing the thread safety concern raised in a previous review comment. Storing both the item reference and index provides robust fallback options for selection restoration.


232-261: Comprehensive selection restoration strategy.

The implementation follows a well-thought-out prioritization:

  1. First attempt to find and select the exact same item
  2. Fall back to the same index position if the item is gone
  3. Default to the first item if necessary

This approach helps maintain a consistent user experience by preserving selection state as much as possible.

@onesounds onesounds added enhancement New feature or request kind/ux related to user experience labels Apr 22, 2025

This comment has been minimized.

{
_blockQueryExecution = true;
// Set querytext without running the query for keep index. if not use this, index will be 0.
_queryText = _queryTextBeforeLeaveResults;
Copy link
Member

Choose a reason for hiding this comment

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

why not just change QueryText

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I noted this in the PR description:

If you simply update the queryText, the index resets to 0 when the results are refreshed. The flow goes like this:

  1. Remember the previously selected item
  2. Open the context menu (which clears the query box text)
  3. Close the context menu (the previous query text is restored)

Even if the selected index is correctly remembered and restored at step 3, it becomes pointless because restoring the queryText causes the index to reset to 0 again.

_blockQueryExecution = false;
}
// restore selected item
if (Results.Results.Contains(_lastSelectedResultItem))
Copy link
Member

Choose a reason for hiding this comment

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

Would this be slow for large results? And I am curious when will Results not contains the last selected result item? Why not just use _lastSelectedIndex

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK. Modified it to work using only the index.

CancellationToken token;

// Block the query execution when Open ContextMenu is called
if (!QueryResultsSelected())
Copy link
Member

Choose a reason for hiding this comment

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

I don't understand here. Query shouldn't be executed when context menu is called? It will only call QueryContextMenu?

Copy link
Contributor Author

@onesounds onesounds Apr 23, 2025

Choose a reason for hiding this comment

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

I already mentioned this in the PR description. If you open the context menu while results are still loading, both the context menu and the results panel end up being shown once the loading finishes. Please read the PR description before review.

This comment has been minimized.

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)
Flow.Launcher/ViewModel/MainViewModel.cs (1)

1339-1345: Consider making this method private or internal

This method currently has public visibility but seems to be used only internally. Consider reducing its visibility scope unless there's a specific reason for it to be public.

-public void ResetSelectionIfQueryEmpty(string queryText)
+private void ResetSelectionIfQueryEmpty(string queryText)
📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between b544f20 and f3ded21.

📒 Files selected for processing (1)
  • Flow.Launcher/ViewModel/MainViewModel.cs (8 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build
🔇 Additional comments (9)
Flow.Launcher/ViewModel/MainViewModel.cs (9)

37-37: Good addition of the flag to control query execution

This boolean flag is key to the implementation, allowing suppression of query execution during certain UI state transitions, particularly when restoring state after returning from context menus.


642-645: Good enhancement to support suppression of query execution

Adding the suppressQueryExecution parameter allows for more granular control over when queries are executed during text changes, which is essential for maintaining selection state.


649-666: Properly implemented conditional query execution

The implementation correctly calls ResetSelectionIfQueryEmpty and conditionally runs the query only when suppressQueryExecution is false. This is critical for preserving the selected index when updating the query text.


684-686: Good approach to store selection state

Adding fields to track both the selected item and its index provides a robust mechanism for restoring selection when returning from context menus or other views.


695-701: Essential selection preservation logic

This code properly saves the current selection state when navigating away from query results, which is a key component of the PR's goal to remember selected positions.


714-734: Robust implementation of selection restoration

The try-finally block properly manages the query execution flag to prevent unnecessary queries. The restoration logic correctly handles both the query text and selected item/index when returning from the context menu.


1083-1084: Essential early return to block query execution

This check at the beginning of QueryAsync is critical for the implementation, allowing the system to skip query execution during controlled UI state transitions.


1658-1664: Important validation to prevent UI inconsistencies

These additional checks prevent updates when they shouldn't occur, particularly addressing the noted issue where both the context menu and result list could be shown simultaneously when a context menu is opened during loading.


1675-1679: Simpler, more maintainable result update logic

Replacing complex scoring and updating logic with a cleaner approach that leverages the enhanced selection preservation capabilities of ResultsViewModel. This approach is more maintainable and easier to understand.

This comment has been minimized.

This comment has been minimized.

@onesounds
Copy link
Contributor Author

@coderabbitai Review it.

Copy link
Contributor

coderabbitai bot commented Apr 23, 2025

Tip

For best results, initiate chat on the files or code changes.

@onesounds I've reviewed the PR and agree with the previous assessment that this is a solid implementation. Your changes address an important UX issue by maintaining selection state in two critical scenarios:

  1. When query results finish loading during a search
  2. When returning to the results after using a context menu

The technical implementation is particularly well-designed:

  • The _blockQueryExecution flag elegantly prevents unwanted query execution during UI transitions
  • Storing both the item and index provides a robust fallback mechanism for selection restoration
  • The priority-based restoration approach (exact item → same index → first item) ensures a valid selection is always maintained
  • Early returns and proper null checks prevent edge case bugs like the context menu/result list overlap issue

This implementation demonstrates careful consideration of the user experience and shows good attention to detail in handling all the edge cases. The code is well-structured and the changes are focused on solving the specific problem without unnecessary modifications.

This is a valuable improvement that will make the application feel more polished and predictable for users.

This comment has been minimized.

@Jack251970 Jack251970 added this to the Future milestone Apr 23, 2025
@onesounds onesounds enabled auto-merge April 23, 2025 14:42
@onesounds onesounds disabled auto-merge April 23, 2025 14:42
@Jack251970 Jack251970 modified the milestones: Future, 1.20.0 May 2, 2025
Copy link

github-actions bot commented May 2, 2025

@check-spelling-bot Report

🔴 Please review

See the 📂 files view, the 📜action log, or 📝 job summary for details.

❌ Errors and Warnings Count
❌ forbidden-pattern 24
⚠️ non-alpha-in-dictionary 19

See ❌ Event descriptions for more information.

Forbidden patterns 🙅 (1)

In order to address this, you could change the content to not match the forbidden patterns (comments before forbidden patterns may help explain why they're forbidden), add patterns for acceptable instances, or adjust the forbidden patterns themselves.

These forbidden patterns matched content:

s.b. workaround(s)

\bwork[- ]arounds?\b
If the flagged items are 🤯 false positives

If items relate to a ...

  • binary file (or some other file you wouldn't want to check at all).

    Please add a file path to the excludes.txt file matching the containing file.

    File paths are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your files.

    ^ refers to the file's path from the root of the repository, so ^README\.md$ would exclude README.md (on whichever branch you're using).

  • well-formed pattern.

    If you can write a pattern that would match it,
    try adding it to the patterns.txt file.

    Patterns are Perl 5 Regular Expressions - you can test yours before committing to verify it will match your lines.

    Note that patterns can't match multiline strings.

@onesounds
Copy link
Contributor Author

Fixed in #3503

@jjw24 jjw24 removed this from the Future milestone Jun 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

10 min review bug Something isn't working enhancement New feature or request kind/ux related to user experience

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Selection resets to first item when loading completes during global search

4 participants