fix(FN-3175): reduce dashboard log stalls
This commit is contained in:
@@ -57,7 +57,7 @@ describe("Database", () => {
|
||||
const journalSizeLimit = db.prepare("PRAGMA journal_size_limit").get() as { journal_size_limit: number };
|
||||
|
||||
expect(synchronous.synchronous).toBe(1); // NORMAL
|
||||
expect(autoCheckpoint.wal_autocheckpoint).toBe(100);
|
||||
expect(autoCheckpoint.wal_autocheckpoint).toBe(1000);
|
||||
expect(journalSizeLimit.journal_size_limit).toBe(4_194_304);
|
||||
});
|
||||
|
||||
@@ -267,6 +267,13 @@ describe("Database", () => {
|
||||
expect(typeof result.log).toBe("number");
|
||||
expect(typeof result.checkpointed).toBe("number");
|
||||
});
|
||||
|
||||
it("supports explicit truncate checkpoints when requested", () => {
|
||||
const result = db.walCheckpoint("TRUNCATE");
|
||||
expect(result).toHaveProperty("busy");
|
||||
expect(result).toHaveProperty("log");
|
||||
expect(result).toHaveProperty("checkpointed");
|
||||
});
|
||||
});
|
||||
|
||||
describe("transactions", () => {
|
||||
|
||||
@@ -4158,6 +4158,25 @@ Task with acceptance criteria
|
||||
expect(events[1]).toMatchObject({ text: "tool", type: "tool", detail: "read file", agent: "executor" });
|
||||
});
|
||||
|
||||
it("truncates oversized tool detail before persisting and emitting", async () => {
|
||||
const task = await createTestTask();
|
||||
const events: any[] = [];
|
||||
const oversizedDetail = "X".repeat(5000);
|
||||
const truncationMarker = "[tool output truncated to keep dashboard log views responsive]";
|
||||
store.on("agent:log", (entry) => events.push(entry));
|
||||
|
||||
await store.appendAgentLogBatch([
|
||||
{ taskId: task.id, text: "Bash", type: "tool_result", detail: oversizedDetail, agent: "executor" },
|
||||
]);
|
||||
|
||||
const logs = await store.getAgentLogs(task.id);
|
||||
expect(logs).toHaveLength(1);
|
||||
expect(logs[0].detail).toContain(truncationMarker);
|
||||
expect(logs[0].detail!.match(/\[tool output truncated to keep dashboard log views responsive\]/g)).toHaveLength(1);
|
||||
expect(logs[0].detail!.length).toBeLessThan(oversizedDetail.length);
|
||||
expect(events[0].detail).toBe(logs[0].detail);
|
||||
});
|
||||
|
||||
it("appendAgentLogBatch with empty entries is a no-op", async () => {
|
||||
const task = await createTestTask();
|
||||
|
||||
@@ -4304,6 +4323,28 @@ Task with acceptance criteria
|
||||
expect(logs[0].detail!.length).toBe(longDetail.length);
|
||||
});
|
||||
|
||||
it("clips oversized historical tool detail at read time", async () => {
|
||||
const task = await createTestTask();
|
||||
const oversizedDetail = "Y".repeat(7000);
|
||||
const truncationMarker = "[tool output truncated to keep dashboard log views responsive]";
|
||||
|
||||
insertLogEntryWithTimestamp(
|
||||
store,
|
||||
task.id,
|
||||
"Bash",
|
||||
"tool_result",
|
||||
"2026-04-24T12:00:00.000Z",
|
||||
oversizedDetail,
|
||||
"executor",
|
||||
);
|
||||
|
||||
const logs = await store.getAgentLogs(task.id);
|
||||
expect(logs).toHaveLength(1);
|
||||
expect(logs[0].detail).toContain(truncationMarker);
|
||||
expect(logs[0].detail!.match(/\[tool output truncated to keep dashboard log views responsive\]/g)).toHaveLength(1);
|
||||
expect(logs[0].detail!.length).toBeLessThan(oversizedDetail.length);
|
||||
});
|
||||
|
||||
it("appendAgentLog persists and reads back the agent field", async () => {
|
||||
const task = await createTestTask();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user