Skip to content

TUI: support @file mentions in the input bar to attach files/dirs to the next message #28

Description

@Hmbown

Motivation

Recent session pain: user knew exactly which file they wanted in context (`docs/DeepSeek_V4.pdf`) but had to describe it and let the agent search. Standard practice in Claude Code, Cursor, Codex CLI, opencode is `@` autocomplete in the input — type `@`, get a fuzzy file picker, hit enter, the file's path (and optionally contents) are attached to the next user message.

Behavior

  • Typing `@` in the input bar pops a fuzzy file picker rooted at the workspace.
  • Selection inserts the relative path as e.g. `@docs/DeepSeek_V4.pdf` into the input text (visible to the user).
  • On submit, the harness expands each mention into either:
    • Path-only mode (default): appends a "# Attached files" block listing the absolute paths so the model can choose to read them.
    • Inline mode (when small): auto-includes the file contents up to a per-file budget (~10K tokens). PDFs use `pdftotext` if available, else fall back to path-only with a note.
  • `@` followed by a directory inserts the dir; on expand we attach a one-level tree listing.
  • Multiple `@` mentions in one message all expand.

Implementation pointers

  • Input bar lives in `crates/tui/src/tui/app.rs` / the input handling code there.
  • Expansion happens in the message-submit path — find where `Op::SendUserMessage` (or equivalent) is built before sending to the engine.
  • Fuzzy matcher: there's already `utils::project_tree` (used in `prompts.rs:54`); pair with `fuzzy-matcher` crate for picker.
  • For PDF: shell out to `pdftotext` if on PATH; otherwise attach "<binary file: $PATH>".

Out of scope

  • Auto-attaching by detecting bare paths in plain text. Only `@`-prefixed mentions get expanded.
  • Image attachment / VLM (separate feature; can build on top later).

Acceptance criteria

  • Typing `@` opens picker; arrow keys + enter select; esc cancels.
  • Picker is fast in repos with >10k files (debounced search, capped result list).
  • Submitted message visibly contains `@` so the user can see what was attached.
  • Tab-completion works on partial paths.

Target

v0.5.1 (basic path-only) — inline expansion can slip to v0.5.2.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions