Skip to content

Commit b7d3b74

Browse files
akrimm702steipete
andauthored
fix(ui): order live chat items by timestamp (#81016)
* fix(ui): order live chat items by timestamp * fix(ui): stabilize chat timestamp sorting * test: refresh core lint fixtures * test: refresh current main guard fixtures * test: refresh codex prompt snapshots * test(matrix): keep runtime helper local --------- Co-authored-by: Peter Steinberger <[email protected]>
1 parent 439e396 commit b7d3b74

16 files changed

Lines changed: 233 additions & 89 deletions

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Docs: https://docs.openclaw.ai
77
### Fixes
88

99
- Media-understanding: retry transient remote attachment fetch failures before audio or vision processing, so Discord voice notes are not lost after one network/CDN blip. Fixes #74316. Thanks @vyctorbrzezowski and @gabrielexito-stack.
10+
- Control UI: order timestamped live stream and tool items before untimestamped history fallbacks, keeping chat history in visible time order. Fixes #80759. (#81016) Thanks @akrimm702.
1011
- iMessage: stop sending visible `<media:image>` placeholder text for media-only native image sends while preserving the internal echo key that prevents self-echo duplicate replies. (#81209) Thanks @homer-byte.
1112
- Agents/sessions: create configured agent main sessions before first `sessions_send` or gateway send, so agent-to-agent messages no longer fail when the target agent has not started yet.
1213
- gateway: pass Talk session scope to resolver [AI]. (#81379) Thanks @pgondhi987.

‎extensions/matrix/src/test-runtime.ts‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,7 @@ function createMatrixRuntimeMediaMock(
2828
>["media"]["readRemoteMediaBuffer"];
2929
return {
3030
readRemoteMediaBuffer,
31-
fetchRemoteMedia: readRemoteMediaBuffer as NonNullable<
32-
PluginRuntime["channel"]
33-
>["media"]["fetchRemoteMedia"],
31+
fetchRemoteMedia: readRemoteMediaBuffer,
3432
saveRemoteMedia: vi.fn().mockResolvedValue({
3533
path: "/tmp/test-media.jpg",
3634
contentType: "image/jpeg",

‎scripts/e2e/lib/release-user-journey/clickclack-fixture.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ function readBody(req) {
100100
});
101101
}
102102

103-
function createMessage({ body, author = humanUser, parentMessageId = undefined }) {
103+
function createMessage({ body, author = humanUser, parentMessageId }) {
104104
messageSeq += 1;
105105
const id = `msg_${messageSeq}`;
106106
const message = {

‎scripts/lib/config-boundary-guard.mjs‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ const COMPAT_CONFIG_API_FILES = new Set([
1515
"src/plugins/compat/registry.ts",
1616
"src/plugins/contracts/config-boundary-guard.test.ts",
1717
"src/plugins/contracts/deprecated-internal-config-api.test.ts",
18+
"src/plugins/registry.runtime-config.test.ts",
19+
"src/plugins/registry.ts",
1820
"src/plugins/runtime/runtime-config.test.ts",
1921
"src/plugins/runtime/runtime-config.ts",
2022
"src/plugins/runtime/types-core.ts",

‎src/gateway/server.node-invoke-approval-bypass.test.ts‎

Lines changed: 87 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import crypto from "node:crypto";
22
import { afterAll, beforeAll, describe, expect, test, vi } from "vitest";
33
import { WebSocket } from "ws";
4+
import { writeConfigFile } from "../config/config.js";
45
import {
56
deriveDeviceIdFromPublicKey,
67
type DeviceIdentity,
@@ -174,7 +175,17 @@ describe("node.invoke approval bypass", () => {
174175
let port: number;
175176

176177
beforeAll(async () => {
177-
const started = await startServerWithClient("secret", { controlUiEnabled: true });
178+
await writeConfigFile({
179+
gateway: {
180+
nodes: {
181+
pairing: { autoApproveCidrs: ["127.0.0.1/32", "::1/128"] },
182+
allowCommands: ["system.run", "system.run.prepare", "system.which"],
183+
},
184+
},
185+
});
186+
const started = await startServerWithClient("secret", {
187+
controlUiEnabled: true,
188+
});
178189
server = started.server;
179190
port = started.port;
180191
started.ws.close();
@@ -186,12 +197,19 @@ describe("node.invoke approval bypass", () => {
186197

187198
const approveAllPendingPairings = async () => {
188199
const { approveDevicePairing, listDevicePairing } = await import("../infra/device-pairing.js");
189-
const list = await listDevicePairing();
190-
for (const pending of list.pending) {
200+
const { approveNodePairing, listNodePairing } = await import("../infra/node-pairing.js");
201+
const deviceList = await listDevicePairing();
202+
for (const pending of deviceList.pending) {
191203
await approveDevicePairing(pending.requestId, {
192204
callerScopes: pending.scopes ?? ["operator.admin"],
193205
});
194206
}
207+
const nodeList = await listNodePairing();
208+
for (const pending of nodeList.pending) {
209+
await approveNodePairing(pending.requestId, {
210+
callerScopes: ["operator.admin"],
211+
});
212+
}
195213
};
196214

197215
const connectOperatorWithRetry = async (
@@ -299,67 +317,75 @@ describe("node.invoke approval bypass", () => {
299317
deviceIdentity?: DeviceIdentity,
300318
commands: string[] = ["system.run"],
301319
) => {
302-
let readyResolve: (() => void) | null = null;
303-
const ready = new Promise<void>((resolve) => {
304-
readyResolve = resolve;
305-
});
306-
307320
const resolvedDeviceIdentity = deviceIdentity ?? createDeviceIdentity();
308-
const client = new GatewayClient({
309-
url: `ws://127.0.0.1:${port}`,
310-
// Keep challenge timeout realistic in tests; 0 maps to a 250ms timeout and can
311-
// trigger reconnect backoff loops under load.
312-
connectChallengeTimeoutMs: 2_000,
313-
token: "secret",
314-
role: "node",
315-
clientName: GATEWAY_CLIENT_NAMES.NODE_HOST,
316-
clientVersion: "1.0.0",
317-
platform: "linux",
318-
mode: GATEWAY_CLIENT_MODES.NODE,
319-
scopes: [],
320-
commands,
321-
deviceIdentity: resolvedDeviceIdentity,
322-
onHelloOk: () => readyResolve?.(),
323-
onEvent: (evt) => {
324-
if (evt.event !== "node.invoke.request") {
325-
return;
326-
}
327-
onInvoke(evt.payload);
328-
const payload = evt.payload as {
329-
id?: string;
330-
nodeId?: string;
331-
};
332-
const id = typeof payload?.id === "string" ? payload.id : "";
333-
const nodeId = typeof payload?.nodeId === "string" ? payload.nodeId : "";
334-
if (!id || !nodeId) {
335-
return;
321+
322+
const startNodeClient = async () => {
323+
let readyResolve: (() => void) | null = null;
324+
const ready = new Promise<void>((resolve) => {
325+
readyResolve = resolve;
326+
});
327+
const client = new GatewayClient({
328+
url: `ws://127.0.0.1:${port}`,
329+
// Keep challenge timeout realistic in tests; 0 maps to a 250ms timeout and can
330+
// trigger reconnect backoff loops under load.
331+
connectChallengeTimeoutMs: 2_000,
332+
token: "secret",
333+
role: "node",
334+
clientName: GATEWAY_CLIENT_NAMES.NODE_HOST,
335+
clientVersion: "1.0.0",
336+
platform: "linux",
337+
mode: GATEWAY_CLIENT_MODES.NODE,
338+
scopes: [],
339+
caps: ["system"],
340+
commands,
341+
deviceIdentity: resolvedDeviceIdentity,
342+
onHelloOk: () => readyResolve?.(),
343+
onEvent: (evt) => {
344+
if (evt.event !== "node.invoke.request") {
345+
return;
346+
}
347+
onInvoke(evt.payload);
348+
const payload = evt.payload as {
349+
id?: string;
350+
nodeId?: string;
351+
};
352+
const id = typeof payload?.id === "string" ? payload.id : "";
353+
const nodeId = typeof payload?.nodeId === "string" ? payload.nodeId : "";
354+
if (!id || !nodeId) {
355+
return;
356+
}
357+
void client.request("node.invoke.result", {
358+
id,
359+
nodeId,
360+
ok: true,
361+
payloadJSON: JSON.stringify({ ok: true }),
362+
});
363+
},
364+
});
365+
client.start();
366+
let timer: NodeJS.Timeout | undefined;
367+
try {
368+
await Promise.race([
369+
ready,
370+
new Promise<never>((_, reject) => {
371+
timer = setTimeout(
372+
() => reject(new Error("timeout waiting for node to connect")),
373+
NODE_CONNECT_TIMEOUT_MS,
374+
);
375+
}),
376+
]);
377+
} finally {
378+
if (timer) {
379+
clearTimeout(timer);
336380
}
337-
void client.request("node.invoke.result", {
338-
id,
339-
nodeId,
340-
ok: true,
341-
payloadJSON: JSON.stringify({ ok: true }),
342-
});
343-
},
344-
});
345-
client.start();
346-
let timer: NodeJS.Timeout | undefined;
347-
try {
348-
await Promise.race([
349-
ready,
350-
new Promise<never>((_, reject) => {
351-
timer = setTimeout(
352-
() => reject(new Error("timeout waiting for node to connect")),
353-
NODE_CONNECT_TIMEOUT_MS,
354-
);
355-
}),
356-
]);
357-
} finally {
358-
if (timer) {
359-
clearTimeout(timer);
360381
}
361-
}
362-
return client;
382+
return client;
383+
};
384+
385+
const pendingClient = await startNodeClient();
386+
await approveAllPendingPairings();
387+
pendingClient.stop();
388+
return await startNodeClient();
363389
};
364390

365391
test("rejects malformed/forbidden node.invoke payloads before forwarding", async () => {

‎src/gateway/sessions-patch.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ export async function applySessionsPatchToStore(params: {
125125
updatedAt: Math.max(existing.updatedAt ?? 0, now),
126126
}
127127
: {
128-
...(existing ?? {}),
128+
...existing,
129129
sessionId: randomUUID(),
130130
sessionFile: undefined,
131131
updatedAt: Math.max(existing?.updatedAt ?? 0, now),

‎src/plugins/registry.runtime-config.test.ts‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,13 @@ describe("plugin registry runtime config scope", () => {
2727
previousHash: null,
2828
nextHash: "next",
2929
} as unknown as Awaited<ReturnType<PluginRuntime["config"]["replaceConfigFile"]>>;
30+
const mutateConfigFile: PluginRuntime["config"]["mutateConfigFile"] = async () => ({
31+
...replaceResult,
32+
result: undefined,
33+
});
3034
const configRuntime = {
3135
current: vi.fn(() => config),
32-
mutateConfigFile: async <T = void>() => ({
33-
...replaceResult,
34-
result: undefined as T | undefined,
35-
}),
36+
mutateConfigFile,
3637
replaceConfigFile: async () => replaceResult,
3738
loadConfig: vi.fn(() => {
3839
loadScope = getPluginRuntimeGatewayRequestScope();
@@ -42,13 +43,16 @@ describe("plugin registry runtime config scope", () => {
4243
writeScope = getPluginRuntimeGatewayRequestScope();
4344
}),
4445
} satisfies PluginRuntime["config"];
45-
const pluginRegistry = createTestRegistry({ config: configRuntime } as PluginRuntime);
46+
const pluginRegistry = createTestRegistry({
47+
config: configRuntime,
48+
} as unknown as PluginRuntime);
4649
const record = createPluginRecord({
4750
id: "legacy-plugin",
4851
name: "Legacy Plugin",
4952
source: "/plugins/legacy-plugin/index.js",
5053
origin: "global",
5154
enabled: true,
55+
configSchema: false,
5256
});
5357
const api = pluginRegistry.createApi(record, { config });
5458

‎src/plugins/registry.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2396,7 +2396,7 @@ export function createPluginRegistry(registryParams: PluginRegistryParams) {
23962396
} satisfies PluginRuntime["state"];
23972397
}
23982398
if (prop === "config") {
2399-
const config = Reflect.get(target, prop, receiver) as PluginRuntime["config"];
2399+
const config = Reflect.get(target, prop, receiver);
24002400
return {
24012401
...config,
24022402
loadConfig: () => runWithPluginScope(() => config.loadConfig()),

‎test/fixtures/agents/prompt-snapshots/codex-runtime-happy-path/codex-dynamic-tools.discord-group.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -889,7 +889,7 @@
889889
},
890890
{
891891
"deferLoading": true,
892-
"description": "Send a message into another visible session by sessionKey or label. Thread-scoped chat sessions are rejected; target the parent channel session for inter-agent coordination. Use this to delegate follow-up work to an existing session; waits for the target run and returns the updated assistant reply when available.",
892+
"description": "Send a message into another visible session by sessionKey or label, or to a configured agent by agentId. Thread-scoped chat sessions are rejected; target the parent channel session for inter-agent coordination. Missing configured agent main sessions are created before send; waits for the target run and returns the updated assistant reply when available.",
893893
"inputSchema": {
894894
"properties": {
895895
"agentId": {

‎test/fixtures/agents/prompt-snapshots/codex-runtime-happy-path/codex-dynamic-tools.heartbeat-turn.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@
925925
},
926926
{
927927
"deferLoading": true,
928-
"description": "Send a message into another visible session by sessionKey or label. Thread-scoped chat sessions are rejected; target the parent channel session for inter-agent coordination. Use this to delegate follow-up work to an existing session; waits for the target run and returns the updated assistant reply when available.",
928+
"description": "Send a message into another visible session by sessionKey or label, or to a configured agent by agentId. Thread-scoped chat sessions are rejected; target the parent channel session for inter-agent coordination. Missing configured agent main sessions are created before send; waits for the target run and returns the updated assistant reply when available.",
929929
"inputSchema": {
930930
"properties": {
931931
"agentId": {

0 commit comments

Comments
 (0)