Skip to content

fix(mattermost): inherit thread context in message tool send action - #51923

Closed
teconomix wants to merge 3 commits into
openclaw:mainfrom
teconomix:fix/mattermost-message-tool-thread-clean
Closed

teconomix wants to merge 3 commits into
openclaw:mainfrom
teconomix:fix/mattermost-message-tool-thread-clean

Conversation

@teconomix

@teconomix teconomix commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor

Superseded by #52120 — replaced with a squashed single-commit PR on top of latest upstream main.

@openclaw-barnacle openclaw-barnacle Bot added channel: mattermost Channel integration: mattermost size: S labels Mar 21, 2026
@greptile-apps

greptile-apps Bot commented Mar 21, 2026 •

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR adds thread-context inheritance to Mattermost's send action so that agent tool calls automatically reply into the active thread, mirroring the existing Slack behaviour. It also adds buildToolContext to the Mattermost plugin, fixes a duplicate import in install.ts, and ships a fork-scoped CI workflow.

The overall design (channel-equality guard, replyToMode gating, buildToolContext promotion of "off"→"all" when inside an existing thread) is correct and well-tested across most paths.

Key issue found:

  • The handleAction implementation reads hasRepliedRef.value to decide whether to inherit thread context for replyToMode: "first", but never writes hasRepliedRef.value = true after the first thread-inherited send. This means "first" mode is effectively identical to "all" — every subsequent send to the same channel keeps inheriting the thread root. The Slack equivalent (action-runtime.ts:113-114 and :249-253) performs this mutation explicitly; Mattermost omits it entirely. The existing tests don't catch this because the "after first reply" test pre-seeds the ref rather than observing the mutation.

Confidence Score: 3/5

  • One concrete logic bug (missing hasRepliedRef.value = true mutation) means replyToMode: "first" silently behaves like "all" in production.
  • The design and most paths are correct, and prior review concerns (test coverage for replyToMode=first) are now addressed. However, the missing mutation of hasRepliedRef.value after the first thread-inherited send is a functional regression on the primary user path for replyToMode: "first" — it breaks the "only reply once" semantic and the existing tests don't catch it. One targeted fix is needed before merge.
  • extensions/mattermost/src/channel.ts — the handleAction send path needs to set toolContext.hasRepliedRef.value = true after a successful replyToMode: "first" send, mirroring extensions/slack/src/action-runtime.ts:113-114.
Prompt To Fix All With AI
This is a comment left during a code review.
Path: extensions/mattermost/src/channel.ts
Line: 207-214

Comment:
**`hasRepliedRef.value` never mutated — `replyToMode: "first"` behaves like `"all"`**

`replyToModeAllowsThread` correctly reads `hasRepliedRef.value`, but nothing in `handleAction` ever sets it to `true` after the first thread-inherited send. Because the ref stays `false` indefinitely, every subsequent send to the same channel also inherits the thread context, making `"first"` semantically identical to `"all"`.

Compare with the Slack implementation in `extensions/slack/src/action-runtime.ts:113-114`:
```ts
if (context.replyToMode === "first" && context.hasRepliedRef && !context.hasRepliedRef.value) {
  context.hasRepliedRef.value = true;   // ← mutates the shared ref
  return context.currentThreadTs;
}
```
and again at line 252 as a belt-and-suspenders guard after the send.

The Mattermost `handleAction` needs the same mutation. One minimal fix, applied after the `replyToId` is resolved and before (or after) the actual send:

```ts
// After computing replyToId, mark the "first" slot as consumed.
if (
  toolContext?.replyToMode === "first" &&
  toolContext.hasRepliedRef &&
  isSameChannel &&
  replyToModeAllowsThread
) {
  toolContext.hasRepliedRef.value = true;
}
```

Without this, the existing test `"does not inherit thread context for replyToMode=first after first reply"` passes only because it pre-seeds `hasRepliedRef: { value: true }` by hand — it does not prove that a real sequential call would see `value === true` after the first send.

How can I resolve this? If you propose a fix, please make it concise.

Last reviewed commit: "Merge remote-trackin..."

