New option "Tree view always by PID", replicating htop 2 behavior#411
New option "Tree view always by PID", replicating htop 2 behavior#411
Conversation
|
Can you have a look how much work implementing the suggestion from #399 (comment) to use different sort order for the list mode vs. tree mode would cause? With tree mode defaulting to PID? |
BenBE
left a comment
There was a problem hiding this comment.
I'm not quite happy with this patch effectively leaving us with two function callbacks for sorting in the platform structure where the first one is more or less always defaulting to a platform independent one. Can we get rid of that and just stick with the new one in its place?
* This removes duplicated code that adjusts the sort direction from every OS-specific folder. * Most fields in a regular htop screen are OS-independent, so trying Process_compare first and only falling back to the OS-specific compareByKey function if it's an OS-specific field makes sense. * This will allow us to override the sortKey in a global way without having to edit each OS-specific file.
6393baa to
8601177
Compare
Thanks to the previous commits, it was easy! 🎉 I still kept the "Tree view always by PID" option in the Settings, which results in some specific behaviors such as "clicking on the column header to exit tree view" and "picking a new sort order to exit tree view", for the sake of the muscle memory of long time htop users. :) 🙏 I also added a minor improvement to the handling of command-line arguments so that
I don't think so, because of the order of the logic that happens: the platform-specific fallback only really needs to run if the platform-agnostic one doesn't take care of the comparison, so it makes sense that |
8601177 to
73328c4
Compare
Implements the suggestion from #399 (comment) Thanks to the refactors from 0bd5c8f and 6393baa, this was really easy and clean to do. It maintains the "Tree view always by PID" option in the Settings, which results in some specific behaviors such as "clicking on the column header to exit tree view" and "picking a new sort order to exit tree view", for the sake of the muscle memory of long time htop users. :)
73328c4 to
b6b98ee
Compare
This acheives two things: - Allows for simple tie-breaking if values compare equal (needed to make sorting the tree-view stable) - Allows for platform-dependent overriding of the sort-order for specific fields Also fixes a small oversight on DragonFlyBSD when default-sorting.
b7d013e to
a9bd113
Compare
|
I like the patch, thank you very much @hishamhm. I'd prefer to drop the "- Tree view is always sorted by PID (htop 2 behavior)" option though as people can now select sorting for tree mode and list mode independently. That is very intuitive and provides the desired functionality. The option is quite confusing as you cannot sort in tree mode anymore unless you disable that, so it should be "- Tree view is always sorted by PID (htop 2 behavior) which also disables sorting in tree mode so selecting sort will force you back to list mode" to really explain what it does ... I think that's overly complicated and "surprising" behavior to the user. These surprises are not desirable, UIs should be intuitive and discoverable. The two options for sort are much better from a discoverability perspective and do everything we want already. What do you think, can we drop the configure option and the assorted logic in |
|
@fasterit The option restores previous behaviour (quick return to htop2 behaviour). For the sake of discoverability it shouldn't be default. Yet the wording might be better? Maybe |
All right, I was nerd-sniped by @fasterit into doing this :)
This implements part (2) of the comment I left here: #399 (comment)
I did not implement part (1) because I'm unfamiliar with new tree-sorting logic (which I think is the most important bit, actually, but it is not as severe when the new flag is enabled — the tree only moves when processes die, which is inevitable) and I figured that (2) would be a much quicker tweak.
In order to minimize the actual feature commit, I made a refactor in the Process_compare logic, which I think is actually beneficial. I inverted the resolution of the Process_compare operation so that the "superclass" logic runs first:
And hey, in the end this PR removes more lines than it adds! 😁
I believe this fixes #399, but then a new issue could be created for "Add auto-temp-pause in sorted tree view matching behavior of list view".
🎁 Happy holidays to the htop dev team! 🎄