Repository navigation
fix(settings): wait for complete multi-part settings before syncing canonical mdbase type (#2758) - #2759
Merged
Conversation
…anonical mdbase type (#2758)
…e-definition-race # Conflicts: # docs/releases/unreleased.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #2758
Cause
When Turn on type definitions (
enableMdbaseSpec) was enabled, changing a multi-part portable setting triggered an immediate canonical type sync inMdbaseSpecService:taskIdentificationMethod,taskPropertyName,taskPropertyValue,taskTag): Switching Identify tasks by from Tag to Property whiletaskPropertyNamewas still empty (or clearingtaskPropertyName/taskTagmid-edit) caused@tasknotes/model'sbuildMatch()to fall back to tag matching (tags.contains: task).writeCanonicalTypeSnapshot()wrote that fallback to_mdbase/types/task.mdand immediately read it back throughapplyCanonicalState(), overwritingplugin.settings.taskIdentificationMethodback to"tag"(or snappingtaskTagback to"task"). WhenSettingsContext.write()finished flushing and refreshed the UI, the warning disappeared and the property inputs flipped back to disabled.storeTitleInFilename,taskFilenameFormat,customFilenameTemplate): Selecting"custom"with an emptycustomFilenameTemplate(or clearing the template mid-edit) causedbuildCanonicalMdbaseResources()to throw (A custom TaskNotes filename format requires a template.), clearing canonical sync state and reverting settings on the next edit.applyCanonicalTaskTypeToSettings()unconditionally ranapplyAppSettingsToPluginSettings()even when neithersources.recordnorsources.legacyBindingwas passed, revertinguseBodyTemplate/useOccurrenceBodyTemplatetofalse(when their template path was empty) and snapping a clearedarchiveFolderback to its default whenever any portable setting synced. Re-applying written canonical types on self-write also stripped trailing spaces while typing multi-word values.Changes
hasIncompletePortableSettings()insrc/services/mdbaseCanonicalConfig.tsto detect incomplete multi-part portable settings (property identification without a property name, tag identification without a tag, or custom filename format without a template).MdbaseSpecService.syncSettingsToCanonicalTypeSnapshot()to defer writing canonical types (and avoid creating empty metadata folders or writing fallback/unusable task match rules) while portable settings are incomplete, syncing automatically once the required field is filled in.buildCanonicalSupportResources()so support resource checks do not invokebuildCanonicalMdbaseResources()on incomplete local settings.writeCanonicalTypeSnapshot()from overwriting in-memoryplugin.settingson self-writes, and updatedapplyCanonicalTaskTypeToSettings()to only apply app settings whensources.recordorsources.legacyBindingis present.tests/unit/issues/issue-2758-settings-type-definition-race.test.tsand an Obsidian E2E regression test ine2e/issues/issue-2758-settings-type-definition-race.spec.ts.docs/releases/unreleased.md.Verification
npx jest tests/unit/issues/issue-2758-settings-type-definition-race.test.ts(7/7 failed before the fix, 7/7 pass after)npm run e2e -- e2e/issues/issue-2758-settings-type-definition-race.spec.ts(passed in isolated Obsidian 1.14.2)npm run typecheck(passed)npm run lint(passed)npm run build&npm run check:bundle-size(passed)npm run i18n:verify,npm run test:i18n-source,npm run test:translation-contracts,npm run test:language-packs,npm run conformance:test(all passed)npm test -- --maxWorkers=2(864/865 suites, 6,748 tests passed; 4 unrelatedSafeMetadatafilesystem timeout flakes intests/unit/services/mdbaseMetadataSwap.test.tsunder heavy local host load)