Skip to content

Commit 5b418c3

Browse files
committed
fix(channels): preserve Telegram ordering without blocking follow-ups
1 parent c722ae6 commit 5b418c3

17 files changed

Lines changed: 303 additions & 63 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ Docs: https://docs.openclaw.ai
1313

1414
- Control UI/chat: reconcile terminal and reconnect run cleanup with cached session activity, stale compaction/fallback indicators, and a compact composer run-status chip so completed or interrupted turns do not leave Stop active. Fixes #76874 and #64220; refs #71630. Thanks @BunsDev.
1515
- Maintainer tooling: clarify which pnpm test/check commands are safe locally versus inside Codex worktrees, routing linked-worktree gates through node wrappers and Crabbox/Testbox.
16+
- Telegram/WhatsApp: keep Telegram same-chat replies ordered behind active no-delay turns without blocking WhatsApp follow-up message dispatch.
17+
- Codex migration: avoid duplicate cached plugin bundle warnings when app-server plugin inventory is available.
1618
- iOS/chat: resize PhotosPicker image attachments to capped JPEGs before staging and sending, stripping source metadata and keeping oversized camera photos under the chat upload budget. Fixes #68524. Thanks @BunsDev.
1719
- Control UI: keep shared form, config, and usage text-entry controls at 16px on touch-primary devices while preserving chat composer input sizing, so iOS Safari no longer auto-zooms focused fields. Fixes #64651; carries forward #64673. Thanks @NianJiuZst and @BunsDev.
1820
- Codex harness: classify native app-server token-refresh logout and relogin failures as authentication refresh errors, so users get re-authentication guidance instead of a raw runtime failure.

‎extensions/active-memory/index.test.ts‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,14 @@ describe("active-memory plugin", () => {
116116
config: {
117117
current: () => configFile,
118118
loadConfig: () => configFile,
119+
mutateConfigFile: vi.fn(
120+
async ({ mutate }: { mutate: (draft: Record<string, unknown>) => void }) => {
121+
const draft = structuredClone(configFile);
122+
mutate(draft);
123+
configFile = draft;
124+
return { changed: true, config: configFile };
125+
},
126+
),
119127
replaceConfigFile: vi.fn(
120128
async ({ nextConfig }: { nextConfig: Record<string, unknown> }) => {
121129
configFile = nextConfig;
@@ -476,7 +484,7 @@ describe("active-memory plugin", () => {
476484
});
477485

478486
expect(offResult.text).toBe("Active Memory: off globally.");
479-
expect(api.runtime.config.replaceConfigFile).toHaveBeenCalledTimes(1);
487+
expect(api.runtime.config.mutateConfigFile).toHaveBeenCalledTimes(1);
480488
expect(
481489
requireRecord(
482490
requireRecord(requireRecord(configFile.plugins, "plugins").entries, "entries")[
@@ -576,7 +584,7 @@ describe("active-memory plugin", () => {
576584
expect(result.text).toContain("global enable/disable changes require operator.admin");
577585
}
578586

579-
expect(api.runtime.config.replaceConfigFile).not.toHaveBeenCalled();
587+
expect(api.runtime.config.mutateConfigFile).not.toHaveBeenCalled();
580588
});
581589

582590
it("allows admin-scoped gateway callers to change global active-memory config", async () => {
@@ -595,7 +603,7 @@ describe("active-memory plugin", () => {
595603
});
596604

597605
expect(result.text).toBe("Active Memory: off globally.");
598-
expect(api.runtime.config.replaceConfigFile).toHaveBeenCalledTimes(1);
606+
expect(api.runtime.config.mutateConfigFile).toHaveBeenCalledTimes(1);
599607
expect(
600608
requireRecord(
601609
requireRecord(requireRecord(configFile.plugins, "plugins").entries, "entries")[

‎extensions/codex/src/migration/plan.ts‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -441,9 +441,6 @@ export async function buildCodexMigrationPlan(
441441
"Codex app-backed plugins were planned without source app accessibility verification. Re-run with --verify-plugin-apps to force a fresh source app/list check before planning native plugin activation.",
442442
]
443443
: []),
444-
...(source.plugins.some((plugin) => plugin.sourceKind === "cache")
445-
? ["Codex cached plugin bundles remain manual-review only."]
446-
: []),
447444
...(source.pluginDiscoveryError
448445
? [
449446
`Codex app-server plugin inventory discovery failed: ${source.pluginDiscoveryError}. Cached plugin bundles, if any, are advisory only.`,

‎extensions/memory-core/src/dreaming-command.test.ts‎

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,20 @@ function createHarness(initialConfig: OpenClawConfig = {}) {
2828
config: {
2929
current: vi.fn(() => runtimeConfig),
3030
loadConfig: vi.fn(() => runtimeConfig),
31+
mutateConfigFile: vi.fn(async ({ mutate }: { mutate: (draft: OpenClawConfig) => void }) => {
32+
const draft = structuredClone(runtimeConfig);
33+
mutate(draft);
34+
runtimeConfig = draft;
35+
return {
36+
path: "/tmp/openclaw.json",
37+
previousHash: null,
38+
snapshot: {},
39+
nextConfig: runtimeConfig,
40+
afterWrite: { mode: "auto" },
41+
followUp: { mode: "auto", requiresRestart: false },
42+
result: undefined,
43+
};
44+
}),
3145
replaceConfigFile: vi.fn(async ({ nextConfig }: { nextConfig: OpenClawConfig }) => {
3246
runtimeConfig = nextConfig;
3347
}),
@@ -116,7 +130,7 @@ describe("memory-core /dreaming command", () => {
116130

117131
const result = await command.handler(createCommandContext("off"));
118132

119-
expect(runtime.config.replaceConfigFile).toHaveBeenCalledTimes(1);
133+
expect(runtime.config.mutateConfigFile).toHaveBeenCalledTimes(1);
120134
const storedDreaming = resolveStoredDreaming(getRuntimeConfig());
121135
expect(storedDreaming.enabled).toBe(false);
122136
expect(storedDreaming.frequency).toBe("0 */6 * * *");
@@ -133,7 +147,7 @@ describe("memory-core /dreaming command", () => {
133147
);
134148

135149
expect(result.text).toContain("requires operator.admin");
136-
expect(runtime.config.replaceConfigFile).not.toHaveBeenCalled();
150+
expect(runtime.config.mutateConfigFile).not.toHaveBeenCalled();
137151
});
138152

139153
it("blocks write-scoped gateway callers from persisting dreaming config", async () => {
@@ -146,7 +160,7 @@ describe("memory-core /dreaming command", () => {
146160
);
147161

148162
expect(result.text).toContain("requires operator.admin");
149-
expect(runtime.config.replaceConfigFile).not.toHaveBeenCalled();
163+
expect(runtime.config.mutateConfigFile).not.toHaveBeenCalled();
150164
});
151165

152166
it("allows admin-scoped gateway callers to persist dreaming config", async () => {
@@ -158,7 +172,7 @@ describe("memory-core /dreaming command", () => {
158172
}),
159173
);
160174

161-
expect(runtime.config.replaceConfigFile).toHaveBeenCalledTimes(1);
175+
expect(runtime.config.mutateConfigFile).toHaveBeenCalledTimes(1);
162176
expect(resolveStoredDreaming(getRuntimeConfig()).enabled).toBe(true);
163177
expect(result.text).toContain("Dreaming enabled.");
164178
});
@@ -189,14 +203,14 @@ describe("memory-core /dreaming command", () => {
189203
expect(result.text).toContain("- enabled: off (America/Los_Angeles)");
190204
expect(result.text).toContain("- sweep cadence: 15 */8 * * *");
191205
expect(result.text).toContain("- promotion policy: score>=0.8, recalls>=3, uniqueQueries>=3");
192-
expect(runtime.config.replaceConfigFile).not.toHaveBeenCalled();
206+
expect(runtime.config.mutateConfigFile).not.toHaveBeenCalled();
193207
});
194208

195209
it("shows usage for invalid args and does not mutate config", async () => {
196210
const { command, runtime } = createHarness();
197211
const result = await command.handler(createCommandContext("unknown-mode"));
198212

199213
expect(result.text).toContain("Usage: /dreaming status");
200-
expect(runtime.config.replaceConfigFile).not.toHaveBeenCalled();
214+
expect(runtime.config.mutateConfigFile).not.toHaveBeenCalled();
201215
});
202216
});

‎extensions/msteams/src/attachments/graph.test.ts‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,25 @@ vi.mock("../runtime.js", () => ({
3131
},
3232
channel: {
3333
media: {
34+
saveResponseMedia: vi.fn(
35+
async (
36+
response: Response,
37+
options?: { fallbackContentType?: string; maxBytes?: number },
38+
) => {
39+
const length = Number(response.headers.get("content-length"));
40+
if (
41+
Number.isFinite(length) &&
42+
options?.maxBytes !== undefined &&
43+
length > options.maxBytes
44+
) {
45+
throw new Error("content length exceeds maxBytes");
46+
}
47+
return {
48+
path: "/tmp/saved.png",
49+
contentType: options?.fallbackContentType ?? "image/png",
50+
};
51+
},
52+
),
3453
saveMediaBuffer: vi.fn(async (_buf: Buffer, ct: string) => ({
3554
path: "/tmp/saved.png",
3655
contentType: ct ?? "image/png",

‎extensions/nvidia/onboard.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ describe("nvidia onboard", () => {
3939
legacyModelName: "Custom",
4040
});
4141
expect(provider?.models.map((model) => model.id)).toEqual([
42-
"custom-model",
42+
"nvidia/custom-model",
4343
"nvidia/nemotron-3-super-120b-a12b",
4444
"moonshotai/kimi-k2.5",
4545
"minimaxai/minimax-m2.5",

‎extensions/phone-control/index.test.ts‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,24 @@ function createApi(params: {
3131
},
3232
config: {
3333
current: () => params.getConfig(),
34+
mutateConfigFile: async ({
35+
mutate,
36+
}: {
37+
mutate: (draft: Record<string, unknown>) => void;
38+
}) => {
39+
const nextConfig = structuredClone(params.getConfig());
40+
mutate(nextConfig);
41+
await params.writeConfig(nextConfig);
42+
return {
43+
path: "/tmp/openclaw.json",
44+
previousHash: null,
45+
snapshot: {},
46+
nextConfig,
47+
afterWrite: { mode: "auto" },
48+
followUp: { mode: "auto", requiresRestart: false },
49+
result: undefined,
50+
};
51+
},
3452
replaceConfigFile: ({ nextConfig }: { nextConfig: unknown }) =>
3553
params.writeConfig(nextConfig as Record<string, unknown>),
3654
},

‎extensions/talk-voice/index.test.ts‎

Lines changed: 42 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,22 @@ function createHarness(config: Record<string, unknown>) {
99
config: {
1010
current: vi.fn(() => config),
1111
loadConfig: vi.fn(() => config),
12+
mutateConfigFile: vi.fn(
13+
async ({ mutate }: { mutate: (draft: Record<string, unknown>) => void }) => {
14+
const draft = structuredClone(config);
15+
mutate(draft);
16+
config = draft;
17+
return {
18+
path: "/tmp/openclaw.json",
19+
previousHash: null,
20+
snapshot: {},
21+
nextConfig: config,
22+
afterWrite: { mode: "auto" },
23+
followUp: { mode: "auto", requiresRestart: false },
24+
result: undefined,
25+
};
26+
},
27+
),
1228
replaceConfigFile: vi.fn(async ({ nextConfig }: { nextConfig: Record<string, unknown> }) => {
1329
config = nextConfig;
1430
}),
@@ -187,19 +203,20 @@ describe("talk-voice plugin", () => {
187203
createCommandContext("set Claudia", "webchat", ["operator.admin"]),
188204
);
189205

190-
expect(runtime.config.replaceConfigFile).toHaveBeenCalledWith({
206+
expect(runtime.config.mutateConfigFile).toHaveBeenCalledWith({
191207
afterWrite: { mode: "auto" },
192-
nextConfig: {
193-
talk: {
194-
provider: "elevenlabs",
195-
providers: {
196-
elevenlabs: {
197-
apiKey: "sk-eleven",
198-
voiceId: "voice-a",
199-
},
208+
mutate: expect.any(Function),
209+
});
210+
expect(runtime.config.current()).toEqual({
211+
talk: {
212+
provider: "elevenlabs",
213+
providers: {
214+
elevenlabs: {
215+
apiKey: "sk-eleven",
216+
voiceId: "voice-a",
200217
},
201-
voiceId: "voice-a",
202218
},
219+
voiceId: "voice-a",
203220
},
204221
});
205222
expect(result).toEqual({
@@ -220,15 +237,16 @@ describe("talk-voice plugin", () => {
220237

221238
await command.handler(createCommandContext("set Ava", "webchat", ["operator.admin"]));
222239

223-
expect(runtime.config.replaceConfigFile).toHaveBeenCalledWith({
240+
expect(runtime.config.mutateConfigFile).toHaveBeenCalledWith({
224241
afterWrite: { mode: "auto" },
225-
nextConfig: {
226-
talk: {
227-
provider: "microsoft",
228-
providers: {
229-
microsoft: {
230-
voiceId: "en-US-AvaNeural",
231-
},
242+
mutate: expect.any(Function),
243+
});
244+
expect(runtime.config.current()).toEqual({
245+
talk: {
246+
provider: "microsoft",
247+
providers: {
248+
microsoft: {
249+
voiceId: "en-US-AvaNeural",
232250
},
233251
},
234252
},
@@ -240,22 +258,22 @@ describe("talk-voice plugin", () => {
240258
const result = await run();
241259

242260
expect(result.text).toContain("requires operator.admin");
243-
expect(runtime.config.replaceConfigFile).not.toHaveBeenCalled();
261+
expect(runtime.config.mutateConfigFile).not.toHaveBeenCalled();
244262
});
245263

246264
it("rejects /voice set from non-webchat gateway callers missing operator.admin", async () => {
247265
const { runtime, run } = createElevenlabsVoiceSetHarness("telegram", ["operator.write"]);
248266
const result = await run();
249267

250268
expect(result.text).toContain("requires operator.admin");
251-
expect(runtime.config.replaceConfigFile).not.toHaveBeenCalled();
269+
expect(runtime.config.mutateConfigFile).not.toHaveBeenCalled();
252270
});
253271

254272
it("allows /voice set from gateway client with operator.admin scope", async () => {
255273
const { runtime, run } = createElevenlabsVoiceSetHarness("webchat", ["operator.admin"]);
256274
const result = await run();
257275

258-
expect(runtime.config.replaceConfigFile).toHaveBeenCalled();
276+
expect(runtime.config.mutateConfigFile).toHaveBeenCalled();
259277
expect(result.text).toContain("voice-a");
260278
});
261279

@@ -264,22 +282,22 @@ describe("talk-voice plugin", () => {
264282
const result = await run();
265283

266284
expect(result.text).toContain("requires operator.admin");
267-
expect(runtime.config.replaceConfigFile).not.toHaveBeenCalled();
285+
expect(runtime.config.mutateConfigFile).not.toHaveBeenCalled();
268286
});
269287

270288
it("allows /voice set from non-gateway channels without operator.admin", async () => {
271289
const { runtime, run } = createElevenlabsVoiceSetHarness("telegram");
272290
const result = await run();
273291

274-
expect(runtime.config.replaceConfigFile).toHaveBeenCalled();
292+
expect(runtime.config.mutateConfigFile).toHaveBeenCalled();
275293
expect(result.text).toContain("voice-a");
276294
});
277295

278296
it("allows /voice set when operator.admin is present on a non-webchat channel", async () => {
279297
const { runtime, run } = createElevenlabsVoiceSetHarness("telegram", ["operator.admin"]);
280298
const result = await run();
281299

282-
expect(runtime.config.replaceConfigFile).toHaveBeenCalled();
300+
expect(runtime.config.mutateConfigFile).toHaveBeenCalled();
283301
expect(result.text).toContain("voice-a");
284302
});
285303

‎extensions/telegram/src/bot-deps.ts‎

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1+
import { recordChannelActivity } from "openclaw/plugin-sdk/channel-activity-runtime";
2+
import { buildChannelTurnContext } from "openclaw/plugin-sdk/channel-inbound";
13
import {
24
createChannelMessageReplyPipeline,
35
deliverInboundReplyWithMessageSendContext,
46
} from "openclaw/plugin-sdk/channel-message";
57
import { readChannelAllowFromStore } from "openclaw/plugin-sdk/conversation-runtime";
6-
import { upsertChannelPairingRequest } from "openclaw/plugin-sdk/conversation-runtime";
8+
import {
9+
recordInboundSession,
10+
upsertChannelPairingRequest,
11+
} from "openclaw/plugin-sdk/conversation-runtime";
712
import { buildModelsProviderData } from "openclaw/plugin-sdk/models-provider-runtime";
813
import { dispatchReplyWithBufferedBlockDispatcher } from "openclaw/plugin-sdk/reply-dispatch-runtime";
14+
import { resolveInboundLastRouteSessionKey } from "openclaw/plugin-sdk/routing";
915
import { getRuntimeConfig } from "openclaw/plugin-sdk/runtime-config-snapshot";
10-
import { resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
16+
import { resolvePinnedMainDmOwnerFromAllowlist } from "openclaw/plugin-sdk/security-runtime";
17+
import { readSessionUpdatedAt, resolveStorePath } from "openclaw/plugin-sdk/session-store-runtime";
1118
import { loadSessionStore } from "openclaw/plugin-sdk/session-store-runtime";
1219
import { listSkillCommandsForAgents } from "openclaw/plugin-sdk/skill-commands-runtime";
1320
import { enqueueSystemEvent } from "openclaw/plugin-sdk/system-event-runtime";
@@ -23,6 +30,12 @@ export type TelegramBotDeps = {
2330
getRuntimeConfig: typeof getRuntimeConfig;
2431
resolveStorePath: typeof resolveStorePath;
2532
loadSessionStore?: typeof loadSessionStore;
33+
readSessionUpdatedAt?: typeof readSessionUpdatedAt;
34+
recordInboundSession?: typeof recordInboundSession;
35+
recordChannelActivity?: typeof recordChannelActivity;
36+
resolveInboundLastRouteSessionKey?: typeof resolveInboundLastRouteSessionKey;
37+
resolvePinnedMainDmOwnerFromAllowlist?: typeof resolvePinnedMainDmOwnerFromAllowlist;
38+
buildChannelTurnContext?: typeof buildChannelTurnContext;
2639
readChannelAllowFromStore: typeof readChannelAllowFromStore;
2740
upsertChannelPairingRequest: typeof upsertChannelPairingRequest;
2841
enqueueSystemEvent: typeof enqueueSystemEvent;
@@ -54,6 +67,24 @@ export const defaultTelegramBotDeps: TelegramBotDeps = {
5467
get loadSessionStore() {
5568
return loadSessionStore;
5669
},
70+
get readSessionUpdatedAt() {
71+
return readSessionUpdatedAt;
72+
},
73+
get recordInboundSession() {
74+
return recordInboundSession;
75+
},
76+
get recordChannelActivity() {
77+
return recordChannelActivity;
78+
},
79+
get resolveInboundLastRouteSessionKey() {
80+
return resolveInboundLastRouteSessionKey;
81+
},
82+
get resolvePinnedMainDmOwnerFromAllowlist() {
83+
return resolvePinnedMainDmOwnerFromAllowlist;
84+
},
85+
get buildChannelTurnContext() {
86+
return buildChannelTurnContext;
87+
},
5788
get upsertChannelPairingRequest() {
5889
return upsertChannelPairingRequest;
5990
},

‎extensions/telegram/src/bot-handlers.runtime.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ export const registerTelegramHandlers = ({
391391

392392
const inboundDebouncer = createInboundDebouncer<TelegramDebounceEntry>({
393393
debounceMs,
394+
serializeImmediate: true,
394395
resolveDebounceMs: (entry) =>
395396
entry.debounceLane === "forward" ? FORWARD_BURST_DEBOUNCE_MS : debounceMs,
396397
buildKey: (entry) => entry.debounceKey,

0 commit comments

Comments
 (0)