You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This PR avoids a full sysinfo process-tree scan on Procs::new() and replaces the broad refresh_processes() calls scattered across the codebase with targeted refresh_pids(&[pid]) calls that only refresh the specific PIDs actually needed.
Procs::new() now returns an empty struct; every call site that needs process data explicitly refreshes the relevant PIDs before querying, removing the hidden startup cost.
A refresh_daemon_pids helper and a refresh_daemon_list_pids local helper are introduced to consolidate the common pattern of collecting daemon PIDs and refreshing only those.
Precondition documentation is added to kill and kill_process_group making the required refresh-before-call contract explicit; watchers.rs retains its refresh_processes() call because it needs the full process tree for child-process resource aggregation via get_batch_group_stats.
Confidence Score: 5/5
Safe to merge — all call sites correctly refresh targeted PIDs before querying; the one path that still needs a full refresh (watchers.rs) is untouched.
Every is_running, title(), and kill call site was audited and each has a refresh_pids immediately preceding it. The resource-monitoring watcher retains its full refresh_processes() because it uses get_batch_group_stats over the complete process tree. No silent no-ops or missed refreshes were found in the changed paths.
No files require special attention.
Important Files Changed
Filename
Overview
src/procs.rs
Core change: Procs::new() no longer pre-populates sysinfo; adds refresh_daemon_pids helper and precondition docs on kill/kill_process_group.
src/supervisor/lifecycle.rs
Adds refresh_pids after daemon spawn (before upsert_daemon reads title()); replaces full refresh with targeted PID check in stop path.
src/supervisor/mod.rs
Fixes implicit dependency on stale PROCS state in start_if_not_running and run; adds explicit targeted refresh before each is_running/title() call.
src/tui/app.rs
TUI stats refresh now targets only daemon root PIDs instead of all processes; consistent with get_stats which only examines the root PID anyway.
src/web/routes/daemons.rs
Extracts refresh_daemon_list_pids helper; replaces all broad refreshes with targeted ones; show now reads StateFile earlier to get the PID before refreshing.
src/cli/supervisor/mod.rs
Adds refresh_pids(&[existing_pid]) before is_running in kill_or_stop, satisfying the new precondition contract.
src/cli/wait.rs
Moves refresh to loop start and replaces broad refresh_processes with targeted refresh_pids; semantically equivalent and more efficient.
src/web/routes/index.rs
Reads StateFile before calling refresh_daemon_pids so only managed daemon PIDs are refreshed on each page render.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fixes #439.