From ee4be1f989175a8a8ba0be0b44888d29db7fdbab Mon Sep 17 00:00:00 2001 From: Gustavo Madeira Santana Date: Sun, 8 Mar 2026 21:54:01 -0400 Subject: [PATCH] Matrix: keep default account device fields scoped --- extensions/matrix/src/channel.directory.test.ts | 13 +++++++++++++ src/channels/plugins/setup-helpers.ts | 2 ++ 2 files changed, 15 insertions(+) diff --git a/extensions/matrix/src/channel.directory.test.ts b/extensions/matrix/src/channel.directory.test.ts index 5dc08b1d102..3e937934fd9 100644 --- a/extensions/matrix/src/channel.directory.test.ts +++ b/extensions/matrix/src/channel.directory.test.ts @@ -1,6 +1,7 @@ import type { PluginRuntime, RuntimeEnv } from "openclaw/plugin-sdk/matrix"; import { beforeEach, describe, expect, it, vi } from "vitest"; import { matrixPlugin } from "./channel.js"; +import { resolveMatrixConfigForAccount } from "./matrix/client/config.js"; import { setMatrixRuntime } from "./runtime.js"; import type { CoreConfig } from "./types.js"; @@ -192,6 +193,8 @@ describe("matrix directory", () => { matrix: { homeserver: "https://default.example.org", accessToken: "default-token", + deviceId: "DEFAULTDEVICE", + avatarUrl: "mxc://server/avatar", encryption: true, threadReplies: "inbound", groups: { @@ -212,9 +215,13 @@ describe("matrix directory", () => { }) as CoreConfig; expect(updated.channels?.["matrix"]?.accessToken).toBeUndefined(); + expect(updated.channels?.["matrix"]?.deviceId).toBeUndefined(); + expect(updated.channels?.["matrix"]?.avatarUrl).toBeUndefined(); expect(updated.channels?.["matrix"]?.accounts?.default).toMatchObject({ accessToken: "default-token", homeserver: "https://default.example.org", + deviceId: "DEFAULTDEVICE", + avatarUrl: "mxc://server/avatar", encryption: true, threadReplies: "inbound", groups: { @@ -227,6 +234,12 @@ describe("matrix directory", () => { userId: "@ops:example.org", accessToken: "ops-token", }); + expect(resolveMatrixConfigForAccount(updated, "ops", {})).toMatchObject({ + homeserver: "https://matrix.example.org", + userId: "@ops:example.org", + accessToken: "ops-token", + deviceId: undefined, + }); }); it("writes default matrix account credentials under channels.matrix.accounts.default", () => { diff --git a/src/channels/plugins/setup-helpers.ts b/src/channels/plugins/setup-helpers.ts index 1e5f0ffb1eb..d2d5be73f85 100644 --- a/src/channels/plugins/setup-helpers.ts +++ b/src/channels/plugins/setup-helpers.ts @@ -336,6 +336,8 @@ const COMMON_SINGLE_ACCOUNT_KEYS_TO_MOVE = new Set([ const SINGLE_ACCOUNT_KEYS_TO_MOVE_BY_CHANNEL: Record> = { matrix: new Set([ + "deviceId", + "avatarUrl", "initialSyncLimit", "encryption", "allowlistOnly",