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.
This commit is contained in:
@@ -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));
|
||||
|
||||
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user