-
Notifications
You must be signed in to change notification settings - Fork 34
🤖 feat: support @file mentions for instant context #1365
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Change-Id: Iec28d70bf3d49a990a75a5b492a647a58b636a14 Signed-off-by: Thomas Kosiewski <tk@coder.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Change-Id: I1c237ca9fa07767aed0c6b1f6a9013abe98b1528 Signed-off-by: Thomas Kosiewski <tk@coder.com>
|
@codex review Addressed your note about stale @mention suggestions when the caret moves:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
Change-Id: Icd9690bb579fbf55debeddf5417c52972639be4c Signed-off-by: Thomas Kosiewski <tk@coder.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| const pathLooksLikeFilePath = isLikelyFilePathToken(displayPath) || mention.range !== undefined; | ||
|
|
||
| if (mention.rangeError) { | ||
| const block = renderMuxFileError(displayPath, mention.rangeError); | ||
| const blockBytes = Buffer.byteLength(block, "utf8"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Skip range errors for non-file @mentions
With the relaxed matching, tokens like @alice#123 (issue/PR refs or other non-file uses of @...#...) will now hit the rangeError branch and always inject a <mux-file-error> block, even though the token doesn’t look like a file path. That contradicts the “ignore bare @tokens to avoid @user noise” goal and adds irrelevant context that can skew model responses. Consider gating the rangeError emission on pathLooksLikeFilePath (or confirming the file exists) so non-file mentions with # are ignored instead of producing errors.
Useful? React with 👍 / 👎.
Add support for
@filementions in chat input so the model can receive file context automatically.@-triggered file path autocomplete in ChatInput (reuses CommandSuggestions)workspace.getFileCompletionsendpoint backed bygit ls-files -co --exclude-standardwith a short TTL cache@path/@path#Lx-yinto a synthetic user message containing<mux-file>blocksTests:
make static-check📋 Implementation Plan
Plan:
@filementions (@path.ts/@path.ts#L1-30) for instant file contextDoes this idea make sense?
Yes—this is a sensible and common workflow improvement: it lets the model start from the code instead of spending turns calling
file_readfor obvious context.It will “work” as long as we put guardrails around:
..traversal), and handle binary/huge files safely.Recommended implementation: Server-side expansion at request-build time
Net LoC (product code only): ~600–900
Why this approach
chat.jsonl).Non-goals (initial cut)
@src/) beyond autocomplete convenience.Syntax + semantics (spec)
@relative/path/to/file.ts@relative/path/to/file.ts#L1-30@and runs until whitespace.#L<start>-<end>is optional; start/end are positive ints;start <= end.Formatting shown to the model (proposed)
Inject a single synthetic user message immediately before the user’s prompt:
If truncated:
This mirrors existing “system update”/attachment rendering conventions while staying plain-text compatible.
Work breakdown
1) Frontend:
@file-path autocomplete in ChatInputCommandSuggestions) used for slash commands.@...token.@<relativePath>.Touch points (expected):
src/browser/components/ChatInput/index.tsx(detect@token, render suggestions, replace text)src/browser/components/CommandSuggestions.tsx(reuse existing suggestions dropdown)src/browser/utils/atMentions/{parser,suggestions,types}.tsImplementation notes:
2) Backend: file completion API
src/common/orpc/schemas/api.ts(addworkspace.getFileCompletions)src/node/orpc/router.tsunderworkspace: { ... }Add a dedicated endpoint to avoid per-keystroke directory scans:
workspace.getFileCompletions({ workspaceId, query, limit }) -> { paths: string[] }git ls-files(and optionally--others --exclude-standard) in the workspace root..git/indexmtime) to keep typing responsive.3) Backend: expand
@filementions into model-visible contextsrc/node/services/aiService.tsafterworkspacePathis computed (runtime created) and before provider conversion.readFileString()/execBuffered()fromsrc/node/utils/runtime/helpers.tssrc/node/services/tools/fileCommon.ts(same checks used byfile_read)Hook into the request-building pipeline (in-memory only):
@...references.Error handling (self-healing):
<mux-file-error ...>block (don’t throw).4) (Optional but recommended) UI transparency
src/foo.ts (L1–30)”Testing plan
@...token + replacement logic.@file.ts#L1-3, confirm the produced model messages include the injected<mux-file ...>block in the right order.Rollout / safety
Why not use the poll-based notification system?
Mux’s poll-based notifications are currently designed to run after tool calls and only receive limited context (tool name/success/timestamp). They’re great for model-only reminders, but not a natural fit for user-authored
@filereferences.Doing expansion in the request-building pipeline is simpler, more explicit, and avoids extending the notification context contract.
Generated with
mux• Model:openai:gpt-5.2• Thinking:xhigh