fix(memos-local-plugin): use POSIX-ERE-compatible pgrep pattern for hermes chat detection - #2192
fix(memos-local-plugin): use POSIX-ERE-compatible pgrep pattern for hermes chat detection#2192kiwipaulrob wants to merge 5 commits into
Conversation
…ermes chat detection The MemTensor#1915 pattern used `(?:\s+\S+)*` — a PCRE non-capturing group. `pgrep -f` on Linux compiles patterns with glibc's POSIX ERE, which has no non-capturing groups, so every call failed with: pgrep: regex error: Invalid preceding regular expression `isHermesChatRunning()` swallows the error and returns `false`, so the daemon viewer was permanently stuck on "disconnected" even with a `hermes chat` session attached. The JS unit test passed because JavaScript RegExp accepts `(?:…)` — the proxy was not faithful for ERE. Replace the non-capturing group with a plain capturing group `(\s+\S+)*`, which is valid in both POSIX ERE and JavaScript RegExp, and update the doc comment to warn that the pattern must stay within ERE. Add a regression test that runs the real `pgrep` binary and asserts it does not exit 2 (regex syntax error), so a PCRE-ism can never silently return.
🤖 Open Code ReviewTarget: PR #2192 🔍 OpenCodeReview found 2 issue(s) in this PR. 1.
|
|
|
Thanks for running the checks. A quick note on the AutoTest result: This failure is an environment-preparation issue, not a test failure. The report states "Environment preparation failed before any gating tests executed" — the runner never reached the memos_local_plugin test suite, so there is no test result from this run to act on. For reference, here's what does validate this change:
Could the AutoTest environment be re-run when convenient (or is there a known issue with environment prep for the |
✅ Automated Test Results: PASSEDAll tests passed (35/35 executed). memos_local_plugin/unit: 35/35. Duration: 5s Branch: |
|
Maintainer follow-up completed on
OCR completed successfully. Its two remaining notes are non-blocking: the Linux target executes the exact |
Summary
Fixes the Hermes chat process detection regex in the memos-local-plugin. The pattern introduced for #1915 used a JavaScript/PCRE non-capturing group, but
pgrep -fon Linux compiles patterns with glibc's POSIX ERE engine. The invalid pattern made every detection call fail and left the daemon viewer stuck on"disconnected".Root cause
The unit helper compiled the same string with JavaScript's
RegExp, which accepts(?:...). That verified matching behavior but not whether the pattern passed topgrepwas valid ERE.Fix
[[:space:]]character classes and capturing groups only.\\s/\\Stokens.chatto be a complete argv token, preventing false positives such ashermes chat-server.pgrepbinary on Linux and require an exit status of 0 or 1, so syntax errors and missing executables cannot pass silently.maininto the contributor branch.Verification
pgrepexits 2 with a regex compilation error.vitest run tests/unit/bridge/hermes-process.test.ts tests/unit/bridge-status.test.ts: 18 passed, 1 Linux-only test skipped on macOS.npm run lint: passed.npm run test:unit: 155 files passed; 1297 tests passed, 2 skipped.npm run build: passed.Notes
The Linux-only
pgrepregression executes in CI. No runtime dependencies or generateddist/files are added.