Skip to content

Feature Request: Automatically include related files in chat context ("auto add file to chat") #4385

@codingmiao

Description

@codingmiao

💡 Description

Currently, when using the Tabby IntelliJ plugin, the quality of completions in the chat or inline suggestions can drop significantly if not all related files are manually added to the chat context.

For example:

  • I'm editing A.java, which calls foo() from B.java.
  • The method foo() returns a C class defined in C.java.
  • If I only add A.java to the chat, Tabby often hallucinates — such as calling foo() with wrong parameters, or accessing non-existent properties in C.

To avoid this, I have to manually click “Add file to chat” for B.java and C.java.
However, this process is manual and error-prone, especially in large projects where dependencies are not obvious.


🧱 Real-world Use Case

In our Java project, a typical service or logic file depends on multiple model, utility, and helper classes across different packages.
When writing or modifying a method, I often need related files (e.g., Entity, Mapper, DTO) to be included in context for Tabby to generate correct suggestions.

Manually adding all these files to the chat is not practical in a large-scale enterprise project with hundreds of interdependent files.


🚀 Feature Proposal

Add an “auto context expansion” or “smart add related files” mechanism in the IntelliJ plugin (or Tabby server) that automatically includes related files based on usage or imports.

Possible Strategies:

  1. Static analysis
    Parse import statements and symbol references in the current file, and automatically include referenced files or classes in the chat context.

  2. Dependency depth control
    Allow user configuration like:

    autoContext:
      enabled: true
      maxDepth: 2
      includeTests: false

    So the plugin only pulls in files up to a certain depth.

  3. Interactive confirmation
    Optionally show a prompt:

    "Detected dependencies: B.java, C.java — include them in context?"


🧠 Expected Benefits

  • Reduce hallucinations caused by missing context.
  • Improve completion accuracy for cross-file references.
  • Enhance developer experience and reduce manual steps.

📝 Additional Notes

Some LSP-based tools (e.g., Cursor, Continue.dev) already implement “auto include related files” via static dependency scanning or background indexing.
A similar mechanism would make Tabby’s completions much more context-aware without requiring users to manually add files.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions