fix: honor bluebubbles default runtime account

This commit is contained in:
Tak Hoffman
2026-04-03 13:39:22 -05:00
parent 9289f967df
commit 17c0026c04
2 changed files with 31 additions and 1 deletions

View File

@@ -41,7 +41,9 @@ export function resolveBlueBubblesAccount(params: {
cfg: OpenClawConfig;
accountId?: string | null;
}): ResolvedBlueBubblesAccount {
const accountId = normalizeAccountId(params.accountId);
const accountId = normalizeAccountId(
params.accountId ?? resolveDefaultBlueBubblesAccountId(params.cfg),
);
const baseEnabled = params.cfg.channels?.bluebubbles?.enabled;
const merged = mergeBlueBubblesAccountConfig(params.cfg, accountId);
const accountEnabled = merged.enabled !== false;

View File

@@ -217,6 +217,34 @@ describe("bluebubbles setup surface", () => {
expect(next?.channels?.bluebubbles?.accounts?.work?.dmPolicy).toBe("open");
});
it("uses configured defaultAccount when accountId is omitted in account resolution", async () => {
const { resolveBlueBubblesAccount } = await import("./accounts.js");
const resolved = resolveBlueBubblesAccount({
cfg: {
channels: {
bluebubbles: {
defaultAccount: "work",
serverUrl: "http://localhost:3000",
password: "top-secret",
accounts: {
work: {
serverUrl: "http://localhost:1234",
password: "secret",
name: "Work",
},
},
},
},
} as OpenClawConfig,
});
expect(resolved.accountId).toBe("work");
expect(resolved.name).toBe("Work");
expect(resolved.baseUrl).toBe("http://localhost:1234");
expect(resolved.configured).toBe(true);
});
it('writes open policy state to the named account and preserves inherited allowFrom with "*"', async () => {
const { blueBubblesSetupWizard } = await import("./setup-surface.js");