From e30651473dce16cda6201cf0d217c95da2b50c90 Mon Sep 17 00:00:00 2001 From: l0ng-ai Date: Thu, 3 Dec 2026 14:37:37 +0800 Subject: [PATCH] fix(run): don't let an unedited invalid configuration block saving others (#7708) Running the same Maven goals with different options (clean install / clean install -U) named two temporary configurations alike, which made both invalid; any invalid configuration disabled OK and Apply in Run/Debug Configurations, so no other configuration could be saved. A temporary configuration whose name is taken now gets a numbered name, and only configurations added or changed in the dialog block saving. One that was already invalid when the dialog opened keeps its marker; Run and Debug stay disabled for it. Fixes #7621 --- src/features/run/EditConfigsDialog.tsx | 20 +++++++++++++---- src/features/run/removal.test.tsx | 31 ++++++++++++++++++++++++++ src/features/run/store.ts | 7 +++++- 3 files changed, 53 insertions(+), 5 deletions(-) diff --git a/src/features/run/EditConfigsDialog.tsx b/src/features/run/EditConfigsDialog.tsx index 50334226ba..a4455ecb83 100644 --- a/src/features/run/EditConfigsDialog.tsx +++ b/src/features/run/EditConfigsDialog.tsx @@ -230,8 +230,20 @@ function EditConfigsDialog() { } return out; }, [draft, formErrorsById, types]); - const invalid = Object.keys(errorsById).length > 0; + // Only configurations added or changed here keep the dialog from saving: one that was already + // invalid when it opened (an older temporary, a project file) doesn't block the others. + const [opened] = useState(() => new Map(initialConfigs.map((c) => [c.id, JSON.stringify(c)]))); + const [savedUnedited] = useState(() => (useRun.getState().editDirty ? target : null)); + const blocking = useMemo( + () => + draft + .filter((c) => errorsById[c.id] && (c.id === savedUnedited || opened.get(c.id) !== JSON.stringify(c))) + .map((c) => c.id), + [draft, errorsById, opened, savedUnedited], + ); + const invalid = blocking.length > 0; const errors = (current && errorsById[current.id]) ?? {}; + const cannotLaunch = invalid || (!!current && !!errorsById[current.id]); const currentType = current ? typeForConfig(current, types) : undefined; const currentTemplateType = currentTemplate ? typeFor(currentTemplate.kind) : undefined; @@ -323,7 +335,7 @@ function EditConfigsDialog() { const save = async (andClose: boolean): Promise => { if (invalid) { - const firstBad = Object.keys(errorsById)[0]; + const firstBad = blocking[0]; if (firstBad) { setMode("configs"); setSelection({ type: "config", id: firstBad }); @@ -414,14 +426,14 @@ function EditConfigsDialog() {