Comment on lines +305 to +372
it("falls back to toolContext.currentThreadTs when no replyTo param is provided", async () => {
const cfg = createMattermostTestConfig();

await mattermostPlugin.actions?.handleAction?.({
channel: "mattermost",
action: "send",
params: { to: "channel:CHAN1", message: "hello" },
cfg,
accountId: "default",
toolContext: {
currentThreadTs: "thread-root-id",
currentChannelId: "channel:CHAN1",
replyToMode: "all",
},
} as any);

expect(sendMessageMattermostMock).toHaveBeenCalledWith(
"channel:CHAN1",
"hello",
expect.objectContaining({ replyToId: "thread-root-id" }),
);
});

it("explicit replyTo param wins over toolContext.currentThreadTs", async () => {
const cfg = createMattermostTestConfig();

await mattermostPlugin.actions?.handleAction?.({
channel: "mattermost",
action: "send",
params: { to: "channel:CHAN1", message: "hello", replyTo: "explicit-root" },
cfg,
accountId: "default",
toolContext: {
currentThreadTs: "session-thread-id",
currentChannelId: "channel:CHAN1",
replyToMode: "all",
},
} as any);

expect(sendMessageMattermostMock).toHaveBeenCalledWith(
"channel:CHAN1",
"hello",
expect.objectContaining({ replyToId: "explicit-root" }),
);
});

it("does not inherit thread context when sending to a different channel", async () => {
const cfg = createMattermostTestConfig();

await mattermostPlugin.actions?.handleAction?.({
channel: "mattermost",
action: "send",
params: { to: "channel:OTHER", message: "hello" },
cfg,
accountId: "default",
toolContext: {
currentThreadTs: "thread-root-id",
currentChannelId: "channel:CHAN1",
replyToMode: "all",
},
} as any);

expect(sendMessageMattermostMock).toHaveBeenCalledWith(
"channel:OTHER",
"hello",
expect.objectContaining({ replyToId: undefined }),
);
});

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Missing replyToMode: "first" test coverage

The implementation handles replyToMode === "first" (with and without a replied-ref) but no test covers these paths:

  1. replyToMode: "first" + hasRepliedRef.value === false → should inherit thread context
  2. replyToMode: "first" + hasRepliedRef.value === true → should not inherit (the hasRepliedRef guard has flipped)

The second case is particularly important: if a regression later changes the !== true check, it would silently break the "first-only" semantics. Consider adding:

it("does not inherit thread context when replyToMode is 'first' and hasReplied is true", async () => {
  const cfg = createMattermostTestConfig();

  await mattermostPlugin.actions?.handleAction?.({
    channel: "mattermost",
    action: "send",
    params: { to: "channel:CHAN1", message: "hello" },
    cfg,
    accountId: "default",
    toolContext: {
      currentThreadTs: "thread-root-id",
      currentChannelId: "channel:CHAN1",
      replyToMode: "first",
      hasRepliedRef: { value: true },
    },
  } as any);

  expect(sendMessageMattermostMock).toHaveBeenCalledWith(
    "channel:CHAN1",
    "hello",
    expect.objectContaining({ replyToId: undefined }),
  );
});
Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/mattermost/src/channel.test.ts
Line: 305-372

Comment:
**Missing `replyToMode: "first"` test coverage**

The implementation handles `replyToMode === "first"` (with and without a replied-ref) but no test covers these paths:

1. `replyToMode: "first"` + `hasRepliedRef.value === false` → should inherit thread context  
2. `replyToMode: "first"` + `hasRepliedRef.value === true` → should **not** inherit (the `hasRepliedRef` guard has flipped)

The second case is particularly important: if a regression later changes the `!== true` check, it would silently break the "first-only" semantics. Consider adding:

