Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Option to disable sorting when in tree view #399

Closed
jakem72360 opened this issue Dec 14, 2020 · 10 comments · Fixed by #411
Closed

Option to disable sorting when in tree view #399

jakem72360 opened this issue Dec 14, 2020 · 10 comments · Fixed by #411
Labels
enhancement Extension or improvement to existing feature

Comments

@jakem72360
Copy link

It would be nice if there was an option to disable sorting in tree view (reverting to previous functionality).

I routinely use the t key to toggle to tree view to find a specific process or it's children, and it's difficult to
follow now, with process groups constantly jumping around. Ideally, sorting should only be done in "Sorted"
mode, but I suppose you could implement it as a user-configurable option if someone really likes the idea of
sorting in tree view.

@BenBE
Copy link
Member

BenBE commented Dec 14, 2020

You can sort by PID in tree mode by pressing F6 for least distraction (which was also the previous behaviour implicitly). Also you may press Shift+Z to pause the gathering of process updates. Finally there's Shift+F to follow one particular process around. Does any of these options help with your usecase?

@BenBE BenBE added support request This is not a code issue but merely a support request. Please use the mailing list or IRC instead. enhancement Extension or improvement to existing feature and removed support request This is not a code issue but merely a support request. Please use the mailing list or IRC instead. labels Dec 14, 2020
@BenBE BenBE changed the title [Feature Request] Option to disable sorting when in tree view Option to disable sorting when in tree view Dec 16, 2020
@JoZie
Copy link

JoZie commented Dec 17, 2020

Thanks for the ongoing maintenance and new features!
But I have the same issue with the constant reordering of processes in the tree view.

Also you may press Shift+Z to pause the gathering of process updates.

This makes things worse. There seems to be more reordering than before. However it woks fine if I disable the tree view. Maybe there is a bug.

Finally there's Shift+F to follow one particular process around.

Although it helps, it's hard to select a particular process when it's constantly disappearing under the cursor.

You can sort by PID in tree mode by pressing F6 for least distraction (which was also the previous behaviour implicitly).

Currently that's my workaround. But this is quite cumbersome if you quickly switch in and out of the tree view.
Previously I setup the sorting, mostly using a shortcut like 'M'. Then I switch the tree view on and off, depending on if I want to apply sorting or not.

I guess a shortcut for 'sort by PID' is also a viable solution if you don't want to go back to the old behavior.

@BenBE
Copy link
Member

BenBE commented Dec 17, 2020

But I have the same issue with the constant reordering of processes in the tree view.

Also you may press Shift+Z to pause the gathering of process updates.

This makes things worse. There seems to be more reordering than before. However it woks fine if I disable the tree view. Maybe there is a bug.

The release version had a bug with the pause mode that is fixed on master. There the pause mode should work too, cf. #378.

I guess a shortcut for 'sort by PID' is also a viable solution if you don't want to go back to the old behavior.

The actual solution we want to implement for this issue hasn't been decided yet.

@hishamhm
Copy link
Member

hishamhm commented Dec 17, 2020

It would be nice if there was an option to disable sorting in tree view (reverting to previous functionality).

Oh, I'm glad not the only one who noticed this! I was afraid I was being too picky.

There are two behavior changes which I noticed that, combined, seem to have made it more difficult to pick processes in tree mode.

First, is the sorting behavior in tree mode. One habit that I just noticed that I had, because it stopped working in htop 3, was to click "CPU%" or "MEM%" on the title bar to exit tree mode and quickly see the top-consuming process at the top of the list. Now it's a two-step operation (exiting tree mode, switching sort order).

