From c343af0ad2b3cf4efbdd0f878a862f7ae59625c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Almeida?= Date: Thu, 14 May 2026 00:05:25 +0100 Subject: [PATCH] fix(web): block submit when selected agent is incompatible with executor useExecutorProfileCompat returned noCompatibleAgent=true only when NO agent profile was compatible with the chosen executor. The user could still pick an agent that happened to be incompatible with the currently-selected executor (e.g. by switching executor after the agent was chosen) and the submit gate didn't fire. Two fixes: - Hook now takes the selected agent profile ID and returns noCompatibleAgent=true when the *selected* agent isn't in the compatible set (covers both the old "no agents at all" case and the new "wrong agent picked" case). - Footer's session-mode disable was gating only on missing agent; add noCompatibleAgent so the disable matches the reason text sessionDefaultReason already surfaces. --- .../web/components/task-create-dialog-footer.tsx | 8 +++++++- apps/web/components/task-create-dialog-state.ts | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/apps/web/components/task-create-dialog-footer.tsx b/apps/web/components/task-create-dialog-footer.tsx index 320abe9afa..2dd444fafb 100644 --- a/apps/web/components/task-create-dialog-footer.tsx +++ b/apps/web/components/task-create-dialog-footer.tsx @@ -329,7 +329,13 @@ function computeFooterState(props: TaskCreateDialogFooterProps) { const blocked = Boolean(props.submitBlockedReason); const altDisabled = computeBaseDisabled(props) || blocked; const splitDisabled = altDisabled || !props.agentProfileId; - const defaultDisabled = (props.isSessionMode ? !props.agentProfileId : altDisabled) || blocked; + // Session mode previously only gated on missing agent — it ignored + // noCompatibleAgent, so a user who switched executor after picking an + // agent could still submit a known-incompatible combination. The reason + // text already surfaces noCompatibleAgentReason in this branch (see + // sessionDefaultReason), so the disable gate needs to match. + const sessionDisabled = !props.agentProfileId || props.noCompatibleAgent; + const defaultDisabled = (props.isSessionMode ? sessionDisabled : altDisabled) || blocked; const disabledReason = computeDisabledReason(props, resolveButtonKind(props, showStartTask)); diff --git a/apps/web/components/task-create-dialog-state.ts b/apps/web/components/task-create-dialog-state.ts index 7a2d19a082..0d4155471c 100644 --- a/apps/web/components/task-create-dialog-state.ts +++ b/apps/web/components/task-create-dialog-state.ts @@ -556,6 +556,7 @@ export function useDialogComputed({ const exec = useExecutorProfileCompat( allExecutorProfiles, fs.executorProfileId, + fs.agentProfileId, agentProfiles, pickExecutorDisabledReason(fs.noRepository, isMultiRepoSelection), ); @@ -596,6 +597,7 @@ export function useDialogComputed({ function useExecutorProfileCompat( allExecutorProfiles: ExecutorProfile[], selectedProfileId: string, + selectedAgentProfileId: string, agentProfiles: DialogComputedArgs["agentProfiles"], disabledReasonFor?: (profile: ExecutorProfile) => string | null, ) { @@ -613,11 +615,23 @@ function useExecutorProfileCompat( isAgentConfiguredOnExecutor(ap, selectedExecutorProfile, authSpecs), ); }, [agentProfiles, selectedExecutorProfile, authSpecs, authLoaded]); + // `noCompatibleAgent` gates the submit button. It must catch BOTH cases: + // 1. The selected executor has no compatible agents at all. + // 2. The user picked an agent that isn't compatible with the executor + // (e.g. switched executor after the agent was chosen). + // Previously this only checked case 1, so case 2 silently let the user + // submit with a known-incompatible combination. + const noCompatibleAgent = useMemo(() => { + if (!selectedExecutorProfile) return false; + if (compatibleAgentProfiles.length === 0) return true; + if (!selectedAgentProfileId) return false; + return !compatibleAgentProfiles.some((ap) => ap.id === selectedAgentProfileId); + }, [selectedExecutorProfile, compatibleAgentProfiles, selectedAgentProfileId]); return { selectedExecutorProfile, compatibleAgentProfiles, executorProfileOptions, - noCompatibleAgent: Boolean(selectedExecutorProfile) && compatibleAgentProfiles.length === 0, + noCompatibleAgent, }; }