← Back to PRs

#12028: fix: normalize // to / for Matrix client escaped commands

by githabideri open 2026-02-08 18:41 View on GitHub →
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