fix: support dash prefix in parseMarkdownChecklist for todo lists#8055
Merged
fix: support dash prefix in parseMarkdownChecklist for todo lists#8055
Conversation
- Updated regex pattern to support optional dash prefix (e.g., "- [ ] Task") - Added comprehensive test coverage for both formats - Fixes issue where todo lists with dash prefixes were not being parsed correctly Fixes #8054
| for (const line of lines) { | ||
| const match = line.match(/^\[\s*([ xX\-~])\s*\]\s+(.+)$/) | ||
| // Support both "[ ] Task" and "- [ ] Task" formats | ||
| const match = line.match(/^(?:-\s*)?\[\s*([ xX\-~])\s*\]\s+(.+)$/) |
Contributor
Author
There was a problem hiding this comment.
The regex pattern (?:-\s*)? elegantly makes the dash prefix optional while maintaining backward compatibility. This is a clean solution that addresses the issue without overcomplicating the implementation.
| const md2 = `- [ ] Task 1` | ||
| const result1 = parseMarkdownChecklist(md1) | ||
| const result2 = parseMarkdownChecklist(md2) | ||
| expect(result1[0].id).toBe(result2[0].id) |
Contributor
Author
There was a problem hiding this comment.
Excellent test coverage! The 21 test cases thoroughly validate both formats (with and without dash prefix) and cover important edge cases. The ID generation consistency tests at lines 235-240 are particularly valuable for ensuring the same todo item generates the same ID regardless of format.
Contributor
|
It has been tested and works as expected |
mrubens
approved these changes
Sep 20, 2025
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.
Description
This PR fixes issue #8054 where the
parseMarkdownChecklistmethod doesn't support checklists with the '-' prefix (e.g.,- [ ] Task), even though markdown supports this syntax.Problem
When users activate the to-do feature, some models (particularly those with poor instruction-following capabilities) may return a to-do list with a dash prefix:
Previously, this would result in an empty todo list being displayed.
Solution
Updated the regex pattern in
parseMarkdownChecklistto support an optional dash prefix:/^\[\s*([ xX\-~])\s*\]\s+(.+)$//^(?:-\s*)?\[\s*([ xX\-~])\s*\]\s+(.+)$/The
(?:-\s*)?pattern makes the dash prefix optional, supporting both formats while maintaining backward compatibility.Testing
Related Issue
Fixes #8054
Type of Change
Checklist
Important
Updated
parseMarkdownChecklistto support dash-prefixed checklists and added comprehensive tests for various formats and edge cases.parseMarkdownChecklistinupdateTodoListTool.tsto support dash-prefixed checklists by changing regex from/^\[\s*([ xX\-~])\s*\]\s+(.+)$/to/^(?:-\s*)?\[\s*([ xX\-~])\s*\]\s+(.+)$/.updateTodoListTool.spec.tscovering standard, dash-prefixed, mixed formats, and edge cases.This description was created by
for 31bbe9d. You can customize this summary. It will automatically update as commits are pushed.