MemOS icon indicating copy to clipboard operation
MemOS copied to clipboard

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

Open SunayKulkarni opened this issue 5 months ago • 0 comments

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

  • [x] 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"
  • [x] Test Script Or Test Steps (please provide)

Checklist

  • [x] I have performed a self-review of my own code
  • [x] 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)
  • [x] I have linked the issue to this PR (if applicable)
  • [ ] I have mentioned the person who will review this PR

Reviewer Checklist

  • [ ] closes #1915
  • [ ] Made sure Checks passed
  • [ ] Tests have been provided

SunayKulkarni avatar Jun 12 '26 18:06 SunayKulkarni