fix: keep optimistic status during agent bootstrap phase

This commit is contained in:
Mohamed Boudra
2026-02-22 20:01:05 +07:00
parent 1974c33971
commit 84e3140f19
3 changed files with 122 additions and 8 deletions
@@ -93,7 +93,17 @@ export function deriveAgentScreenViewState({
nextMemory.hadInitialSyncFailure = true;
}
const candidateAgent = input.agent ?? input.placeholderAgent;
const useOptimisticCreateFlowAgent =
input.shouldUseOptimisticStream &&
Boolean(input.placeholderAgent) &&
(!input.agent ||
input.agent.status === "initializing" ||
input.agent.status === "idle");
const candidateAgent =
input.agent && useOptimisticCreateFlowAgent && input.placeholderAgent
? { ...input.agent, status: input.placeholderAgent.status }
: input.agent ?? input.placeholderAgent;
if (candidateAgent) {
nextMemory.hasRenderedReady = true;
nextMemory.lastReadyAgent = candidateAgent;
@@ -132,11 +142,13 @@ export function deriveAgentScreenViewState({
};
}
const source: "authoritative" | "optimistic" | "stale" = input.agent
? "authoritative"
: input.shouldUseOptimisticStream
? "optimistic"
: "stale";
const source: "authoritative" | "optimistic" | "stale" = useOptimisticCreateFlowAgent
? "optimistic"
: input.agent
? "authoritative"
: input.shouldUseOptimisticStream
? "optimistic"
: "stale";
let sync: AgentScreenReadySyncState;
if (!input.isConnected) {