Skip to content

feat(tui): @-mention files in the composer with autocomplete (ATO-665) - #1428

Merged
sosidudku1 merged 1 commit into
mainfrom
feat/ato-665-at-mentions
Nov 17, 2026
Merged

sosidudku1 merged 1 commit into
mainfrom
feat/ato-665-at-mentions

Conversation

@sosidudku1

Copy link
Copy Markdown
Collaborator

What

@-mention files in the TUI composer, with autocomplete.

  • Typing @ (at the start of the buffer or after a space) opens a palette of the working directory's files above the composer, filtered with fuzzysort. Up/Down move, Tab, Enter or Right complete the highlighted path, Esc closes it until the buffer changes. Clicks follow the usual list rule (first selects, second completes).
  • File list (src/tui/file-mentions/file-index.ts): git ls-files --cached --others --exclude-standard inside a repository (so .gitignore is respected), otherwise a breadth-first walk that skips node_modules, .git, build and cache folders. Capped at 20k paths and a 200 ms walk budget; one cached list per folder, refreshed in the background after 15 s. Paths containing whitespace are left out, since a mention ends at whitespace.
  • On an idle submit (submit-handler.ts), each @path that resolves to a real file inside the working directory is inlined after the typed text in a <mentioned-files> block (same placement as the channels' [attachments] block). Caps: 32 KB per file, 96 KB and 8 files per message. A cut file says so in the message ([truncated: showing the first 32 KB of 195 KB; read the file itself for the rest]); a binary file or one over the message budget is listed but not inlined.
  • Security: nothing outside the working directory is read. The check runs on the written path (@../x, @/etc/passwd) and again on the real path, so a symlink inside the folder that points out of it is refused. Unresolved @words (@team, a folder, a missing file) stay plain text.
  • Display: the user bubble folds the block to one line per file, and its height estimate measures the folded form. Up-arrow history recalls only the typed text. The message itself keeps the full block, so [try again] and rollback still match the stored prompt.

Why

ATO-665. The TUI had no way to put a file in context: prompt-shell.tsx deferred @file for opencode parity, and the only route was asking the agent to read a path itself.

Not covered here:

  • Steered and queued messages (sent while a turn runs) are not expanded: those are matched back to their pending strip entry by text, so their @path reaches the model as words it can read with its own tools.
  • The palette follows the token at the end of the buffer (the app shell does not see the editor caret), so editing a mention in the middle of a longer buffer does not open it.
  • The caps (32 KB / 96 KB / 8 files, 20k paths) are first guesses, open to tuning.
  • Desktop composer is a separate PR.

Tests

Added (not run on this machine):

  • src/tui/file-mentions/mention-query.test.ts: finding and completing the trailing @ token, email addresses ignored.
  • src/tui/file-mentions/mention-block.test.ts: block format, truncation and skip notes, split/collapse round trip, history text.
  • src/tui/file-mentions/expand-mentions.test.ts: inlining, unresolved words left alone, trailing punctuation, paths outside the folder and an escaping symlink refused, per-file cut, binary file, message budget, file cap.
  • src/tui/file-mentions/file-index.test.ts: walk skips dependency folders, file cap, time budget; index cache, background refresh, whitespace filter, failed listing.
  • src/tui/file-mentions/rank-mention-files.test.ts: empty-query ordering, fuzzy match, result cap.
  • src/tui/file-mentions/file-mention-palette.test.tsx: loading, no match, rows, windowing.
  • src/tui/file-mentions/mention-display.test.tsx: folded bubble, height estimate, transcript vs history.
  • src/tui/submit-handler.test.ts: idle submit sends the expanded text, falls back when unwired, slash commands untouched.

Not yet checked on the second Mac.

Typing @ in the composer now opens a palette of the working directory's
files, filtered with fuzzysort. Up/Down move, Tab/Enter/Right complete,
Esc closes. The list comes from git ls-files (respects .gitignore) or a
bounded walk outside a repository, capped at 20k paths and a 200 ms walk
budget, cached per folder and refreshed in the background.

On an idle submit every @path that is a real file inside the working
directory is inlined under the message in a <mentioned-files> block,
capped at 32 KB per file and 96 KB / 8 files per message, with the cut
stated in the message. Paths outside the folder are never read (checked
on the written path and again after symlinks); unresolved @words stay
plain text. The chat bubble folds the block to one line per file and
input history recalls only the typed text, while the transcript keeps
the full message so retry and rollback still match the stored prompt.

Until now the TUI had no way to put a file in context: the composer
deferred @file for opencode parity and the only route was asking the
agent to read the path itself.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant