Skip to content

fix(bases-filter-defaults): extract property from generated conjunction + map filter (closes #2043)#2055

Open
ther12k wants to merge 1 commit into
callumalpass:mainfrom
ther12k:fix/issue-2043-subtasks-default-project
Open

fix(bases-filter-defaults): extract property from generated conjunction + map filter (closes #2043)#2055
ther12k wants to merge 1 commit into
callumalpass:mainfrom
ther12k:fix/issue-2043-subtasks-default-project

Conversation

@ther12k

@ther12k ther12k commented Jun 21, 2026

Copy link
Copy Markdown

Fixes #2043.

Root cause
The default-relationships Subtasks filter generated by formatProjectEntryLinkExpression in src/templates/defaultBasesFiles.ts emits a normalized expression like:

file.hasLink(this.file) && list(note.projects).map(file(value.replace(/^\[[^\]]+\]\((.*)\)$/, "$1").replace(/%20/g, " ")).asLink()).contains(this.file.asLink())

currentFileContainsMatch in src/bases/basesFilterDefaults.ts matches the entire conjunction as the property expression. normalizeFilterProperty then sees:

file.hasLink(this.file) && list(note.projects).map(file(value.replace(/^\[[^\]]+\]\((.*)\)$/, "$1").replace(/%20/g, " ")).asLink())

The leading list( regex doesn't match (string starts with file.hasLink), the generated .map(...) wrapper prevents recognition, and note./task. prefix stripping leaves a complex expression that doesn't match any core/user field — so normalizeFilterProperty returns null and no projects default is applied. Net effect: the task is created without a projects field, fails the view filter, and vanishes from the Subtasks widget.

Fix
In normalizeFilterProperty, before the existing list(...) / note. / task. recognition runs:

  1. If the expression contains &&, keep only the right-hand operand (strips the file.hasLink(this.file) && left side).
  2. If the expression contains a trailing .map(...), strip it (balanced-paren walk, since .asLink() lives inside the .map argument, 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

  • 3 new regression tests in tests/unit/bases/basesFilterDefaults.test.ts:
    1. core projects field extracted from the generated conjunction + map filter
    2. user-defined customField extracted from the generated conjunction + map filter
    3. graceful fallback (empty defaults) when no current file link is available
  • All 6/6 tests in basesFilterDefaults.test.ts pass.
  • All 13/13 tests across kanbanCreationDefaults, basesTaskCreation, KanbanView.manualOrderFastPath, and basesCreateFileForView pass — 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.

…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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Default Subtasks "+" button does not assign current project (generated filter not parsed by filter-defaults)

1 participant