mirror of
https://github.com/openclaw/openclaw.git
synced 2026-04-04 22:01:15 +00:00
fix(ui): gate compaction retry status on success
This commit is contained in:
@@ -166,7 +166,7 @@ describe("app-tool-stream fallback lifecycle handling", () => {
|
||||
stream: "compaction",
|
||||
ts: Date.now(),
|
||||
sessionKey: "main",
|
||||
data: { phase: "end", willRetry: true },
|
||||
data: { phase: "end", willRetry: true, completed: true },
|
||||
});
|
||||
|
||||
expect(host.compactionStatus).toEqual({
|
||||
@@ -236,7 +236,7 @@ describe("app-tool-stream fallback lifecycle handling", () => {
|
||||
stream: "compaction",
|
||||
ts: Date.now(),
|
||||
sessionKey: "main",
|
||||
data: { phase: "end", willRetry: true },
|
||||
data: { phase: "end", willRetry: true, completed: true },
|
||||
});
|
||||
|
||||
expect(host.compactionStatus).toEqual({
|
||||
@@ -269,4 +269,44 @@ describe("app-tool-stream fallback lifecycle handling", () => {
|
||||
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("does not surface retrying or complete when retry compaction failed", () => {
|
||||
vi.useFakeTimers();
|
||||
const host = createHost();
|
||||
|
||||
handleAgentEvent(host, {
|
||||
runId: "run-1",
|
||||
seq: 1,
|
||||
stream: "compaction",
|
||||
ts: Date.now(),
|
||||
sessionKey: "main",
|
||||
data: { phase: "start" },
|
||||
});
|
||||
|
||||
handleAgentEvent(host, {
|
||||
runId: "run-1",
|
||||
seq: 2,
|
||||
stream: "compaction",
|
||||
ts: Date.now(),
|
||||
sessionKey: "main",
|
||||
data: { phase: "end", willRetry: true, completed: false },
|
||||
});
|
||||
|
||||
expect(host.compactionStatus).toBeNull();
|
||||
expect(host.compactionClearTimer).toBeNull();
|
||||
|
||||
handleAgentEvent(host, {
|
||||
runId: "run-1",
|
||||
seq: 3,
|
||||
stream: "lifecycle",
|
||||
ts: Date.now(),
|
||||
sessionKey: "main",
|
||||
data: { phase: "error", error: "boom" },
|
||||
});
|
||||
|
||||
expect(host.compactionStatus).toBeNull();
|
||||
expect(host.compactionClearTimer).toBeNull();
|
||||
|
||||
vi.useRealTimers();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -298,6 +298,7 @@ function setCompactionComplete(host: CompactionHost, runId: string) {
|
||||
export function handleCompactionEvent(host: CompactionHost, payload: AgentEventPayload) {
|
||||
const data = payload.data ?? {};
|
||||
const phase = typeof data.phase === "string" ? data.phase : "";
|
||||
const completed = data.completed === true;
|
||||
|
||||
clearCompactionTimer(host);
|
||||
|
||||
@@ -311,7 +312,7 @@ export function handleCompactionEvent(host: CompactionHost, payload: AgentEventP
|
||||
return;
|
||||
}
|
||||
if (phase === "end") {
|
||||
if (data.willRetry === true) {
|
||||
if (data.willRetry === true && completed) {
|
||||
// Compaction already succeeded, but the run is still retrying.
|
||||
// Keep that distinct state until the matching lifecycle end arrives.
|
||||
host.compactionStatus = {
|
||||
@@ -322,7 +323,11 @@ export function handleCompactionEvent(host: CompactionHost, payload: AgentEventP
|
||||
};
|
||||
return;
|
||||
}
|
||||
setCompactionComplete(host, payload.runId);
|
||||
if (completed) {
|
||||
setCompactionComplete(host, payload.runId);
|
||||
return;
|
||||
}
|
||||
host.compactionStatus = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user