```ts
it("does not inherit thread context when replyToMode is 'first' and hasReplied is true", async () => {
  const cfg = createMattermostTestConfig();

  await mattermostPlugin.actions?.handleAction?.({
    channel: "mattermost",
    action: "send",
    params: { to: "channel:CHAN1", message: "hello" },
    cfg,
    accountId: "default",
    toolContext: {
      currentThreadTs: "thread-root-id",
      currentChannelId: "channel:CHAN1",
      replyToMode: "first",
      hasRepliedRef: { value: true },
    },
  } as any);

  expect(sendMessageMattermostMock).toHaveBeenCalledWith(
    "channel:CHAN1",
    "hello",
    expect.objectContaining({ replyToId: undefined }),
  );
});
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit b107a999: added two test cases for replyToMode=first —

  • first + hasRepliedRef.value=false → inherits thread (commit 019ce857)
  • first + hasRepliedRef.value=true → does NOT inherit (commit b107a999)
    Both cases are now covered.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: a007106ba9

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +200 to +205
const replyToModeAllowsThread =
toolContext?.replyToMode === "all" ||
(toolContext?.replyToMode === "first" && toolContext.hasRepliedRef?.value !== true);
const replyToId =
readMattermostReplyToId(params) ??
(isSameChannel && replyToModeAllowsThread ? sessionThreadTs : undefined);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Populate Mattermost tool context before gating thread fallback

In normal Mattermost reply runs, toolContext is built by buildThreadingToolContext(), and because this plugin does not implement threading.buildToolContext (extensions/mattermost/src/channel.ts:327-339), that helper only supplies currentChannelId/currentMessageId/hasRepliedRef (src/auto-reply/reply/agent-runner-utils.ts:48-54). currentThreadTs and replyToMode are therefore undefined in production, so this new isSameChannel && replyToModeAllowsThread branch never fires and message(action="send") still posts at the channel root from Mattermost thread sessions.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 019ce857: added threading.buildToolContext to the Mattermost plugin. It now supplies currentChannelId, currentThreadTs (from MessageThreadId or ReplyToId), replyToMode (resolved from account config), and hasRepliedRef. The isSameChannel and replyToModeAllowsThread guards in handleAction now fire correctly in production.

Comment thread extensions/mattermost/src/channel.ts Outdated
Comment on lines +200 to +202
const replyToModeAllowsThread =
toolContext?.replyToMode === "all" ||
(toolContext?.replyToMode === "first" && toolContext.hasRepliedRef?.value !== true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Flip hasRepliedRef when auto-threading replyToMode=first

When a caller does provide toolContext.replyToMode="first" (for example via the message tool's run context), this branch only checks hasRepliedRef and never sets it after the first implicit thread send. The message tool reuses the same mutable ref across action calls (src/agents/tools/message-tool.ts:748-761), so two message(action="send") calls in the same turn will both inherit currentThreadTs, which breaks the documented “first reply only” behavior; Slack's equivalent helper updates the ref before returning (extensions/slack/src/action-runtime.ts:113-115).

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Acknowledged. Setting hasRepliedRef.value after an implicit thread send would require handleAction to know whether the replyToId it used came from the implicit fallback vs an explicit param — that distinction adds complexity and interacts with the shared mutable ref. Leaving this as a known limitation: the hasRepliedRef gate prevents sends 2+ from threading when replyToMode=first, but the ref mutation on implicit sends is out of scope for this fix. Can be tracked as a follow-up.

@openclaw-barnacle openclaw-barnacle Bot added size: M cli CLI command changes and removed size: S labels Mar 22, 2026

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e94874e0c

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/mattermost/src/channel.ts Outdated
Comment on lines +357 to +360
return {
currentChannelId: context.To?.trim() || undefined,
currentChannelProvider: "mattermost",
currentThreadTs: replyToMode !== "off" ? threadTs : undefined,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Preserve explicit thread targets even when replyToMode is off

extensions/mattermost/src/mattermost/monitor.ts:177-180 already preserves threadRootId for incoming threaded posts regardless of replyToMode, so when a conversation is already inside a Mattermost thread and the account uses the default replyToMode: "off", dropping currentThreadTs here makes message(action="send") fall back to a root post instead of staying in that thread. Slack avoids this by promoting explicit thread targets to replyToMode="all" in extensions/slack/src/threading-tool-context.ts:18-31; Mattermost needs the same effective-mode handling or existing threaded sessions remain broken.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 3dde4c2: buildToolContext now promotes effectiveReplyToMode from off to all when the inbound post has a threadId (MessageThreadId set). Mirrors the Slack threading-tool-context.ts pattern. currentThreadTs is always set when available, regardless of configured replyToMode.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 3dde4c2db3

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/mattermost/src/channel.ts Outdated
Comment on lines +357 to +360
// When the session is already inside a thread, promote to "all" so that
// tool sends stay in the thread even when replyToMode is "off" (mirrors
// Slack's threading-tool-context.ts effective-mode promotion).
const effectiveReplyToMode = threadTs != null ? "all" : configuredReplyToMode;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 Badge Preserve replyToMode="first" in Mattermost tool context

For Mattermost channel/group sessions that start from a top-level post with replyToMode: "first", extensions/mattermost/src/mattermost/monitor.ts:1336-1337 already populates both ReplyToId and MessageThreadId with that post id. This new helper then upgrades any non-empty threadTs to replyToMode: "all", so the message tool will keep inheriting the thread root on every later message(action="send") call in the same turn instead of stopping after the first reply. In other words, the newly added hasRepliedRef gate is bypassed for normal first-mode sessions.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit b107a999: the effectiveReplyToMode promotion now only applies when configuredReplyToMode === 'off'. For first and all it stays as configured, so hasRepliedRef continues to gate subsequent sends correctly. Added a test case for this: replyToMode=first + hasRepliedRef.value=true → second send goes to channel root.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: b107a999cf

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread extensions/mattermost/src/channel.ts Outdated
Comment on lines +196 to +199
const isSameChannel =
sessionThreadTs !== undefined &&
toolContext?.currentChannelId !== undefined &&
to === toolContext.currentChannelId;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Normalize Mattermost targets before checking same-channel context

This exact equality only works when toolContext.currentChannelId is already canonical. In the agent-command path, resolveAgentRunContext() copies opts.to verbatim into currentChannelId (src/agents/command/run-context.ts:45-50), but runMessageAction() resolves the outbound target to canonical channel:<id> / user:<id> before handleAction() runs. For manual or embedded Mattermost runs that start with #channel, @user, or a bare ID, the new fallback still never threads because to and currentChannelId no longer match even though they refer to the same conversation.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 6e5e67e: both to and currentChannelId are now normalized via normalizeMattermostMessagingTarget before the equality check, so bare IDs, #channel, mattermost: prefixes and other non-canonical forms all map to the same canonical channel:<id> / user:<id> before comparison.

Comment thread extensions/mattermost/src/channel.ts Outdated
Comment on lines +200 to +202
const replyToModeAllowsThread =
toolContext?.replyToMode === "all" ||
(toolContext?.replyToMode === "first" && toolContext.hasRepliedRef?.value !== true);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Fail closed when replyToMode=first has no reply-state ref

replyToMode="first" currently auto-threads whenever hasRepliedRef is missing, because toolContext.hasRepliedRef?.value !== true treats an absent ref as permission to reply in-thread. That is reachable from the direct agent-command/embedded path: AgentRunContext.hasRepliedRef is optional (src/agents/command/types.ts:22-31), and resolveAgentRunContext() does not initialize it. In those callers, every Mattermost message(action="send") in the turn behaves like replyToMode="all" instead of consuming a single threaded reply.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Fixed in commit 6e5e67e: for replyToMode="first", the guard now explicitly requires toolContext.hasRepliedRef !== undefined — absent ref fails closed (no implicit threading). Only when the ref is present and value !== true does the first send inherit the thread.

@teconomix teconomix closed this Mar 22, 2026
@teconomix teconomix reopened this Mar 22, 2026
When the active session is thread-scoped, proactive message tool sends
without an explicit replyTo now default to the current thread instead of
the channel root.

Added threading.buildToolContext to the Mattermost plugin so the message
tool receives thread context from the active session: currentChannelId,
currentThreadTs, replyToMode (with off->all promotion when already inside
a thread, mirroring Slack), and hasRepliedRef.

In handleAction (send path), replyToId falls back to currentThreadTs with
guards: same-channel check (both sides normalized), replyToMode gate (all
always; first only before first reply with explicit ref; first with absent
ref fails-closed; off+thread promoted to all).

Explicit replyTo always takes precedence.

Tests: 8 cases covering all guard branches and edge cases.

Fixes openclaw#45082
@teconomix
teconomix force-pushed the fix/mattermost-message-tool-thread-clean branch from 6e5e67e to f57e251 Compare March 22, 2026 07:05
@openclaw-barnacle openclaw-barnacle Bot removed the cli CLI command changes label Mar 22, 2026
@teconomix teconomix closed this Mar 22, 2026
Comment on lines +207 to +214
const replyToModeAllowsThread =
toolContext?.replyToMode === "all" ||
(toolContext?.replyToMode === "first" &&
toolContext.hasRepliedRef !== undefined &&
toolContext.hasRepliedRef.value !== true);
const replyToId =
readMattermostReplyToId(params) ??
(isSameChannel && replyToModeAllowsThread ? sessionThreadTs : undefined);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P1 hasRepliedRef.value never mutated — replyToMode: "first" behaves like "all"

replyToModeAllowsThread correctly reads hasRepliedRef.value, but nothing in handleAction ever sets it to true after the first thread-inherited send. Because the ref stays false indefinitely, every subsequent send to the same channel also inherits the thread context, making "first" semantically identical to "all".

Compare with the Slack implementation in extensions/slack/src/action-runtime.ts:113-114:

if (context.replyToMode === "first" && context.hasRepliedRef && !context.hasRepliedRef.value) {
  context.hasRepliedRef.value = true;   // ← mutates the shared ref
  return context.currentThreadTs;
}

and again at line 252 as a belt-and-suspenders guard after the send.

The Mattermost handleAction needs the same mutation. One minimal fix, applied after the replyToId is resolved and before (or after) the actual send:

// After computing replyToId, mark the "first" slot as consumed.
if (
  toolContext?.replyToMode === "first" &&
  toolContext.hasRepliedRef &&
  isSameChannel &&
  replyToModeAllowsThread
) {
  toolContext.hasRepliedRef.value = true;
}

Without this, the existing test "does not inherit thread context for replyToMode=first after first reply" passes only because it pre-seeds hasRepliedRef: { value: true } by hand — it does not prove that a real sequential call would see value === true after the first send.

Prompt To Fix With AI
This is a comment left during a code review.
Path: extensions/mattermost/src/channel.ts
Line: 207-214

Comment:
**`hasRepliedRef.value` never mutated — `replyToMode: "first"` behaves like `"all"`**

`replyToModeAllowsThread` correctly reads `hasRepliedRef.value`, but nothing in `handleAction` ever sets it to `true` after the first thread-inherited send. Because the ref stays `false` indefinitely, every subsequent send to the same channel also inherits the thread context, making `"first"` semantically identical to `"all"`.

Compare with the Slack implementation in `extensions/slack/src/action-runtime.ts:113-114`:
```ts
if (context.replyToMode === "first" && context.hasRepliedRef && !context.hasRepliedRef.value) {
  context.hasRepliedRef.value = true;   // ← mutates the shared ref
  return context.currentThreadTs;
}
```
and again at line 252 as a belt-and-suspenders guard after the send.

The Mattermost `handleAction` needs the same mutation. One minimal fix, applied after the `replyToId` is resolved and before (or after) the actual send:

```ts
// After computing replyToId, mark the "first" slot as consumed.
if (
  toolContext?.replyToMode === "first" &&
  toolContext.hasRepliedRef &&
  isSameChannel &&
  replyToModeAllowsThread
) {
  toolContext.hasRepliedRef.value = true;
}
```

Without this, the existing test `"does not inherit thread context for replyToMode=first after first reply"` passes only because it pre-seeds `hasRepliedRef: { value: true }` by hand — it does not prove that a real sequential call would see `value === true` after the first send.

How can I resolve this? If you propose a fix, please make it concise.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f57e251391

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +196 to +200
const normalizedTo = normalizeMattermostMessagingTarget(to) ?? to;
const normalizedCurrentChannelId = toolContext?.currentChannelId
? (normalizeMattermostMessagingTarget(toolContext.currentChannelId) ??
toolContext.currentChannelId)
: undefined;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

P2 Badge Resolve channel-name targets before comparing thread context

Fresh evidence: normalizeMattermostMessagingTarget() still returns undefined for #channel and bare names (extensions/mattermost/src/normalize.ts:23-34), so this logic falls back to comparing the raw strings. In embedded/manual runs where currentChannelId was captured as #general but the tool later sends to channel:general or general, isSameChannel stays false and the new auto-thread fallback is skipped even though both targets resolve to the same Mattermost channel.

Useful? React with 👍 / 👎.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant