mirror of
https://github.com/moltbot/moltbot.git
synced 2026-05-19 12:32:59 +00:00
Summary:
- Add agent-scoped Control chat session filtering and agent-first session controls.
- Refine responsive chat controls, transcript, result-panel, and duplicate-message behavior.
- Reduce chat load churn by avoiding duplicate initial avatar refreshes.
Verification:
- pnpm test ui/src/ui/app-gateway.node.test.ts ui/src/ui/app-gateway-chat-load.node.test.ts ui/src/ui/chat/chat-responsive.browser.test.ts ui/src/ui/app-render.helpers.browser.test.ts ui/src/ui/app-render.helpers.node.test.ts ui/src/ui/views/chat.test.ts ui/src/ui/app-scroll.test.ts
- pnpm test src/plugin-sdk/file-lock.test.ts
- pnpm exec oxfmt --check --threads=1 ui/src/ui/chat/chat-responsive.browser.test.ts src/plugin-sdk/file-lock.test.ts
- pnpm --dir ui build
- Testbox pnpm check:changed: https://github.com/openclaw/openclaw/actions/runs/25309629891
- PR CI on cd22d3d1ab: https://github.com/openclaw/openclaw/actions/runs/25310534399
80 lines
2.2 KiB
TypeScript
80 lines
2.2 KiB
TypeScript
import fs from "node:fs/promises";
|
|
import os from "node:os";
|
|
import path from "node:path";
|
|
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import {
|
|
acquireFileLock,
|
|
drainFileLockStateForTest,
|
|
FILE_LOCK_TIMEOUT_ERROR_CODE,
|
|
resetFileLockStateForTest,
|
|
} from "./file-lock.js";
|
|
|
|
describe("acquireFileLock", () => {
|
|
let tempDir = "";
|
|
|
|
beforeEach(async () => {
|
|
resetFileLockStateForTest();
|
|
tempDir = await fs.mkdtemp(path.join(os.tmpdir(), "openclaw-file-lock-"));
|
|
});
|
|
|
|
afterEach(async () => {
|
|
await drainFileLockStateForTest();
|
|
if (tempDir) {
|
|
await fs.rm(tempDir, { recursive: true, force: true });
|
|
}
|
|
});
|
|
|
|
it("respects the configured retry budget even when stale windows are much larger", async () => {
|
|
const filePath = path.join(tempDir, "oauth-refresh");
|
|
const lockPath = `${filePath}.lock`;
|
|
const options = {
|
|
retries: {
|
|
retries: 1,
|
|
factor: 1,
|
|
minTimeout: 20,
|
|
maxTimeout: 20,
|
|
},
|
|
stale: 100,
|
|
} as const;
|
|
|
|
await fs.writeFile(
|
|
lockPath,
|
|
JSON.stringify({ pid: process.pid, createdAt: new Date().toISOString() }, null, 2),
|
|
"utf8",
|
|
);
|
|
|
|
await expect(acquireFileLock(filePath, options)).rejects.toSatisfy((error) => {
|
|
expect(error).toMatchObject({
|
|
code: FILE_LOCK_TIMEOUT_ERROR_CODE,
|
|
});
|
|
expect((error as { lockPath?: string }).lockPath).toBeTruthy();
|
|
expect((error as { lockPath?: string }).lockPath).toMatch(/oauth-refresh\.lock$/);
|
|
return true;
|
|
});
|
|
}, 5_000);
|
|
|
|
it("closes an opened lock handle when writing the owner payload fails", async () => {
|
|
const filePath = path.join(tempDir, "write-fails");
|
|
const writeError = new Error("owner write failed");
|
|
const close = vi.fn().mockResolvedValue(undefined);
|
|
vi.spyOn(fs, "open").mockResolvedValue({
|
|
close,
|
|
writeFile: vi.fn().mockRejectedValue(writeError),
|
|
} as unknown as Awaited<ReturnType<typeof fs.open>>);
|
|
|
|
await expect(
|
|
acquireFileLock(filePath, {
|
|
retries: {
|
|
retries: 0,
|
|
factor: 1,
|
|
minTimeout: 1,
|
|
maxTimeout: 1,
|
|
},
|
|
stale: 100,
|
|
}),
|
|
).rejects.toThrow(writeError);
|
|
|
|
expect(close).toHaveBeenCalledTimes(1);
|
|
});
|
|
});
|