fix(docker): explain missing agent credentials

This commit is contained in:
José Almeida
2026-05-03 20:30:22 +01:00
parent 3bc9e1bc02
commit 567a0414d6
6 changed files with 102 additions and 3 deletions
@@ -22,6 +22,8 @@ type CreateModeSelectorsProps = {
onAgentProfileChange: (v: string) => void;
onExecutorProfileChange: (v: string) => void;
workflowAgentLocked: boolean;
noCompatibleAgent: boolean;
executorProfileName: string | null;
};
/**
@@ -44,6 +46,8 @@ export function CreateModeSelectors(props: CreateModeSelectorsProps) {
onExecutorProfileChange={props.onExecutorProfileChange}
executorsLoading={props.executorsLoading}
workflowAgentLocked={props.workflowAgentLocked}
noCompatibleAgent={props.noCompatibleAgent}
executorProfileName={props.executorProfileName}
AgentSelectorComponent={AgentSelector}
ExecutorProfileSelectorComponent={ExecutorProfileSelector}
/>
@@ -111,7 +111,7 @@ describe("computeDisabledReason (start-task)", () => {
KIND_START,
);
expect(reason).toContain("Docker (sandbox)");
expect(reason).toContain("configured");
expect(reason).toContain("credentials");
});
});
@@ -270,7 +270,7 @@ export const REASON_DESCRIPTION = "Add a session description";
function noCompatibleAgentReason(executorProfileName: string | null): string {
const target = executorProfileName ? `“${executorProfileName}”` : "this executor";
return `No agent profile is configured for ${target}. Configure credentials in Settings → Executors.`;
return `No compatible agent profile is configured for ${target}. Configure agent credentials in Settings → Executors.`;
}
function baseReason(props: TaskCreateDialogFooterProps): string | null {
@@ -51,6 +51,8 @@ type CreateEditSelectorsProps = {
triggerClassName?: string;
}>;
workflowAgentLocked: boolean;
noCompatibleAgent: boolean;
executorProfileName: string | null;
};
type AgentColumnProps = Pick<
@@ -63,8 +65,28 @@ type AgentColumnProps = Pick<
| "isCreatingSession"
| "AgentSelectorComponent"
| "workflowAgentLocked"
| "noCompatibleAgent"
| "executorProfileName"
>;
function NoCompatibleAgentState({ executorProfileName }: { executorProfileName: string | null }) {
const target = executorProfileName ? `“${executorProfileName}”` : "this executor";
return (
<div
className="flex h-auto min-h-7 items-center justify-between gap-3 rounded-sm border border-input px-3 py-1.5 text-xs text-muted-foreground"
data-testid="agent-profile-empty-state"
>
<span>No compatible agent profiles for {target}.</span>
<Link
href="/settings/executors"
className="shrink-0 cursor-pointer text-primary hover:underline"
>
Configure credentials
</Link>
</div>
);
}
function AgentColumn({
agentProfiles,
agentProfilesLoading,
@@ -74,10 +96,15 @@ function AgentColumn({
isCreatingSession,
AgentSelectorComponent,
workflowAgentLocked,
noCompatibleAgent,
executorProfileName,
}: AgentColumnProps) {
if (agentProfiles.length === 0 && !agentProfilesLoading) {
return (
<div className="flex h-7 items-center justify-center gap-2 rounded-sm border border-input px-3 text-xs text-muted-foreground">
<div
className="flex h-7 items-center justify-center gap-2 rounded-sm border border-input px-3 text-xs text-muted-foreground"
data-testid="agent-profile-empty-state"
>
<span>No agents found.</span>
<Link href="/settings/agents" className="cursor-pointer text-primary hover:underline">
Add agent
@@ -85,6 +112,9 @@ function AgentColumn({
</div>
);
}
if (noCompatibleAgent && !agentProfilesLoading) {
return <NoCompatibleAgentState executorProfileName={executorProfileName} />;
}
const placeholder = agentProfilesLoading ? "Loading agents..." : "Select agent";
return (
<>
@@ -138,6 +138,8 @@ type DialogFormBodyProps = {
* branch for local execution; fresh-branch mode unlocks it).
*/
isLocalExecutor: boolean;
noCompatibleAgent: boolean;
executorProfileName: string | null;
/** Optional render slot above the description editor. */
aboveDescriptionSlot?: React.ReactNode;
/** Optional render slot inside the dialog body (rendered above the chip row). */
@@ -230,6 +232,8 @@ function CreateModeBody(props: DialogFormBodyProps) {
onAgentProfileChange={onAgentProfileChange}
onExecutorProfileChange={onExecutorProfileChange}
workflowAgentLocked={workflowAgentLocked}
noCompatibleAgent={props.noCompatibleAgent}
executorProfileName={props.executorProfileName}
/>
{props.bottomSlot}
</>
@@ -553,6 +557,8 @@ export function TaskCreateDialog(props: TaskCreateDialogProps) {
repositories={repositories}
freshBranchAvailable={freshBranchAvailable}
isLocalExecutor={computed.isLocalExecutor}
noCompatibleAgent={computed.noCompatibleAgent}
executorProfileName={computed.selectedExecutorProfileName}
extraFormSlot={props.extraFormSlot}
aboveDescriptionSlot={props.aboveDescriptionSlot}
bottomSlot={props.bottomSlot}
@@ -78,6 +78,65 @@ test.describe("Task creation", () => {
await expect(testPage.getByTestId("create-task-dialog")).toBeVisible();
});
test("explains when a Docker executor has no compatible agent credentials", async ({
testPage,
apiClient,
seedData,
}) => {
const profile = await apiClient.getAgentProfile(seedData.agentProfileId);
const { agents } = await apiClient.listAgents();
const agent = agents.find((item) => item.profiles?.some((p) => p.id === profile.id));
if (!agent) {
throw new Error(`agent for profile ${profile.id} not found`);
}
const dockerExec = await apiClient.createExecutor("E2E Docker Empty Agent", "local_docker");
await apiClient.createExecutorProfile(dockerExec.id, {
name: "Docker Missing Auth",
config: {
image_tag: "kandev-mock-agent:test",
dockerfile: "FROM busybox\nWORKDIR /workspace\n",
},
});
await testPage.route("**/api/v1/remote-credentials", async (route) => {
await route.fulfill({
status: 200,
contentType: "application/json",
body: JSON.stringify({
auth_specs: [
{
id: agent.name,
display_name: profile.agent_display_name,
methods: [{ method_id: "test-token", type: "env", env_var: "TEST_TOKEN" }],
},
],
}),
});
});
try {
const kanban = new KanbanPage(testPage);
await kanban.goto();
await kanban.createTaskButton.first().click();
const dialog = testPage.getByTestId("create-task-dialog");
await expect(dialog).toBeVisible();
await testPage.getByTestId("task-title-input").fill("Docker Missing Auth Task");
await testPage.getByTestId("task-description-input").fill("testing docker auth empty state");
await testPage.getByTestId("executor-profile-selector").click();
await testPage.getByRole("option", { name: /Docker Missing Auth/i }).click();
await expect(testPage.getByTestId("agent-profile-empty-state")).toContainText(
"No compatible agent profiles",
);
await expect(testPage.getByTestId(START_AGENT_TEST_ID)).toBeDisabled();
} finally {
await apiClient.deleteExecutor(dockerExec.id).catch(() => {});
}
});
test("can fill in task title and description", async ({ testPage }) => {
const kanban = new KanbanPage(testPage);
await kanban.goto();