← Back to PRs

#19265: feat(mattermost): Add directory adapter for channel/user name resolution

by oskarmodig open 2026-02-17 15:57 View on GitHub →
channel: mattermost size: M
Closes #19264 Enables agents to send messages using channel names (e.g. `target: "infra"`) instead of 26-character Mattermost IDs. ## Changes ### `src/mattermost/directory.ts` (new) - `listMattermostDirectoryGroups` — scans all enabled bot accounts (deduplicated by token), returns public + private channels - `listMattermostDirectoryPeers` — returns team members via first available client - Multi-account scanning ensures private channels are discoverable regardless of which bot the requesting agent uses ### `src/channel.ts` - Added `directory` property with `listGroups`/`listPeers` + live variants - Core's `DirectoryCache` handles caching; both variants call the same function ### `src/normalize.ts` - Bare names return `undefined` → falls through to directory lookup - Stricter `looksLikeId`: 26-char alnum + DM format (`id__id`) ## Testing Tested live with 19 bot accounts across public and private channels. <!-- greptile_comment --> <h3>Greptile Summary</h3> Adds directory adapter for Mattermost to enable channel/user name resolution, allowing agents to send messages using friendly names instead of 26-character IDs. **Major changes:** - New `directory.ts` implements `listMattermostDirectoryGroups` and `listMattermostDirectoryPeers` with multi-account scanning for comprehensive channel discovery - `normalize.ts` updated to return `undefined` for bare names, triggering directory lookup fallback - `looksLikeMattermostTargetId` now uses strict 26-char alphanumeric pattern plus DM format validation - `monitor.ts` improved to record pending history for messages from non-allowlisted senders, preserving conversation context for future `@mentions` **Issues found:** - Both directory functions ignore the `limit` parameter—other channel implementations (msteams, matrix, feishu) apply it via `.slice(0, limit)` <h3>Confidence Score: 4/5</h3> - Safe to merge after fixing the limit parameter handling - Well-structured implementation following existing patterns from other channel adapters. The limit parameter bug is straightforward and doesn't affect core functionality—results will just be unbounded when limit is specified. The monitor.ts history recording logic is sound and the normalize.ts changes correctly enable directory fallback. - Fix `limit` parameter handling in `extensions/mattermost/src/mattermost/directory.ts` before merging <sub>Last reviewed commit: 67dc87d</sub> <!-- greptile_other_comments_section --> <sub>(4/5) You can add custom instructions or style guidelines for the agent [here](https://app.greptile.com/review/github)!</sub> <!-- /greptile_comment -->

Most Similar PRs