Fix app stream/timeline ordering desync and init lifecycle race (#73)

* fix(app): enforce canonical stream sequencing and init resolution

* refactor: extract timeline and stream reducers to pure functions
This commit is contained in:
Mohamed Boudra
2026-02-23 19:30:48 +07:00
committed by GitHub
parent 9b6f5e028c
commit a134132418
12 changed files with 1732 additions and 109 deletions
@@ -0,0 +1,20 @@
import type { AgentLifecycleStatus } from "@server/shared/agent-lifecycle";
import type { AgentStreamEventPayload } from "@server/shared/messages";
export function deriveOptimisticLifecycleStatus(
currentStatus: AgentLifecycleStatus,
event: AgentStreamEventPayload
): AgentLifecycleStatus | null {
if (currentStatus !== "running") {
return null;
}
switch (event.type) {
case "turn_completed":
case "turn_canceled":
return "idle";
case "turn_failed":
return "error";
default:
return null;
}
}