Skip to content

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

Closed
oskarmodig wants to merge 4 commits intoopenclaw:mainfrom
oskarmodig:feat/mattermost-directory-adapter
Closed

feat(mattermost): Add directory adapter for channel/user name resolution#19265
oskarmodig wants to merge 4 commits intoopenclaw:mainfrom
oskarmodig:feat/mattermost-directory-adapter

Conversation

@oskarmodig
Copy link

@oskarmodig oskarmodig commented Feb 17, 2026

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 Summary

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)

Confidence Score: 4/5

  • 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

Last reviewed commit: 67dc87d

(4/5) You can add custom instructions or style guidelines for the agent here!

…AllowFrom

When a message in a channel is dropped because the sender is not in
groupAllowFrom (e.g. another agent's bot reply), the message is now
saved as pending history. This preserves conversation context so that
when an agent is later @mentioned, it sees the full conversation
including other agents' replies.

Previously, the early return in the groupAllowFrom check meant these
messages were silently discarded with no history record, causing agents
to miss parts of multi-agent channel conversations.
Enables agents to send messages using channel names (e.g. target: "infra")
instead of 26-character Mattermost IDs.

- Add directory.ts: multi-account channel/user discovery
- Add directory property to channel plugin
- Fix normalize: bare names fall through to directory lookup
- Fix looksLikeId: strict 26-char regex + DM format

Closes openclaw#19264
@openclaw-barnacle openclaw-barnacle bot added channel: mattermost Channel integration: mattermost size: M labels Feb 17, 2026
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

4 files reviewed, 2 comments

Edit Code Review Agent Settings | Greptile

…stPeers

Both functions accepted a limit param but never applied it to the
returned results. Slice entries before returning when limit is set.

Reported by Greptile review bot.
Keep both directory adapter and new actions adapter from upstream.
tonydehnke added a commit to tonydehnke/openclaw that referenced this pull request Feb 20, 2026
Previously, `#off-topic` was normalized to `channel:off-topic` which
passed the `looksLikeId` check and skipped directory resolution,
causing a 403 error when the bare name was used as a channel ID.

Now `#name` targets return `undefined` from normalize (same as bare
names), triggering the core's directory adapter to resolve the channel
name to its actual Mattermost ID. This follows the pattern established
by the directory adapter (openclaw#19265) with zero custom resolution code.
@openclaw-barnacle
Copy link

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle bot added the stale Marked as stale due to inactivity label Feb 28, 2026
@mukhtharcm mukhtharcm closed this Mar 8, 2026
@mukhtharcm
Copy link
Member

Closing this out because this branch is now mixed.

The directory / name-resolution part of the PR is already in main.
The only still-relevant part is the first stacked commit that records pending history for messages dropped by groupAllowFrom; that behavior is still missing, but it is better carried by the narrower follow-up in #16622 rather than reopening this larger stacked branch.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: mattermost Channel integration: mattermost size: M stale Marked as stale due to inactivity

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants