Fix last opened result not showing in 'Empty Last Query' mode#4375
Fix last opened result not showing in 'Empty Last Query' mode#4375
Conversation
|
🥷 Code experts: Jack251970 Jack251970 has most 👩💻 activity in the files. See details
Activity based on git-commit:
Knowledge based on git-blame: ✨ Comment |
|
Be a legend 🏆 by adding a before and after screenshot of the changes you made, especially if they are around UI/UX. |
|
@coderabbitai full review. |
|
🧠 Learnings used✅ Actions performedFull review triggered. |
There was a problem hiding this comment.
Pull request overview
Fixes a timing issue in MainViewModel.OpenResultAsync where calling Hide() could trigger a re-query before the selected result was added to “last opened” history, causing the item to be missing in “Empty Last Query” mode (issue #4374).
Changes:
- Reorders
OpenResultAsyncto add selected results to history before conditionally callingHide(). - Consolidates the Dialog Jump left-click condition into a single local (
isDialogJumpLeftClick) and defersHide()until after history update. - Makes the hide behavior conditional so Dialog Jump left-click navigation doesn’t trigger a hide path.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
📝 WalkthroughWalkthroughReordered MainViewModel result-open flow: introduced Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@Flow.Launcher/ViewModel/MainViewModel.cs`:
- Around line 553-560: Move the call to _userSelectedRecord.Add(result) to occur
before calling Hide() because Hide() can trigger an immediate, asynchronous
re-query (in LastQueryMode.Empty and LastQueryMode.ActionKeyword*), and
UpdateResultView() reads _userSelectedRecord to score rebuilt results; change
the ordering in MainViewModel so _userSelectedRecord.Add(result) executes prior
to Hide() to avoid a race that can reopen with stale ranking.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 752a9fbf-49b1-4ef9-b64f-09defc641606
📒 Files selected for processing (1)
Flow.Launcher/ViewModel/MainViewModel.cs
There was a problem hiding this comment.
♻️ Duplicate comments (1)
Flow.Launcher/ViewModel/MainViewModel.cs (1)
553-560:⚠️ Potential issue | 🟡 MinorMove
_userSelectedRecord.Add(result)beforeHide()too.
Hide()is fire-and-forget here and can immediately re-query inLastQueryMode.EmptyandLastQueryMode.ActionKeyword*.UpdateResultView()then reads_userSelectedRecordon Lines 2302-2311 while rescoring rebuilt results, so this can still reopen with stale ranking even though the history write is now ordered correctly.🔧 Suggested ordering
if (queryResultsSelected) { _history.Add(result); lastHistoryIndex = 1; } + // Record user selected result for result ranking before any hide-triggered requery. + _userSelectedRecord.Add(result); + // Only hide for query results (not Dialog Jump left-click mode) if (!isDialogJumpLeftClick && hideWindow) { Hide(); } - - // Record user selected result for result ranking - _userSelectedRecord.Add(result);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@Flow.Launcher/ViewModel/MainViewModel.cs` around lines 553 - 560, Move the call that records the user selection so it executes before the asynchronous Hide() call: change the ordering in the click-handling block so _userSelectedRecord.Add(result) runs before calling Hide(), ensuring UpdateResultView() (which reads _userSelectedRecord during rescoring for LastQueryMode.Empty and LastQueryMode.ActionKeyword*) sees the new record; update the code around the current Hide()/_userSelectedRecord.Add(result) pair in MainViewModel (the click/result selection handling method) so the history write happens synchronously prior to invoking Hide().
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Duplicate comments:
In `@Flow.Launcher/ViewModel/MainViewModel.cs`:
- Around line 553-560: Move the call that records the user selection so it
executes before the asynchronous Hide() call: change the ordering in the
click-handling block so _userSelectedRecord.Add(result) runs before calling
Hide(), ensuring UpdateResultView() (which reads _userSelectedRecord during
rescoring for LastQueryMode.Empty and LastQueryMode.ActionKeyword*) sees the new
record; update the code around the current
Hide()/_userSelectedRecord.Add(result) pair in MainViewModel (the click/result
selection handling method) so the history write happens synchronously prior to
invoking Hide().
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 61b673b3-0165-4712-8531-53d8a33a5e54
📒 Files selected for processing (1)
Flow.Launcher/ViewModel/MainViewModel.cs
Fix last opened result not showing in 'Empty Last Query' query style mode after result is selected, and would only show when re-queried or clearing of a new query.
The cause is the Hide() call after result is actioned triggers a
QueryResultsAsyncwhich constructs the result list before the result is added to the last opened history items.Closing #4374
Summary by cubic
Fixes the bug where the last opened result didn’t appear in history in “Empty Last Query” mode by recording history before hiding the window. Keeps the window visible for Dialog Jump left-click to keep navigation smooth.
Summary of changes
Written for commit 654026e. Summary will update on new commits.