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

推荐订阅源

Vercel News
Vercel News
博客园 - 司徒正美
C
Check Point Blog
G
Google Developers Blog
The GitHub Blog
The GitHub Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
有赞技术团队
有赞技术团队
P
Proofpoint News Feed
IT之家
IT之家
B
Blog
博客园_首页
量子位
MongoDB | Blog
MongoDB | Blog
博客园 - Franky
J
Java Code Geeks
H
Help Net Security
A
About on SuperTechFans
Apple Machine Learning Research
Apple Machine Learning Research
Jina AI
Jina AI
D
DataBreaches.Net
Y
Y Combinator Blog
大猫的无限游戏
大猫的无限游戏
云风的 BLOG
云风的 BLOG
Google DeepMind News
Google DeepMind News

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): carry reply typing feedback through queue ·...
zhuisDEV · 2026-05-31 · via Recent Commits to openclaw:main

@@ -86,6 +86,16 @@ vi.mock("../send.js", () => ({

8686

},

8787

}));

888889+

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

90+

sendTyping: vi.fn<(params: { rest: unknown; channelId: string }) => Promise<void>>(

91+

async () => {},

92+

),

93+

}));

94+95+

vi.mock("./typing.js", () => ({

96+

sendTyping: typingMocks.sendTyping,

97+

}));

98+8999

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

90100

