This commit is contained in:
Saurabh Chopda 2026-01-30 14:43:47 +00:00 committed by GitHub
commit a9d875a883
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 58 additions and 10 deletions

View File

@ -6,6 +6,7 @@ Docs: https://docs.openclaw.ai
Status: stable. Status: stable.
### Changes ### Changes
- Sessions: fix displayName being overwritten by outbound message recipient instead of session owner. (#4683)
- Rebrand: rename the npm package/CLI to `openclaw`, add a `openclaw` compatibility shim, and move extensions to the `@openclaw/*` scope. - Rebrand: rename the npm package/CLI to `openclaw`, add a `openclaw` compatibility shim, and move extensions to the `@openclaw/*` scope.
- Onboarding: strengthen security warning copy for beta + access control expectations. - Onboarding: strengthen security warning copy for beta + access control expectations.
- Onboarding: add Venice API key to non-interactive flow. (#1893) Thanks @jonisjongithub. - Onboarding: add Venice API key to non-interactive flow. (#1893) Thanks @jonisjongithub.

View File

@ -20,4 +20,33 @@ describe("deriveSessionMetaPatch", () => {
expect(patch?.channel).toBe("whatsapp"); expect(patch?.channel).toBe("whatsapp");
expect(patch?.groupId).toBe("123@g.us"); expect(patch?.groupId).toBe("123@g.us");
}); });
it("skips displayName when skipDisplayName is true", () => {
const patchWithDisplayName = deriveSessionMetaPatch({
ctx: {
Provider: "whatsapp",
ChatType: "group",
GroupSubject: "Family",
From: "123@g.us",
},
sessionKey: "agent:main:whatsapp:group:123@g.us",
});
expect(patchWithDisplayName?.displayName).toBeDefined();
const patchWithoutDisplayName = deriveSessionMetaPatch({
ctx: {
Provider: "whatsapp",
ChatType: "group",
GroupSubject: "Family",
From: "123@g.us",
},
sessionKey: "agent:main:whatsapp:group:123@g.us",
skipDisplayName: true,
});
expect(patchWithoutDisplayName?.displayName).toBeUndefined();
// Other fields should still be present
expect(patchWithoutDisplayName?.subject).toBe("Family");
expect(patchWithoutDisplayName?.channel).toBe("whatsapp");
expect(patchWithoutDisplayName?.groupId).toBe("123@g.us");
});
}); });

View File

@ -62,6 +62,8 @@ export function deriveGroupSessionPatch(params: {
sessionKey: string; sessionKey: string;
existing?: SessionEntry; existing?: SessionEntry;
groupResolution?: GroupKeyResolution | null; groupResolution?: GroupKeyResolution | null;
/** Skip displayName derivation (e.g., for outbound session entries). */
skipDisplayName?: boolean;
}): Partial<SessionEntry> | null { }): Partial<SessionEntry> | null {
const resolution = params.groupResolution ?? resolveGroupSessionKey(params.ctx); const resolution = params.groupResolution ?? resolveGroupSessionKey(params.ctx);
if (!resolution?.channel) return null; if (!resolution?.channel) return null;
@ -91,15 +93,17 @@ export function deriveGroupSessionPatch(params: {
if (nextGroupChannel) patch.groupChannel = nextGroupChannel; if (nextGroupChannel) patch.groupChannel = nextGroupChannel;
if (space) patch.space = space; if (space) patch.space = space;
const displayName = buildGroupDisplayName({ if (!params.skipDisplayName) {
provider: channel, const displayName = buildGroupDisplayName({
subject: nextSubject ?? params.existing?.subject, provider: channel,
groupChannel: nextGroupChannel ?? params.existing?.groupChannel, subject: nextSubject ?? params.existing?.subject,
space: space ?? params.existing?.space, groupChannel: nextGroupChannel ?? params.existing?.groupChannel,
id: resolution.id, space: space ?? params.existing?.space,
key: params.sessionKey, id: resolution.id,
}); key: params.sessionKey,
if (displayName) patch.displayName = displayName; });
if (displayName) patch.displayName = displayName;
}
return patch; return patch;
} }
@ -109,8 +113,16 @@ export function deriveSessionMetaPatch(params: {
sessionKey: string; sessionKey: string;
existing?: SessionEntry; existing?: SessionEntry;
groupResolution?: GroupKeyResolution | null; groupResolution?: GroupKeyResolution | null;
/** Skip displayName derivation (e.g., for outbound session entries). */
skipDisplayName?: boolean;
}): Partial<SessionEntry> | null { }): Partial<SessionEntry> | null {
const groupPatch = deriveGroupSessionPatch(params); const groupPatch = deriveGroupSessionPatch({
ctx: params.ctx,
sessionKey: params.sessionKey,
existing: params.existing,
groupResolution: params.groupResolution,
skipDisplayName: params.skipDisplayName,
});
const origin = deriveSessionOrigin(params.ctx); const origin = deriveSessionOrigin(params.ctx);
if (!groupPatch && !origin) return null; if (!groupPatch && !origin) return null;

View File

@ -361,6 +361,8 @@ export async function recordSessionMetaFromInbound(params: {
ctx: MsgContext; ctx: MsgContext;
groupResolution?: import("./types.js").GroupKeyResolution | null; groupResolution?: import("./types.js").GroupKeyResolution | null;
createIfMissing?: boolean; createIfMissing?: boolean;
/** Skip displayName derivation (e.g., for outbound session entries). */
skipDisplayName?: boolean;
}): Promise<SessionEntry | null> { }): Promise<SessionEntry | null> {
const { storePath, sessionKey, ctx } = params; const { storePath, sessionKey, ctx } = params;
const createIfMissing = params.createIfMissing ?? true; const createIfMissing = params.createIfMissing ?? true;
@ -371,6 +373,7 @@ export async function recordSessionMetaFromInbound(params: {
sessionKey, sessionKey,
existing, existing,
groupResolution: params.groupResolution, groupResolution: params.groupResolution,
skipDisplayName: params.skipDisplayName,
}); });
if (!patch) return existing ?? null; if (!patch) return existing ?? null;
if (!existing && !createIfMissing) return null; if (!existing && !createIfMissing) return null;

View File

@ -850,6 +850,9 @@ export async function ensureOutboundSessionEntry(params: {
storePath, storePath,
sessionKey: params.route.sessionKey, sessionKey: params.route.sessionKey,
ctx, ctx,
// Outbound sends should not update displayName since it represents the
// session owner (inbound initiator), not the last outbound recipient.
skipDisplayName: true,
}); });
} catch { } catch {
// Do not block outbound sends on session meta writes. // Do not block outbound sends on session meta writes.