Skip to content

Implement a click handler for Meters and make the thr/kthr counters in TasksMeter toggle thread visibility - #2085

Merged
BenBE merged 6 commits into
htop-dev:mainfrom
fasterit:header-meter-clicks
Sep 11, 2026
Merged

Implement a click handler for Meters and make the thr/kthr counters in TasksMeter toggle thread visibility#2085
BenBE merged 6 commits into
htop-dev:mainfrom
fasterit:header-meter-clicks

Conversation

@fasterit

Copy link
Copy Markdown
Member

Idea from Hisham in #2083 (comment)

Assisted-by: Microsoft Copilot/Claude Sonnet 4.6

@fasterit fasterit added the enhancement Extension or improvement to existing feature label Aug 23, 2026
@BenBE BenBE linked an issue Aug 23, 2026 that may be closed by this pull request
@coderabbitai

coderabbitai Bot commented Aug 23, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: bbfd44d3-2cf4-43d7-b396-afa99347a6f4

📥 Commits

Reviewing files that changed from the base of the PR and between ad73d73 and fe87829.

📒 Files selected for processing (1)
  • Header.c

Included review availability: Your plan provides up to 8 included reviews per hour; 6 remain after this review.


📝 Walkthrough

Walkthrough

The change adds Header_click and the Meter_Click callback contract. ScreenManager routes header-area mouse clicks through this API. TasksMeter handles text-mode clicks to toggle thread visibility and return update actions. HeaderLayout_getColumnDimensions now provides column bounds for Header_draw and Header_click.

Merge Risk: 🔵 Low · up to fe878

The PR adds header click handling and lets the thread counters toggle visibility, but when updates are paused the visible process rows may remain stale after a toggle. This is a bounded UI correctness risk that is mergeable with explicit owner awareness or follow-up.


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

Columns align in measured rows,
A click finds where each meter goes.
Callbacks wake and settings turn,
Thread labels shift, then screens return.
The header listens, clear and bright.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 5


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: b866daa5-8423-4d2a-9022-bcff22d81fd3

📥 Commits

Reviewing files that changed from the base of the PR and between 1a4504c and 5becead.

📒 Files selected for processing (5)
  • Header.c
  • Header.h
  • Meter.h
  • ScreenManager.c
  • TasksMeter.c

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread Header.c Outdated
Comment thread Header.c Outdated
Comment thread Header.c Outdated
Comment thread Meter.h
Comment thread TasksMeter.c

@BenBE BenBE left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OVerall handling LGTM; minor function split to help keep some location calculations in sync.

Unrelated note: The , text should probably be printed in teal always, not just when the element after them (thr/kthr) are active. ATM they are grey when inactive.

Comment thread Meter.h Outdated
Comment thread ScreenManager.c
Comment thread ScreenManager.c Outdated
Comment thread Header.c Outdated
Comment thread Header.c Outdated
@BenBE
BenBE force-pushed the header-meter-clicks branch from 5becead to aa4d475 Compare August 23, 2026 11:15
@hishamhm

Copy link
Copy Markdown
Member

@fasterit I built the branch and yes, it's working! Nice!

Clicking threads on and off like this made me realize that I never kept the selection stable across these toggles (that's most noticeable in tree view). If I'm looking at a process and then enable threads, the list jumps around and I have to hunt for the process again. That was already the case when toggling via keyboard; this just made me notice it.

Implementation-wise, I understand it's a bit trickier to keep the selection stable when disabling rather than enabling: if the selection is in a process, it's easy to keep it in the same PID and have threads show up beneath it. If the current selection is a thread and one toggles threads off, then of course the selected PID disappears, so I guess the logical thing for the selection would be for it to go up to the parent process. But yeah, that would no longer be just flicking a boolean.

But then of course that's a general behavior pattern: htop doesn't preserve the selected PID when going in and out of tree view, etc. But I don't know if it's worth it: preserving the selection across toggles (without having to enable "follow") doesn't make a lot of sense unless one is in "tree view sorted by PID" (which tends to be the most stable view in terms of screen movement).

But that's just an aside, just thinking out loud about the UI behavior! The clickable Meter is already a nice improvement! Thank you!!

@fasterit

Copy link
Copy Markdown
Member Author

@hishamhm: you have stable tree mode (check Setup -> Display options -> Tree view is kept visually stable) and we have much improved the Follow function (F) and there is "Sticky follow" in the Display options too which allows you to get out of Follow mode with the UP/DOWNcursor keys. Or not. That may help a bit already.

I don't think people toggle the thread views that often. But if you (or somebody else, please chime in) think differently ... we can make the view "stable" on the last PID selected.

@fasterit
fasterit force-pushed the header-meter-clicks branch from f03813f to 83b0fdf Compare August 27, 2026 10:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (1)
TasksMeter.c (1)

90-99: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Refresh process rows when updates are paused.

When pauseUpdate is enabled, the requested recalculation does not call Machine_scanTables. These toggles update the setting and redraw the meter, but process rows retain the previous thread visibility until updates resume. Use the shared thread-toggle action path or refresh the process table before returning the reaction.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 1dbbd584-2127-4ef7-b15b-29486909ea6f

📥 Commits

Reviewing files that changed from the base of the PR and between aa4d475 and ad73d73.

📒 Files selected for processing (4)
  • Header.c
  • HeaderLayout.h
  • ScreenManager.c
  • TasksMeter.c

Included review availability: Your plan provides up to 8 included reviews per hour; 7 remain after this review.

Comment thread Header.c Outdated
@fasterit
fasterit marked this pull request as ready for review August 27, 2026 12:59
@fasterit

Copy link
Copy Markdown
Member Author

Stable PID re-selection has been implemented on top of this PR in #2090 .
@hishamhm and @BenBE both wanted it. 🎉

@BenBE BenBE added this to the 3.6.0 milestone Sep 11, 2026
@BenBE
BenBE force-pushed the header-meter-clicks branch from fe87829 to f575168 Compare September 11, 2026 14:41
@BenBE
BenBE merged commit aefc011 into htop-dev:main Sep 11, 2026
21 checks passed
fasterit pushed a commit to fasterit/htop that referenced this pull request Sep 11, 2026
…hreads / container visibility

Applies on top of the header-meter-clicks branch (PR htop-dev#2085)

Assisted-by: OpenCode Zen
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 this pull request may close these issues.

Allow to toggle thr/kthr display by clicking in the Tasks Meter

3 participants