Copy inherited config as default when unchecking inherit checkbox

When unchecking the "Inherit project workspace runtime config" checkbox,
if the runtime config field is empty, automatically populate it with the
inherited config value so the user has a starting point to edit from.
Existing values are preserved and never overwritten.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
dotta 2026-04-05 07:39:38 -05:00
parent 612bab1eb6
commit aff56c2297

View file

@ -547,9 +547,17 @@ export function ExecutionWorkspaceDetail() {
id="inherit-runtime-config"
type="checkbox"
checked={form.inheritRuntime}
onChange={(event) =>
setForm((current) => current ? { ...current, inheritRuntime: event.target.checked } : current)
}
onChange={(event) => {
const checked = event.target.checked;
setForm((current) => {
if (!current) return current;
// When unchecking "inherit" and the field is empty, copy inherited config as a starting point
if (!checked && !current.workspaceRuntime.trim() && inheritedRuntimeConfig) {
return { ...current, inheritRuntime: checked, workspaceRuntime: formatJson(inheritedRuntimeConfig) };
}
return { ...current, inheritRuntime: checked };
});
}}
/>
<label htmlFor="inherit-runtime-config">Inherit project workspace runtime config</label>
</div>