resolveDiscordTargetChannelId: vi.fn(async (target: string, _opts?: unknown) => ({

91101

channelId: target === "user:u1" ? "dm-u1" : target,

@@ -169,6 +179,7 @@ type DispatchInboundParams = {

169179

onPartialReply?: (payload: { text?: string }) => Promise<void> | void;

170180

onAssistantMessageStart?: () => Promise<void> | void;

171181

allowProgressCallbacksWhenSourceDeliverySuppressed?: boolean;

182+

onTypingCleanup?: () => Promise<void> | void;

172183

};

173184

};

174185

const dispatchInboundMessage = vi.hoisted(() =>

@@ -233,6 +244,7 @@ let createThreadBindingManager: typeof import("./thread-bindings.js").createThre

233244

let processDiscordMessage: typeof import("./message-handler.process.js").processDiscordMessage;

234245

let formatDiscordReplySkip: typeof import("./message-handler.process.js").formatDiscordReplySkip;

235246

let notifyDiscordInboundEventOutboundSuccess: typeof import("../inbound-event-delivery.js").notifyDiscordInboundEventOutboundSuccess;

247+

let createDiscordReplyTypingFeedback: typeof import("./reply-typing-feedback.js").createDiscordReplyTypingFeedback;

236248237249

vi.mock("openclaw/plugin-sdk/reply-runtime", () => ({

238250

dispatchReplyWithBufferedBlockDispatcher: async (params: {

@@ -244,6 +256,14 @@ vi.mock("openclaw/plugin-sdk/reply-runtime", () => ({

244256

deliver: (payload: unknown, info: { kind: "block" | "final" }) => Promise<void> | void;

245257

onError?: (err: unknown, info: { kind: "block" | "final" }) => void;

246258

transformReplyPayload?: (payload: ReplyPayload) => ReplyPayload | null;

259+

typingCallbacks?: {

260+

onReplyStart?: () => Promise<void> | void;

261+

onIdle?: () => void;

262+

onCleanup?: () => void;

263+

};

264+

onReplyStart?: () => Promise<void> | void;

265+

onIdle?: () => void;

266+

onCleanup?: () => void;

247267

onSettled?: () => unknown;

248268

onFreshSettledDelivery?: () => unknown;

249269

};

@@ -273,10 +293,16 @@ vi.mock("openclaw/plugin-sdk/reply-runtime", () => ({

273293

pendingDeliveries.push(delivery);

274294

return true;

275295

};

296+

const typingCallbacks = params.dispatcherOptions.typingCallbacks;

297+

const replyOptions = {

298+

...params.replyOptions,

299+

onReplyStart: params.dispatcherOptions.onReplyStart ?? typingCallbacks?.onReplyStart,

300+

onTypingCleanup: params.dispatcherOptions.onCleanup ?? typingCallbacks?.onCleanup,

301+

};

276302

try {

277303

return await dispatchInboundMessage({

278304

ctx: params.ctx,

279-

replyOptions: params.replyOptions,

305+

replyOptions,

280306

dispatcher: {

281307

sendBlockReply: vi.fn((payload: ReplyPayload) =>

282308

queueDelivery(payload, { kind: "block" }),

@@ -292,6 +318,8 @@ vi.mock("openclaw/plugin-sdk/reply-runtime", () => ({

292318

} finally {

293319

await params.dispatcherOptions.onSettled?.();

294320

await params.dispatcherOptions.onFreshSettledDelivery?.();

321+

params.dispatcherOptions.onIdle?.();

322+

typingCallbacks?.onIdle?.();

295323

}

296324

},

297325

dispatchInboundMessage: (params: DispatchInboundParams) => dispatchInboundMessage(params),

@@ -456,12 +484,15 @@ beforeAll(async () => {

456484

({ processDiscordMessage, formatDiscordReplySkip } =

457485

await import("./message-handler.process.js"));

458486

({ notifyDiscordInboundEventOutboundSuccess } = await import("../inbound-event-delivery.js"));

487+

({ createDiscordReplyTypingFeedback } = await import("./reply-typing-feedback.js"));

459488

});

460489461490

beforeEach(() => {

462491

vi.useRealTimers();

463492

sendMocks.reactMessageDiscord.mockClear();

464493

sendMocks.removeReactionDiscord.mockClear();

494+

typingMocks.sendTyping.mockClear();

495+

typingMocks.sendTyping.mockResolvedValue(undefined);

465496

discordTargetMocks.resolveDiscordTargetChannelId.mockClear();

466497

editMessageDiscord.mockClear();

467498

deliverDiscordReply.mockClear();

@@ -873,6 +904,70 @@ describe("processDiscordMessage ack reactions", () => {

873904

expect(feedbackRest).not.toBe(deliveryRest);

874905

});

875906907+

it("reuses accepted typing feedback through reply dispatch", async () => {

908+

const replyTypingFeedback = {

909+

onReplyStart: vi.fn(async () => {}),

910+

onIdle: vi.fn(),

911+

onCleanup: vi.fn(),

912+

updateChannelId: vi.fn(),

913+

getChannelId: vi.fn(() => "c1"),

914+

restartForDispatch: vi.fn(),

915+

};

916+

dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => {

917+

await params?.replyOptions?.onReplyStart?.();

918+

return createNoQueuedDispatchResult();

919+

});

920+

const ctx = await createAutomaticSourceDeliveryContext({

921+

replyTypingFeedback,

922+

});

923+924+

await runProcessDiscordMessage(ctx);

925+926+

expect(replyTypingFeedback.updateChannelId).not.toHaveBeenCalled();

927+

expect(replyTypingFeedback.restartForDispatch).toHaveBeenCalledWith("c1");

928+

expect(replyTypingFeedback.onReplyStart).toHaveBeenCalledTimes(1);

929+

expect(replyTypingFeedback.onIdle).toHaveBeenCalledTimes(1);

930+

expect(replyTypingFeedback.onCleanup).toHaveBeenCalledTimes(1);

931+

expect(typingMocks.sendTyping).not.toHaveBeenCalled();

932+

});

933+934+

it("restarts stale carried typing feedback before dispatch", async () => {

935+

vi.useFakeTimers();

936+

const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => {});

937+

const rest = { kind: "feedback-rest" };

938+

try {

939+

dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => {

940+

await params?.replyOptions?.onReplyStart?.();

941+

await vi.advanceTimersByTimeAsync(3_500);

942+

return createNoQueuedDispatchResult();

943+

});

944+

const ctx = await createAutomaticSourceDeliveryContext();

945+

ctx.replyTypingFeedback = createDiscordReplyTypingFeedback({

946+

cfg: ctx.cfg,

947+

token: ctx.token,

948+

accountId: ctx.accountId,

949+

channelId: "c1",

950+

rest: rest as never,

951+

log: vi.fn(),

952+

maxDurationMs: 5_000,

953+

});

954+

await ctx.replyTypingFeedback.onReplyStart();

955+

await vi.advanceTimersByTimeAsync(5_100);

956+

typingMocks.sendTyping.mockClear();

957+958+

await runProcessDiscordMessage(ctx);

959+960+

expect(typingMocks.sendTyping.mock.calls.length).toBeGreaterThanOrEqual(2);

961+

expect(

962+

typingMocks.sendTyping.mock.calls.every(

963+

([params]) => params.channelId === "c1" && params.rest === rest,

964+

),

965+

).toBe(true);

966+

} finally {

967+

warnSpy.mockRestore();

968+

}

969+

});

970+876971

it("debounces intermediate phase reactions and jumps to done for short runs", async () => {

877972

dispatchInboundMessage.mockImplementationOnce(async (params?: DispatchInboundParams) => {

878973

await params?.replyOptions?.onReasoningStream?.();