From c195523d4aece7f033140942ed0a3f5cfbaedd80 Mon Sep 17 00:00:00 2001 From: Test Date: Tue, 17 Mar 2026 06:43:46 -0300 Subject: [PATCH] fix: strip parenthetical comments from depends-on values in parseWishGroups `depends-on: 1 (must be done first)` was parsed as dependency on "1 (must be done first)" which doesn't match any group. Now strips `(...)` suffixes from both the none-check and individual dep values. --- src/term-commands/dispatch.test.ts | 9 +++++++++ src/term-commands/dispatch.ts | 11 +++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/src/term-commands/dispatch.test.ts b/src/term-commands/dispatch.test.ts index d19ac4b8b..94450ad3f 100644 --- a/src/term-commands/dispatch.test.ts +++ b/src/term-commands/dispatch.test.ts @@ -550,6 +550,15 @@ describe('parseWishGroups()', () => { const groups = parseWishGroups(SAMPLE_WISH); expect(groups[0].dependsOn).toEqual([]); }); + + it('should strip parenthetical comments from depends-on values', () => { + const content = + '### Group 1: First\n**depends-on:** none (this is the start)\n\n### Group 2: Second\n**depends-on:** 1 (must be done first)\n\n### Group 3: Third\n**depends-on:** Group 1 (setup), Group 2 (core work)'; + const groups = parseWishGroups(content); + expect(groups[0].dependsOn).toEqual([]); + expect(groups[1].dependsOn).toEqual(['1']); + expect(groups[2].dependsOn).toEqual(['1', '2']); + }); }); // ============================================================================ diff --git a/src/term-commands/dispatch.ts b/src/term-commands/dispatch.ts index d61de1bec..2e91208bf 100644 --- a/src/term-commands/dispatch.ts +++ b/src/term-commands/dispatch.ts @@ -162,10 +162,17 @@ export function parseWishGroups(content: string): GroupDefinition[] { let dependsOn: string[] = []; if (depsMatch) { const depsStr = depsMatch[1].trim(); - if (depsStr.toLowerCase() !== 'none') { + const depsNormalized = depsStr.replace(/\s*\([^)]*\)/g, '').trim(); + if (depsNormalized.toLowerCase() !== 'none') { dependsOn = depsStr .split(',') - .map((d) => d.trim().replace(/^group\s*/i, '')) + .map((d) => + d + .trim() + .replace(/^group\s*/i, '') + .replace(/\s*\(.*\)\s*$/, '') + .trim(), + ) .filter(Boolean); } }