fix: keep optimistic status during agent bootstrap phase
This commit is contained in:
@@ -652,6 +652,14 @@ function AgentScreenContent({
|
||||
}, [optimisticStreamItems, streamItems]);
|
||||
|
||||
const shouldUseOptimisticStream = isPendingCreateForRoute && optimisticStreamItems.length > 0;
|
||||
const authoritativeStatus = agent?.status;
|
||||
const isAuthoritativeBootstrapping =
|
||||
authoritativeStatus === "initializing" || authoritativeStatus === "idle";
|
||||
const showPendingCreateSubmitLoading =
|
||||
isPendingCreateForRoute &&
|
||||
(!authoritativeStatus || isAuthoritativeBootstrapping);
|
||||
const canFinalizePendingCreate =
|
||||
Boolean(authoritativeStatus) && !isAuthoritativeBootstrapping;
|
||||
|
||||
const placeholderAgent: Agent | null = useMemo(() => {
|
||||
if (!shouldUseOptimisticStream || !resolvedAgentId) {
|
||||
@@ -730,7 +738,7 @@ function AgentScreenContent({
|
||||
item.kind === "user_message" &&
|
||||
item.id === pendingCreate.clientMessageId
|
||||
);
|
||||
if (agent && hasUserMessage) {
|
||||
if (hasUserMessage && canFinalizePendingCreate) {
|
||||
if (
|
||||
resolvedAgentId &&
|
||||
pendingCreate.images &&
|
||||
@@ -760,7 +768,7 @@ function AgentScreenContent({
|
||||
clearPendingCreate();
|
||||
}
|
||||
}, [
|
||||
agent,
|
||||
canFinalizePendingCreate,
|
||||
clearPendingCreate,
|
||||
isPendingCreateForRoute,
|
||||
markPendingCreateLifecycle,
|
||||
@@ -1239,6 +1247,7 @@ function AgentScreenContent({
|
||||
agentId={resolvedAgentId}
|
||||
serverId={serverId}
|
||||
autoFocus
|
||||
isSubmitLoading={showPendingCreateSubmitLoading}
|
||||
onAddImages={handleAddImagesCallback}
|
||||
/>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user