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

推荐订阅源

Apple Machine Learning Research
Apple Machine Learning Research
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
G
Google Developers Blog
博客园 - 司徒正美
J
Java Code Geeks
aimingoo的专栏
aimingoo的专栏
A
About on SuperTechFans
博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
T
The Blog of Author Tim Ferriss
D
Docker
大猫的无限游戏
大猫的无限游戏
D
DataBreaches.Net
腾讯CDC
V
Visual Studio Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
C
Check Point Blog
M
MIT News - Artificial intelligence
Jina AI
Jina AI
I
InfoQ
雷峰网
雷峰网
The Cloudflare Blog
美团技术团队
Engineering at Meta
Engineering at Meta

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(channels): bypass debounce for bare abort triggers [A...
IWhatsskill · 2026-05-22 · via Recent Commits to openclaw:main

@@ -1,3 +1,4 @@

1+

import { createInboundDebouncer } from "openclaw/plugin-sdk/channel-inbound-debounce";

12

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

23

import { monitorMattermostProvider } from "./monitor.js";

34

import type { OpenClawConfig, RuntimeEnv } from "./runtime-api.js";

@@ -148,6 +149,14 @@ function createRuntimeCore(

148149

mainSessionKey?: string;

149150

sessionKey?: string;

150151

},

152+

overrides: {

153+

inboundDebounceMs?: number;

154+

isControlCommandMessage?: (text?: string) => boolean;

155+

shouldComputeCommandAuthorized?: (text?: string) => boolean;

156+

shouldHandleTextCommands?: () => boolean;

157+

textHasControlCommand?: (text?: string) => boolean;

158+

createInboundDebouncer?: typeof createInboundDebouncer;

159+

} = {},

151160

) {

152161

const runPrepared = vi.fn(

153162

async (turn: {

@@ -230,20 +239,23 @@ function createRuntimeCore(

230239

record: vi.fn(),

231240

},

232241

commands: {

233-

shouldHandleTextCommands: () => false,

242+

isControlCommandMessage: overrides.isControlCommandMessage ?? (() => false),

243+

shouldComputeCommandAuthorized: overrides.shouldComputeCommandAuthorized ?? (() => false),

244+

shouldHandleTextCommands: overrides.shouldHandleTextCommands ?? (() => false),

234245

},

235246

debounce: {

236-

resolveInboundDebounceMs: () => 0,

237-

createInboundDebouncer: <T>(params: {

238-

onFlush: (entries: T[]) => Promise<void> | void;

239-

}) => ({

240-

enqueue: async (entry: T) => {

241-

await params.onFlush([entry]);

242-

},

243-

}),

247+

resolveInboundDebounceMs: () => overrides.inboundDebounceMs ?? 0,

248+

createInboundDebouncer:

249+

overrides.createInboundDebouncer ??

250+

(<T>(params: { onFlush: (entries: T[]) => Promise<void> | void }) => ({

251+

enqueue: async (entry: T) => {

252+

await params.onFlush([entry]);

253+

},

254+

})),

244255

},

245256

groups: {

246-

resolveRequireMention: () => false,

257+

resolveRequireMention: (params: { requireMentionOverride?: boolean }) =>

258+

params.requireMentionOverride ?? false,

247259

},

248260

media: {

249261

readRemoteMediaBuffer: vi.fn(),

@@ -316,7 +328,7 @@ function createRuntimeCore(

316328

text: {

317329

chunkMarkdownTextWithMode: (text: string) => [text],

318330

convertMarkdownTables: (text: string) => text,

319-

hasControlCommand: () => false,

331+

hasControlCommand: overrides.textHasControlCommand ?? (() => false),

320332

resolveChunkMode: () => "off",

321333

resolveMarkdownTableMode: () => "off",

322334

resolveTextChunkLimit: () => 4000,

@@ -432,6 +444,73 @@ describe("mattermost inbound user posts", () => {

432444

expect(ctx?.Provider).toBe("mattermost");

433445

});

434446447+

it("does not drop inline command-looking group text from non-command-authorized senders", async () => {

448+

const socket = new FakeWebSocket();

449+

const abortController = new AbortController();

450+

mockState.abortController = abortController;

451+

const inlineCommandConfig: OpenClawConfig = {

452+

commands: { useAccessGroups: true },

453+

channels: {

454+

mattermost: {

455+

enabled: true,

456+

baseUrl: "https://mattermost.example.com",

457+

botToken: "bot-token",

458+

chatmode: "onmessage",

459+

dmPolicy: "open",

460+

groupPolicy: "open",

461+

},

462+

},

463+

};

464+

const isControlCommandMessage = vi.fn(() => false);

465+

const shouldComputeCommandAuthorized = vi.fn(() => true);

466+

mockState.runtimeCore = createRuntimeCore(inlineCommandConfig, undefined, {

467+

isControlCommandMessage,

468+

shouldComputeCommandAuthorized,

469+

shouldHandleTextCommands: () => true,

470+

});

471+472+

const monitor = monitorMattermostProvider({

473+

config: inlineCommandConfig,

474+

runtime: testRuntime(),

475+

abortSignal: abortController.signal,

476+

webSocketFactory: () => socket,

477+

});

478+479+

await vi.waitFor(() => {

480+

expect(socket.openListenerCount).toBeGreaterThan(0);

481+

});

482+

socket.emitOpen();

483+484+

await socket.emitMessage({

485+

event: "posted",

486+

data: {

487+

channel_id: "chan-1",

488+

channel_name: "town-square",

489+

channel_display_name: "Town Square",

490+

sender_name: "alice",

491+

post: JSON.stringify({

492+

id: "post-inline-command",

493+

channel_id: "chan-1",

494+

user_id: "user-1",

495+

message: "hello /status",

496+

create_at: 1_714_000_000_000,

497+

}),

498+

},

499+

broadcast: {

500+

channel_id: "chan-1",

501+

user_id: "user-1",

502+

},

503+

});

504+

socket.emitClose(1000);

505+

await monitor;

506+507+

expect(isControlCommandMessage).toHaveBeenCalledWith("hello /status", inlineCommandConfig);

508+

expect(mockState.dispatchReplyFromConfig).toHaveBeenCalledTimes(1);

509+

const ctx = mockState.dispatchReplyFromConfig.mock.calls.at(0)?.[0].ctx;

510+

expect(ctx?.BodyForAgent).toBe("hello /status");

511+

expect(ctx?.CommandAuthorized).toBe(false);

512+

});

513+435514

it("uses websocket channel type when REST channel lookup fails", async () => {

436515

const socket = new FakeWebSocket();

437516

const abortController = new AbortController();

@@ -543,6 +622,98 @@ describe("mattermost inbound user posts", () => {

543622

expect(runtimeCore.channel.session.recordInboundSession).not.toHaveBeenCalled();

544623

});

545624625+

it("flushes pending group text before authorizing a bare abort without a mention", async () => {

626+

const socket = new FakeWebSocket();

627+

const abortController = new AbortController();

628+

mockState.abortController = abortController;

629+

const mentionConfig: OpenClawConfig = {

630+

commands: { useAccessGroups: false },

631+

messages: { inbound: { debounceMs: 60_000 } },

632+

channels: {

633+

mattermost: {

634+

enabled: true,

635+

baseUrl: "https://mattermost.example.com",

636+

botToken: "bot-token",

637+

chatmode: "oncall",

638+

dmPolicy: "open",

639+

groupPolicy: "open",

640+

},

641+

},

642+

};

643+

const isBareAbort = (text?: string) => ["abort", "stop"].includes(text?.trim() ?? "");

644+

const runtimeCore = createRuntimeCore(mentionConfig, undefined, {

645+

inboundDebounceMs: 60_000,

646+

createInboundDebouncer,

647+

isControlCommandMessage: isBareAbort,

648+

shouldComputeCommandAuthorized: isBareAbort,

649+

shouldHandleTextCommands: () => true,

650+

textHasControlCommand: () => false,

651+

});

652+

mockState.runtimeCore = runtimeCore;

653+654+

const monitor = monitorMattermostProvider({

655+

config: mentionConfig,

656+

runtime: testRuntime(),

657+

abortSignal: abortController.signal,

658+

webSocketFactory: () => socket,

659+

});

660+661+

await vi.waitFor(() => {

662+

expect(socket.openListenerCount).toBeGreaterThan(0);

663+

});

664+

socket.emitOpen();

665+666+

await socket.emitMessage({

667+

event: "posted",

668+

data: {

669+

channel_id: "chan-1",

670+

channel_name: "town-square",

671+

channel_display_name: "Town Square",

672+

sender_name: "alice",

673+

post: JSON.stringify({

674+

id: "post-pending",

675+

channel_id: "chan-1",

676+

user_id: "user-1",

677+

message: "pending text",

678+

create_at: 1_714_000_000_000,

679+

}),

680+

},

681+

broadcast: {

682+

channel_id: "chan-1",

683+

user_id: "user-1",

684+

},

685+

});

686+

expect(mockState.dispatchReplyFromConfig).not.toHaveBeenCalled();

687+688+

await socket.emitMessage({

689+

event: "posted",

690+

data: {

691+

channel_id: "chan-1",

692+

channel_name: "town-square",

693+

channel_display_name: "Town Square",

694+

sender_name: "alice",

695+

post: JSON.stringify({

696+

id: "post-abort",

697+

channel_id: "chan-1",

698+

user_id: "user-1",

699+

message: "abort",

700+

create_at: 1_714_000_000_100,

701+

}),

702+

},

703+

broadcast: {

704+

channel_id: "chan-1",

705+

user_id: "user-1",

706+

},

707+

});

708+

socket.emitClose(1000);

709+

await monitor;

710+711+

expect(mockState.dispatchReplyFromConfig).toHaveBeenCalledTimes(1);

712+

const ctx = mockState.dispatchReplyFromConfig.mock.calls.at(0)?.[0].ctx;

713+

expect(ctx?.BodyForAgent).toBe("abort");

714+

expect(ctx?.CommandAuthorized).toBe(true);

715+

});

716+546717

it("pins direct-message main route updates to the configured owner", async () => {

547718

const socket = new FakeWebSocket();

548719

const abortController = new AbortController();