feat(tui): restore @ file mentions - #493
Merged
Merged
Conversation
Referencing a file with `@path` stopped working when the classic REPL was removed: the parser survived (it still backs `/files` reporting) but nothing completed a mention or expanded one, so `@src/main.rs` reached the model as literal text. - Tab completes `@` tokens to files and directories under the session cwd, gitignore-aware, directories gaining a trailing slash so you can drill in. Completion targets the token under the cursor, so multiple mentions in one prompt each complete independently; non-`@` input still completes slash commands exactly as before. - On submit, each mention's contents are inlined for the model while the transcript keeps the line as typed. Skipped or truncated mentions surface as a note rather than failing the turn. - Paths are confined to the workspace by canonicalizing both sides before comparing, so a symlink cannot escape it; `.git/` and binary files are skipped. Content is capped at 64 KiB per file and 256 KiB per prompt, read through a limited reader so an oversized file is never held whole. - Directories expand to a one-level listing instead of being ignored. The existing mention parser is reused rather than duplicated, and the slash completer's longest-common-prefix helper is now shared by both.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@pathfile mentions regressed out when the classic REPL was removed. The parser survived (it still backs/filesreporting), but nothing completes a mention or expands one — so@src/main.rsreaches the model as literal text. Both peer terminal agents have this; it's table stakes.What works now
@tokens → files and directories under the session cwd, gitignore-aware,.gitnever offered, directories gain a trailing/so you can drill in. Completion targets the token under the cursor, so several mentions in one prompt each complete independently. Non-@input still completes slash commands exactly as before.Limits
@app.logcan't dominate the context window… +N morebeyond thatFiles are read through a limited reader, so an oversized file is never held in memory whole. Binaries are skipped via a NUL sniff plus a UTF-8 decode (a read cut mid-character is trimmed, not misreported as binary).
Security note — worth reviewing closely
The obvious reuse for path confinement,
Permissions::read_scope_allows_path, is unsafe here: it returnstrueunconditionally when no AMR read scope is configured, which is exactly the interactive TUI case. Using it would have provided zero confinement and made@../../etc/passwdreadable.Instead the check canonicalises both sides before prefix-comparing — mirroring the approach of the private
read_scope_allows— so a symlink cannot defeat a lexical check. There are explicit tests for a../escape and for a symlink escape, plus a.git/component reject.Verification
30 new tests, all pure functions over
(cwd, text)so they need no terminal:a@b.comis never a token), multibyte input.gitexclusion,../and/etc/refusal, unknown prefixcargo test,clippy --all-targets -- -D warnings,fmt --check, and a whole-workspacecargo check --all-targetsare all clean.Note
One parser quirk documented in passing: mentions require a
/or.in the token (that's what keeps@aliceand emails safe), so completing an extensionless top-level file emits./Makefileto round-trip through the existing parser.