diff --git a/extensions/matrix/src/matrix/accounts.ts b/extensions/matrix/src/matrix/accounts.ts index 385c99864a8..2da5614abf1 100644 --- a/extensions/matrix/src/matrix/accounts.ts +++ b/extensions/matrix/src/matrix/accounts.ts @@ -18,7 +18,10 @@ function listConfiguredAccountIds(cfg: CoreConfig): string[] { if (!accounts || typeof accounts !== "object") { return []; } - return Object.keys(accounts).filter(Boolean); + // Normalize keys so listing and resolution use the same semantics + return Object.keys(accounts) + .filter(Boolean) + .map((id) => normalizeAccountId(id)); } export function listMatrixAccountIds(cfg: CoreConfig): string[] { @@ -43,7 +46,18 @@ function resolveAccountConfig(cfg: CoreConfig, accountId: string): MatrixConfig if (!accounts || typeof accounts !== "object") { return undefined; } - return accounts[accountId] as MatrixConfig | undefined; + // Direct lookup first (fast path for already-normalized keys) + if (accounts[accountId]) { + return accounts[accountId] as MatrixConfig; + } + // Fall back to case-insensitive match (user may have mixed-case keys in config) + const normalized = normalizeAccountId(accountId); + for (const key of Object.keys(accounts)) { + if (normalizeAccountId(key) === normalized) { + return accounts[key] as MatrixConfig; + } + } + return undefined; } export function resolveMatrixAccount(params: { diff --git a/extensions/matrix/src/matrix/client/config.ts b/extensions/matrix/src/matrix/client/config.ts index 3e48c28e99d..7fbb281d9bf 100644 --- a/extensions/matrix/src/matrix/client/config.ts +++ b/extensions/matrix/src/matrix/client/config.ts @@ -22,8 +22,16 @@ export function resolveMatrixConfigForAccount( const normalizedAccountId = normalizeAccountId(accountId); const matrixBase = cfg.channels?.matrix ?? {}; - // Try to get account-specific config first - const accountConfig = matrixBase.accounts?.[normalizedAccountId]; + // Try to get account-specific config first (direct lookup, then case-insensitive fallback) + let accountConfig = matrixBase.accounts?.[normalizedAccountId]; + if (!accountConfig && matrixBase.accounts) { + for (const key of Object.keys(matrixBase.accounts)) { + if (normalizeAccountId(key) === normalizedAccountId) { + accountConfig = matrixBase.accounts[key]; + break; + } + } + } // Merge: account-specific values override top-level values // For DEFAULT_ACCOUNT_ID with no accounts, use top-level directly