Skip to content

ui: fixed rules views selection and refreshing issues#1614

Open
redsies wants to merge 5 commits into
evilsocket:masterfrom
redsies:fix/rules-selection-master
Open

ui: fixed rules views selection and refreshing issues#1614
redsies wants to merge 5 commits into
evilsocket:masterfrom
redsies:fix/rules-selection-master

Conversation

@redsies

@redsies redsies commented Jun 6, 2026

Copy link
Copy Markdown

Selecting rules with the keyboard applied the selection to the previous row instead of the current one, so Edit/Delete from the contextual menu operated on the wrong rule. While debugging it I found a few more problems in the same area:

  • pressing the Down key raised an exception on every keypress
  • the focused row was lost every time the views refreshed
  • clicking on an empty area of a view removed the highlight, but the contextual menu kept operating on the previously selected rows
  • the rules contextual menu opened with no selection, and its actions failed silently

Fixed all of the above and added tests for the selection behaviour (ui/tests/customwidgets).

While I was in the same area I also fixed a few related issues with the rules views not refreshing correctly:

  • rules created from pop-ups, temporary rule expiration, or rules received when a node connects were not displayed until you interacted with the views (the periodic refresh is skipped while rows are selected); the views are now notified whenever rules are added/deleted/disabled in the db
  • while the rules editor was opened from a contextual menu, every table refresh was discarded, so saving a rule kept showing the old values until the editor was closed
  • changing the view query (filtering, paginating) while the scrollbar wasn't at the top or bottom kept displaying the rows of the previous query, so selections and menu actions didn't match what was shown
  • changing the action of an auto-named rule (e.g. reject -> allow) renamed it but the editor kept tracking the old name, so saving again wrongly reported "There's already a rule with this name"

Added regression tests for these as well. ref #1291

@redsies redsies changed the title ui: fixed rows selection and keyboard navigation issues ui: fixed rules views selection and refreshing issues Jun 21, 2026
redsies added 5 commits June 21, 2026 11:49
 - Fixed selecting rows with the keyboard. The selection was applied
   to the previous row instead of the current one, so actions from the
   contextual menu (edit, delete, etc) operated on the wrong rule.
 - Fixed exception pressing the Down key.
 - Keep the current row focused after refreshing the views.
 - Discard the selection when clicking on an empty area of a view.
   Previously the rows were no longer highlighted, but the actions
   kept operating on them.
 - Don't display the rules contextual menu when there's no selection,
   and don't swallow exceptions of the menu actions silently.
 - Added tests for the rows selection behaviour.
 - Misc: right click no longer activates the mouse-dragging selection
   logic, and fixed highlighting rows when selecting ranges from the
   db.

ref: evilsocket#1291
 - When the rules editor was opened from a contextual menu, the
   contextual-menu-active flag was kept set during the whole editor
   session, discarding every table refresh. Saving a rule updated the
   daemon and the db, but the views kept displaying the old values
   until the editor was closed.
 - When the query of a view changed (filtering the view by a word,
   paginating, etc) while the scrollbar was not at the top or bottom
   of the view, the viewport kept displaying the rows of the previous
   query. Selections and menu actions operated on the new result set,
   so they didn't match the rows displayed.
 - Added a regression test for the above.

ref: evilsocket#1291
 - Notify the views whenever rules are added, deleted or disabled in
   the db. Rules created from pop-ups, temporary rules expiration and
   rules received when a node connects were not displayed until
   interacting with the views, because the periodic refresh is skipped
   while there're rows selected.
 - Emit the notification once per batch when adding several rules, to
   avoid a refresh storm when a node connects.
 - Misc: moved the views update of the rules editor to the central
   rules class, and added tests for these notifications.
 - When the action of an auto-named rule was changed (e.g. reject to
   allow), the rule was renamed (reject-xxx -> allow-xxx), but the
   editor kept tracking the old name. Saving the rule again then
   wrongly reported "There's already a rule with this name", as it
   compared the renamed rule against itself.
 - Track the saved rule name instead of the one typed in the field,
   and stop mutating the rule object while deleting the old name.
 - Added a regression test.

ref: evilsocket#1291
@redsies redsies force-pushed the fix/rules-selection-master branch from ad937ca to 5045ccf Compare June 21, 2026 07:52
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