fix: stop --append-agent-note duplicating @agent-note past body text - #75
Merged
Conversation
…74) Annotation lookup now scans the task's whole body, mirroring the parser's orphaned-annotation merge, instead of only the contiguous block.
| /// which the parser still attributes to this task). | ||
| fn find_annotation_line(&self, key: &str) -> Option<usize> { | ||
| let (start, end) = self.annotation_block_range(); | ||
| let start = self.task_idx + 1; |
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 #74.
Root cause
TaskLines::find_annotation_lineinupdate/mutations.rssearched only the contiguous annotation block directly under the checkbox, stopping at the first non-@line. The parser is more forgiving: an@key:line found after free-text body lines becomes an orphaned annotation and is merged into the most recent task (parse_task_section_internal). So a note below body text belonged to the task in the parsed model, but the editor couldn't see it —--append-agent-noteconcluded the task had no note and fell through to the create path, writing a second@agent-note:under the checkbox. Lint then rejected the file as a duplicate annotation,lash indexskipped it, and later mutations died onE_INDEX_STALE.Fix
find_annotation_linenow scans the task's whole body region — up to the next checkbox line or##heading, the same boundary that ends the parser's orphan merging.continuation_rangehandles the orphaned position with a stricter rule (only lines indented deeper than the annotation), so trailing same-indent body text is never swallowed.append_agent_noteindents the continuation relative to the found annotation line (unchanged result for the normal in-block case).This also fixes the same latent duplicate-insert path in
--agent-note(replace),--owner/--estimate, and@labels:edits.Tests
E_INDEX_STALE).Out of scope
The parser attaches an orphaned annotation as a single line and silently drops its indented continuation lines, so
lash showrenders only the first line of a note in this position. That predates this fix (the repro's original "Second line" was already invisible) and is a lash-core parsing gap worth its own issue.