fix: use regex in pgrep to match hermes chat with global flags#1918
Open
SunayKulkarni wants to merge 2 commits into
Open
fix: use regex in pgrep to match hermes chat with global flags#1918SunayKulkarni wants to merge 2 commits into
SunayKulkarni wants to merge 2 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adjusts the process-detection regex used to determine whether “hermes chat” is running.
Changes:
- Updates the
pgrep -fpattern used byisHermesChatRunning()to a more regex-like form.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| function isHermesChatRunning(): boolean { | ||
| try { | ||
| const out = childProcess.execFileSync("pgrep", ["-f", "hermes chat"], { | ||
| const out = childProcess.execFileSync("pgrep", ["-f", "hermes\\s.*chat\\b"], { |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
isHermesChatRunning()inapps/memos-local-plugin/bridge.ctsusedpgrep -f "hermes chat"to detect an active Hermes chat session. This only matched whenhermesandchatwere adjacent tokens in the process command line.When the Hermes CLI is invoked with global flags before the subcommand (e.g.
hermes --skills memory-routing chat), the substring"hermes chat"does not appear contiguously, causingpgrepto return no match even though a chat session is actively running. This affects daemon mode only —applyStaleRule()usesisHermesChatRunning()to upgrade status from"disconnected"to"reconnecting", so the viewer incorrectly stays disconnected.The fix replaces the fixed string with a regex
hermes\s.*chat\bthat allows optional flags betweenhermesandchat.Related Issue (Required): Fixes #1915
Type of change
How Has This Been Tested?
hermes --skills memory-routing chatpgrep -f "hermes\s.*chat\b"— confirm it returns the PIDpgrep -f "hermes chat"— confirm it returns nothing (old pattern misses it)"reconnecting"instead of staying"disconnected"Checklist
Reviewer Checklist