zed/crates
Rutger Cappendijk 52182e43cd
agent_ui: Add ability to add terminal output to agent context (#47637)
Summary

This PR adds the ability to quote terminal selections into Agent
threads, similar to how editor selections can be quoted. Users can now
select text in the terminal and add it as context to their agent
conversation.

### Features

- **Context menu**: Added "Add to Agent Thread" option to the terminal's
right-click menu (only shows when text is selected)
- **Keyboard shortcut**: The existing `cmd->` / `ctrl->` shortcut now
works in the terminal
- **Collapsed display**: Terminal output appears as a collapsed
"Terminal" crease in the chat, just like code references
- **Works with both thread types**: Supports both ACP-style threads
(Claude Code) and text threads

### Implementation

- Extended `quote_selection` handler to check for terminal panel focus
after checking for editor selections
- Terminal content is formatted as ` ```terminal` code blocks via new
`insert_terminal_crease` method
- Refactored crease insertion into `insert_crease_impl` helper to
support both code snippets (with `TextSnippet` icon) and terminal output
(with `Terminal` icon)
- Added automatic detection and folding of ` ```terminal` blocks in
`set_message` so terminal content stays collapsed in sent message
history
- Terminal creases use a trailing space instead of newline so cursor
behavior matches user expectations

### Demo

1. Select text in terminal
2. Right-click → "Add to Agent Thread" (or press `cmd->`)
3. Terminal content appears as collapsed "Terminal" block in chat
4. Send message - AI receives full terminal output, but chat history
shows it collapsed

### General note

I'm new to open source and the codebase in general so let me know if
anything should be different!
I tried to stay in line with other patterns I saw.
I didn't see a way to setup an end to end test with a real terminal so I
just added a unit test for the adding of the text to the chat, if it
exists and I missed it then I think the test coverage could be improved
with a test that uses a real terminal + running the command

<img width="431" height="148" alt="image"
src="https://github.com/user-attachments/assets/854732f9-2a7f-4f31-867e-d54af068c97c"
/>


Release Notes:

- agent: Added the ability to send selections from terminals into the
Agent thread

---------

Co-authored-by: Ben Brandt <benjamin.j.brandt@gmail.com>
2026-01-29 15:15:03 +00:00
..
acp_thread agent_ui: Add ability to add terminal output to agent context (#47637) 2026-01-29 15:15:03 +00:00
acp_tools ui: Improve performance in the CopyButton component (#47292) 2026-01-21 13:40:42 -03:00
action_log git: Side-by-side diff UI (#47349) 2026-01-22 02:31:14 -05:00
activity_indicator remote: Support opening builtin host files in remote workspaces on wsl (#46910) 2026-01-15 15:21:57 +00:00
agent agent_ui: Add ability to add terminal output to agent context (#47637) 2026-01-29 15:15:03 +00:00
agent_servers Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
agent_settings agent: Add setting for controlling terminal tool stop button behavior (#47521) 2026-01-23 20:41:07 -03:00
agent_ui agent_ui: Add ability to add terminal output to agent context (#47637) 2026-01-29 15:15:03 +00:00
agent_ui_v2 agent_ui: Refactor in preparation for subagent permission work (#47874) 2026-01-29 10:53:53 +00:00
ai_onboarding Add student plan (#47866) 2026-01-28 21:34:10 +00:00
anthropic ep: Handle errored requests in Anthropic batches (#46351) 2026-01-08 10:59:03 +00:00
askpass Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
assets
assistant_slash_command Handle removed IconName variants in text thread deserialization (#47624) 2026-01-26 23:56:55 +00:00
assistant_slash_commands agent: Multiline review comments (#47448) 2026-01-23 06:25:42 +00:00
assistant_text_thread Fix rate limiter holding permits during tool execution (#47494) 2026-01-23 12:15:55 -05:00
audio gpui: Actually remove the Result from AsyncApp (#45809) 2026-01-07 12:48:24 -08:00
auto_update remote: Add configurable remote server cache retention (default 5) (#47202) 2026-01-26 07:25:51 +00:00
auto_update_helper
auto_update_ui remote: Support opening builtin host files in remote workspaces on wsl (#46910) 2026-01-15 15:21:57 +00:00
aws_http_client
bedrock bedrock: Add Bedrock API key authentication support (#41393) 2025-12-17 12:54:57 +01:00
breadcrumbs Multibuffer breadcrumbs toolbar redesign (#45547) 2026-01-06 09:42:00 -03:00
buffer_diff git: Fix incorrect diff transforms being computed for side-by-side diff LHS (#47515) 2026-01-25 22:08:48 -05:00
call gpui: Actually remove the Result from AsyncApp (#45809) 2026-01-07 12:48:24 -08:00
channel gpui: Actually remove the Result from AsyncApp (#45809) 2026-01-07 12:48:24 -08:00
cli Make zed --wait work with directories (#44936) 2025-12-16 01:22:41 +00:00
client client: Fix ACP registry blog post URL (#47881) 2026-01-28 18:28:53 +00:00
clock
cloud_api_client
cloud_api_types Add student plan (#47866) 2026-01-28 21:34:10 +00:00
cloud_llm_client cloud_llm_client: Move Plan type into cloud_api_types (#47778) 2026-01-27 15:58:05 +00:00
codestral Introduce new predict_edits/v3 endpoint (#46960) 2026-01-16 02:16:34 +00:00
collab Reapply "Try namespace mac runners (#47675)" (#47721) (#47727) 2026-01-26 22:02:52 -07:00
collab_ui build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
collections
command_palette Revert "Revert scheduler update (#46659)" (#46671) 2026-01-14 07:19:13 +00:00
command_palette_hooks
component
component_preview build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
context_server Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
copilot copilot: Decouple authentication from the lifetime of any single Copilot instance (#47473) 2026-01-23 17:20:16 +01:00
copilot_chat copilot_chat: Fix Anthropic models not appearing in model picker (#47549) 2026-01-25 13:10:22 +01:00
copilot_ui copilot: Decouple authentication from the lifetime of any single Copilot instance (#47473) 2026-01-23 17:20:16 +01:00
crashes Revert "Revert scheduler update (#46659)" (#46671) 2026-01-14 07:19:13 +00:00
credentials_provider gpui: Actually remove the Result from AsyncApp (#45809) 2026-01-07 12:48:24 -08:00
dap dap: Make ProtoConversion::to_proto consume self (#47871) 2026-01-28 16:00:52 +00:00
dap_adapters Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
db
debug_adapter_extension Revert "Revert scheduler update (#46659)" (#46671) 2026-01-14 07:19:13 +00:00
debugger_tools gpui: Actually remove the Result from AsyncApp (#45809) 2026-01-07 12:48:24 -08:00
debugger_ui Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
deepseek deepseek: Fix for max output tokens blocking completions (#45236) 2025-12-18 12:47:34 +00:00
denoise
dev_container Clean up error handling for some edge cases to prevent panic (#47513) 2026-01-23 13:22:08 -08:00
diagnostics Implement Vim's tag stack (#46002) 2026-01-15 17:48:15 +00:00
docs_preprocessor Remove zed dependency from docs_preprocessor (#45130) 2025-12-18 21:59:05 -05:00
edit_prediction ep_cli: rated-after: query (#47906) 2026-01-28 16:36:44 -08:00
edit_prediction_cli ep_cli: rated-after: query (#47906) 2026-01-28 16:36:44 -08:00
edit_prediction_context Introduce new predict_edits/v3 endpoint (#46960) 2026-01-16 02:16:34 +00:00
edit_prediction_types Add sweep acceptance tracking (#46199) 2026-01-06 17:20:25 -05:00
edit_prediction_ui zeta2: Remove experimental_edit_prediction_context_retrieval setting (#47783) 2026-01-27 12:10:08 -05:00
editor git: Fix a couple of bugs with buffer headers in the side-by-side diff UI (#47809) 2026-01-28 22:01:27 -05:00
encoding_selector encoding: Add "reopen with encoding" (#46553) 2026-01-27 05:27:26 +00:00
eval Fix rate limiter holding permits during tool execution (#47494) 2026-01-23 12:15:55 -05:00
eval_utils Fix self-referential symbolic link (#45265) 2025-12-18 17:26:20 +01:00
explorer_command_injector
extension xtask: Remove transitive GPUI dependency (#47748) 2026-01-27 14:00:45 +01:00
extension_api extension api: Make server id types constructible, to ease writing tests (#45174) 2025-12-17 16:25:07 -08:00
extension_cli extension: Ensure that compiled extension provides at least one feature (#47715) 2026-01-28 14:25:47 +01:00
extension_host Revert " Add vim/emacs modeline support " (#47479) 2026-01-23 15:24:37 +00:00
extensions_ui acp: Add agent server extension deprecation banner (#47817) 2026-01-28 10:28:43 +01:00
feature_flags agent: Add thinking toggle for Zed provider (#47407) 2026-01-22 18:08:32 +00:00
feedback
file_finder build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
file_icons
fs Revert "fs: Replace MacWatcher with notify::FsEventWatcher" (#47799) 2026-01-27 20:27:53 +00:00
fs_benchmarks
fsevent Revert "fs: Replace MacWatcher with notify::FsEventWatcher" (#47799) 2026-01-27 20:27:53 +00:00
fuzzy fuzzy: Use lowercase representations for matrix size calculation (#44338) 2025-12-08 19:50:20 +01:00
git Use SharedString::new_static for string literals (#47865) 2026-01-28 15:12:48 +00:00
git_graph git_graph: Add feature graph (#47861) 2026-01-28 14:41:17 +00:00
git_hosting_providers git_ui: Add CreatePullRequest action (#42959) 2026-01-05 16:15:21 +00:00
git_ui git: Hide toggle split diff button behind feature flag (#47878) 2026-01-28 17:15:09 +00:00
go_to_line Add optional relative line jumps to go-to-line action (#46932) 2026-01-27 05:51:11 +00:00
google_ai google_ai: Refactor token count methods in Google AI (#45184) 2025-12-17 20:12:40 -06:00
gpui agent_ui: Refactor in preparation for subagent permission work (#47874) 2026-01-29 10:53:53 +00:00
gpui_macros gpui: Add min_size and max_size style methods (#47775) 2026-01-27 15:37:22 -03:00
gpui_tokio gpui: Actually remove the Result from AsyncApp (#45809) 2026-01-07 12:48:24 -08:00
html_to_markdown
http_client Remove reqwest dependency from gpui (#44424) 2025-12-09 09:29:40 -08:00
http_client_tls
icons thread view: Improve thinking mode toggle UI (#47945) 2026-01-29 12:11:13 -03:00
image_viewer image_viewer: Compute better initial zoom level (#47886) 2026-01-28 23:29:25 +01:00
inspector_ui build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
install_cli gpui: Actually remove the Result from AsyncApp (#45809) 2026-01-07 12:48:24 -08:00
journal multi_buffer: Typed MultiBufferOffset (#42707) 2025-11-19 22:00:58 +00:00
json_schema_store gpui: Add action_schema_by_name for O(1) action schema lookup (#47180) 2026-01-26 08:25:18 +00:00
keymap_editor build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
language Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
language_extension ztracing: Enable memory profiling and callstack sampling (#47052) 2026-01-17 19:29:19 +00:00
language_model Add support for refreshing outdated LLM tokens (#47512) 2026-01-23 21:03:28 +00:00
language_models cloud_api_types: Rework Plan type (#47784) 2026-01-27 12:15:05 -05:00
language_onboarding
language_selector build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
language_tools syntax_tree_view: Fix highlights persisting after view was closed (#47638) 2026-01-26 11:07:01 +00:00
languages Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
line_ending_selector
livekit_api
livekit_client livekit_client: Revert #46986 for macos (#46990) 2026-01-16 14:20:23 +00:00
lmstudio
lsp lsp: Skip serializing of params if unit type (#46027) 2026-01-22 15:06:02 +02:00
markdown repl: Streamline Markdown output usage (#47713) 2026-01-28 17:42:07 +00:00
markdown_preview Add item for opening Markdown/SVG files in preview tab in right-click menu (#47821) 2026-01-28 00:19:13 -03:00
media
menu ui: Add submenus to ContextMenu (#45743) 2025-12-30 07:49:01 -03:00
migrator Remove Burn Mode code (#46950) 2026-01-15 21:28:33 +00:00
miniprofiler_ui Revert "Revert scheduler update (#46659)" (#46671) 2026-01-14 07:19:13 +00:00
mistral Update Mistral models context length to their recommended values (#45194) 2025-12-18 09:49:32 +00:00
multi_buffer build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
nc smol: Use Unblock instead of Async for stdin, stdout and stderr handles (#46141) 2026-01-06 08:14:34 +00:00
net
node_runtime acp: Allow running NPM agents from registry (#47291) 2026-01-21 14:52:44 +00:00
notifications gpui: Actually remove the Result from AsyncApp (#45809) 2026-01-07 12:48:24 -08:00
ollama
onboarding onboarding: Fix theme picker always updating theme based on system appearance (#47245) 2026-01-21 10:12:29 +00:00
open_ai ep: Use rejected_output for DPO training + OpenAI support (#47697) 2026-01-27 13:02:40 +00:00
open_path_prompt Use suggested name for "use_system_path_prompts": false dialogue when creating new files (#47802) 2026-01-27 20:54:20 +00:00
open_router Fix Gemini 3 on OpenRouter (#43416) 2025-11-24 13:24:26 -05:00
outline outline: Enable scrollbar in outline view picker (#46774) 2026-01-14 08:06:55 -03:00
outline_panel project_panel: Show Reveal in File Manager on wsl (#47288) 2026-01-22 11:24:23 +00:00
panel
paths remote_server: Cleanup old server binaries on wsl (#47839) 2026-01-28 13:30:43 +01:00
picker build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
platform_title_bar build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
prettier Revert " Add vim/emacs modeline support " (#47479) 2026-01-23 15:24:37 +00:00
project project: Increase search detect yield threshold to 20KB (#47824) 2026-01-29 13:45:04 +01:00
project_benchmarks ep_cli: Fix "Too many open files" errors (#47243) 2026-01-20 15:41:31 -05:00
project_panel project_panel: Add bold_folder_labels setting (#47631) 2026-01-28 09:54:03 +05:30
project_symbols Revert "Revert scheduler update (#46659)" (#46671) 2026-01-14 07:19:13 +00:00
prompt_store Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
proto project: Implement range formatting for remoting (#47194) 2026-01-20 09:10:18 +00:00
recent_projects Disable opening dev container from within a remote project (#47816) 2026-01-27 23:35:55 +00:00
refineable gpui: Make refining a Style properly refine the TextStyle (#42852) 2025-12-15 13:30:13 +00:00
release_channel release_version: Do not use prerelease field (#43669) 2025-11-27 13:46:43 +00:00
remote Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
remote_server remote_server: Cleanup old server binaries on wsl (#47839) 2026-01-28 13:30:43 +01:00
repl repl: Streamline Markdown output usage (#47713) 2026-01-28 17:42:07 +00:00
reqwest_client Remove reqwest dependency from gpui (#44424) 2025-12-09 09:29:40 -08:00
rich_text
rope rope: Fix an unintentional panic (#47019) 2026-01-20 12:23:17 +00:00
rpc Fix worktree trust handling of multiple projects on the same remote host (#45834) 2025-12-29 20:21:59 +00:00
rules_library build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
scheduler Restore run_with_clock_advancement (#46930) 2026-01-15 18:39:06 +00:00
schema_generator Add project settings schema to schema_generator CLI (#44321) 2025-12-16 10:48:14 -05:00
search project: Add spinner while search is underway (#47620) 2026-01-27 00:26:25 +00:00
session Revert "Revert scheduler update (#46659)" (#46671) 2026-01-14 07:19:13 +00:00
settings project_panel: Add bold_folder_labels setting (#47631) 2026-01-28 09:54:03 +05:30
settings_content project_panel: Add bold_folder_labels setting (#47631) 2026-01-28 09:54:03 +05:30
settings_json
settings_macros Fallible Settings (#42938) 2025-11-21 08:28:17 -07:00
settings_profile_selector
settings_ui project_panel: Add bold_folder_labels setting (#47631) 2026-01-28 09:54:03 +05:30
snippet
snippet_provider extension_cli: Validate that all snippets can be parsed (#47649) 2026-01-26 13:49:26 +00:00
snippets_ui build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
sqlez
sqlez_macros
story
storybook Revert "Revert scheduler update (#46659)" (#46671) 2026-01-14 07:19:13 +00:00
streaming_diff
sum_tree git: Side-by-side diff UI (#47349) 2026-01-22 02:31:14 -05:00
supermaven collab: Remove Supermaven API key issuance (#46044) 2026-01-04 23:28:18 +00:00
supermaven_api collab: Remove Supermaven API key issuance (#46044) 2026-01-04 23:28:18 +00:00
svg_preview Add item for opening Markdown/SVG files in preview tab in right-click menu (#47821) 2026-01-28 00:19:13 -03:00
system_specs releases: Add build number to Nightly builds (#42990) 2025-11-24 13:34:04 +01:00
tab_switcher tab_switcher: Fix missing preview on initial ctrl-shift-tab press (#44959) 2025-12-16 08:26:29 +00:00
task Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
tasks_ui tasks: Show error for unknown ZED_ variables (#45621) 2026-01-26 19:47:36 +00:00
telemetry
telemetry_events ep_cli: rated-after: query (#47906) 2026-01-28 16:36:44 -08:00
terminal Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
terminal_view agent_ui: Add ability to add terminal output to agent context (#47637) 2026-01-29 15:15:03 +00:00
text Fix inverted char boundary check causing invalid offsets (#47112) 2026-01-19 09:08:45 +01:00
theme Update nim entry with additional file suffixes (#47616) 2026-01-26 13:02:05 +00:00
theme_extension
theme_importer Split settings content into its own crate (#46845) 2026-01-15 18:10:21 +00:00
theme_selector Allow dynamic set_theme based on Appearance (#42812) 2025-12-01 20:52:57 -07:00
time_format time_format: Determine year difference based on months passed (#47687) 2026-01-28 17:05:34 +01:00
title_bar Add student plan (#47866) 2026-01-28 21:34:10 +00:00
toolchain_selector build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
ui Fix typing emoji (#47835) 2026-01-28 07:04:22 +00:00
ui_input build: Simplify build graph (#47253) 2026-01-23 18:29:20 +01:00
ui_macros
ui_prompt
util Allow always_allow patterns for Nushell, Elvish, and Rc shells (#47908) 2026-01-29 06:08:05 +00:00
util_macros
vercel project: Move tests to integration layer (#47596) 2026-01-25 21:35:32 +01:00
vim docs: Correct action descriptions to reflect actual purpose (#46931) 2026-01-28 23:10:25 +00:00
vim_mode_setting
watch
web_search
web_search_providers Add helper method for checking if the LLM token needs to be refreshed (#47511) 2026-01-23 20:50:50 +00:00
which_key Add Vim-like Which-key Popup menu (#43618) 2025-12-17 11:53:48 -07:00
workspace Fix typing emoji (#47835) 2026-01-28 07:04:22 +00:00
worktree worktree: Use public-api-only tests (#47152) 2026-01-22 10:22:04 +01:00
worktree_benchmarks gpui: Actually remove the Result from AsyncApp (#45809) 2026-01-07 12:48:24 -08:00
x_ai Add support for Grok 4.1 Fast models in xAI provider (#43419) 2025-12-08 16:38:34 +01:00
zed agent_ui: Refactor in preparation for subagent permission work (#47874) 2026-01-29 10:53:53 +00:00
zed_actions docs: Correct action descriptions to reflect actual purpose (#46931) 2026-01-28 23:10:25 +00:00
zed_env_vars Enable configuring edit prediction providers through the settings UI (#44505) 2025-12-13 11:06:30 -05:00
zeta_prompt zeta2: Improve format prompt budgeting (#47808) 2026-01-27 17:36:27 -05:00
zlog zlog: Fix dynamic mod path filtering (#44296) 2025-12-06 17:56:49 +00:00
zlog_settings
ztracing ztracing: Enable memory profiling and callstack sampling (#47052) 2026-01-17 19:29:19 +00:00
ztracing_macro adds tracing for instrumenting non-async functions (#44147) 2025-12-05 17:23:06 +00:00