Skip to content

Commit d8f8522

Browse files
committed
refactor(slack): keep slash fix focused
1 parent 01e9e9a commit d8f8522

2 files changed

Lines changed: 2 additions & 121 deletions

File tree

‎extensions/slack/src/monitor/slash.test.ts‎

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1575,112 +1575,6 @@ describe("slack slash command session metadata", () => {
15751575
);
15761576
});
15771577

1578-
it("keeps the monitor's resolved secrets when the runtime snapshot is unrelated", async () => {
1579-
const harness = createPolicyHarness({
1580-
channelId: "D123",
1581-
channelName: "directmessage",
1582-
resolveChannelName: async () => ({ name: "directmessage", type: "im" }),
1583-
});
1584-
const resolvedCfg = {
1585-
...(harness.ctx as { cfg: OpenClawConfig }).cfg,
1586-
channels: {
1587-
slack: {
1588-
accounts: {
1589-
default: {
1590-
botToken: "xoxb-resolved",
1591-
appToken: "xapp-resolved",
1592-
},
1593-
},
1594-
},
1595-
},
1596-
} as OpenClawConfig;
1597-
(harness.ctx as { cfg: OpenClawConfig }).cfg = resolvedCfg;
1598-
const unresolvedSnapshot = {
1599-
channels: {
1600-
slack: {
1601-
accounts: {
1602-
default: {
1603-
botToken: {
1604-
source: "env",
1605-
provider: "default",
1606-
id: "SLACK_BOT_TOKEN",
1607-
},
1608-
appToken: {
1609-
source: "env",
1610-
provider: "default",
1611-
id: "SLACK_APP_TOKEN",
1612-
},
1613-
},
1614-
},
1615-
},
1616-
},
1617-
} as OpenClawConfig;
1618-
setRuntimeConfigSnapshot(unresolvedSnapshot, unresolvedSnapshot);
1619-
await registerCommands(harness.ctx, harness.account);
1620-
1621-
await runSlashHandler({
1622-
commands: harness.commands,
1623-
command: {
1624-
channel_id: harness.channelId,
1625-
channel_name: harness.channelName,
1626-
},
1627-
});
1628-
1629-
expect(dispatchMock).toHaveBeenCalledWith(
1630-
expect.objectContaining({
1631-
cfg: resolvedCfg,
1632-
}),
1633-
);
1634-
});
1635-
1636-
it("adopts matching runtime refreshes after resolving monitor secrets", async () => {
1637-
const harness = createPolicyHarness({
1638-
channelId: "D123",
1639-
channelName: "directmessage",
1640-
resolveChannelName: async () => ({ name: "directmessage", type: "im" }),
1641-
});
1642-
const sourceCfg = (harness.ctx as { cfg: OpenClawConfig }).cfg;
1643-
const resolvedCfg = {
1644-
...sourceCfg,
1645-
channels: {
1646-
slack: {
1647-
accounts: {
1648-
default: {
1649-
botToken: "xoxb-resolved",
1650-
appToken: "xapp-resolved",
1651-
},
1652-
},
1653-
},
1654-
},
1655-
} as OpenClawConfig;
1656-
const refreshedSourceCfg = {
1657-
...sourceCfg,
1658-
session: { dmScope: "per-channel-peer" },
1659-
} as OpenClawConfig;
1660-
const refreshedResolvedCfg = {
1661-
...resolvedCfg,
1662-
session: { dmScope: "per-channel-peer" },
1663-
} as OpenClawConfig;
1664-
(harness.ctx as { cfg: OpenClawConfig }).cfg = resolvedCfg;
1665-
setRuntimeConfigSnapshot(resolvedCfg, sourceCfg);
1666-
await registerCommands(harness.ctx, harness.account);
1667-
setRuntimeConfigSnapshot(refreshedResolvedCfg, refreshedSourceCfg);
1668-
1669-
await runSlashHandler({
1670-
commands: harness.commands,
1671-
command: {
1672-
channel_id: harness.channelId,
1673-
channel_name: harness.channelName,
1674-
},
1675-
});
1676-
1677-
expect(dispatchMock).toHaveBeenCalledWith(
1678-
expect.objectContaining({
1679-
cfg: refreshedResolvedCfg,
1680-
}),
1681-
);
1682-
});
1683-
16841578
it("calls recordSessionMetaFromInbound after dispatching a slash command", async () => {
16851579
const harness = createPolicyHarness({ groupPolicy: "open" });
16861580
await registerAndRunPolicySlash({ harness });

‎extensions/slack/src/monitor/slash.ts‎

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ import {
2121
} from "openclaw/plugin-sdk/native-command-config-runtime";
2222
import type { ReplyPayload } from "openclaw/plugin-sdk/reply-runtime";
2323
import type { ResolvedAgentRoute } from "openclaw/plugin-sdk/routing";
24-
import {
25-
getRuntimeConfigSnapshot,
26-
getRuntimeConfigSourceSnapshot,
27-
selectApplicableRuntimeConfig,
28-
} from "openclaw/plugin-sdk/runtime-config-snapshot";
24+
import { getRuntimeConfigSnapshot } from "openclaw/plugin-sdk/runtime-config-snapshot";
2925
import { danger, logVerbose, warn } from "openclaw/plugin-sdk/runtime-env";
3026
import { getSessionEntry, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
3127
import {
@@ -387,7 +383,6 @@ export async function registerSlackMonitorSlashCommands(params: {
387383
const slashCommand = resolveSlackSlashCommandConfig(
388384
ctx.slashCommand ?? account.config.slashCommand,
389385
);
390-
const startupRuntimeSourceConfig = getRuntimeConfigSourceSnapshot();
391386

392387
const handleSlashCommand = async (p: {
393388
command: SlackCommandMiddlewareArgs["command"];
@@ -416,15 +411,7 @@ export async function registerSlackMonitorSlashCommands(params: {
416411
}
417412
: createSlackResponseUrlBudget(respondWithoutBudget);
418413
const respond = responseBudget.respond;
419-
const applicableRuntimeConfig = selectApplicableRuntimeConfig({
420-
inputConfig: startupRuntimeSourceConfig ?? ctx.cfg,
421-
runtimeConfig: getRuntimeConfigSnapshot(),
422-
runtimeSourceConfig: getRuntimeConfigSourceSnapshot(),
423-
});
424-
const cfg =
425-
applicableRuntimeConfig === startupRuntimeSourceConfig
426-
? ctx.cfg
427-
: (applicableRuntimeConfig ?? ctx.cfg);
414+
const cfg = getRuntimeConfigSnapshot() ?? ctx.cfg;
428415
try {
429416
if (ctx.shouldDropMismatchedSlackEvent?.(body)) {
430417
await ack();

0 commit comments

Comments
 (0)