Fix bottom anchoring and Claude wake routing

This commit is contained in:
Mohamed Boudra
2026-03-08 12:54:08 +07:00
parent 0c44e7db80
commit b339c5e61d
27 changed files with 3801 additions and 326 deletions
@@ -19,6 +19,16 @@ export interface AgentScreenMachineInput {
hasHydratedHistoryBefore: boolean;
}
function shouldBlockInitialAuthoritativeReadyState(
input: AgentScreenMachineInput
): boolean {
return (
!input.shouldUseOptimisticStream &&
!input.hasHydratedHistoryBefore &&
(input.needsAuthoritativeSync || input.isHistorySyncing)
);
}
export type AgentScreenToastLatch = "none" | "history_refresh" | "sync_error";
export interface AgentScreenMachineMemory {
@@ -104,10 +114,7 @@ export function deriveAgentScreenViewState({
input.agent && useOptimisticCreateFlowAgent && input.placeholderAgent
? { ...input.agent, status: input.placeholderAgent.status }
: input.agent ?? input.placeholderAgent;
if (candidateAgent) {
nextMemory.hasRenderedReady = true;
nextMemory.lastReadyAgent = candidateAgent;
}
const shouldBlockReadyState = shouldBlockInitialAuthoritativeReadyState(input);
if (input.missingAgentState.kind === "not_found") {
return {
@@ -129,6 +136,22 @@ export function deriveAgentScreenViewState({
};
}
if (candidateAgent && shouldBlockReadyState) {
return {
state: {
tag: "boot",
reason: "loading",
source: "none",
},
memory: nextMemory,
};
}
if (candidateAgent) {
nextMemory.hasRenderedReady = true;
nextMemory.lastReadyAgent = candidateAgent;
}
const displayAgent =
candidateAgent ?? (nextMemory.hasRenderedReady ? nextMemory.lastReadyAgent : null);
if (!displayAgent) {