fix: honor bluebubbles action discovery account config

This commit is contained in:
Tak Hoffman
2026-04-03 11:11:50 -05:00
parent 0b4cdfc53e
commit da5c6ac2b6
3 changed files with 38 additions and 5 deletions

View File

@@ -125,6 +125,28 @@ describe("bluebubblesMessageActions", () => {
expect(actions).toContain("unsend");
});
it("honors account-scoped action gates during discovery", () => {
const cfg: OpenClawConfig = {
channels: {
bluebubbles: {
serverUrl: "http://localhost:1234",
password: "test-password",
actions: { reactions: false },
accounts: {
work: {
serverUrl: "http://localhost:5678",
password: "work-password",
actions: { reactions: true },
},
},
},
},
};
expect(describeMessageTool({ cfg, accountId: "default" })?.actions).not.toContain("react");
expect(describeMessageTool({ cfg, accountId: "work" })?.actions).toContain("react");
});
it("hides private-api actions when private API is disabled", () => {
vi.mocked(getCachedBlueBubblesPrivateApiStatus).mockReturnValueOnce(false);
const cfg: OpenClawConfig = {

View File

@@ -72,12 +72,12 @@ const PRIVATE_API_ACTIONS = new Set<ChannelMessageActionName>([
]);
export const bluebubblesMessageActions: ChannelMessageActionAdapter = {
describeMessageTool: ({ cfg, currentChannelId }) => {
const account = resolveBlueBubblesAccount({ cfg: cfg });
describeMessageTool: ({ cfg, accountId, currentChannelId }) => {
const account = resolveBlueBubblesAccount({ cfg, accountId });
if (!account.enabled || !account.configured) {
return null;
}
const gate = createActionGate(cfg.channels?.bluebubbles?.actions);
const gate = createActionGate(account.config.actions);
const actions = new Set<ChannelMessageActionName>();
const macOS26 = isMacOS26OrHigher(account.accountId);
const privateApiStatus = getCachedBlueBubblesPrivateApiStatus(account.accountId);

View File

@@ -31,9 +31,20 @@ export function resolveBlueBubblesAccountFromConfig(params: {
cfg?: { channels?: { bluebubbles?: Record<string, unknown> } };
accountId?: string;
}) {
const config = params.cfg?.channels?.bluebubbles ?? {};
const baseConfig = params.cfg?.channels?.bluebubbles ?? {};
const accountId = params.accountId ?? "default";
const accountConfig =
accountId === "default"
? {}
: ((baseConfig.accounts as Record<string, Record<string, unknown> | undefined> | undefined)?.[
accountId
] ?? {});
const config = {
...baseConfig,
...accountConfig,
};
return {
accountId: params.accountId ?? "default",
accountId,
enabled: config.enabled !== false,
configured: Boolean(config.serverUrl && config.password),
config,