Skip to content

[AI generated] Display process CWD and add parent navigation - #1936

Open
cjoushua wants to merge 2 commits into
aristocratos:mainfrom
cjoushua:feature/process-cwd-parent-navigation-1883
Open

cjoushua wants to merge 2 commits into
aristocratos:mainfrom
cjoushua:feature/process-cwd-parent-navigation-1883

Conversation

@cjoushua

Copy link
Copy Markdown

[AI generated]

Closes #1883

Summary

This PR adds two improvements to the process detail view:

Display the current working directory (CWD) of the selected process.

Add a Jump parent action to navigate directly to the process's parent.

Current working directory

On Linux, the CWD is retrieved from:

/proc//cwd

The CWD section is displayed only when:

the CWD can be retrieved, and

the process panel has enough vertical space.

When the terminal becomes too small, the CWD section is hidden and the original process detail layout is used.

The CWD is also cleared when the selected process exits to avoid displaying stale information.

Other platform collectors are currently unchanged.

Parent navigation

The process detail view now provides a Jump parent action.

Press J to navigate to the current process's parent.

The action is also available through the mouse when the button is visible.

Parent navigation uses the existing ppid stored in proc_info.

When following the detailed process, jumping to the parent updates the followed PID as well.

The action is disabled when the process is dead or there is no valid parent PID.

Testing

  • Tested on Linux with a debug build (make DEBUG=true):
  • CWD displayed correctly for normal processes.
  • Long CWD paths wrap correctly.
  • CWD and command paths can differ.
  • CWD is hidden when unavailable.
  • CWD is hidden when the process panel becomes too small.
  • CWD reappears correctly when the terminal is enlarged.
  • Mouse selection remains aligned after the detail panel changes height.
  • Keyboard process selection remains aligned.
  • Selected processes can exit without crashing btop.
  • Stale CWD is cleared when the selected process exits.
  • J successfully navigates from a process to its parent.
  • Repeated J navigation walks up the process hierarchy.
  • Mouse Jump parent navigation works.
  • Parent navigation works correctly with process following enabled.
  • Jump parent becomes inactive for dead processes or when no valid parent exists.
  • Resizing the terminal does not leave a stale mouse interaction region.

AI disclosure

AI assistance was used during parts of the implementation and code review process. I traced the existing process-detail, input, and collection flows, implemented and tested the changes locally, and verified the behavior described above.

@cjoushua
cjoushua force-pushed the feature/process-cwd-parent-navigation-1883 branch from c2ed009 to 7778e5c Compare October 24, 2026 11:34
@cjoushua
cjoushua force-pushed the feature/process-cwd-parent-navigation-1883 branch from 1ffcb31 to 48aca31 Compare October 25, 2026 14: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.

display current directory of a process and allow navigating to a parent

1 participant