Feature: History context menu with delete & info item & Refactor context menu logic - #4609
Feature: History context menu with delete & info item & Refactor context menu logic#4609Jack251970 wants to merge 6 commits into
Conversation
Implemented Remove method in QueryHistory to delete entries. Added delete icon and context menu option in MainViewModel. Updated Constant.cs for icon reference. Added unit tests for single and multiple entry removal.
Remember and restore previous results view and query text when opening/closing the context menu. Add fields to track context menu state. Refactor context menu logic for regular/history results. Implement ReturnFromContextMenu() to centralize UI restoration. Update Esc command to close context menu and restore state. Improve context menu population and handle history result deletion with results refresh.
Added a "History Info" option to the history item context menu in MainViewModel. The new ContextMenuHistoryInfo method creates this entry, allowing users to view information about a history item. The menu now includes both "Delete History" and "History Info" options.
The context menu now loads when a history item is selected and the caret is at the end of the text box, in addition to query results. Made HistorySelected internal in MainViewModel.cs to enable this behavior from MainWindow.xaml.cs.
📝 WalkthroughWalkthroughThe change adds history-entry removal, history-specific context-menu actions, and context restoration. Right Arrow opens context menus for history selections when the caret is at the query end. Escape returns from context menus before changing views or hiding the launcher. ChangesHistory context-menu flow
Estimated code review effort: 4 (Complex) | ~45 minutes Possibly related PRs
Suggested reviewers: Sequence Diagram(s)sequenceDiagram
participant MainWindow
participant MainViewModel
participant History
MainWindow->>MainViewModel: Open context menu for selected history result
MainViewModel->>History: Remove history item
History-->>MainViewModel: Return removal count
MainViewModel->>History: Save updated history
MainViewModel-->>MainWindow: Restore source view and refresh results
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 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.
Pull request overview
This PR enhances Flow Launcher’s history UX by adding a dedicated context menu for history results (with delete and info actions) and refactors context menu navigation so users can reliably return to the prior results view (query results vs. history) after interacting with the context menu.
Changes:
- Added deletion support for history entries via
History.Remove(...)and surfaced it as a “Delete” context menu item for history results. - Refactored context menu flow to preserve/restore the originating results view and target item for context menu generation.
- Added unit tests covering single-entry and “remove all matching” deletion behavior; added a
DeleteIconconstant for UI usage.
Reviewed changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| Flow.Launcher/ViewModel/MainViewModel.cs | Refactors context menu navigation, adds history context menu items (delete/info), and wires deletion + UI refresh behavior. |
| Flow.Launcher/Storage/QueryHistory.cs | Adds History.Remove(...) to support deleting individual history entries or all matching entries. |
| Flow.Launcher/MainWindow.xaml.cs | Enables opening context menu from the history view via keyboard (Right arrow). |
| Flow.Launcher.Test/QueryHistoryTest.cs | Adds unit tests for the new history removal behavior. |
| Flow.Launcher.Infrastructure/Constant.cs | Introduces DeleteIcon path for the new context menu item icon. |
Suppressed comments (1)
Flow.Launcher/ViewModel/MainViewModel.cs:1894
- The lambda parameter in the delete-history context menu action is unused. Using
_ =>makes this explicit and avoids unused-parameter warnings from analyzers.
OriginQuery = result.OriginQuery
};
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Refactored ReturnFromContextMenu to ReturnFromContextMenuAsync and updated all call sites to use await. Related methods like ChangeQueryText and UpdatePreviewAsync are now awaited. Updated context menu delete action to use an async lambda, ensuring UI and data updates complete asynchronously before proceeding.
This pull request adds the ability to delete individual or all matching history entries from the context menu, improves context menu navigation for history results, and introduces related tests and refactoring. The most important changes are summarized below.
History Deletion Feature:
Removemethod to theHistoryclass, allowing deletion of a single history entry or all matching entries, depending on the current history style (LastOpenedorQuery).Removemethod and updates the UI accordingly.DeleteIcon) toConstant.csfor use in the context menu.Context Menu Navigation and Refactoring:
Testing:
Removemethod inQueryHistoryTest.cs, covering both single and multiple entry deletion scenarios.Internal API Changes:
HistorySelected()to internal to support broader usage in the codebase.Minor Updates:
Summary by cubic
Adds a context menu to history items with Delete and Info. The context menu now opens from results or history, restores your previous view and query on close (incl. Esc), and the whole flow is now fully async for reliable UI updates.
Summary of changes
delete.pngicon andDeleteIconconstant.Release Note
You can open a context menu on history items to delete them or view info, and the app returns you to your previous view after closing the menu.
Written for commit 5876575. Summary will update on new commits.