Skip to content

fix: use regex in pgrep to match hermes chat with global flags#1918

Open
SunayKulkarni wants to merge 2 commits into
MemTensor:mainfrom
SunayKulkarni:fix/hermes-pgrep-pattern
Open

fix: use regex in pgrep to match hermes chat with global flags#1918
SunayKulkarni wants to merge 2 commits into
MemTensor:mainfrom
SunayKulkarni:fix/hermes-pgrep-pattern

Conversation

@SunayKulkarni

Copy link
Copy Markdown

Description

isHermesChatRunning() in apps/memos-local-plugin/bridge.cts used pgrep -f "hermes chat" to detect an active Hermes chat session. This only matched when hermes and chat were 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, causing pgrep to return no match even though a chat session is actively running. This affects daemon mode only — applyStaleRule() uses isHermesChatRunning() 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\b that allows optional flags between hermes and chat.

Related Issue (Required): Fixes #1915

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  1. Start a Hermes chat session with a global flag: hermes --skills memory-routing chat
  2. Run pgrep -f "hermes\s.*chat\b" — confirm it returns the PID
  3. Run pgrep -f "hermes chat" — confirm it returns nothing (old pattern misses it)
  4. Confirm the daemon bridge correctly transitions to "reconnecting" instead of staying "disconnected"
  • Test Script Or Test Steps (please provide)

Checklist

  • I have performed a self-review of my own code
  • I have commented my code in hard-to-understand areas
  • I have added tests that prove my fix is effective or that my feature works
  • I have created related documentation issue/PR in MemOS-Docs (if applicable)
  • I have linked the issue to this PR (if applicable)
  • I have mentioned the person who will review this PR

Reviewer Checklist

Copilot AI review requested due to automatic review settings June 12, 2026 18:32

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 -f pattern used by isHermesChatRunning() to a more regex-like form.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread apps/memos-local-plugin/bridge.cts Outdated
function isHermesChatRunning(): boolean {
try {
const out = childProcess.execFileSync("pgrep", ["-f", "hermes chat"], {
const out = childProcess.execFileSync("pgrep", ["-f", "hermes\\s.*chat\\b"], {
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.

fix(memos-local-plugin): bridge status detection misses hermes chat with global flags

2 participants