fix(hooks): avoid stale thread ownership startup fallback · openclaw/openclaw@65ae1e5
vincentkoc
·
2026-04-23
·
via Recent Commits to openclaw:main
File tree
extensions/thread-ownership
| Original file line number | Diff line number | Diff line change |
|---|
@@ -211,6 +211,32 @@ describe("thread-ownership plugin", () => {
|
211 | 211 | expect(globalThis.fetch).not.toHaveBeenCalled(); |
212 | 212 | }); |
213 | 213 | |
| 214 | +it("does not fall back to startup allowlists when live plugin config is removed", async () => { |
| 215 | +api.pluginConfig = { abTestChannels: ["C999"] }; |
| 216 | +register.register(api as unknown as OpenClawPluginApi); |
| 217 | +vi.mocked(globalThis.fetch).mockResolvedValue( |
| 218 | +new Response(JSON.stringify({ owner: "test-agent" }), { status: 200 }), |
| 219 | +); |
| 220 | + |
| 221 | +const result = await hooks.message_sending( |
| 222 | +{ |
| 223 | +content: "hello", |
| 224 | +replyToId: "1234.5678", |
| 225 | +to: "C123", |
| 226 | +}, |
| 227 | +{ channelId: "slack", conversationId: "C123" }, |
| 228 | +); |
| 229 | + |
| 230 | +expect(result).toBeUndefined(); |
| 231 | +expect(globalThis.fetch).toHaveBeenCalledWith( |
| 232 | +"http://localhost:8750/api/v1/ownership/C123/1234.5678", |
| 233 | +expect.objectContaining({ |
| 234 | +method: "POST", |
| 235 | +body: JSON.stringify({ agent_id: "test-agent" }), |
| 236 | +}), |
| 237 | +); |
| 238 | +}); |
| 239 | + |
214 | 240 | it("cancels when thread owned by another agent", async () => { |
215 | 241 | vi.mocked(globalThis.fetch).mockResolvedValue( |
216 | 242 | new Response(JSON.stringify({ owner: "other-agent" }), { status: 409 }), |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -83,11 +83,14 @@ export default definePluginEntry({
|
83 | 83 | description: "Slack thread claim coordination for multi-agent setups", |
84 | 84 | register(api: OpenClawPluginApi) { |
85 | 85 | const resolveCurrentState = () => { |
86 | | -const currentConfig = api.runtime.config?.loadConfig?.() ?? api.config; |
| 86 | +const runtimeConfigAvailable = typeof api.runtime.config?.loadConfig === "function"; |
| 87 | +const currentConfig = runtimeConfigAvailable |
| 88 | + ? (api.runtime.config.loadConfig() ?? api.config) |
| 89 | + : api.config; |
87 | 90 | const livePluginCfg = resolvePluginConfigObject(currentConfig, "thread-ownership"); |
88 | 91 | const pluginCfg = isThreadOwnershipConfig(livePluginCfg) |
89 | 92 | ? livePluginCfg |
90 | | - : isThreadOwnershipConfig(api.pluginConfig) |
| 93 | + : !runtimeConfigAvailable && isThreadOwnershipConfig(api.pluginConfig) |
91 | 94 | ? api.pluginConfig |
92 | 95 | : {}; |
93 | 96 | return { |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -70,7 +70,8 @@ const BUNDLED_LIVE_CONFIG_HOOK_GUARDS = {
|
70 | 70 | ], |
71 | 71 | "extensions/thread-ownership/index.ts": [ |
72 | 72 | 'resolvePluginConfigObject(currentConfig, "thread-ownership")', |
73 | | -"api.runtime.config?.loadConfig?.() ?? api.config", |
| 73 | +'typeof api.runtime.config?.loadConfig === "function"', |
| 74 | +"api.runtime.config.loadConfig() ?? api.config", |
74 | 75 | ], |
75 | 76 | } as const satisfies Record<string, readonly string[]>; |
76 | 77 | |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。