Files
kandev/apps/web/components/settings/profile-edit/profile-runtime-sections.tsx
T
José Almeida f470ea85e2 fix(docker-profile): persist Dockerfile/image_tag and apply tag override at runtime
Two bugs:

1. The Dockerfile editor and Image Tag input on the executor profile page
   stored their values in component-local useState inside DockerSections,
   not in the form state. Saving the profile never wrote them back, so
   "Use defaults" / typing in the editor / changing the tag never
   persisted — and the Build button was the only thing that consumed
   them. The same gap existed in the new-executor flow's
   buildProfileConfig.

   Lift `dockerfile` and `image_tag` into useProfileFormState (edit) and
   useCreateProfileFormState (new), and emit them in buildSaveConfig /
   buildProfileConfig so they round-trip through profile.config.

2. Even when an image_tag is set on the profile, the container builder
   ignored it. imageName was always derived from the agent runtime's
   hardcoded `kandev/multi-agent`, so a user who built a custom image
   like `kandev/agent:latest` would still see Docker fail with
   "No such image: kandev/multi-agent:latest".

   Propagate `profile.config.image_tag` → metadata
   (`image_tag_override`) → ExecutorCreateRequest → ContainerConfig,
   and let it override `rt.Image` in buildContainerConfig when set.

Also align the frontend default image tag (kandev/multi-agent:latest)
with the backend's hardcoded runtime default so users who don't override
end up with a working build.
2026-05-04 21:08:51 +01:00

109 lines
3.1 KiB
TypeScript

"use client";
import type { ExecutorProfile } from "@/lib/types/http";
import type { SecretListItem } from "@/lib/types/http-secrets";
import type { NetworkPolicyRule } from "@/lib/api/domains/settings-api";
import {
RemoteCredentialsCard,
type GitIdentityMode,
type GitIdentityState,
} from "@/components/settings/profile-edit/remote-credentials-card";
import {
DockerfileBuildCard,
DockerContainersCard,
} from "@/components/settings/profile-edit/docker-sections";
import { NetworkPoliciesCard } from "@/components/settings/profile-edit/sprites-sections";
import { SpritesInstancesCard } from "@/components/settings/sprites-settings";
type DockerSectionsProps = {
profile: ExecutorProfile;
dockerfile: string;
onDockerfileChange: (v: string) => void;
imageTag: string;
onImageTagChange: (v: string) => void;
};
export function DockerSections({
profile,
dockerfile,
onDockerfileChange,
imageTag,
onImageTagChange,
}: DockerSectionsProps) {
return (
<>
<DockerfileBuildCard
dockerfile={dockerfile}
onDockerfileChange={onDockerfileChange}
imageTag={imageTag}
onImageTagChange={onImageTagChange}
/>
<DockerContainersCard profileId={profile.id} />
</>
);
}
type SpritesSectionsProps = {
isRemote: boolean;
isSprites: boolean;
secretId: string | null;
networkRules: NetworkPolicyRule[];
onNetworkRulesChange: (rules: NetworkPolicyRule[]) => void;
remoteCredentials: string[];
onRemoteCredentialsChange: (ids: string[]) => void;
agentEnvVars: Record<string, string | null>;
onAgentEnvVarChange: (agentId: string, secretId: string | null) => void;
gitIdentityMode: GitIdentityMode;
onGitIdentityModeChange: (mode: GitIdentityMode) => void;
gitUserName: string;
gitUserEmail: string;
onGitUserNameChange: (value: string) => void;
onGitUserEmailChange: (value: string) => void;
localGitIdentity: GitIdentityState;
secrets: SecretListItem[];
};
export function SpritesSections({
isRemote,
isSprites,
secretId,
networkRules,
onNetworkRulesChange,
remoteCredentials,
onRemoteCredentialsChange,
agentEnvVars,
onAgentEnvVarChange,
gitIdentityMode,
onGitIdentityModeChange,
gitUserName,
gitUserEmail,
onGitUserNameChange,
onGitUserEmailChange,
localGitIdentity,
secrets,
}: SpritesSectionsProps) {
return (
<>
{isSprites && secretId && <SpritesInstancesCard secretId={secretId} />}
<RemoteCredentialsCard
isRemote={isRemote}
selectedIds={remoteCredentials}
onChange={onRemoteCredentialsChange}
agentEnvVars={agentEnvVars}
onAgentEnvVarChange={onAgentEnvVarChange}
secrets={secrets}
gitIdentityMode={gitIdentityMode}
onGitIdentityModeChange={onGitIdentityModeChange}
gitUserName={gitUserName}
gitUserEmail={gitUserEmail}
onGitUserNameChange={onGitUserNameChange}
onGitUserEmailChange={onGitUserEmailChange}
localGitIdentity={localGitIdentity}
/>
{isSprites && (
<NetworkPoliciesCard rules={networkRules} onRulesChange={onNetworkRulesChange} />
)}
</>
);
}