fix(bases-filter-defaults): extract property from generated conjunction + map filter (closes #2043)#2055
Open
ther12k wants to merge 1 commit into
Open
Conversation
…on + map filter (closes callumalpass#2043) The default-relationships Subtasks filter generated by formatProjectEntryLinkExpression in defaultBasesFiles.ts emits: file.hasLink(this.file) && list(note.PROP).map(<link-normalizer>).asLink()).contains(this.file.asLink()) The currentFileContainsMatch regex captures the entire conjunction as the property expression. normalizeFilterProperty then sees: file.hasLink(this.file) && list(note.projects).map(...).asLink()) which fails every check (no leading 'list(' since the string starts with 'file.hasLink', no trailing match for the core field set, etc.) and returns null. Net effect: clicking the column '+' button on the default Subtasks tab creates a task with no 'projects' field, which then fails the view filter and disappears. Fix: strip the &&-joined left side and the generated .map(...) wrapper (balanced-paren walk, since .asLink() lives inside the .map argument) before the existing list()/note-prefix recognition runs. Tests: - 3 new regression tests in basesFilterDefaults.test.ts covering the generated core-field case, the user-defined-field case, and the missing-current-file-link fallback. - All 6/6 tests in basesFilterDefaults.test.ts pass. - All 13/13 tests across kanbanCreationDefaults, basesTaskCreation, KanbanView.manualOrderFastPath, and basesCreateFileForView pass. Refs: callumalpass#2043, callumalpass#1657, callumalpass#1902.
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 #2043.
Root cause
The default-relationships Subtasks filter generated by
formatProjectEntryLinkExpressioninsrc/templates/defaultBasesFiles.tsemits a normalized expression like:currentFileContainsMatchinsrc/bases/basesFilterDefaults.tsmatches the entire conjunction as the property expression.normalizeFilterPropertythen sees:The leading
list(regex doesn't match (string starts withfile.hasLink), the generated.map(...)wrapper prevents recognition, andnote./task.prefix stripping leaves a complex expression that doesn't match any core/user field — sonormalizeFilterPropertyreturnsnulland noprojectsdefault is applied. Net effect: the task is created without aprojectsfield, fails the view filter, and vanishes from the Subtasks widget.Fix
In
normalizeFilterProperty, before the existinglist(...)/note./task.recognition runs:&&, keep only the right-hand operand (strips thefile.hasLink(this.file) &&left side)..map(...), strip it (balanced-paren walk, since.asLink()lives inside the.mapargument, not after it).After these two steps, the existing logic cleanly extracts
projects(or any other core/user field) from the normalized list/map expression.Tests
tests/unit/bases/basesFilterDefaults.test.ts:projectsfield extracted from the generated conjunction + map filtercustomFieldextracted from the generated conjunction + map filterbasesFilterDefaults.test.tspass.kanbanCreationDefaults,basesTaskCreation,KanbanView.manualOrderFastPath, andbasesCreateFileForViewpass — no regressions in adjacent code paths.Scope
Scoped to #2043 only. Independent from #2051 (#2046, NLP autofocus), #2052 (#2045, Basic Information user fields), and #2053 (#2040, Google Calendar sync queue).
Refs #2043, #1657, #1902.