#12028: fix: normalize // to / for Matrix client escaped commands
stale
Servus Peter and hi to all others involved :)
I am using Matrix and immediately started modifying the code base immediately, since i think these changes would make sense upstream for others as well i am going for some PRs. To following was written bt openclaw (opus):
Matrix clients like Element and nheko escape unrecognized slash commands as //command (e.g., //status becomes //status). This change normalizes // back to / at the start of messages so these commands work correctly.
Affected areas:
- normalizeCommandBody() in commands-registry.ts
- extractModelDirective() regex patterns in model.ts (both /model and aliases)
<!-- greptile_comment -->
<h2>Greptile Overview</h2>
<h3>Greptile Summary</h3>
This PR updates text-command parsing to accommodate Matrix clients that escape unknown slash commands by doubling the leading slash. Specifically:
- `normalizeCommandBody()` now rewrites a leading `//...` into `/...` before command detection/alias normalization.
- `extractModelDirective()` extends its `/model` and alias patterns to accept `//model` and `//<alias>`.
These changes fit into the auto-reply pipeline where inbound message bodies are normalized and then inspected for commands/directives (command registry + directive handling) before routing to model selection/behavior changes.
<h3>Confidence Score: 4/5</h3>
- Mostly safe to merge, with a small risk of unintended directive matches due to the relaxed `//` regex patterns.
- The `normalizeCommandBody` change is localized and straightforward, but the updated `/model` + alias regexes can match whitespace-separated slash sequences (e.g. `/ /model`) which would change behavior for certain inputs. Also, the new Matrix normalization behavior is not covered by tests in the existing command-registry test suite.
- src/auto-reply/model.ts; src/auto-reply/commands-registry.ts
<!-- greptile_other_comments_section -->
<sub>(2/5) Greptile learns from your feedback when you react with thumbs up/down!</sub>
**Context used:**
- Context from `dashboard` - CLAUDE.md ([source](https://app.greptile.com/review/custom-context?memory=fd949e91-5c3a-4ab5-90a1-cbe184fd6ce8))
- Context from `dashboard` - AGENTS.md ([source](https://app.greptile.com/review/custom-context?memory=0d0c8278-ef8e-4d6c-ab21-f5527e322f13))
<!-- /greptile_comment -->
Most Similar PRs
#20278: Fix/matrix missing bot sdk dependency
by saurav470 · 2026-02-18
74.3%
#19294: fix: normalize room ID case in Matrix config lookup
by MisterGuy420 · 2026-02-17
73.5%
#7845: Fix Matrix mention detection with URL-encoded user IDs
by emadomedher · 2026-02-03
73.3%
#7842: Fix Matrix mention detection for Element client (formatted_body links)
by emadomedher · 2026-02-03
73.2%
#11453: fix: apply normalizeToolName() at all tool lookup points
by sypsyp97 · 2026-02-07
73.0%
#10721: fix for matrix media: destructure downloadContent return value in m...
by mklasen · 2026-02-06
72.5%
#10606: fix(matrix): keep room IDs without :server suffix as-is during reso...
by majorminors · 2026-02-06
71.7%
#6059: fix #6044
by vivganes · 2026-02-01
71.5%
#8083: fix(tui): update model status immediately after /model command
by rohanjangala · 2026-02-03
71.3%
#9490: Add Internationalization (i18n) Support
by luuman · 2026-02-05
71.1%