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, }; }