Fix `register_attachment` calling `handler.get` individually preventing pattern precedence
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16
- Forks
- 3
- Avg merge
- 1d 1h
- Merged PRs (30d)
- 121
Description
The register_attachment function calls handler.get individually for each added pattern, which prevents later patterns from overriding earlier patterns and breaks gitignore-style pattern precedence.
Expected Behavior
Pattern precedence should work correctly so that later patterns can override earlier ones. For example:
- First pattern:
foo/(exclude all foo directories) - Second pattern:
!foo/bar.txt(include this specific file)
The second pattern should override the first for the specific file, allowing foo/bar.txt to be included even though foo/ is excluded.
Actual Behavior
The current register_attachment function calls handler.add(uri) followed immediately by handler.get() for each URI individually:
handler.add(uri).await?;
attachments.extend(handler.get(&ctx.workspace.root, ctx.mcp_client.clone()).await?);
This means each pattern is processed in isolation, and later patterns cannot override the effects of earlier patterns because handler.get is called before the next pattern is added.
Proposed Solution
Modify the attachment registration process to:
- Call
handler.add()for all patterns first - Call
handler.get()only once after all patterns have been added
This could be achieved by either:
- Modifying
register_attachmentto accept multiple URIs and batch process them - Or creating a new batch registration function that handles multiple attachments at once
- Or modifying the calling code to collect all URIs and call a batch registration function
Resources
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in crates/jp_cli/src/cmd/attachment.rs:81-106 and inspect register_attachment and its handler.add/handler.get calls. Check the calling path in crates/jp_cli/src/cmd/query.rs:404-406. Done means all patterns are added before one retrieval, allowing later patterns to override earlier ones as in the foo/ and !foo/bar.txt example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100