fix: keep main session displayName on outbound sends

This commit is contained in:
Manoj Naik 2026-01-30 19:59:58 +05:30
parent 6af205a13a
commit 0267171e29

View File

@ -2,7 +2,11 @@ import type { MsgContext } from "../../auto-reply/templating.js";
import { getChannelPlugin } from "../../channels/plugins/index.js"; import { getChannelPlugin } from "../../channels/plugins/index.js";
import type { ChannelId } from "../../channels/plugins/types.js"; import type { ChannelId } from "../../channels/plugins/types.js";
import type { OpenClawConfig } from "../../config/config.js"; import type { OpenClawConfig } from "../../config/config.js";
import { recordSessionMetaFromInbound, resolveStorePath } from "../../config/sessions.js"; import {
recordSessionMetaFromInbound,
resolveStorePath,
updateLastRoute,
} from "../../config/sessions.js";
import { parseDiscordTarget } from "../../discord/targets.js"; import { parseDiscordTarget } from "../../discord/targets.js";
import { parseIMessageTarget, normalizeIMessageHandle } from "../../imessage/targets.js"; import { parseIMessageTarget, normalizeIMessageHandle } from "../../imessage/targets.js";
import { import {
@ -10,7 +14,7 @@ import {
type RoutePeer, type RoutePeer,
type RoutePeerKind, type RoutePeerKind,
} from "../../routing/resolve-route.js"; } from "../../routing/resolve-route.js";
import { resolveThreadSessionKeys } from "../../routing/session-key.js"; import { buildAgentMainSessionKey, resolveThreadSessionKeys } from "../../routing/session-key.js";
import { resolveSlackAccount } from "../../slack/accounts.js"; import { resolveSlackAccount } from "../../slack/accounts.js";
import { createSlackWebClient } from "../../slack/client.js"; import { createSlackWebClient } from "../../slack/client.js";
import { normalizeAllowListLower } from "../../slack/monitor/allow-list.js"; import { normalizeAllowListLower } from "../../slack/monitor/allow-list.js";
@ -833,6 +837,24 @@ export async function ensureOutboundSessionEntry(params: {
const storePath = resolveStorePath(params.cfg.session?.store, { const storePath = resolveStorePath(params.cfg.session?.store, {
agentId: params.agentId, agentId: params.agentId,
}); });
const mainSessionKey = buildAgentMainSessionKey({ agentId: params.agentId });
if (params.route.baseSessionKey === mainSessionKey) {
try {
await updateLastRoute({
storePath,
sessionKey: params.route.sessionKey,
deliveryContext: {
channel: params.channel,
to: params.route.to,
accountId: params.accountId ?? undefined,
threadId: params.route.threadId,
},
});
} catch {
// Do not block outbound sends on session store writes.
}
return;
}
const ctx: MsgContext = { const ctx: MsgContext = {
From: params.route.from, From: params.route.from,
To: params.route.to, To: params.route.to,