Fix workspace codebase form not allowing empty saves and not auto-updating

- Allow saving empty values to clear repo URL or local folder from an existing workspace
- submitLocalWorkspace/submitRepoWorkspace now handle empty input as a "clear" operation
- Save button is only disabled for empty input when there's no existing workspace to clear
- removeWorkspace.onSuccess now resets form state (matching create/update handlers)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Dotta
2026-03-16 19:19:38 -05:00
parent e079b8ebcf
commit 3456808e1c

View File

@@ -223,7 +223,13 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
const removeWorkspace = useMutation({
mutationFn: (workspaceId: string) => projectsApi.removeWorkspace(project.id, workspaceId),
onSuccess: invalidateProject,
onSuccess: () => {
setWorkspaceCwd("");
setWorkspaceRepoUrl("");
setWorkspaceMode(null);
setWorkspaceError(null);
invalidateProject();
},
});
const updateWorkspace = useMutation({
mutationFn: ({ workspaceId, data }: { workspaceId: string; data: Record<string, unknown> }) =>
@@ -322,6 +328,11 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
const submitLocalWorkspace = () => {
const cwd = workspaceCwd.trim();
if (!cwd) {
setWorkspaceError(null);
persistCodebase({ cwd: null });
return;
}
if (!isAbsolutePath(cwd)) {
setWorkspaceError("Local folder must be a full absolute path.");
return;
@@ -332,6 +343,11 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
const submitRepoWorkspace = () => {
const repoUrl = workspaceRepoUrl.trim();
if (!repoUrl) {
setWorkspaceError(null);
persistCodebase({ repoUrl: null });
return;
}
if (!isGitHubRepoUrl(repoUrl)) {
setWorkspaceError("Repo must use a valid GitHub repo URL.");
return;
@@ -678,7 +694,7 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
variant="outline"
size="xs"
className="h-6 px-2"
disabled={!workspaceCwd.trim() || createWorkspace.isPending || updateWorkspace.isPending}
disabled={(!workspaceCwd.trim() && !primaryCodebaseWorkspace) || createWorkspace.isPending || updateWorkspace.isPending}
onClick={submitLocalWorkspace}
>
Save
@@ -711,7 +727,7 @@ export function ProjectProperties({ project, onUpdate, onFieldUpdate, getFieldSa
variant="outline"
size="xs"
className="h-6 px-2"
disabled={!workspaceRepoUrl.trim() || createWorkspace.isPending || updateWorkspace.isPending}
disabled={(!workspaceRepoUrl.trim() && !primaryCodebaseWorkspace) || createWorkspace.isPending || updateWorkspace.isPending}
onClick={submitRepoWorkspace}
>
Save