Second, is that it seems that the auto-temporary-pause in the sorting order when there is cursor movement seems to be missing. That temporary pause was deliberately added in order to help the user to aim at the correct process when performing a task. For example, if you select a process then press F7/F8 to renice it or F9 to kill it, s to strace it, etc., but then the sorting changes under your feet a millisecond before you type, you end up applying the action to the wrong process. (Upon further testing, it seems that the auto-pause is still present in non-tree view, but it's missing from sorted tree view, which jumps around under your feet).

As an end user, my 2 cents with regard to behavior would be to (1) add the auto-temporary-pause to sorted tree view, so that it matches regular view (I think this one is pretty important to avoid accidents), and (2) add Display Options toggles like [ ] Tree view is always sorted by PID which, when enabled, causes (a) entering and exiting tree view makes it return to the previously sorted list order, (b) selecting any sort order (via F6, P, M, T or clicking the header) to exit tree view. That flag would effectively restore htop 2 behavior for those of us used to it. :)

@fasterit
Copy link
Member

@hishamhm Greetings from the running team meeting, folks say I should remind you: patches accepted :-)
And kind regards and happy holidays!

@jakem72360
Copy link
Author

@BenBE My suggestion would be to have htop quietly remember the sorting mode for list and tree views separately. Switching to tree view, would set the sort mode to the last used sorting mode in tree view. Switching to list view would set the sort mode to the last used mode in list view.

A shortcut for PID sorting would also be nice (as well as showing the keybinds for sorting in the F1 help screen and not just the man page).

@BenBE
Copy link
Member

BenBE commented Dec 18, 2020

@BenBE My suggestion would be to have htop quietly remember the sorting mode for list and tree views separately. Switching to tree view, would set the sort mode to the last used sorting mode in tree view. Switching to list view would set the sort mode to the last used mode in list view.

I kinda like that idea. Will see how complicated this is to get into the source. As always: PRs appreciated. ;-)

(as well as showing the keybinds for sorting in the F1 help screen and not just the man page).

Pressing F6 is documented for sorting. Fixed some other documentation issues related to it though in 0401df8.

hishamhm added a commit that referenced this issue Dec 18, 2020
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. :)
@jakem72360
Copy link
Author

jakem72360 commented Dec 18, 2020

Pressing F6 is documented for sorting. Fixed some other documentation issues related to it though in 0401df8.

Sorry, I meant shortcuts like P, for entering CPU sorting mode directly, without bringing up the F6 sorting menu. I think it's a really neat keybind, but I discovered it only by accident, since it's not listed in the F1 help page, only the man page.

I kinda like that idea. Will see how complicated this is to get into the source. As always: PRs appreciated. ;-)

I can take a hint :) Unfortunately, I have very limited time atm, and the time required to familiarise oneself with each project's codebase, means that I have to pick my PR's carefully. I hope you can understand...

hishamhm added a commit that referenced this issue Dec 18, 2020
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. :)
hishamhm added a commit that referenced this issue Dec 18, 2020
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. :)
@BenBE
Copy link
Member

BenBE commented Dec 18, 2020

Pressing F6 is documented for sorting. Fixed some other documentation issues related to it though in 0401df8.

Sorry, I meant shortcuts like P, for entering CPU sorting mode directly, without bringing up the F6 sorting menu. I think it's a really neat keybind, but I discovered it only by accident, since it's not listed in the F1 help page, only the man page.

Just checked, it's there on master (left column, third from bottom).

I kinda like that idea. Will see how complicated this is to get into the source. As always: PRs appreciated. ;-)

I can take a hint :) Unfortunately, I have very limited time atm, and the time required to familiarise oneself with each project's codebase, means that I have to pick my PR's carefully. I hope you can understand...

Sure. I've been working on OSS for long enough, to know the various difficulties that come with it. :)

Would be glad if you could test #411, which should make the tree view experience much more enjoyable. ;-)

@jakem72360
Copy link
Author

#411 looks great, and works fine on my machine. If others are okay with this method, I'd say go for it.

Regarding the keybinds, I did decide to have a crack after-all. #413 has my proposed changes for a sort by PID shortcut.

BenBE pushed a commit that referenced this issue Dec 19, 2020
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. :)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Extension or improvement to existing feature
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants