From 14548acd52e2284dcfbf3b0b0aad73621ca74a3d Mon Sep 17 00:00:00 2001 From: Stefan Lau Date: Thu, 20 Nov 2025 18:35:32 +0100 Subject: [PATCH 1/2] Fix toolset configuration submit button not being enabled from the start --- src/renderer/components/TextEditor.tsx | 5 ++++- src/renderer/components/WithToolsetConfig.tsx | 17 +++++++++-------- src/renderer/components/selectedMod/NewMod.tsx | 3 ++- 3 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/renderer/components/TextEditor.tsx b/src/renderer/components/TextEditor.tsx index 881aff4..5e5356f 100644 --- a/src/renderer/components/TextEditor.tsx +++ b/src/renderer/components/TextEditor.tsx @@ -9,8 +9,11 @@ import { useFileJsonSchema } from '../hooks/useFileJsonSchema'; import { useFileTextValue } from '../hooks/useFileTextValue'; import { useFileTextUpdate } from '../hooks/useFileTextUpdate'; import { useFileEditMode } from '../hooks/useFileEditMode'; +import { omit } from 'remeda'; -const JSON_PATCH_JSON_SCHEMA = toJSONSchema(JSON_PATCH_SCHEMA); +const JSON_PATCH_JSON_SCHEMA = omit(toJSONSchema(JSON_PATCH_SCHEMA), [ + '$schema', +]); const MONACO_OPTIONS = { fixedOverflowWidgets: true }; diff --git a/src/renderer/components/WithToolsetConfig.tsx b/src/renderer/components/WithToolsetConfig.tsx index 2de0509..5b60f45 100644 --- a/src/renderer/components/WithToolsetConfig.tsx +++ b/src/renderer/components/WithToolsetConfig.tsx @@ -13,8 +13,11 @@ import { PartialToolsetConfig, } from '../../common/invokables/toolset'; import jsonSchemaValidator from '@rjsf/validator-ajv8'; +import { omit } from 'remeda'; -const CONFIG_JSON_SCHEMA = toJSONSchema(FULL_TOOLSET_CONFIG_SCHEMA); +const CONFIG_JSON_SCHEMA = omit(toJSONSchema(FULL_TOOLSET_CONFIG_SCHEMA), [ + '$schema', +]); const CONFIG_UI_SCHEMA = { stracciatellaHome: { 'ui:widget': HostPathWidget, @@ -52,14 +55,12 @@ function Configure() { useEffect(() => { if (data) { setTimeout(() => { - setState(data.config); - - setValid( - !jsonSchemaValidator.rawValidation( - CONFIG_JSON_SCHEMA as any, - data.config, - ).validationError, + const { validationError } = jsonSchemaValidator.rawValidation( + CONFIG_JSON_SCHEMA as any, + data.config, ); + setState(data.config); + setValid(!validationError); }, 0); } }, [data]); diff --git a/src/renderer/components/selectedMod/NewMod.tsx b/src/renderer/components/selectedMod/NewMod.tsx index f40bd85..78ccd48 100644 --- a/src/renderer/components/selectedMod/NewMod.tsx +++ b/src/renderer/components/selectedMod/NewMod.tsx @@ -10,8 +10,9 @@ import { useSelectedMod } from '../../hooks/useSelectedMod'; import { selectStracciatellaHome } from '../../state/selectors'; import { toJSONSchema } from 'zod'; import { MOD_SCHEMA, Mod } from '../../../common/invokables/mods'; +import { omit } from 'remeda'; -const MOD_JSON_SCHEMA = toJSONSchema(MOD_SCHEMA); +const MOD_JSON_SCHEMA = omit(toJSONSchema(MOD_SCHEMA), ['$schema']); export function NewMod({ onCancel }: { onCancel: () => void }) { const { From fb33be79aab4e45fcce893f229158bb3f5a72f3e Mon Sep 17 00:00:00 2001 From: Stefan Lau Date: Thu, 20 Nov 2025 19:28:43 +0100 Subject: [PATCH 2/2] Fix issue with patches getting reapplied when switching to visual edit mode --- src/renderer/state/files.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/renderer/state/files.tsx b/src/renderer/state/files.tsx index 9e9c14a..6ca08d2 100644 --- a/src/renderer/state/files.tsx +++ b/src/renderer/state/files.tsx @@ -304,7 +304,7 @@ const filesSlice = createSlice({ try { if (open.saveMode === 'patch') { const patch = JSON_PATCH_SCHEMA.parse(JSON.parse(open.value)); - const applied = applyPatch(disk.applied, patch); + const applied = applyPatch(disk.vanilla, patch); state.open[filename] = { ...open, editMode: editMode as 'visual',