Skip to content

Feature: History context menu with delete & info item & Refactor context menu logic - #4609

Draft
Jack251970 wants to merge 6 commits into
devfrom
feature/history-context-menu-delete
Draft

Feature: History context menu with delete & info item & Refactor context menu logic#4609
Jack251970 wants to merge 6 commits into
devfrom
feature/history-context-menu-delete

Conversation

@Jack251970

@Jack251970 Jack251970 commented Aug 7, 2026

Copy link
Copy Markdown
Member
image

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:

  • Added a Remove method to the History class, allowing deletion of a single history entry or all matching entries, depending on the current history style (LastOpened or Query).
  • Added a "Delete" option to the context menu for history results, which uses the new Remove method and updates the UI accordingly.
  • Added a delete icon path (DeleteIcon) to Constant.cs for use in the context menu.

Context Menu Navigation and Refactoring:

  • Refactored context menu handling to support returning from the context menu to the previous results view, and to properly handle history results as context menu targets. [1] [2] [3] [4]
  • Allowed opening the context menu for history results from both the main results list and the dedicated history view, and ensured correct restoration of state when returning. [1] [2] [3]

Testing:

  • Added unit tests for the new Remove method in QueryHistoryTest.cs, covering both single and multiple entry deletion scenarios.

Internal API Changes:

  • Changed the visibility of HistorySelected() to internal to support broader usage in the codebase.

Minor Updates:

  • Added missing UTF-8 BOM to some files for consistency. [1] [2]

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

  • Changed
    • Context menu now toggles: opening stores source view and query; closing returns to them (incl. Esc).
    • Right arrow opens the context menu when a history or result item is selected and the caret is at the end.
    • Context menu uses the currently selected item (supports history) and restores preview on return; home page results refresh after deletion.
    • Made context menu flow fully async: introduced ReturnFromContextMenuAsync and awaited calls, including ChangeQueryText/UpdatePreview and delete action.
    • History items now carry ContextData so their context menu acts on the correct record; made HistorySelected internal for key handling.
  • Added
    • Delete and Info options for history items in the context menu.
    • History.Remove(...) to delete a single entry or all matching entries (for LastOpened style).
    • delete.png icon and DeleteIcon constant.
  • Removed
    • The restriction that blocked context menus for history results.
  • Memory impact
    • Minimal: a few new view-model fields and an icon.
  • Security
    • No new inputs or elevated actions; only local history mutation.
  • Tests
    • Added QueryHistoryTest covering single and multi-entry deletion.

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.

Review in cubic

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.
Copilot AI lite review requested due to automatic review settings August 7, 2026 08:29
@github-actions github-actions Bot added this to the 2.2.0 milestone Aug 7, 2026
@coderabbitai

coderabbitai Bot commented Aug 7, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

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

Changes

History context-menu flow

Layer / File(s) Summary
History removal contract and tests
Flow.Launcher/Storage/QueryHistory.cs, Flow.Launcher.Test/QueryHistoryTest.cs
History.Remove supports single-entry removal and removal of matching entries. Tests verify removal counts and remaining entries.
Context-menu state and navigation
Flow.Launcher/ViewModel/MainViewModel.cs, Flow.Launcher/MainWindow.xaml.cs
Context-menu navigation preserves the source view, query, selected result, and history item. Right Arrow and Escape handle history context menus.
History menu actions and persistence
Flow.Launcher/ViewModel/MainViewModel.cs, Flow.Launcher.Infrastructure/Constant.cs
History results expose delete and history-information actions. Deletion saves changed history and refreshes the appropriate view.

Estimated code review effort: 4 (Complex) | ~45 minutes

Possibly related PRs

Suggested reviewers: copilot, taooceros, onesounds

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
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the history context-menu feature and context-menu refactoring covered by the changeset.
Description check ✅ Passed The description directly explains history deletion, context-menu navigation, refactoring, and related tests.
✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feature/history-context-menu-delete

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

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

@Jack251970 Jack251970 removed this from the 2.2.0 milestone Aug 7, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

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 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 DeleteIcon constant 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.

@Jack251970 Jack251970 added enhancement New feature or request Code Refactor labels Aug 7, 2026
@Jack251970
Jack251970 marked this pull request as draft August 7, 2026 08:35
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Code Refactor enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants