diff --git a/src/channels/plugins/account-helpers.test.ts b/src/channels/plugins/account-helpers.test.ts index 9a7a67cf652..b82625dd0c2 100644 --- a/src/channels/plugins/account-helpers.test.ts +++ b/src/channels/plugins/account-helpers.test.ts @@ -81,6 +81,35 @@ describe("createAccountListHelpers", () => { it("returns sorted ids", () => { expect(listAccountIds(cfg({ z: {}, a: {}, m: {} }))).toEqual(["a", "m", "z"]); }); + + it("includes default when base config has botToken and named accounts exist", () => { + const config = { + channels: { + testchannel: { + botToken: "xoxb-base", + appToken: "xapp-base", + accounts: { tank: {} }, + }, + }, + } as unknown as OpenClawConfig; + expect(listAccountIds(config)).toEqual(["default", "tank"]); + }); + + it("does not duplicate default when already in accounts", () => { + const config = { + channels: { + testchannel: { + botToken: "xoxb-base", + accounts: { default: {}, tank: {} }, + }, + }, + } as unknown as OpenClawConfig; + expect(listAccountIds(config)).toEqual(["default", "tank"]); + }); + + it("does not include default when base has no tokens", () => { + expect(listAccountIds(cfg({ tank: {} }))).toEqual(["tank"]); + }); }); describe("resolveDefaultAccountId", () => { diff --git a/src/channels/plugins/account-helpers.ts b/src/channels/plugins/account-helpers.ts index 7f72b5e3c55..03fbf9a9725 100644 --- a/src/channels/plugins/account-helpers.ts +++ b/src/channels/plugins/account-helpers.ts @@ -43,6 +43,16 @@ export function createAccountListHelpers( if (ids.length === 0) { return [DEFAULT_ACCOUNT_ID]; } + // If the base channel config has its own tokens (botToken/appToken/token), + // include the default account alongside named accounts so both providers start. + if (!ids.includes(DEFAULT_ACCOUNT_ID)) { + const channel = cfg.channels?.[channelKey]; + const base = channel as Record | undefined; + const hasBaseTokens = Boolean(base?.botToken || base?.appToken || base?.token); + if (hasBaseTokens) { + return [DEFAULT_ACCOUNT_ID, ...ids].toSorted((a, b) => a.localeCompare(b)); + } + } return ids.toSorted((a, b) => a.localeCompare(b)); }