fix: remove legacy config APIs

Remove stale ToolConfig and ConfigFolder backend/frontend surfaces after the ConfigProfile refactor. Drop dead routers, schemas, model exports, frontend routes, clients, pages, and tests; keep ToolType API compatibility for existing interface/is_builtin response shape.

Quality gates: backend LSP diagnostics passed; backend py_compile passed; backend ruff passed; frontend ToolWorkshopPage test passed. Frontend typecheck blocked by unrelated missing xterm-addon-serialize types.
This commit is contained in:
2026-06-03 12:40:47 +02:00
parent b6f89f9df0
commit 4201326467
33 changed files with 290 additions and 2932 deletions
@@ -1,289 +0,0 @@
import { useCallback, useEffect, useState } from "react";
import { Icon } from "../../ui/Icon";
import {
createConfigFolder,
deleteConfigFolder,
listConfigFolders,
updateConfigFolder,
type ConfigFolder,
type CreateConfigFolderRequest,
type UpdateConfigFolderRequest,
} from "../../../api/config-folders";
export const ConfigFoldersTab = () => {
const [folders, setFolders] = useState<ConfigFolder[]>([]);
const [status, setStatus] = useState<"loading" | "ready" | "error">(
"loading",
);
const [selectedFolder, setSelectedFolder] = useState<ConfigFolder | null>(
null,
);
const [folderForm, setFolderForm] = useState({
name: "",
description: "",
mount_path: "/home/user",
files_json: "{}",
is_active: true,
});
const [folderError, setFolderError] = useState<string | null>(null);
const [showFolderForm, setShowFolderForm] = useState(false);
const loadFolders = useCallback(async () => {
setStatus("loading");
try {
const data = await listConfigFolders();
setFolders(data);
setStatus("ready");
} catch {
setStatus("error");
}
}, []);
useEffect(() => {
void loadFolders();
}, [loadFolders]);
const openCreateFolder = () => {
setFolderForm({
name: "",
description: "",
mount_path: "/home/user",
files_json: "{}",
is_active: true,
});
setFolderError(null);
setShowFolderForm(true);
setSelectedFolder(null);
};
const openEditFolder = (folder: ConfigFolder) => {
setFolderForm({
name: folder.name,
description: folder.description || "",
mount_path: folder.mount_path,
files_json: JSON.stringify(folder.files, null, 2),
is_active: folder.is_active,
});
setFolderError(null);
setShowFolderForm(true);
setSelectedFolder(folder);
};
const handleFolderSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setFolderError(null);
if (!folderForm.name.trim() || !folderForm.mount_path.trim()) {
setFolderError("Name and mount path are required");
return;
}
let files: Record<string, string> | undefined;
try {
if (
folderForm.files_json.trim() &&
folderForm.files_json.trim() !== "{}"
) {
files = JSON.parse(folderForm.files_json);
}
} catch {
setFolderError("Files must be valid JSON object");
return;
}
const data: CreateConfigFolderRequest | UpdateConfigFolderRequest = {
name: folderForm.name.trim(),
description: folderForm.description.trim() || undefined,
mount_path: folderForm.mount_path.trim(),
files,
is_active: folderForm.is_active,
};
try {
if (selectedFolder) {
await updateConfigFolder(selectedFolder.id, data);
} else {
await createConfigFolder(data as CreateConfigFolderRequest);
}
setShowFolderForm(false);
setSelectedFolder(null);
await loadFolders();
} catch (err) {
const axiosError = err as { response?: { data?: { detail?: string } } };
setFolderError(
axiosError?.response?.data?.detail || "Failed to save folder",
);
}
};
const handleDeleteFolder = async (id: string) => {
if (!window.confirm("Delete this config folder?")) return;
try {
await deleteConfigFolder(id);
await loadFolders();
} catch {
alert("Failed to delete folder");
}
};
if (status === "loading") {
return <p className="muted">Loading Config Folders...</p>;
}
if (status === "error") {
return (
<div className="card stack">
<p className="text-error">Failed to load config folders.</p>
<button onClick={() => void loadFolders()}>
<Icon name="refresh" size="sm" /> Retry
</button>
</div>
);
}
return (
<div>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginBottom: "1rem",
}}
>
<h2>Config Folders</h2>
<button onClick={openCreateFolder}>
<Icon name="add" size="sm" /> Create Folder
</button>
</div>
{showFolderForm && (
<div className="card stack" style={{ marginBottom: "1rem" }}>
<h3>{selectedFolder ? "Edit" : "Create"} Config Folder</h3>
<form onSubmit={handleFolderSubmit} className="stack">
<div className="form-group">
<label htmlFor="folder-name">Name *</label>
<input
id="folder-name"
type="text"
value={folderForm.name}
onChange={(e) =>
setFolderForm({ ...folderForm, name: e.target.value })
}
placeholder="e.g., my-dotfiles"
className="form-input"
required
/>
</div>
<div className="form-group">
<label htmlFor="folder-description">Description</label>
<input
id="folder-description"
type="text"
value={folderForm.description}
onChange={(e) =>
setFolderForm({ ...folderForm, description: e.target.value })
}
placeholder="Optional description"
className="form-input"
/>
</div>
<div className="form-group">
<label htmlFor="folder-mount-path">Mount Path *</label>
<input
id="folder-mount-path"
type="text"
value={folderForm.mount_path}
onChange={(e) =>
setFolderForm({ ...folderForm, mount_path: e.target.value })
}
placeholder="e.g., /home/user"
className="form-input"
required
/>
</div>
<div className="form-group">
<label htmlFor="folder-files">Files (JSON object)</label>
<textarea
id="folder-files"
value={folderForm.files_json}
onChange={(e) =>
setFolderForm({ ...folderForm, files_json: e.target.value })
}
placeholder='{".zshrc": "export ZSH=...", ".gitconfig": "[user]\\nname = ..."}'
className="form-input"
rows={8}
/>
</div>
<div className="form-group">
<label className="checkbox-label">
<input
type="checkbox"
checked={folderForm.is_active}
onChange={(e) =>
setFolderForm({
...folderForm,
is_active: e.target.checked,
})
}
/>
Active (mount into new instances)
</label>
</div>
{folderError && <p className="text-error">{folderError}</p>}
<div className="dialog-actions">
<button type="submit">
{selectedFolder ? "Update" : "Create"}
</button>
<button
type="button"
onClick={() => setShowFolderForm(false)}
className="button-secondary"
>
Cancel
</button>
</div>
</form>
</div>
)}
<div className="card-grid">
{folders.map((folder) => (
<div key={folder.id} className="card">
<div className="card-header">
<h3>{folder.name}</h3>
{folder.is_active && <span className="badge">Active</span>}
</div>
<p className="text-secondary">
{folder.description || "No description"}
</p>
<div className="tool-type-meta">
<span>Mount: {folder.mount_path}</span>
<span>Files: {Object.keys(folder.files || {}).length}</span>
</div>
<div className="card-actions">
<button
onClick={() => openEditFolder(folder)}
className="button-secondary"
>
<Icon name="edit" size="sm" /> Edit
</button>
<button
onClick={() => handleDeleteFolder(folder.id)}
className="button-danger"
>
<Icon name="delete" size="sm" /> Delete
</button>
</div>
</div>
))}
</div>
</div>
);
};
@@ -1,460 +0,0 @@
import { useCallback, useEffect, useState } from "react";
import { Icon } from "../../ui/Icon";
import {
createToolConfig,
deleteToolConfig,
listToolConfigs,
updateToolConfig,
type CreateToolConfigRequest,
type ToolConfig,
} from "../../../api/tool-configs";
import { listToolTypes, type ToolType } from "../../../api/tool-types";
export const ToolConfigsTab = () => {
const [configs, setConfigs] = useState<ToolConfig[]>([]);
const [toolTypes, setToolTypes] = useState<ToolType[]>([]);
const [status, setStatus] = useState<"loading" | "ready" | "error">(
"loading",
);
const [selectedConfig, setSelectedConfig] = useState<ToolConfig | null>(null);
const [configForm, setConfigForm] = useState({
tool_type_id: "",
key: "",
value: "",
config_type: "env",
file_path: "",
port_override: "",
start_command: "",
working_directory: "",
env_vars_json: "{}",
volumes_json: "[]",
});
const [configError, setConfigError] = useState<string | null>(null);
const [showConfigForm, setShowConfigForm] = useState(false);
const loadData = useCallback(async () => {
setStatus("loading");
try {
const [cfgs, types] = await Promise.all([
listToolConfigs(),
listToolTypes(),
]);
setConfigs(cfgs);
setToolTypes(types);
setStatus("ready");
} catch {
setStatus("error");
}
}, []);
useEffect(() => {
void loadData();
}, [loadData]);
const openCreateConfig = () => {
setConfigForm({
tool_type_id: toolTypes[0]?.id || "",
key: "",
value: "",
config_type: "env",
file_path: "",
port_override: "",
start_command: "",
working_directory: "",
env_vars_json: "{}",
volumes_json: "[]",
});
setConfigError(null);
setShowConfigForm(true);
setSelectedConfig(null);
};
const openEditConfig = (config: ToolConfig) => {
setConfigForm({
tool_type_id: config.tool_type_id,
key: config.key,
value: config.value,
config_type: config.config_type,
file_path: config.file_path || "",
port_override: config.port_override?.toString() || "",
start_command: config.start_command || "",
working_directory: config.working_directory || "",
env_vars_json: config.environment_variables
? JSON.stringify(config.environment_variables, null, 2)
: "{}",
volumes_json: config.volumes
? JSON.stringify(config.volumes, null, 2)
: "[]",
});
setConfigError(null);
setShowConfigForm(true);
setSelectedConfig(config);
};
const handleConfigSubmit = async (e: React.FormEvent) => {
e.preventDefault();
setConfigError(null);
if (!configForm.tool_type_id || !configForm.key.trim()) {
setConfigError("Tool type and key are required");
return;
}
let envVars: Record<string, string> | undefined;
let volumes:
| Array<{ source: string; target: string; type?: string }>
| undefined;
try {
if (
configForm.env_vars_json.trim() &&
configForm.env_vars_json.trim() !== "{}"
) {
envVars = JSON.parse(configForm.env_vars_json);
}
} catch {
setConfigError("Environment variables must be valid JSON");
return;
}
try {
if (
configForm.volumes_json.trim() &&
configForm.volumes_json.trim() !== "[]"
) {
volumes = JSON.parse(configForm.volumes_json);
}
} catch {
setConfigError("Volumes must be valid JSON array");
return;
}
const data: CreateToolConfigRequest = {
tool_type_id: configForm.tool_type_id,
key: configForm.key.trim(),
value: configForm.value,
config_type: configForm.config_type,
file_path:
configForm.config_type === "file" ? configForm.file_path : undefined,
port_override: configForm.port_override
? Number(configForm.port_override)
: undefined,
start_command: configForm.start_command.trim() || undefined,
working_directory: configForm.working_directory.trim() || undefined,
environment_variables: envVars,
volumes,
};
try {
if (selectedConfig) {
await updateToolConfig(selectedConfig.id, data);
} else {
await createToolConfig(data);
}
setShowConfigForm(false);
setSelectedConfig(null);
await loadData();
} catch (err) {
const axiosError = err as { response?: { data?: { detail?: string } } };
setConfigError(
axiosError?.response?.data?.detail || "Failed to save config",
);
}
};
const handleDeleteConfig = async (id: string) => {
if (!window.confirm("Delete this config?")) return;
try {
await deleteToolConfig(id);
await loadData();
} catch {
alert("Failed to delete config");
}
};
if (status === "loading") {
return <p className="muted">Loading Configurations...</p>;
}
if (status === "error") {
return (
<div className="card stack">
<p className="text-error">Failed to load configurations.</p>
<button onClick={() => void loadData()}>
<Icon name="refresh" size="sm" /> Retry
</button>
</div>
);
}
return (
<div>
<div
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
marginBottom: "1rem",
}}
>
<h2>Tool Configurations</h2>
<button onClick={openCreateConfig}>
<Icon name="add" size="sm" /> Add Config
</button>
</div>
{showConfigForm && (
<div className="card stack" style={{ marginBottom: "1rem" }}>
<h3>{selectedConfig ? "Edit" : "Add"} Config</h3>
<form onSubmit={handleConfigSubmit} className="stack">
<div className="form-group">
<label htmlFor="config-tool-type">Tool Type *</label>
<select
id="config-tool-type"
value={configForm.tool_type_id}
onChange={(e) =>
setConfigForm({ ...configForm, tool_type_id: e.target.value })
}
className="form-input"
required
>
<option value="">Select a tool type...</option>
{toolTypes.map((tt) => (
<option key={tt.id} value={tt.id}>
{tt.display_name}
</option>
))}
</select>
</div>
<div className="form-group">
<label htmlFor="config-key">Key *</label>
<input
id="config-key"
type="text"
value={configForm.key}
onChange={(e) =>
setConfigForm({ ...configForm, key: e.target.value })
}
placeholder="e.g., OPENAI_API_KEY"
className="form-input"
required
/>
</div>
<div className="form-group">
<label htmlFor="config-type">Config Type</label>
<select
id="config-type"
value={configForm.config_type}
onChange={(e) =>
setConfigForm({ ...configForm, config_type: e.target.value })
}
className="form-input"
>
<option value="env">Environment Variable</option>
<option value="file">Configuration File</option>
</select>
</div>
{configForm.config_type === "file" && (
<div className="form-group">
<label>File Path</label>
<input
type="text"
value={configForm.file_path}
onChange={(e) =>
setConfigForm({ ...configForm, file_path: e.target.value })
}
placeholder="e.g., /app/config.json"
className="form-input"
/>
</div>
)}
<div className="form-group">
<label htmlFor="config-value">Value</label>
<textarea
id="config-value"
value={configForm.value}
onChange={(e) =>
setConfigForm({ ...configForm, value: e.target.value })
}
placeholder={
configForm.config_type === "env"
? "Enter value..."
: "Enter file contents..."
}
className="form-input"
rows={configForm.config_type === "file" ? 8 : 2}
required
/>
</div>
<div className="row" style={{ gap: "1rem" }}>
<div className="form-group" style={{ flex: 1 }}>
<label htmlFor="config-port-override">Port Override</label>
<input
id="config-port-override"
type="number"
value={configForm.port_override}
onChange={(e) =>
setConfigForm({
...configForm,
port_override: e.target.value,
})
}
placeholder="e.g., 8080"
className="form-input"
/>
</div>
<div className="form-group" style={{ flex: 1 }}>
<label htmlFor="config-start-command">Start Command</label>
<input
id="config-start-command"
type="text"
value={configForm.start_command}
onChange={(e) =>
setConfigForm({
...configForm,
start_command: e.target.value,
})
}
placeholder="e.g., npm start"
className="form-input"
/>
</div>
</div>
<div className="form-group">
<label>Working Directory</label>
<input
type="text"
value={configForm.working_directory}
onChange={(e) =>
setConfigForm({
...configForm,
working_directory: e.target.value,
})
}
placeholder="e.g., /workspace"
className="form-input"
/>
</div>
<div className="form-group">
<label>Environment Variables (JSON)</label>
<textarea
value={configForm.env_vars_json}
onChange={(e) =>
setConfigForm({
...configForm,
env_vars_json: e.target.value,
})
}
placeholder='{"KEY": "value"}'
className="form-input"
rows={4}
/>
</div>
<div className="form-group">
<label>Volumes (JSON array)</label>
<textarea
value={configForm.volumes_json}
onChange={(e) =>
setConfigForm({ ...configForm, volumes_json: e.target.value })
}
placeholder='[{"source": "/host", "target": "/container"}]'
className="form-input"
rows={4}
/>
</div>
{configError && <p className="text-error">{configError}</p>}
<div className="dialog-actions">
<button type="submit">{selectedConfig ? "Update" : "Add"}</button>
<button
type="button"
onClick={() => setShowConfigForm(false)}
className="button-secondary"
>
Cancel
</button>
</div>
</form>
</div>
)}
<div className="stack" style={{ gap: "0.5rem" }}>
{configs.length === 0 ? (
<p className="muted">No configurations yet.</p>
) : (
configs.map((config) => (
<div
key={config.id}
className="card"
style={{
display: "flex",
justifyContent: "space-between",
alignItems: "center",
padding: "0.75rem 1rem",
}}
>
<div>
<div
className="row"
style={{ gap: "0.5rem", alignItems: "center" }}
>
<code style={{ fontWeight: 600 }}>{config.key}</code>
<span
className="badge"
style={{
fontSize: "0.7rem",
textTransform: "uppercase",
background:
config.config_type === "env"
? "var(--color-info)"
: "var(--color-warning)",
color: "white",
padding: "0.125rem 0.5rem",
borderRadius: "9999px",
}}
>
{config.config_type}
</span>
</div>
<p
className="muted"
style={{ marginTop: "0.25rem", fontSize: "0.875rem" }}
>
{config.config_type === "file" && config.file_path
? `File: ${config.file_path}`
: "Environment variable"}
{config.port_override && ` · Port: ${config.port_override}`}
</p>
</div>
<div className="row" style={{ gap: "0.5rem" }}>
<button
className="ghost-button small"
onClick={() => openEditConfig(config)}
type="button"
>
<Icon name="edit" size="sm" />
</button>
<button
className="ghost-button small"
onClick={() => handleDeleteConfig(config.id)}
type="button"
>
<Icon name="delete" size="sm" />
</button>
</div>
</div>
))
)}
</div>
</div>
);
};
@@ -196,7 +196,7 @@ export const ToolTypesTab = () => {
const handleDeleteToolType = async (id: string) => {
if (
!window.confirm(
"Delete this tool type? All associated configs will be removed.",
"Delete this tool type? Existing instances using it may be affected.",
)
)
return;
@@ -327,33 +327,22 @@ export const ToolTypesTab = () => {
</div>
<div className="form-group">
<label>Interfaces</label>
<div className="checkbox-group">
{["web", "terminal"].map((iface) => (
<label key={iface} className="checkbox-label">
<input
type="checkbox"
checked={toolTypeForm.interfaces.includes(iface)}
onChange={(e) => {
if (e.target.checked) {
setToolTypeForm({
...toolTypeForm,
interfaces: [...toolTypeForm.interfaces, iface],
});
} else {
setToolTypeForm({
...toolTypeForm,
interfaces: toolTypeForm.interfaces.filter(
(i) => i !== iface,
),
});
}
}}
/>
{iface}
</label>
))}
</div>
<label htmlFor="tool-type-interface">Interface</label>
<select
id="tool-type-interface"
value={toolTypeForm.interfaces[0] ?? ""}
onChange={(e) =>
setToolTypeForm({
...toolTypeForm,
interfaces: e.target.value ? [e.target.value] : [],
})
}
className="form-input"
>
<option value="">Select interface</option>
<option value="web">web</option>
<option value="terminal">terminal</option>
</select>
</div>
<div className="form-group">
@@ -1,3 +1 @@
export { ToolTypesTab } from "./ToolTypesTab";
export { ToolConfigsTab } from "./ToolConfigsTab";
export { ConfigFoldersTab } from "./ConfigFoldersTab";