Skip to content

Add E hotkey to collapse/expand all processes in tree mode#1564

Open
sardonyx001 wants to merge 3 commits intoaristocratos:mainfrom
sardonyx001:feature/tree-expand-collapse-all
Open

Add E hotkey to collapse/expand all processes in tree mode#1564
sardonyx001 wants to merge 3 commits intoaristocratos:mainfrom
sardonyx001:feature/tree-expand-collapse-all

Conversation

@sardonyx001
Copy link
Copy Markdown

Closes #1563, addresses #520, #673, #1528 and #686.

Been using btop for years, it's my favorite system monitor by far.
Tree mode is great but I always found myself tediously spacebar-collapsing every single node just to get the per-app summary view. Finally sat down gave it a try.

Here's the overview:

  • E collapses all processes in tree mode at once, or expands them all if everything is already collapsed
  • Root processes (launchd, systemd, top-level daemons) are left untouched since collapsing them would just hide everything underneath rather than giving you the summary view
  • E pairs naturally with the existing e (toggle tree mode on/off)
  • Also fixes the one-frame rendering glitch from [BUG] Sorting in tree mode with collapsed nodes causes a brief visual glitch #1563: sort key presses were calling Runner::run with no_update=true, which meant _tree_gen skipped setting p.filtered=true for collapsed children while line 211 of btop_shared.cpp was unconditionally clearing their stale flag from the previous cycle. Fixed by forcing no_update=false on left/right when proc_tree is active.

This is my first time contributing to a project so large so please tell me if there's anything I need to update/change.

Before and After:

Screen.Recording.2026-03-04.at.14.09.33.mov

Pressing E in tree mode collapses all processes if any parent is
currently expanded, or expands all if everything is already collapsed.
This gives a quick per-application resource summary without having
to manually toggle each node.

Implemented across all platforms (Linux, macOS, FreeBSD, OpenBSD, NetBSD).
Root processes (those whose parent is not in the tracked process list,
e.g. launchd on macOS or a top-level colima) are now left untouched by
the E hotkey. Only their descendants are collapsed or expanded.

The toggle direction is also determined solely from non-root parents,
so a tree full of root-only visible rows correctly expands on the
next E press.
When proc_tree is active and left/right changes the sort column,
no_update was left as true. _tree_gen is called with no_update=true,
which skips the p.filtered=true assignment for children of collapsed
nodes while the unconditional else-if on line 211 of btop_shared.cpp
clears their stale filtered flag from the previous cycle. This leaves
collapsed children in an inconsistent state for one frame, causing a
brief visual glitch before the next full update corrects it.

Setting no_update=false only in tree mode keeps the fast path for
flat list mode unchanged.
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.

[BUG] Sorting in tree mode with collapsed nodes causes a brief visual glitch

1 participant