Skip to content

Commit 77eae69

Browse files
committed
fix(servers): stop auto-inserting duplicate draft on custom server add
The 'Add Custom Server' menu always opened ConfigEditorModal with insertNewServer=true, which unconditionally injected a blank 'New Custom Server' draft into the space JSON on open. Combined with the existing manual 'Insert Server' toolbar button (same addCustomServerDraft call), saving would persist both the intended server and the untouched draft as duplicate entries. Remove the auto-insert-on-open path; the toolbar button already covers inserting a draft on demand. Signed-off-by: crimsonsunset <jsangio1@gmail.com>
1 parent eb5ae35 commit 77eae69

2 files changed

Lines changed: 3 additions & 8 deletions

File tree

apps/desktop/src/components/ConfigEditorModal.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ const EDITOR_MOUNT_TIMEOUT_MS = 10_000;
1414
interface ConfigEditorModalProps {
1515
spaceId: string;
1616
spaceName: string;
17-
insertNewServer?: boolean;
1817
onClose: () => void;
1918
onSaved: () => void;
2019
}
@@ -60,7 +59,6 @@ function addCustomServerDraft(config: SpaceConfigJson): SpaceConfigJson {
6059
export function ConfigEditorModal({
6160
spaceId,
6261
spaceName,
63-
insertNewServer = false,
6462
onClose,
6563
onSaved,
6664
}: ConfigEditorModalProps) {
@@ -91,12 +89,10 @@ export function ConfigEditorModal({
9189
setIsLoading(true);
9290
setError(null);
9391
const data = await readSpaceConfig(spaceId);
94-
// Auto-format on load if valid JSON. When opened from Add Custom Server,
95-
// insert a unique draft entry instead of replacing an existing server block.
92+
// Auto-format on load if valid JSON.
9693
try {
9794
const parsed = JSON.parse(data) as SpaceConfigJson;
98-
const nextConfig = insertNewServer ? addCustomServerDraft(parsed) : parsed;
99-
setContent(JSON.stringify(nextConfig, null, 2));
95+
setContent(JSON.stringify(parsed, null, 2));
10096
} catch {
10197
setContent(data);
10298
}
@@ -105,7 +101,7 @@ export function ConfigEditorModal({
105101
} finally {
106102
setIsLoading(false);
107103
}
108-
}, [spaceId, insertNewServer]);
104+
}, [spaceId]);
109105

110106
useEffect(() => {
111107
void loadConfig();

apps/desktop/src/features/servers/ServersPage.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2689,7 +2689,6 @@ export function ServersPage() {
26892689
<ConfigEditorModal
26902690
spaceId={editConfigSpace.id}
26912691
spaceName={editConfigSpace.name}
2692-
insertNewServer
26932692
onClose={() => setEditConfigSpace(null)}
26942693
onSaved={() => {
26952694
loadData(); // Reload servers after config save

0 commit comments

Comments
 (0)