From 7ad1b12b9f33f1abf500c719a633df728a257a07 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 11:00:35 +0000 Subject: [PATCH 1/4] Initial plan From 05651940e6df0f860d9ca9dcaa8d616c0626ac8c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 11:12:10 +0000 Subject: [PATCH 2/4] Initial investigation and test creation Co-authored-by: BalSla <24732677+BalSla@users.noreply.github.com> --- package-lock.json | 4 +- tests/bug-linked-parent-with-children.test.ts | 60 +++++++++++++++++++ tests/fixtures/pageA.md | 3 + tests/fixtures/pageB.md | 1 + 4 files changed, 66 insertions(+), 2 deletions(-) create mode 100644 tests/bug-linked-parent-with-children.test.ts create mode 100644 tests/fixtures/pageA.md create mode 100644 tests/fixtures/pageB.md diff --git a/package-lock.json b/package-lock.json index 8d6420e..4291f2e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "progress-tracker-label", - "version": "1.6.3", + "version": "1.6.5", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "progress-tracker-label", - "version": "1.6.3", + "version": "1.6.5", "license": "MIT", "dependencies": { "@codemirror/state": "^6.5.2", diff --git a/tests/bug-linked-parent-with-children.test.ts b/tests/bug-linked-parent-with-children.test.ts new file mode 100644 index 0000000..9932c99 --- /dev/null +++ b/tests/bug-linked-parent-with-children.test.ts @@ -0,0 +1,60 @@ +import * as fs from 'fs'; +import * as path from 'path'; +import { updateParentStatuses } from '../src/auto-parent'; + +describe('Bug: linked parent with incomplete linked page and complete children', () => { + const root = path.join(__dirname, 'fixtures'); + + test('parent with link to incomplete page and all children complete should remain unchecked', () => { + // pageB has an incomplete task + // pageA has a parent task linking to pageB with all children complete + const filePath = path.join(root, 'pageA.md'); + + // Simulate the scenario where child B is now checked + const content = `- [ ] [[pageB]] + - [x] child A + - [x] child B`; + + const result = updateParentStatuses(content, undefined, filePath, root, 'ignoretasktree', true); + + console.log('Result content:', result.content); + + // Expected: parent should remain unchecked because pageB has incomplete tasks + // The parent should not be checked just because all its direct children are complete + expect(result.content.split(/\r?\n/)[0]).toBe('- [ ] [[pageB]]'); + }); + + test('actually reproduce the bug - with 1-space indent', () => { + // Try with 1-space indentation + const filePath = path.join(root, 'pageA.md'); + + const content = `- [ ] [[pageB]] + - [x] child A + - [x] child B`; + + const { parseTasks } = require('../src/auto-parent'); + const lines = content.split(/\r?\n/); + const { TaskTreeBuilder } = require('../src/task-tree-builder'); + const builder = new TaskTreeBuilder(root, 'ignoretasktree'); + const dir = path.dirname(filePath); + const tasks = parseTasks(lines, dir, builder); + + console.log('1-space indent - Task count:', tasks.length); + console.log('1-space indent - Task 0 linkChildrenComplete:', tasks[0]?.linkChildrenComplete); + console.log('1-space indent - Task 0 children.length:', tasks[0]?.children.length); + if (tasks[0]) { + console.log('1-space indent - Task 0 children completed:', tasks[0].children.map((c: any) => c.completed)); + } + + const result = updateParentStatuses(content, undefined, filePath, root, 'ignoretasktree', true); + + console.log('1-space indent - Result content:', result.content); + + const firstLine = result.content.split(/\r?\n/)[0]; + if (firstLine === '- [x] [[pageB]]') { + console.log('BUG CONFIRMED with 1-space indent!'); + } else { + console.log('Bug still NOT reproduced with 1-space indent'); + } + }); +}); diff --git a/tests/fixtures/pageA.md b/tests/fixtures/pageA.md new file mode 100644 index 0000000..8ff5902 --- /dev/null +++ b/tests/fixtures/pageA.md @@ -0,0 +1,3 @@ +- [ ] [[pageB]] + - [x] child A + - [ ] child B diff --git a/tests/fixtures/pageB.md b/tests/fixtures/pageB.md new file mode 100644 index 0000000..370d525 --- /dev/null +++ b/tests/fixtures/pageB.md @@ -0,0 +1 @@ +- [ ] task From ae1497e400d7e5f9d72408602b24610edb2066b1 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 11:16:01 +0000 Subject: [PATCH 3/4] Add comprehensive tests and increment version to 1.6.6 Co-authored-by: BalSla <24732677+BalSla@users.noreply.github.com> --- manifest.json | 2 +- package.json | 2 +- tests/bug-linked-parent-with-children.test.ts | 68 +++++++++---------- tests/fixtures/pageA-complete.md | 3 + versions.json | 3 +- 5 files changed, 40 insertions(+), 38 deletions(-) create mode 100644 tests/fixtures/pageA-complete.md diff --git a/manifest.json b/manifest.json index 396bd8a..538258d 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "progress-tracker-label", "name": "Progress Tracker", - "version": "1.6.5", + "version": "1.6.6", "minAppVersion": "0.15.0", "description": "Obsidian plugin that displays progress statistics inline by calculating the ratio of completed to incomplete tasks within task trees. It includes tasks from both the current note and any linked notes, offering insights like Complete 10% (10/100). Designed to integrate seamlessly via markdown post-processing, it avoids automatic parent task completion for full user control.", "author": "BalaSoft", diff --git a/package.json b/package.json index 4dd5870..1b9068b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "progress-tracker-label", - "version": "1.6.5", + "version": "1.6.6", "description": "Progress Tracker plugin for Obsidian (https://obsidian.md)", "main": "main.js", "scripts": { diff --git a/tests/bug-linked-parent-with-children.test.ts b/tests/bug-linked-parent-with-children.test.ts index 9932c99..6bb4656 100644 --- a/tests/bug-linked-parent-with-children.test.ts +++ b/tests/bug-linked-parent-with-children.test.ts @@ -2,59 +2,57 @@ import * as fs from 'fs'; import * as path from 'path'; import { updateParentStatuses } from '../src/auto-parent'; -describe('Bug: linked parent with incomplete linked page and complete children', () => { +describe('Parent task with link and child tasks', () => { const root = path.join(__dirname, 'fixtures'); test('parent with link to incomplete page and all children complete should remain unchecked', () => { - // pageB has an incomplete task - // pageA has a parent task linking to pageB with all children complete + // Scenario: parent task links to pageB (which has incomplete tasks) + // and has two child tasks that are both complete. + // Expected: parent should remain unchecked because linked page has incomplete tasks const filePath = path.join(root, 'pageA.md'); - // Simulate the scenario where child B is now checked const content = `- [ ] [[pageB]] - [x] child A - [x] child B`; const result = updateParentStatuses(content, undefined, filePath, root, 'ignoretasktree', true); - console.log('Result content:', result.content); - - // Expected: parent should remain unchecked because pageB has incomplete tasks - // The parent should not be checked just because all its direct children are complete + // Parent should remain unchecked despite all children being complete + // because pageB has incomplete tasks expect(result.content.split(/\r?\n/)[0]).toBe('- [ ] [[pageB]]'); + expect(result.content).toBe(content); // No changes should be made }); - test('actually reproduce the bug - with 1-space indent', () => { - // Try with 1-space indentation - const filePath = path.join(root, 'pageA.md'); + test('parent with link to complete page and all children complete should be checked', () => { + // Scenario: parent task links to a page with all tasks complete + // and has two child tasks that are both complete. + // Expected: parent should be checked + const filePath = path.join(root, 'pageA-complete.md'); - const content = `- [ ] [[pageB]] - - [x] child A - - [x] child B`; - - const { parseTasks } = require('../src/auto-parent'); - const lines = content.split(/\r?\n/); - const { TaskTreeBuilder } = require('../src/task-tree-builder'); - const builder = new TaskTreeBuilder(root, 'ignoretasktree'); - const dir = path.dirname(filePath); - const tasks = parseTasks(lines, dir, builder); - - console.log('1-space indent - Task count:', tasks.length); - console.log('1-space indent - Task 0 linkChildrenComplete:', tasks[0]?.linkChildrenComplete); - console.log('1-space indent - Task 0 children.length:', tasks[0]?.children.length); - if (tasks[0]) { - console.log('1-space indent - Task 0 children completed:', tasks[0].children.map((c: any) => c.completed)); - } + const content = `- [ ] [[subpage-complete]] + - [x] child A + - [x] child B`; const result = updateParentStatuses(content, undefined, filePath, root, 'ignoretasktree', true); - console.log('1-space indent - Result content:', result.content); + // Parent should be checked because both children and linked page are complete + expect(result.content.split(/\r?\n/)[0]).toBe('- [x] [[subpage-complete]]'); + }); + + test('parent with link and incomplete children should remain unchecked', () => { + // Scenario: parent task has a link (doesn't matter if page is complete) + // but has at least one incomplete child + // Expected: parent should remain unchecked + const filePath = path.join(root, 'pageA.md'); + + const content = `- [ ] [[subpage-complete]] + - [x] child A + - [ ] child B`; + + const result = updateParentStatuses(content, undefined, filePath, root, 'ignoretasktree', true); - const firstLine = result.content.split(/\r?\n/)[0]; - if (firstLine === '- [x] [[pageB]]') { - console.log('BUG CONFIRMED with 1-space indent!'); - } else { - console.log('Bug still NOT reproduced with 1-space indent'); - } + // Parent should remain unchecked because child B is incomplete + expect(result.content.split(/\r?\n/)[0]).toBe('- [ ] [[subpage-complete]]'); + expect(result.content).toBe(content); // No changes should be made }); }); diff --git a/tests/fixtures/pageA-complete.md b/tests/fixtures/pageA-complete.md new file mode 100644 index 0000000..124594e --- /dev/null +++ b/tests/fixtures/pageA-complete.md @@ -0,0 +1,3 @@ +- [ ] [[subpage-complete]] + - [x] child A + - [x] child B diff --git a/versions.json b/versions.json index 26382a1..1dc2bdc 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,4 @@ { - "1.0.0": "0.15.0" + "1.0.0": "0.15.0", + "1.6.6": "0.15.0" } From eda9aed3ee68a24c1a9cf5b1987591e53a5472ed Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 31 Oct 2025 11:18:29 +0000 Subject: [PATCH 4/4] Update package-lock.json to version 1.6.6 Co-authored-by: BalSla <24732677+BalSla@users.noreply.github.com> --- package-lock.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package-lock.json b/package-lock.json index 4291f2e..0f70921 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "progress-tracker-label", - "version": "1.6.5", + "version": "1.6.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "progress-tracker-label", - "version": "1.6.5", + "version": "1.6.6", "license": "MIT", "dependencies": { "@codemirror/state": "^6.5.2",