fix(cli): detect dashboard PIDs when --profile precedes the subcommand#44048
fix(cli): detect dashboard PIDs when --profile precedes the subcommand#44048liuhao1024 wants to merge 1 commit into
Conversation
NousResearch#44035) The stale-dashboard PID scanner used fixed substrings like 'hermes_cli.main dashboard' to find running dashboard processes. When --profile (or -p) sits between the entry point and the subcommand (e.g. 'python -m hermes_cli.main --profile prod dashboard'), none of the patterns matched and the process was missed. Add a _cmd_is_dashboard_subcommand() helper that checks for a known Hermes entry point plus 'dashboard' as a standalone whitespace-delimited token, covering the flag-in-between case while still rejecting unrelated processes that merely mention 'dashboard' in arguments.
|
Thanks for jumping on this — I hit the same issue and want to flag one behavior of The guard against quoted arguments doesn't hold against real which ends with Two smaller variants of the same hole:
I opened #44165 as an alternative that tokenizes the cmdline and only accepts known top-level flags (arity introspected from the real parser, same as |
|
Thanks for the thorough analysis @AIalliAI — you're right on all three points. The substring approach has real holes: |
Problem
_find_stale_dashboard_pids()uses fixed substring patterns ("hermes dashboard","hermes_cli.main dashboard","hermes_cli/main.py dashboard") to detect running dashboard processes.When
--profile(or-p) appears between the entry point and thedashboardsubcommand — e.g.python -m hermes_cli.main --profile prod dashboard --port 9119— none of the patterns match, so:hermes dashboard --statusmisses the processhermes dashboard --stopcan't kill ithermes updateskips the stale-dashboard cleanup, leaving the old backend running with a mismatched JS bundleCloses #44035
Fix
Add a
_cmd_is_dashboard_subcommand()helper that checks for:hermes,hermes_cli.main,hermes_cli/main.py) in the commanddashboardappearing as a standalone whitespace-delimited token (" dashboard "or trailing" dashboard")This catches the flag-in-between case while still rejecting unrelated processes that merely mention "dashboard" in arguments (e.g.
hermes_cli.main chat -q 'rewrite my dashboard').The existing exact-substring patterns are kept as
_EXACT_DASHBOARDfor the common no-flags case; the new helper runs as a fallback.Files Changed
hermes_cli/main.py_cmd_is_dashboard_subcommand(), updated matching logic on both macOS/Linux and Windows pathstests/hermes_cli/test_update_stale_dashboard.pytest_profile_flag_before_subcommandandtest_short_profile_flag_before_subcommandTest Plan
test_profile_flag_before_subcommand—--profile prodbetween entry point anddashboardtest_short_profile_flag_before_subcommand—-p devshort formtest_unrelated_process_containing_word_dashboard_not_matched— confirms no false positives on chat commands mentioning "dashboard"Test output (24/24 passed)