Skip to content

Commit 265b22c

Browse files
Mark LTakhoffman
andauthored
fix(slack): skip monitor startup for disabled accounts [AI-assisted] (#30592) thanks @liuxiaopai-ai
Verified: - pnpm install --frozen-lockfile - pnpm build - pnpm check - pnpm test:macmini Co-authored-by: liuxiaopai-ai <[email protected]> Co-authored-by: Tak Hoffman <[email protected]>
1 parent 53d6e07 commit 265b22c

File tree

3 files changed

+43
-2
lines changed

3 files changed

+43
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ Docs: https://docs.openclaw.ai
113113
- Android/Onboarding + voice reliability: request per-toggle onboarding permissions, update pairing guidance to `openclaw devices list/approve`, restore assistant speech playback in mic capture flow, cancel superseded in-flight speech (mute + per-reply token rotation), and keep `talk.config` loads retryable after transient failures. (#29796) Thanks @obviyus.
114114
- FS/Sandbox workspace boundaries: add a dedicated `outside-workspace` safe-open error code for root-escape checks, and propagate specific outside-workspace messages across edit/browser/media consumers instead of generic not-found/invalid-path fallbacks. (#29715) Thanks @YuzuruS.
115115
- Config/Doctor group allowlist diagnostics: align `groupPolicy: "allowlist"` warnings with per-channel runtime semantics by excluding Google Chat sender-list checks and by warning when no-fallback channels (for example iMessage) omit `groupAllowFrom`, with regression coverage. (#28477) Thanks @tonydehnke.
116+
- Slack/Disabled channel startup: skip Slack monitor socket startup entirely when `channels.slack.enabled=false` (including configs that still contain valid tokens), preventing disabled accounts from opening websocket connections. (#30586)
116117
- Onboarding/Custom providers: use Azure OpenAI-specific verification auth/payload shape (`api-key`, deployment-path chat completions payload) when probing Azure endpoints so valid Azure custom-provider setup no longer fails preflight. (#29421) Thanks @kunalk16.
117118
- Feishu/Docx editing tools: add `feishu_doc` positional insert, table row/column operations, table-cell merge, and color-text updates; switch markdown write/append/insert to Descendant API insertion with large-document batching; and harden image uploads for data URI/base64/local-path inputs with strict validation and routing-safe upload metadata. (#29411) Thanks @Elarwei001.
118119

src/slack/monitor.tool-result.test.ts

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import {
66
defaultSlackTestConfig,
77
getSlackTestState,
88
getSlackClient,
9+
getSlackHandlers,
910
getSlackHandlerOrThrow,
11+
flush,
1012
resetSlackTestState,
1113
runSlackMessageOnce,
1214
startSlackMonitor,
@@ -119,6 +121,32 @@ describe("monitorSlackProvider tool results", () => {
119121
};
120122
}
121123

124+
it("skips socket startup when Slack channel is disabled", async () => {
125+
slackTestState.config = {
126+
channels: {
127+
slack: {
128+
enabled: false,
129+
mode: "socket",
130+
botToken: "xoxb-config",
131+
appToken: "xapp-config",
132+
},
133+
},
134+
};
135+
const client = getSlackClient();
136+
if (!client) {
137+
throw new Error("Slack client not registered");
138+
}
139+
client.auth.test.mockClear();
140+
141+
const { controller, run } = startSlackMonitor(monitorSlackProvider);
142+
await flush();
143+
controller.abort();
144+
await run;
145+
146+
expect(client.auth.test).not.toHaveBeenCalled();
147+
expect(getSlackHandlers()?.size ?? 0).toBe(0);
148+
});
149+
122150
it("skips tool summaries with responsePrefix", async () => {
123151
replyMock.mockResolvedValue({ text: "final reply" });
124152

src/slack/monitor/provider.ts

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,26 @@ function parseApiAppIdFromAppToken(raw?: string) {
5858

5959
export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) {
6060
const cfg = opts.config ?? loadConfig();
61+
const runtime: RuntimeEnv = opts.runtime ?? createNonExitingRuntime();
6162

6263
let account = resolveSlackAccount({
6364
cfg,
6465
accountId: opts.accountId,
6566
});
6667

68+
if (!account.enabled) {
69+
runtime.log?.(`[${account.accountId}] slack account disabled; monitor startup skipped`);
70+
if (opts.abortSignal?.aborted) {
71+
return;
72+
}
73+
await new Promise<void>((resolve) => {
74+
opts.abortSignal?.addEventListener("abort", () => resolve(), {
75+
once: true,
76+
});
77+
});
78+
return;
79+
}
80+
6781
const historyLimit = Math.max(
6882
0,
6983
account.config.historyLimit ??
@@ -93,8 +107,6 @@ export async function monitorSlackProvider(opts: MonitorSlackOpts = {}) {
93107
);
94108
}
95109

96-
const runtime: RuntimeEnv = opts.runtime ?? createNonExitingRuntime();
97-
98110
const slackCfg = account.config;
99111
const dmConfig = slackCfg.dm;
100112

0 commit comments

Comments
 (0)