惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

V
V2EX
Y
Y Combinator Blog
博客园_首页
V
Visual Studio Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
阮一峰的网络日志
阮一峰的网络日志
Hugging Face - Blog
Hugging Face - Blog
宝玉的分享
宝玉的分享
B
Blog
博客园 - 三生石上(FineUI控件)
小众软件
小众软件
WordPress大学
WordPress大学
L
LangChain Blog
爱范儿
爱范儿
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Proofpoint News Feed
Blog — PlanetScale
Blog — PlanetScale
C
Check Point Blog
博客园 - 聂微东
云风的 BLOG
云风的 BLOG
Microsoft Security Blog
Microsoft Security Blog
博客园 - 叶小钗
酷 壳 – CoolShell
酷 壳 – CoolShell
H
Help Net Security

Recent Commits to openclaw:main

test: merge chat side-result checks · openclaw/openclaw@ddd2c2a test: merge cron history checks · openclaw/openclaw@f7eb746 test: merge responsive navigation shell checks · openclaw/openclaw@c2e4b47 docs(changelog): add codex oauth fixes · openclaw/openclaw@628e6cd test: merge navigation routing cases · openclaw/openclaw@5d8cecb Tests: mock channel registry bundled fallback · openclaw/openclaw@2b08233 Secrets: avoid broad web search discovery for single plugin config · openclaw/openclaw@a464f59 test: merge config view browser checks · openclaw/openclaw@20cf511 fix(status): align oauth health with runtime · openclaw/openclaw@eed7116 feat: add macOS screen snapshots for monitor preview (#67954) thanks … · openclaw/openclaw@f377db1 fix: report shared auth scopes in hello-ok (#67810) thanks @BunsDev · openclaw/openclaw@0b6c39b Auto-reply: avoid eager bundled route fallback · openclaw/openclaw@3ea1bf4 Tests: narrow session binding contract setup · openclaw/openclaw@54e4e16 fix(macOS): enable undo/redo in webchat composer text input (#34962) · openclaw/openclaw@00951dc Tests: speed up channel setup promotion · openclaw/openclaw@82b529a Docs: refresh agent instructions · openclaw/openclaw@5775fe2 fix(auth): serialize OAuth refresh across agents to fix #26322 (#67876) · openclaw/openclaw@8e79080 test: allow ollama public surface boundary test · openclaw/openclaw@7d4f1a6 Docs: add test performance guardrails · openclaw/openclaw@89706d3 Tests: restore context-engine usage proof · openclaw/openclaw@e4c4f95 Tests: slim context engine runtime coverage · openclaw/openclaw@74c198f ci: retry failed custom checkouts · openclaw/openclaw@0ee5baf test: trim duplicate provider auth onboarding cases · openclaw/openclaw@1ffc02e matrix: fix sessions_spawn --thread subagent session spawning (#67643) · openclaw/openclaw@1ce2596 test: reduce auth choice fixture churn · openclaw/openclaw@857b9cd test: mock health status config boundaries · openclaw/openclaw@9d5ab4a test: mock onboard config io boundary · openclaw/openclaw@299694d test: mock legacy state plugin boundaries · openclaw/openclaw@2713089 test: mock channel install boundaries · openclaw/openclaw@b945248 test: mock doctor preview channel boundaries · openclaw/openclaw@b1a3ad4
fix(discord): route thread bindings to plugin owners · op...
SYU8384 · 2026-06-01 · via Recent Commits to openclaw:main
11

import { beforeAll, beforeEach, describe, expect, it, vi, type Mock } from "vitest";

22

import { clearAgentHarnesses, registerAgentHarness } from "../../agents/harness/registry.js";

3+

import type { ChannelMessagingAdapter } from "../../channels/plugins/types.core.js";

34

import type { OpenClawConfig } from "../../config/config.js";

45

import {

56

clearApprovalNativeRouteStateForTest,

@@ -38,6 +39,9 @@ import { resolveRoutedDeliveryThreadId } from "./routed-delivery-thread.js";

3839

import { buildTestCtx } from "./test-ctx.js";

39404041

type AbortResult = { handled: boolean; aborted: boolean; stoppedSubagents?: number };

42+

type ResolveInboundConversationParams = Parameters<

43+

NonNullable<ChannelMessagingAdapter["resolveInboundConversation"]>

44+

>[0];

41454246

const mocks = vi.hoisted(() => ({

4347

routeReply: vi.fn(async (_params: unknown) => ({ ok: true, messageId: "mock" })),

@@ -5210,6 +5214,126 @@ describe("dispatchReplyFromConfig", () => {

52105214

expect(replyResolver).not.toHaveBeenCalled();

52115215

});

521252165217+

it("routes Discord thread plugin-owned bindings by raw thread id", async () => {

5218+

setNoAbort();

5219+

setActivePluginRegistry(

5220+

createTestRegistry([

5221+

{

5222+

pluginId: "discord",

5223+

source: "test",

5224+

plugin: {

5225+

...createChannelTestPluginBase({ id: "discord" }),

5226+

messaging: {

5227+

resolveInboundConversation: ({

5228+

to,

5229+

conversationId,

5230+

threadId,

5231+

threadParentId,

5232+

}: ResolveInboundConversationParams) =>

5233+

threadId

5234+

? {

5235+

conversationId: String(threadId),

5236+

...(threadParentId

5237+

? { parentConversationId: `channel:${threadParentId}` }

5238+

: {}),

5239+

}

5240+

: { conversationId: to ?? conversationId },

5241+

},

5242+

},

5243+

},

5244+

]),

5245+

);

5246+

hookMocks.runner.hasHooks.mockImplementation(

5247+

((hookName?: string) =>

5248+

hookName === "inbound_claim" || hookName === "message_received") as () => boolean,

5249+

);

5250+

hookMocks.registry.plugins = [{ id: "openclaw-codex-app-server", status: "loaded" }];

5251+

hookMocks.runner.runInboundClaimForPluginOutcome.mockResolvedValue({

5252+

status: "handled",

5253+

result: { handled: true },

5254+

});

5255+

sessionBindingMocks.resolveByConversation.mockImplementation(

5256+

(ref: {

5257+

channel: string;

5258+

accountId: string;

5259+

conversationId: string;

5260+

parentConversationId?: string;

5261+

}) =>

5262+

ref.channel === "discord" &&

5263+

ref.accountId === "default" &&

5264+

ref.conversationId === "1510164477642014740"

5265+

? ({

5266+

bindingId: "binding-discord-thread",

5267+

targetSessionKey: "plugin-binding:codex:thread",

5268+

targetKind: "session",

5269+

conversation: {

5270+

channel: "discord",

5271+

accountId: "default",

5272+

conversationId: "1510164477642014740",

5273+

parentConversationId: "channel:1510164477642014999",

5274+

},

5275+

status: "active",

5276+

boundAt: 1710000000000,

5277+

metadata: {

5278+

pluginBindingOwner: "plugin",

5279+

pluginId: "openclaw-codex-app-server",

5280+

pluginRoot: "/plugins/openclaw-codex-app-server",

5281+

},

5282+

} satisfies SessionBindingRecord)

5283+

: null,

5284+

);

5285+

const dispatcher = createDispatcher();

5286+

const ctx = buildTestCtx({

5287+

Provider: "discord",

5288+

Surface: "discord",

5289+

OriginatingChannel: "discord",

5290+

OriginatingTo: "channel:1510164477642014740",

5291+

To: "channel:1510164477642014740",

5292+

AccountId: "default",

5293+

SenderId: "user-9",

5294+

CommandAuthorized: true,

5295+

WasMentioned: false,

5296+

RawBody: "continue",

5297+

Body: "continue",

5298+

MessageSid: "msg-claim-discord-thread",

5299+

MessageThreadId: "1510164477642014740",

5300+

ThreadParentId: "1510164477642014999",

5301+

SessionKey: "agent:main:discord:channel:1510164477642014740",

5302+

});

5303+

const replyResolver = vi.fn(async () => ({ text: "should not run" }) satisfies ReplyPayload);

5304+5305+

const result = await dispatchReplyFromConfig({

5306+

ctx,

5307+

cfg: emptyConfig,

5308+

dispatcher,

5309+

replyResolver,

5310+

});

5311+5312+

expect(result).toEqual({ queuedFinal: false, counts: { tool: 0, block: 0, final: 0 } });

5313+

expect(sessionBindingMocks.resolveByConversation).toHaveBeenCalledWith(

5314+

expect.objectContaining({

5315+

channel: "discord",

5316+

accountId: "default",

5317+

conversationId: "1510164477642014740",

5318+

parentConversationId: "channel:1510164477642014999",

5319+

}),

5320+

);

5321+

expect(hookMocks.runner.runInboundClaimForPluginOutcome).toHaveBeenCalledWith(

5322+

"openclaw-codex-app-server",

5323+

expect.objectContaining({

5324+

channel: "discord",

5325+

conversationId: "1510164477642014740",

5326+

parentConversationId: "channel:1510164477642014999",

5327+

}),

5328+

expect.objectContaining({

5329+

conversationId: "1510164477642014740",

5330+

parentConversationId: "channel:1510164477642014999",

5331+

pluginBinding: expect.objectContaining({ bindingId: "binding-discord-thread" }),

5332+

}),

5333+

);

5334+

expect(replyResolver).not.toHaveBeenCalled();

5335+

});

5336+52135337

it("does not run plugin-owned binding delivery when the caller already aborted", async () => {

52145338

setNoAbort();

52155339

hookMocks.runner.hasHooks.mockImplementation(