Skip to content

Fix register_attachment calling handler.get individually preventing pattern precedence #196

@JeanMertz

Description

@JeanMertz

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:

  1. Call handler.add() for all patterns first
  2. Call handler.get() only once after all patterns have been added

This could be achieved by either:

  • Modifying register_attachment to 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions