Skip to content

agent_ui: Make file mention chips clickable to open files#46751

Merged
bennetbo merged 2 commits intozed-industries:mainfrom
soyllamas:main
Mar 3, 2026
Merged

agent_ui: Make file mention chips clickable to open files#46751
bennetbo merged 2 commits intozed-industries:mainfrom
soyllamas:main

Conversation

@soyllamas
Copy link
Copy Markdown
Contributor

@soyllamas soyllamas commented Jan 13, 2026

Summary

Makes file mention chips in the AI chat input clickable to open the referenced files. Previously, chips like @README.md were purely visual indicators with no interaction.

Changes

  • Clickable mention chips: Users can now click on file mentions in the chat input to open those files in the editor
  • Support for all mention types:
    • Files → Opens in editor
    • Files with line numbers → Opens and scrolls to line
    • Directories → Reveals in project panel
    • Threads → Navigates to thread
    • Rules → Opens rules library
    • URLs → Opens in browser
  • Handles files outside workspace: Falls back to open_abs_path() for files not in the current workspace

Implementation

Threads MentionUri and WeakEntity<Workspace> through the crease rendering pipeline:

  1. Updated insert_crease_for_mention() to accept mention URI and workspace references
  2. Added click handler to MentionCrease component using .when() for conditional attachment
  3. Implemented file opening helpers that mirror the existing thread_view.rs::open_link() logic

Demo

Open.file.from.reference.mp4

Testing

Manually tested:

  • Clicking @README.md opens file
  • Clicking file with line numbers navigates correctly
  • Clicking directory reveals in project panel
  • Files outside workspace open via absolute path

Files Changed

  • crates/agent_ui/src/mention_set.rs - Thread URI/workspace through pipeline
  • crates/agent_ui/src/ui/mention_crease.rs - Add click handler and file opening logic
  • crates/agent_ui/src/acp/message_editor.rs - Update call sites

Review feedback addressed

  • Replaced .when() + unwrap() with .when_some() + Option::zip() (0e36efb4eb)
  • De-duplicated open_file and open_file_at_line into a single function with Option<RangeInclusive<u32>> (dbcbb69a4b)
  • Rebased onto latest main and resolved conflicts

Also update item 2 under Implementation from:
Added click handler to MentionCrease component using .when() for conditional attachment

to:
Added click handler to MentionCrease component using .when_some() with Option::zip() for conditional attachment

Release Notes:

  • Agent: File mention chips in the chat input are now clickable and will open the referenced files in the editor.

Closes #46746

@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Jan 13, 2026

We require contributors to sign our Contributor License Agreement, and we don't have @soyllamas on file. You can sign our CLA at https://zed.dev/cla. Once you've signed, post a comment here that says '@cla-bot check'.

@zed-community-bot zed-community-bot bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Jan 13, 2026
@soyllamas
Copy link
Copy Markdown
Contributor Author

@cla-bot check

@cla-bot cla-bot bot added the cla-signed The user has signed the Contributor License Agreement label Jan 13, 2026
@cla-bot
Copy link
Copy Markdown

cla-bot bot commented Jan 13, 2026

The cla-bot has been summoned, and re-checked this pull request!

@SomeoneToIgnore SomeoneToIgnore added the area:ai Related to Agent Panel, Edit Prediction, Copilot, or other AI features label Jan 14, 2026
Copy link
Copy Markdown
Member

@bennetbo bennetbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks mostly good to me. Please fix the conflicts with main. I wanted to, but GitHub won't let me push to your branch

@soyllamas soyllamas force-pushed the main branch 3 times, most recently from 90f073a to dbcbb69 Compare February 13, 2026 02:37
@soyllamas soyllamas requested a review from bennetbo February 13, 2026 02:44
@bennetbo
Copy link
Copy Markdown
Member

bennetbo commented Mar 2, 2026

@soyllamas Looks good, I cannot push to your branch. Please merge main and then we can merge.

soyllamas and others added 2 commits March 2, 2026 15:55
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@soyllamas
Copy link
Copy Markdown
Contributor Author

@bennetbo rebased my changes. Encountered a few conflicts that are now resolved ✅

Copy link
Copy Markdown
Member

@bennetbo bennetbo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@bennetbo bennetbo merged commit 62b9a98 into zed-industries:main Mar 3, 2026
28 checks passed
tahayvr pushed a commit to tahayvr/zed that referenced this pull request Mar 4, 2026
…ries#46751)

### Summary

Makes file mention chips in the AI chat input clickable to open the
referenced files. Previously, chips like `@README.md` were purely visual
indicators with no interaction.

### Changes
- **Clickable mention chips**: Users can now click on file mentions in
the chat input to open those files in the editor
- **Support for all mention types**:
  - Files → Opens in editor
  - Files with line numbers → Opens and scrolls to line
  - Directories → Reveals in project panel
  - Threads → Navigates to thread
  - Rules → Opens rules library
  - URLs → Opens in browser
- **Handles files outside workspace**: Falls back to `open_abs_path()`
for files not in the current workspace

### Implementation

Threads `MentionUri` and `WeakEntity<Workspace>` through the crease
rendering pipeline:

1. Updated `insert_crease_for_mention()` to accept mention URI and
workspace references
2. Added click handler to `MentionCrease` component using `.when()` for
conditional attachment
3. Implemented file opening helpers that mirror the existing
`thread_view.rs::open_link()` logic

### Demo


https://github.com/user-attachments/assets/21b2afb7-7a86-4a0a-aba1-e24bb1b650c2

### Testing

Manually tested:

- [x] Clicking `@README.md` opens file
- [x] Clicking file with line numbers navigates correctly
- [x] Clicking directory reveals in project panel
- [x] Files outside workspace open via absolute path

### Files Changed

- `crates/agent_ui/src/mention_set.rs` - Thread URI/workspace through
pipeline
- `crates/agent_ui/src/ui/mention_crease.rs` - Add click handler and
file opening logic
- `crates/agent_ui/src/acp/message_editor.rs` - Update call sites

### Review feedback addressed

- Replaced `.when()` + `unwrap()` with `.when_some()` + `Option::zip()`
(`0e36efb4eb`)
- De-duplicated `open_file` and `open_file_at_line` into a single
function with `Option<RangeInclusive<u32>>` (`dbcbb69a4b`)
  - Rebased onto latest `main` and resolved conflicts

  Also update item 2 under Implementation from:
_Added click handler to MentionCrease component using `.when()` for
conditional attachment_

  to:
_Added click handler to MentionCrease component using `.when_some()`
with `Option::zip()` for conditional attachment_

### Release Notes:

- agent: File mention chips in the chat input are now clickable and will
open the referenced files in the editor.

Closes  zed-industries#46746

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
wzulfikar pushed a commit to wzulfikar/zed that referenced this pull request Mar 4, 2026
…ries#46751)

### Summary

Makes file mention chips in the AI chat input clickable to open the
referenced files. Previously, chips like `@README.md` were purely visual
indicators with no interaction.

### Changes
- **Clickable mention chips**: Users can now click on file mentions in
the chat input to open those files in the editor
- **Support for all mention types**:
  - Files → Opens in editor
  - Files with line numbers → Opens and scrolls to line
  - Directories → Reveals in project panel
  - Threads → Navigates to thread
  - Rules → Opens rules library
  - URLs → Opens in browser
- **Handles files outside workspace**: Falls back to `open_abs_path()`
for files not in the current workspace

### Implementation

Threads `MentionUri` and `WeakEntity<Workspace>` through the crease
rendering pipeline:

1. Updated `insert_crease_for_mention()` to accept mention URI and
workspace references
2. Added click handler to `MentionCrease` component using `.when()` for
conditional attachment
3. Implemented file opening helpers that mirror the existing
`thread_view.rs::open_link()` logic

### Demo


https://github.com/user-attachments/assets/21b2afb7-7a86-4a0a-aba1-e24bb1b650c2

### Testing

Manually tested:

- [x] Clicking `@README.md` opens file
- [x] Clicking file with line numbers navigates correctly
- [x] Clicking directory reveals in project panel
- [x] Files outside workspace open via absolute path

### Files Changed

- `crates/agent_ui/src/mention_set.rs` - Thread URI/workspace through
pipeline
- `crates/agent_ui/src/ui/mention_crease.rs` - Add click handler and
file opening logic
- `crates/agent_ui/src/acp/message_editor.rs` - Update call sites

### Review feedback addressed

- Replaced `.when()` + `unwrap()` with `.when_some()` + `Option::zip()`
(`0e36efb4eb`)
- De-duplicated `open_file` and `open_file_at_line` into a single
function with `Option<RangeInclusive<u32>>` (`dbcbb69a4b`)
  - Rebased onto latest `main` and resolved conflicts

  Also update item 2 under Implementation from:
_Added click handler to MentionCrease component using `.when()` for
conditional attachment_

  to:
_Added click handler to MentionCrease component using `.when_some()`
with `Option::zip()` for conditional attachment_

### Release Notes:

- agent: File mention chips in the chat input are now clickable and will
open the referenced files in the editor.

Closes  zed-industries#46746

---------

Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai Related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants