From 7851052634a8e535848486ae1f7f18cf1ae974ba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Almeida?= Date: Sun, 10 May 2026 15:00:41 +0100 Subject: [PATCH] fix(web): only block submit during real env prepare, not every STARTING MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The "agent still being set up" submit gate was triggering on every session that briefly transitions through STARTING — including local quick-chat, which has no prepare phase and has its agent live within ~100ms. The eager-init quick-chat e2e tests (chat/quick-chat.spec.ts and chat/message-queue.spec.ts) wait for the editor to become editable, then press Cmd+Enter. The race made wrappedSubmit a no-op exactly when the test was firing — message dropped, agent never saw it, downstream assertions failed. Split the merged isStarting flag in useSessionState: keep the broad flag (still used for the workspace-prep loading UI), and expose isPreparingEnvironment as a separate signal that's only true while prepareProgress.status === "preparing". Thread it through chat-input- area → chat-input-container → useChatInputContainer and gate the submit-disabled tooltip on it instead of the broad isStarting. Net: Docker / Sprites bootstrap still surfaces the "agent still being set up" message and disables submit; quick-chat / local sessions stop silently dropping in-flight messages. --- .../components/task/chat/chat-input-area.tsx | 1 + .../task/chat/chat-input-container.tsx | 6 +++ .../chat/use-chat-input-container.test.ts | 1 + .../task/chat/use-chat-input-container.ts | 43 +++++++++---------- .../domains/session/use-session-state.ts | 6 +++ 5 files changed, 35 insertions(+), 22 deletions(-) diff --git a/apps/web/components/task/chat/chat-input-area.tsx b/apps/web/components/task/chat/chat-input-area.tsx index 55dad36d95..cdb0576901 100644 --- a/apps/web/components/task/chat/chat-input-area.tsx +++ b/apps/web/components/task/chat/chat-input-area.tsx @@ -413,6 +413,7 @@ export function ChatInputArea({ onPlanModeChange={handlePlanModeChange} isAgentBusy={isAgentBusy} isStarting={panelState.isStarting} + isPreparingEnvironment={panelState.isPreparingEnvironment} isMoving={isMoving} isSending={isSending} onCancel={handleCancelTurn} diff --git a/apps/web/components/task/chat/chat-input-container.tsx b/apps/web/components/task/chat/chat-input-container.tsx index e62974f6bc..306a3a5385 100644 --- a/apps/web/components/task/chat/chat-input-container.tsx +++ b/apps/web/components/task/chat/chat-input-container.tsx @@ -57,6 +57,11 @@ type ChatInputContainerProps = { onPlanModeChange: (enabled: boolean) => void; isAgentBusy: boolean; isStarting: boolean; + /** True only while a containerized executor is bootstrapping (Docker + * prepare, Sprites sandbox spin-up). Distinct from the brief STARTING + * state every session — including local quick-chat — passes through; + * see useSessionState. */ + isPreparingEnvironment?: boolean; isMoving?: boolean; isSending: boolean; onCancel: () => void; @@ -292,6 +297,7 @@ export const ChatInputContainer = forwardRef 0 @@ -129,26 +142,11 @@ function computeDerivedState(params: { } export function useChatInputContainer(params: UseChatInputContainerParams) { - const { - ref, - sessionId, - isSending, - isStarting, - isMoving, - isFailed, - needsRecovery, - executorUnavailable, - isAgentBusy, - hasAgentCommands, - placeholder, - contextItems, - pendingClarification, - onClarificationResolved, - pendingCommentsByFile, - showRequestChangesTooltip, - onRequestChangesTooltipDismiss, - onSubmit, - } = params; + const { ref, sessionId, isSending, isStarting, isPreparingEnvironment, isMoving } = params; + const { isFailed, needsRecovery, executorUnavailable, isAgentBusy, hasAgentCommands } = params; + const { placeholder, contextItems, pendingClarification, onClarificationResolved } = params; + const { pendingCommentsByFile, showRequestChangesTooltip } = params; + const { onRequestChangesTooltipDismiss, onSubmit } = params; const [isInputFocused, setIsInputFocused] = useState(false); const [showNewSessionDialog, setShowNewSessionDialog] = useState(false); @@ -202,6 +200,7 @@ export function useChatInputContainer(params: UseChatInputContainerParams) { const derived = computeDerivedState({ isStarting, + isPreparingEnvironment, isMoving, isSending, isFailed, diff --git a/apps/web/hooks/domains/session/use-session-state.ts b/apps/web/hooks/domains/session/use-session-state.ts index bc4bb48d5a..458764f33f 100644 --- a/apps/web/hooks/domains/session/use-session-state.ts +++ b/apps/web/hooks/domains/session/use-session-state.ts @@ -48,5 +48,11 @@ export function useSessionState(sessionId: string | null) { ...flags, isStarting: flags.isStarting || isPreparingEnvironment, isWorking: flags.isWorking || isPreparingEnvironment, + // Exposed separately so consumers that gate on "is the executor still + // bootstrapping" (e.g. the chat input "agent is still being set up" + // tooltip) can distinguish a brief STARTING transition — which every + // session passes through, including local quick-chat — from an active + // Docker / Sprites prepare-environment phase. + isPreparingEnvironment, }; }