Repository navigation
feat(tui): @ mentions attach workspace files client-side with ranges, dirs, globs, @diff/@sha, and completion (T12) - #45
Merged
Conversation
… dirs, globs, @diff/@sha, and completion (T12) The grammar (qq_protocol::parse_mentions) is pure and shared by the TUI and qq run: @path[:line[-line]], @web:URL, @diff[:REF], @sha:REF, @skill:name; recognised at message start or after whitespace/(/[, ended by whitespace/)/]/,/;, trailing .:?! excluded, @@ literal, code fences skipped, unresolvable paths left literal so emails and decorators are never eaten. qq_core::mentions resolves a parsed prompt off the executor through the same cap-std containment and ignore-aware walk the tools use: a file becomes InputPart::WorkspaceFile with expected_hash filled at compose time (SHA-256 of the current bytes) and an optional range; a directory or glob expands to <= 8 attachments or refuses with "narrow the directory"; @diff/@sha attach bounded git output (64 / 16 KiB) as text from the user's own tree; @web becomes text asking the model to fetch so network authority passes server policy; @skill:name at the start becomes /name. complete_paths ranks an ignore-aware walk by prefix, substring, subsequence, and recency of the session's edits, under a 150 ms deadline. Protocol: InputPart::WorkspaceFile gains range: Option<LineRange> (additive; the runtime attaches only those lines but hashes and records the whole file, so an edit needs no re-read); InputError::InvalidRange. The attachment renders <attached-file path=… lines="a-b/total">. TUI: the composer exposes the @ token at the cursor; typing on one requests candidates (Effect::CompleteMention, spawn_blocking) shown in the slash-menu box; Tab/Enter accept (a directory keeps completing), Esc closes. A prompt with mentions submits through Effect::ResolveMentions and comes back as parts; a failure returns the text to the composer. Steering goes through the same path. qq run resolves mentions in the prompt and reports notes on stderr. A client without a workspace tree (TuiOptions.workspace_root None) leaves @ literal. qq-tui now depends on qq-core for the walk.
lg2m
force-pushed
the
feat/tool-layer-t12-mentions
branch
from
September 15, 2026 21:45
198990a to
1dbff75
Compare
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.
T12:
@mentions — attach workspace files client-side, with ranges, directories, globs,@diff/@sha, and completionSpec: docs/plans/tool-layer.md § D8 Linear: ENG-778 Follows: v0.1.0
What changed
User-visible
@pathattaches a workspace file to the prompt asInputPart::WorkspaceFilewithexpected_hashfilled at compose time — so a stale attachment fails the run before the model sees it, exactly as the protocol always promised but no client did.@path:12-40attaches only those lines (rendered<attached-file path=… lines="12-40/230">); the runtime still hashes and records the whole file, soedit_fileon it needs no re-read.@dir/and@globexpand through the same ignore-aware walk the tools use to ≤ 8 attachments; more refuses with "narrow the directory". Generated dirs, hidden files, binaries, and > 256 KiB files are skipped.@diff,@diff:REF,@sha:REFattach boundedgitoutput (64 / 16 KiB) as text — the user's own tree, no policy hop.@web:URLbecomes text asking the model tofetch(network authority stays with server policy).@skill:nameat message start rewrites to/name.@decorators,@@, and anything inside code fences are left literal and noted; the grammar never eats a word.@token opens afilesbox (same chrome as the slash menu) ranked by prefix, substring, subsequence, shorter-path, with the session's recently edited files first. Tab/Enter accept; a directory keeps completing one level down; Esc closes.qq runtoo: mentions in the prompt resolve, notes go to stderr.Design
qq-protocol(parse_mentions), so the browser client can share it; wasm build verified.qq-core::mentions(newpubmodule) reusingWorkspacecontainment,IgnoreStack,list_children, andPathFilterfrom the search walker.qq-tuigains aqq-coredependency for this — the plan's "reuses thesearchmachinery" is not satisfiable from the TUI otherwise, andxtaskalready has the edge.Effects keepApppure:ResolveMentions(PendingSubmit)andCompleteMention { query, recent }run inspawn_blockingfrom the loop and call back intoApp. Stale completion replies are dropped by query. Plain prompts never pay the hop (a cheap parse decides).TuiOptions.workspace_root: Option<PathBuf>—qqpasses its canonical cwd; a remote client without the tree leaves@literal.InputPart::WorkspaceFile.range: Option<LineRange { start, end }>additive withskip_serializing_if;InputError::InvalidRange. NoPROTOCOL_VERSIONbump — a v20 server ignores nothing (the field isdefault) and a v20 client never sends it unless the user types a range; I'd bump at the next release boundary as with T6.How verified
cargo test --workspace: 1416 passed / 0 failed; fmt,clippy -D warningsclean;cargo build -p qq-client --target wasm32-unknown-unknown --features wasmok.git initfor@diff/@sha(5), runtime range slicing (1), TUI composer/popup/submit/no-root (4), headless end-to-end asserting the sliced attachment, stderr note, and transcript placeholder (1).Measurements
rendersessions_200_with_sidebar_framekeystroke_to_frame@token check is onerfind)Evidence:
target/qq-perf/t12-2026-09-14/.Docs
docs/design/tools.md§ File References In Prompts rewritten (grammar, resolution, completion);docs/design/protocol.mdworkspace_filerow; ledger receipt.Compatibility
WorkspaceFileparts as@pathplaceholders onSteerRunand directqq ask(it resolves them only onSubmitPrompt). The TUI now emits file parts on steer, so a steered@filereaches the model as a placeholder until the server side is extended — recorded as open in the ledger.Follow-ups