Commit Graph

353 Commits

Author SHA1 Message Date
Ben Brandt f2cdf3d5bd acp_thread: Add authoritative terminal display updates (#64976)
Add a shared, byte-oriented terminal display update boundary without
enabling v2 transport. References, output-first updates, and snapshots
reuse the existing terminal registry and the same model, renderer, and
read-only view.

- Add tri-state terminal patches for command, cwd, decoded output
snapshots, exit information, and metadata. Keep terminal, snapshot,
exit, and content-reference metadata in their own scopes; consume
appended bytes without another raw-output history store.
- Create display placeholders for unseen v2 tool-content terminal
references. Existing v1 missing references remain errors.
Native/client-owned terminals, including no-PTY wrappers, reject display
patches.
- Keep append separate from replacement. Replacement rebuilds the
emulator/parser at the latest requested bounds, preserves configuration
and entity/view identity, and invalidates selection, search, hover,
scrolling, and cursor blinking.
- Stamp parser events with the output generation so queued old titles
cannot resurface. Drop all obsolete internal events, including
historical resizes, rather than applying them to the new screen.
- Preserve legacy first-Created/first-Exit behavior through independent
event markers. Late creation fills a placeholder without replacing its
renderer; pending legacy bytes drain before later snapshots. Reported
command values and explicit clears outrank caption fallbacks.

## Review guide

1. [Shared model and decoded patch
types](https://github.com/zed-industries/zed/blob/99eb1f22a5f3210d00b4253582c589b60d4a0cb2/crates/acp_thread/src/terminal.rs#L427),
then [registry/upsert entry
points](https://github.com/zed-industries/zed/blob/99eb1f22a5f3210d00b4253582c589b60d4a0cb2/crates/acp_thread/src/acp_thread.rs#L6768):
identity, metadata, output/exit independence, and legacy compatibility.
2. [Renderer
replacement](https://github.com/zed-industries/zed/blob/99eb1f22a5f3210d00b4253582c589b60d4a0cb2/crates/terminal/src/terminal.rs#L2007):
configuration/bounds, parser reset, process isolation, and stale-event
invalidation.
3. [View
invalidation](https://github.com/zed-industries/zed/blob/99eb1f22a5f3210d00b4253582c589b60d4a0cb2/crates/terminal_view/src/terminal_view.rs#L1211)
and the rendered tool-card regression: the existing read-only view
survives replacement and completion changes.

Release Notes:

- N/A
2026-09-30 13:05:18 +00:00
Ben Brandt 39b5329322 acp_thread: Separate submission receipts from session activity (#64930)
Separate prompt submission from session activity without enabling v2
transport. A receipt acknowledges acceptance; it does not mean the agent
has finished working.

- Select an optional, session-bound receipt capability before sending.
Existing v1/native connections retain completion-based prompt behavior.
- Give submissions and foreground activity separate owners. Submission
records own response tasks, IDs, echo correlation, and recoverable
content; activity owns Running/RequiresAction/Idle state, timing,
generations, and cancellation waiters.
- Keep receipt-driven pending text outside the transcript. Only agent
echoes create canonical user messages, with receipt/echo correlation
working in either order. Pending and failed submissions have recovery
controls; restoring an editable copy keeps the original until explicit
Discard.
- Carry generation, duration, and stop reason in completion events.
Stale events cannot advance a newer activity's queue or display old
errors. Timers also reconcile correctly when Running and Idle arrive
before the UI observes either transition.
- Preserve legacy completion/cancellation semantics while running
completion directly in the record-owned task, removing a redundant
task/channel bridge. Native subagent and eval consumers explicitly
require completion rather than accepting a receipt as a finished run.

## Review guide

This is a cross-layer lifecycle change, not a wire adapter. Suggested
review order:

1. [Submission and activity
ownership](https://github.com/zed-industries/zed/blob/279f0074bae5ec7e85acac363fcadbefb04de6d5/crates/acp_thread/src/submission.rs#L98):
retention, echo correlation, task ownership, and idle waiters.
2. [Core
settlement](https://github.com/zed-industries/zed/blob/279f0074bae5ec7e85acac363fcadbefb04de6d5/crates/acp_thread/src/acp_thread.rs#L3910)
and [legacy turn
completion](https://github.com/zed-industries/zed/blob/279f0074bae5ec7e85acac363fcadbefb04de6d5/crates/acp_thread/src/acp_thread.rs#L5765):
receipt settlement must not finish activity; cancellation still waits on
the transport task.
3. [UI activity
reconciliation](https://github.com/zed-industries/zed/blob/279f0074bae5ec7e85acac363fcadbefb04de6d5/crates/agent_ui/src/conversation_view/thread_view.rs#L1446)
and
[recovery](https://github.com/zed-industries/zed/blob/279f0074bae5ec7e85acac363fcadbefb04de6d5/crates/agent_ui/src/conversation_view/thread_view.rs#L1533):
queue/error ownership, batched updates, and recoverable originals.

The receipt capability defaults to absent. Existing agents still use
optimistic v1 messages and completion-based send/command/retry behavior.
Legacy refusal, pending-action cleanup, and native subagent behavior
retain their compatibility paths.

Delta Thread:
https://delta.dev/trunk/join/thread_01m2swv74pzp4c6xk46sh19fmk#s=MYAgERzq

Release Notes:

- N/A
2026-09-30 08:42:44 +00:00
Fabrício Lima 414428c592 agent_ui: Fix agent notifications showing old title after rename (#64907)
## Summary

Renaming a thread whose agent can't set titles (external ACP agents such
as Claude Code) only stores the new name as a `title_override` in
`ThreadMetadataStore`, while the root `AcpThread` keeps the
agent-provided title. The sidebar and the panel's title editor already
prefer the override, but the agent notification read
`AcpThread::title()` directly, so after a rename it kept showing the
thread's original title.

This makes the notification prefer the title override, matching the
precedence already used by the `TitleUpdated` handler. The same title is
passed along when the notification's "View" button loads the thread.

- Extract `ConversationView::title_override` and reuse it in the
`TitleUpdated` handler and `show_notification`
- Add `StubAgentConnection::with_supports_set_title` so tests can model
agents without `set_title` support

## Testing

- Added
`test_notification_uses_renamed_title_when_agent_cannot_set_title`: it
fails without the fix (the notification shows the agent's title) and
passes with it
- `cargo test -p agent_ui notification` and `./script/clippy -p agent_ui
-p acp_thread` pass
- Manually tested on macOS with Claude Code in a dev build: create a
thread, rename it, send another prompt with Zed in the background; the
notification now shows the new title and "View" opens the thread

### Manual test

#### Before:

creating thread and run prompt:
<img width="1341" height="771" alt="image"
src="https://github.com/user-attachments/assets/76a42b32-b238-403d-91eb-4cdd38908fcf"
/>

notification working!
<img width="474" height="93" alt="image"
src="https://github.com/user-attachments/assets/3e7e4572-2abe-47fd-9044-ff69f82cb54d"
/>

rename and run prompt:
<img width="1456" height="830" alt="image"
src="https://github.com/user-attachments/assets/dbafe4b8-cbd0-4691-a34e-295123991774"
/>

notification with incorrect name and view button not working!
<img width="463" height="89" alt="image"
src="https://github.com/user-attachments/assets/360fd555-22a6-462f-b761-92c67e5acdd8"
/>

#### After

creating thread and run prompt:
<img width="1240" height="833" alt="image"
src="https://github.com/user-attachments/assets/09e530da-4de6-4ca3-b76d-26898bde6c12"
/>

notification working!
<img width="466" height="94" alt="image"
src="https://github.com/user-attachments/assets/5b998271-2ab7-4cec-8b0b-6c93a31e48b4"
/>

rename and run prompt:
<img width="1242" height="828" alt="image"
src="https://github.com/user-attachments/assets/dcbd88f3-ce92-4ce6-acd0-640941c7d12f"
/>

notification with correct name and view button working!
<img width="472" height="88" alt="image"
src="https://github.com/user-attachments/assets/3860768f-cc2b-4028-9e7f-3236001e24a3"
/>





## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [x] Tests cover the new or changed behavior.

Release Notes:

- Fixed agent notifications showing a thread's original title after the
thread was renamed

---------

Co-authored-by: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-authored-by: Christopher Biscardi <chris@christopherbiscardi.com>
2026-09-30 05:03:06 +00:00
Ben Brandt 14dd03e896 agent_ui: Guard follow-up sends from stale send results (#64917)
Keep an older agent send's response from mutating the UI state of a
newer started turn.

After cancel/send, the old RPC response may still be outstanding. The
core already guards its own turn completion, but the view previously
cleared `in_flight_prompt` on every successful response and displayed
every returned error, even when a successor was running.

- Apply prompt cleanup, following-state refresh, and response errors
inside one view update guarded by the existing turn generation.
- Clear the previous displayed error again at actual turn start. This
covers an old error arriving while the successor's contents are still
resolving, without starting turn timing early.
- Preserve current-send error visibility, prompt recovery,
generation-protected timer cleanup, and per-send completion telemetry.
Superseded failures are debug-logged rather than shown on the newer
turn.
- Add a test-only controlled prompt-response gate and one regression
covering late success/error, deferred preparation, current success/error
cleanup, and timer ownership.

The guarantee starts when the successor reaches `start_turn`.
Cancellation alone does not invalidate the view generation; an old error
can appear while successor content is preparing, but cannot carry into
that new turn.

Release Notes:

- agent: Fixed stale agent responses clearing a newer prompt or showing
errors from an earlier send.
2026-09-29 10:51:49 +00:00
Ben Brandt 72d28c32c2 acp_thread: Add shared structured plan state (#64884)
Give structured agent plans one retained source record per identity and
a separate selected plan, while preserving the existing single-panel UI
and v1 behavior.

- Adapt complete v1 snapshots into shared SDK-v2 entry values before
mutating state. Retain entry metadata, plan-content metadata, and outer
update metadata at their respective levels.
- Add a keyed structured-items entrypoint without synthetic protocol
IDs. A new ID or meaningful ordered task change selects/reopens the
plan; identical and metadata-only snapshots do not switch the panel or
undo dismissal.
- Make Clear Plan dismiss presentation without deleting keyed source.
Keep v1's clear/repopulate behavior and restrict next-turn
completed-entry pruning to the legacy record.
- Reuse Markdown entities within each plan. Preserve unknown v2
statuses/priorities; distinguish cancellation from successful
completion.
- Observe ordinary thread notifications so status-only, selection-only,
and empty-plan changes repaint without depending on a Markdown update.

Release Notes:

- acp: Improved agent plan state handling and panel refreshes.
2026-09-28 16:59:30 +00:00
Ben Brandt 986828d157 acp_thread: Add shared tool-call state and diff previews (#64875)
Review Thread:
https://delta.dev/trunk/join/thread_01m2swv74pzp4c6xk46sh19fmk#s=pVggqzly

Normalize legacy ACP tool reports and SDK v2 tool patches into one
shared `ToolCall` model, preserving protocol source separately from
local decisions and rendered views.

- Retain reported kind/status, first-class name, metadata, and complete
tool-content sources, including unknown v2 values and envelope metadata.
- Keep authorization ownership and local outcomes separate from reported
status. Support omitted/null/value patches without changing legacy
permission-continuation behavior.
- Preserve the status-before-content-validation contract: invalid
presentation cannot roll back a terminal report or leave its permission
unresolved.
- Render supported v2 patches with read-only diff editors using `diffy`.
Preserve sparse hunk coordinates, multi-file structure,
additions/deletions, and original source without reading or modifying
workspace files. Accept standalone unified patches and unambiguous bare
hunks; retain explicit fallback and export text for unsupported input.
- Keep native live diffs separate from protocol snapshots, preserve
render identity on metadata-only updates, and align patch
expansion/search with visible authorization content.

This adds the shared model and presentation boundary; it does **not**
enable v2 transport negotiation or change prompt lifecycle. Existing
v1/native adapters continue to work. The existing
one-active-authorization-per-tool policy is unchanged.

Release Notes:

- N/A
2026-09-28 15:53:24 +00:00
Ben Brandt 20e3812408 acp_thread: Preserve tool presentation on invalid content (#64784)
- Prepare all incoming tool content before changing presentation fields
or shared display entities. A missing terminal or failed content
conversion no longer leaves a partially updated title, metadata, content
list, or terminal command label.
- Share preparation between creation and updates, filtering unsupported
entries before positional reconciliation without constructing a
disposable second set of views.
- Preserve raw-input Markdown identity across snapshots and skip
rendering unchanged input.
- Reuse unchanged diffs without constructing discarded entities, and
include the path in the reuse check so identical text at a different
path does not retain the old file.

Reported status remains authoritative even when content conversion
fails. Nonterminal updates preserve an open permission request; terminal
status still settles it and resumes sleep prevention as before. The
existing failed-tool update/upsert lifecycle tests remain unchanged.

This makes presentation updates atomic, not the whole tool update.
Existing error propagation, v1 omission semantics, raw-output fallback,
and specialized native diff/terminal updates remain intact. It does not
add v2 tri-state APIs, a canonical wire-state store, or protocol
negotiation.

Release Notes:

- acp: Fixed partial tool-call display updates when content references
an unavailable terminal.
2026-09-28 09:47:17 +00:00
Ben Brandt 3794e5e979 acp_thread: Add keyed message updates (#64773)
Stacked on #64765, with `benbrandt/acp-message-updates` as the base
branch.

- Add typed SDK v2 user-message, assistant-message, and thought upserts,
plus keyed chunk appends, using the existing transcript records.
- Keep legacy optional-ID adjacency and optimistic echo behavior
separate. Keyed records retain their first-seen positions; conflicting
message kinds fail before mutation.
- Apply omitted/null/value content and message metadata independently.
Full snapshots replace content; later chunks append. Chunk-envelope
metadata does not patch message metadata.
- Reconcile rendered text runs and preserve compatible Markdown/image
entities. Replacing a message discards only its superseded streaming
cursor.
- Keep read-only user messages synchronized, including empty snapshots,
without resetting selection on metadata-only or identical updates. A
compact source-change token avoids caching another payload copy.

This does not select v2 connections or change prompt acceptance and
turn-completion semantics. Keyed lookup scans the existing records;
there is no second transcript or maintained ID index.

Release Notes:

- N/A
2026-09-28 09:26:37 +00:00
Ben Brandt ee43be113e acp_thread: Adopt shared ACP v2 content values (#64765)
Use SDK v2 content values as the shared representation inside the
existing message model and render-source owners, while keeping current
v1/native producers and wire APIs working through explicit adapters.

- Preserve payloads, annotations, metadata, optional/empty values, and
original content-block boundaries without a second transcript or
serialization-based conversion.
- Convert v1 inputs explicitly at message, tool/compaction,
prompt-display, and native replay boundaries. Existing v1 prompt
payloads, IDs/grouping, echo policy, streaming, editing, and rewind
behavior remain the compatibility baseline.
- Keep unsupported v2 user data canonical, show a read-only indication,
and prevent a lossy edit/resend. This includes unknown block types,
unknown audience roles, and nonempty v2-only resource-link icons. Empty
icon lists normalize to absence at the v1 boundary.
- Keep checkpoint restoration independent of edit eligibility. Refresh
unsupported focused messages, clear invalid editing state without moving
focus, and recheck the retained editor after asynchronous rewind before
resending.
- Avoid cloning retained source payloads when a focused, supported
editor will not be refreshed.

This enables SDK **type availability**, not v2 connections.

#### Review order

1.
[b166b0c52d](https://github.com/zed-industries/zed/commit/b166b0c52d3d035f05fedea8a9fa92f83e3a79ed)
— mechanical `acp_v1` alias rename and formatting, kept separate to
reduce noise in the functional review.
2.
[2d1b5345c0](https://github.com/zed-industries/zed/commit/2d1b5345c0f8b22a978db42af12e702d7bca1dfa)
— content-value migration, read-only handling, and regressions.
3.
[0c9befbc96](https://github.com/zed-industries/zed/commit/0c9befbc960eb4855b4427230bd8fbba4e7044aa)
— main integration, preserving the newly landed tool-output fallback
(#64708) and completed-plan removal (#64719).
4.
[de22432b3f](https://github.com/zed-industries/zed/commit/de22432b3f3758af7c069f314d7f217a7f1f326b)
— empty-icon normalization and expanded bidirectional/wire round-trip
coverage.

Release Notes:

- N/A
2026-09-28 09:11:35 +00:00
Xin Zhao 98f75a23bc Remove some unnecessary dependencies (#64862)
## Summary

Some dependencies were originally introduced for only a few specific
functions that can either be fulfilled by existing dependencies or
easily implemented in-tree. This PR removes or replaces them:

1. `json_dotpath`: Removed. We do not use the dot-path query feature;
standard methods in `serde_json` are sufficient for our use case.
2. `crossbeam`: Replaced with the more lightweight `crossbeam-queue`.
3. `take-until`: Removed. Calls to `take_until` are replaced with
`take_while_inclusive` from `itertools`, which is already widely used in
Zed.
4. `x11-clipboard`: Removed. It is deprecated and was only an unused
entry left in `Cargo.toml`.
5. `portable-pty`: Removed. We only used the `ExitStatus` transformation
logic from this crate, which has now been inlined into the Zed codebase.

Together, these changes reduce the total crate count from 1,727 to 1,717
during a Linux `cargo build`, slightly improving compile times.

## Testing

This is a refactoring PR with no functional changes. Existing tests were
run locally to ensure no regressions were introduced.

## Self-review

- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [ ] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist).
- [ ] Tests cover the new or changed behavior.

Release Notes:

- N/A
- [GPUI] N/A
2026-09-28 08:56:15 +00:00
Ben Brandt 557f85d25e acp_thread: Fix missing and stale agent tool output (#64708)
- Fix raw-only tool creation displaying no output and successive
raw-output updates leaving stale text visible.
- Keep structured content separate from the cached raw-output fallback,
with one `content()` accessor shared by rendering, search, visibility
checks, and Markdown export.
- Reuse the fallback's Markdown entity across raw snapshots while
preserving existing formatting, permission handling, and native replay
sequencing.

## Display rule

Nonempty structured content takes precedence. When structured content is
empty, display the latest retained raw output. Clearing structured
content restores that fallback without requiring the agent to resend its
raw output.

Release Notes:

- Fixed missing or outdated output in agent tool results.
2026-09-24 12:44:11 +00:00
Ben Brandt 99f947e5f6 acp_thread: Remove completed plan cards from conversation history (#64719)
Stop inserting completed-plan cards into conversation history. Plan
progress stays in the existing plan panel instead of gaining a second
transcript presentation when a turn finishes.

- Keep the completed current plan visible in the plan panel, including
its existing **All Done** state.
- Let later plan updates revise that state in place, preserving Markdown
entity identity.
- Preserve **Clear Plan** and the existing next-turn cleanup of
completed rows.
- Remove the completed-plan transcript variant, snapshot calls, card
renderer, and associated search/export/view-state handling.

This was an experimental UI change when we had an update_plan tool in
the Zed agent. But now that this is ACP only, I think this
simplification is warranted, also because there are upcoming changes to
plans in RFD for v1 and v2 that will be id-based and allow future
updates.

Release Notes:

- N/A
2026-09-24 12:43:39 +00:00
Ben Brandt a405fb91d5 acp_thread: Consolidate agent message content ownership (#64667)
- Make `MessageContent` own the original SDK content blocks and derive
rendering through borrowed views, removing the separately maintained
`UserMessage.chunks` vector.
- Retain assistant content-block metadata and payloads while revealing
streamed text through a source cursor, without a second pending-text
buffer or per-block shared ownership.
- Preserve existing v1 IDs, grouping, optimistic echo behavior, prompt
formatting, and Markdown/image identity. Standalone tool and compaction
output keeps its existing payload-retention contract.
- Reclaim spare source-vector capacity at turn settlement or
cancellation, with a bounded trailing range and stale-turn guards. Late
output can still append normally.

This is content-ownership preparation for ACP v2.

Release Notes:

- N/A
2026-09-24 09:23:58 +00:00
Ben Brandt 05958c4773 acp_thread: Emit elicitation completion from state transitions (#64609)
Emit elicitation completion from the authoritative state transition
rather than from the task awaiting its response.

ACP request cancellation can drop the response task before canceling the
stored elicitation. Previously, the request became canceled but never
emitted `ElicitationResponded`. A regression reproduces the consequence:
idle-sleep prevention stays disabled even though the request is no
longer pending and the agent is still generating.

- Make response tasks receiver-only; emit completion from the owning
session thread or connection store.
- Distinguish resolving a pending request from canceling an
already-accepted URL flow, which must not emit a second response.
- Preserve existing response payloads, update-before-completion event
order, and duplicate/no-op behavior.

Release Notes:

- N/A
2026-09-23 12:07:03 +00:00
Ben Brandt a3ccafef66 Add ACP session notice support (#64606)
Implement Zed client support for the draft [ACP Session Notices
RFD](https://agentclientprotocol.com/rfds/session-notices), allowing
agents to surface operational advisories without turning them into
conversation history.

- Advertise the v1 notices capability behind the existing ACP beta
feature flag
- Keep notices in live, session-local state, with independent local
dismissal and no persistence, transcript/export entries, protocol
acknowledgement, or changes to generation status.
- Render dismissible callouts above the composer in a bounded scrolling
area. Support info, warning, and error treatments, with a generic
presentation for unknown severities and plain-text titles/descriptions.
- Provide screen-reader labels, keyboard dismissal with focus
restoration, and a single scrolling surface for long descriptions.
- Add a shared notice component and designer previews for severity
variants, title-only/detailed content, narrow layouts, and overflowing
stacks.

Open **workspace: open component preview**, then select **Agent →
Session Notice**.

<img width="829" height="316" alt="image"
src="https://github.com/user-attachments/assets/2a6eba57-465e-41e8-b99f-5f57c00199d8"
/>


Release Notes:

- N/A
2026-09-23 12:06:54 +00:00
Ben Brandt 656e3aed84 acp: Fix provider-owned terminal lifecycle (#64544)
Provider terminal metadata creates a display buffer, not a client-owned
process. These terminals previously entered the process-completion path,
which completed immediately when no local task existed and cached empty
output. Provider exit status was also discarded.

- Distinguish client-owned processes from provider-owned display
terminals, including headless processes that use the same lower-level
display renderer.
- Complete display terminals on provider exit and retain ACP exit
codes/signals. Duplicate creation and exit events preserve identity and
completion; late output refreshes cached content without changing exit
time or status.
- Refresh tool-card metadata when provider completion arrives without
another tool update.
- Show Stop only for client-owned processes and avoid treating display
terminals as background processes when their tool completes.
- Preserve the full unsigned exit-code range without manufacturing `-1`
for signal-only exits.

Process wait/kill behavior, PTY release, and sandbox cleanup remain
intact. Header rendering continues to use cached metadata rather than
extracting terminal contents.

Release Notes:

- acp: Fixed premature completion and incorrect exit-status reporting
for external-agent terminals, and removed Stop controls from terminals
managed by the agent.
2026-09-21 12:59:56 +00:00
Ben Brandt df673c1b85 acp_thread: Preserve ordered mixed content in agent messages (#64456)
Preserve ordered mixed content in agent messages without disrupting text
streaming for existing native/v1 agents. The previous single-block
reduction could replace images with placeholders or lose non-text
content as subsequent chunks arrived.

- Introduce [ordered message display
content](https://github.com/zed-industries/zed/blob/929fba3e16f7a378eb1dca3d85ac2f1df2b902c6/crates/acp_thread/src/acp_thread.rs#L1500),
reusing adjacent text entities while retaining image/resource-preview
boundaries.
- Update rendering, text search, response copy/export, Mermaid cache
invalidation, and CLI output to visit the collection.
- Use block-local context menus and existing Markdown getters so copy
commands target the clicked part rather than another part's cached
state.
- Keep existing link/mention formatting, resource-button and blob-label
search behavior, compact prompt mentions, and original user-message
chunks.
- Preserve the separator between a leading resource link and subsequent
direct or streamed text.

Release Notes:

- N/A
2026-09-21 09:24:15 +00:00
Ben Brandt f50ebf2975 agent_ui: Show tool-name fallbacks and tooltips (#64177)
Surface tool-call names without adding a permanent subtitle or badge to
every call.

- Keep nonblank titles as the primary label. Blank or whitespace-only
titles fall back to the exact programmatic tool name, then to "Tool
call" if no usable name is available.
- Preserve real titles on name-only updates, and let later title updates
replace a fallback. Fallback names render literally and remain
searchable; exports escape them at the Markdown boundary.
- Show `Tool: <name>` on existing non-terminal tool icons. Keep the
terminal command layout unchanged, and preserve the existing Go to File,
Interrupted Edit, and Copy Command interactions.
- Apply the same behavior to native and external agents, without an
ACP-beta gate.

Release Notes:

- N/A
2026-09-14 14:04:09 +00:00
Ben Brandt d1dae815f2 acp: Add ACP context compaction support (#64081)
Add support for ACP context-compaction updates and streamed summaries.
The ACP beta flag gates only the capability advertised to external ACP
agents. Native Zed-agent compaction (manual and automatic), including
the shared rendering, search, and export behavior, remains available
regardless of that flag.

- Apply updates by compaction ID without moving their timeline entries,
preserving omitted/null/replacement semantics for summaries and errors.
- Retain rich summary content and show explicit placeholders for
unsupported content instead of silently dropping it.
- Render progress, completion, failure, cancellation, and unknown
statuses. Expanded summaries and literal error details participate in
thread search, and Markdown exports preserve status and details.
- Keep native compaction compatible: failed retry attempts become
terminal, and cancellation is delivered before the stop event even when
the bridge has not yet applied the queued start event. Preserve native
streaming and save/reload behavior.

Release Notes:

- N/A
2026-09-14 10:31:51 +00:00
Ben Brandt 3e442f25b7 acp: Use first-class ACP tool-call names (#64080)
Follow up on #64077 by using first-class ACP tool-call names while
continuing to accept legacy `_meta.tool_name` from older agents.

- Prefer the first-class name when creating a tool call. Explicit name
updates replace the stored name; legacy metadata only fills an absent
name and cannot overwrite a canonical name.
- Emit first-class names from the native agent, including replay when a
tool implementation is unavailable.

Release Notes:

- N/A
2026-09-14 09:30:52 +00:00
Xiaobo Liu 450775244f gpui: Prevent idle sleep during AI response streaming (#53130)
Release Notes:

- Added button tu prevent idle sleep during AI response streaming


**Context / Motivation:**
When an AI agent takes a long time to generate a response, the operating
system might enter an idle sleep (or display sleep) state if there is no
user interaction (mouse or keyboard). This can interrupt the workflow.
This PR aims to prevent the system from sleeping during an active AI
turn by invoking native OS APIs, and provides a UI toggle for users to
control this behavior.

**Key Changes:**

1. **Cross-Platform Idle Sleep Prevention in GPUI (`gpui`, `gpui_*`)**
- Added a new `prevent_idle_sleep` method to the `Platform` trait. It
returns a RAII-based `PreventIdleSleepToken`, which automatically
restores the original sleep policy when dropped.
- **macOS**: Utilizes `NSProcessInfo`'s `beginActivityWithOptions` with
`NSActivityIdleDisplaySleepDisabled`.
- **Windows**: Uses `SetThreadExecutionState` to prevent display and
system sleep, incorporating a reference counter to handle concurrent
requests safely.
- **Linux**: Uses `ashpd` to request `org.freedesktop.portal.Inhibit`
(inhibiting `Idle` and `Suspend` states) via D-Bus.

2. **AI Agent State Integration (`crates/acp_thread`)**
- Introduced idle sleep prevention logic in `AcpThread`: Acquires the
token at the beginning of `run_turn`, and automatically releases it when
the turn completes normally, errors out, or is explicitly canceled by
the user.
- Added comprehensive unit tests to ensure the token is correctly
acquired and released under various cancellation and concurrency
scenarios.

3. **Settings and UI (`crates/agent_settings`, `crates/agent_ui`)**
   - Added `AgentOutputIdleSleepControl` to global state.
- Added a new toggle button (screen icon) to the toolbar at the bottom
of the `ThreadView` (AI conversation panel). Users can hover to view the
tooltip and click to toggle the feature on or off.

<img width="419" height="132" alt="截屏2026-04-04 16 09 08"
src="https://github.com/user-attachments/assets/619da9ff-10f7-46e0-b959-d7c74b16b918"
/>

---------

Signed-off-by: Xiaobo Liu <cppcoffee@gmail.com>
Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-09-09 13:49:13 +00:00
Ben Kunkle 229450844d git: Move diff hunk operations onto buffer diffs (#63556)
# Objective

Keep Git-specific diff-base knowledge in `GitStore`, where Git
operations are defined.

Related to FR-135.

## Solution

Give each `BufferDiff` its supported hunk operations. Keep editor hooks
limited to rendering custom controls.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- N/A
2026-09-01 15:52:33 +00:00
Kirill Bulatov 24254879b7 Stop re-resolving editorconfig sections on every language settings lookup (#63323)
Closes https://github.com/zed-industries/zed/issues/59689

Symbolicating the reporter's profile (21s of typing, Windows) showed
`Window::draw` taking 63% of the main thread at ~62 redraws/s (p95 draw
= 40ms), and 30.9% of the *entire* main thread inside
`EditorconfigStore::properties()`:
every `LanguageSettings` lookup — several per frame via
`DisplayMap::tab_size`, `MultiBuffer::language_settings`, indent guides,
and `LspStore::supports_range_formatting` — re-ran the full editorconfig
resolution (ancestor walk plus `ec4rs::Section::apply_to` over every key
of every section) and then cloned the whole `LanguageSettings` struct.
Real-world `.editorconfig` files carry hundreds of irrelevant keys
(`dotnet_*`, `ij_*`, ...), so the per-call map assembly dominated:
`RtlAllocateHeap` 7.3%, `memcmp` 7.0%, `memcpy` 6.6%,
`Properties::find_idx` 5.9% self time.

## Commit 1: resolve only the editorconfig properties Zed reads

- `EditorconfigStore::properties()` now applies only the 7 keys Zed
consumes (`indent_style`, `indent_size`, `tab_width`, `end_of_line`,
`max_line_length`, `insert_final_newline`, `trim_trailing_whitespace`)
instead of materializing every key of every matching section.
- Worktrees with no editorconfig at all now return `None` early instead
of allocating an empty `Properties` and forcing a `LanguageSettings`
clone on every lookup.
- Adds an `editor_render_with_editorconfig` benchmark: maximized window,
file-backed buffer at `src/app/components/editor_pane.ts`, a root
`.editorconfig` shaped after [the second
report](https://github.com/zed-industries/zed/issues/59689#issuecomment-5475124891)
(no `root = true`, a `[*]` section with ~3200 keys, 25 sections with
large `{...}` alternation lists) plus a 4-level nested chain, and a
typing workload (insert/delete + cursor moves).

```
main (770aac345c):      time: [37.905 ms 38.005 ms 38.107 ms]
                        time: [38.069 ms 38.157 ms 38.248 ms]
this commit:            time: [2.8547 ms 2.8618 ms 2.8702 ms]
                        time: [2.8372 ms 2.8435 ms 2.8510 ms]
```

The candidate is ~13x faster.
GPUI frame report over the same workload: window draw p50 12.71 ms →
0.76 ms, p99 23.38 ms → 1.22 ms; frame budget overruns 556 → 0.

## Commit 2: cache resolved `LanguageSettings` per buffer

- `Buffer` and `BufferSnapshot` now hold `resolved_settings:
Arc<LanguageSettings>`, recomputed by a `SettingsStore` global observer.
- Global methods for retrieving the settings are still there, but buffer
only uses them for multi buffer's `language_settings_at` with an
injected language different from the buffer's primary; cold scopes such
as extension API, LSP workspace configuration, server startup still use
the global resolution

Same benchmark, same method, on top of commit 1 (alternated runs, quiet
machine):

```
commit 1:               time: [2.8547 ms 2.8618 ms 2.8702 ms]
                        time: [2.8372 ms 2.8435 ms 2.8510 ms]
this commit:            time: [1.6256 ms 1.6325 ms 1.6403 ms]
                        change: [-42.685% -42.270% -41.854%] (p = 0.00 < 0.05)
                        time: [1.6221 ms 1.6284 ms 1.6352 ms]
```

Window draw p50 0.76 ms → 0.47 ms, p99 1.22 ms → 0.69 ms, max 1.02 ms;
zero frame-budget overruns on both sides.
Combined, the benchmark's per-keystroke cost drops ~23x vs `main`
(37.9–38.2 ms → 1.62–1.64 ms).


Release Notes:

- Improved typing and rendering performance in projects that use
`.editorconfig` files.
2026-08-31 11:58:50 +00:00
Grant Hutchins 3b90a96830 agent: Release completed terminal PTY resources (#62978)
Closes #62972

Completed Agent terminal cards remain alive so conversation history can
render their output. Each retained terminal also kept its Alacritty PTY
sender alive, which retained a poller and one kqueue descriptor after
the command exited.

Terminal lifecycle state is now more strongly typed to prevent this
class of regression. Task terminals are created through a sealed
`TerminalMode` API that pairs their running state with the correct
completion channel, while PTY resources use explicit active and released
states. This makes invalid lifecycle combinations unrepresentable
instead of relying on callers to coordinate independent `Option` values
correctly.

- Release the live PTY sender after final terminal output is captured.
- Preserve PTY process metadata and working-directory behavior for
historical terminal cards.
- Represent PTY resources as explicit active or released lifecycle
states.
- Construct interactive and task terminals through typed modes so a task
cannot omit its running state or use a mismatched completion channel.
- Keep resource release idempotent for later ACP release and entity
destruction.
- Add a macOS regression test that retains the historical terminal
entity while exercising the complete sandboxed terminal tool path.

Release Notes:

- Fixed Agent terminal tool calls leaking file descriptors on macOS.

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-08-26 17:56:33 +00:00
tidely 5b70f793d3 Use Duration to improve type safety and unit correctness (#62969)
# Objective

- Prefer using `Duration` instead of integers when dealing with spans of
time. This prevents confusing different units of time and comparing
arbitrary integers with durations.
- Remove `_ms`/`_secs` suffixes from variables which are `Duration`,
since their unit is inside of the type.
- Initialize large integer constants using `Duration`, which has more
descriptive constructors, while maintaining the resulting integer type.

Release Notes:

- N/A or Added/Fixed/Improved ...
2026-08-21 07:28:05 +00:00
Mikayla Maki 5e1fd392f6 git: Add diff_base setting for showing changes since the default branch (#61501)
# Objective

Let git indicators — the editor gutter, file colors, and `git::Diff` —
show all changes on the current branch relative to its merge base with
the default branch, instead of only uncommitted changes.

Supersedes #60398; thanks to @samuelcolvin for the original
implementation and motivation.

Closes FR-135

## Solution

- New `git.diff_base` setting (`"head"` | `"default_branch"`), applied
live and toggleable per session from the editor controls menu ("Diff
Against Default Branch").
- Statuses come from a real merge-base-to-worktree tree diff (`git diff
--merge-base`), so local edits that revert branch changes correctly show
as unchanged.
- `GitStore` shares one `DiffBufferList` per repository with the Branch
Diff view; `repo_snapshots` and `project_path_git_status` keep returning
index/worktree truth, while display surfaces use separate `display_*`
APIs.
- `BufferDiff` now records what its base is (`DiffBaseKind`); hunks
whose base isn't HEAD are read-only in the gutter — stage/restore
buttons and keybindings are inert, so committed work can't be silently
rewritten.
- `git::Diff` follows the setting; new `git::DiffHead` always opens the
HEAD diff; `git::BranchDiff` is renamed `git::DiffBranch` (deprecated
alias kept).

Tradeoffs / known limitations:

- Hunk-level staging is unavailable while in `default_branch` mode
(whole-file staging via the git panel still works). Staging just the
uncommitted sub-ranges of a branch hunk is a follow-up.
- Remote hosts running an older server ignore the new
`GetTreeDiff.includes_worktree` proto field and degrade to
committed-changes-only branch diffs.
- Repositories with no resolvable default branch fall back to
HEAD-relative behavior; a failed first resolution retries on the next
branch-list change.

## Testing

- Real-git-repo tests for the merge-base-to-worktree diff's edge cases:
files recreated after index deletion, committed deletions recreated on
disk, and symlinks.
- GPUI tests for status semantics (a branch change reverted on disk
shows clean), `git::Diff` routing, live setting changes, and read-only
hunk enforcement (restore/stage leave buffer and index untouched).

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Git: Added a `git.diff_base` setting (`"head"` or `"default_branch"`)
that makes the editor gutter, file colors, and diff view show all
changes on the current branch since its merge base with the default
branch, instead of only uncommitted changes.

---------

Co-authored-by: Ben Kunkle <ben@zed.dev>
2026-07-31 19:57:13 +00:00
Tim Vermeulen 779c35d256 acp_thread: Disable Git's configured pager in agent terminals (#61732)
Applies the same fix as #43277 to Zed's native agent, which indeed fixes
this issue for me locally (which I could only reproduce when
specifically telling the agent to not use `--no-pager`, FWIW).

Closes #42943

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed hang when the Zed Agent runs a `git` command with a pager
configured.

---------

Co-authored-by: MrSubidubi <finn@zed.dev>
2026-07-31 13:48:46 +00:00
Cameron Mcloughlin 12a19dccef agent: Re-enable sandbox (#61711)
Fixes the bug that made us remove the sandbox.

The bug in question was very dumb:
- there is sophisticated machinery for detecting whether a user-granted
writable path is swapped out for a symlink in the timing gap between
approval and sandbox creation
- there was no equivalent machinery to do the same for the (much larger)
gap between a user *persisting an approval* (either for the current
thread or permanently via settings)
- The fix is essentially to store canonical (i.e. absolute and
symlink-free at all depths) paths as the source of truth, but retain the
raw path for display purposes
- On WSL, there is extra care needed becasue of the bidirectional
mounting (i.e. `/mnt/c/...` and `\\wsl.localhost\Ubuntu\...`). In
particular, `/mnt/c/...` paths, since their inodes do not necessarily
pin NTFS file references, weaken the sandbox guarantees, and so we need
some extra UI to call this out and docs etc...

This also does not remove the feature flag, but just toggles it to
"enabled_for_all"

---

Release Notes:

- N/A or Added/Fixed/Improved ...

---------

Co-authored-by: Richard Feldman <oss@rtfeldman.com>
Co-authored-by: Jakub Konka <kubkon@jakubkonka.com>
Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-07-29 13:03:22 +00:00
Ben Kunkle a1510de54e agent: Report follow-up messages as tool permission denials (#61754)
# Objective

- Treat a follow-up sent during pending tool approval as a denial the
agent can understand.

## Solution

- Preserve the follow-up interruption through permission handling and
return a specific denial result to the model.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Agent: Fixed agents not recognizing follow-up messages as denial of
pending tool calls.
2026-07-28 03:18:02 +00:00
Ben Brandt 33e2058302 acp: Validate and surface more elicitation warnings (#61708)
Eventually more of this should move into the SDK I think, but makes
several states with forms and urls clearer to the user.

Release Notes:

- N/A
2026-07-27 11:30:39 +00:00
MartinYe1234 54f2b5df1d Open relative file links at line numbers (#61006)
## Summary

- Open relative file links with GitHub-style line fragments at the
referenced line
- Support line navigation from agent responses and Markdown previews
- Preserve decoded-first path resolution with literal percent-escape
fallback

## Testing

- cargo test -q -p util test_source_line_from_fragment -- --nocapture
- cargo test -q -p acp_thread test_hyperlink_percent_escapes_are_decoded
-- --nocapture
- cargo test -q -p agent_ui test_open_link -- --nocapture
- cargo test -q -p markdown_preview -- --nocapture
- cargo fmt --all -- --check

Release Notes:

- Improved relative file links with line numbers to open at the
referenced line.
2026-07-21 14:55:19 +00:00
Lukas Wirth f181a2f47b Split out RelPath into a separate crate (#61029)
This is necessary to remove some `util` dependencies from crates, as
well as better sharing for our projects. This also includes the WIP
AbsPath abstraction as well as some bug fixes from internal tooling.


Release Notes:

- N/A or Added/Fixed/Improved ...
2026-07-15 08:33:25 +00:00
Cameron Mcloughlin 8f92822cbf agent: Sandbox security review and docs update (#60291)
Closes security loopholes and updates docs:
- installs seccomp filter for blocking naughty syscalls
- tightens macos seatbelt profile
- fetch tool responses that redirect are now constrained by allowed
domains list

Also adds a few "Learn More" buttons that link to the new docs.

Also fixes a bug where the agent would try to create a
`~/.config/zed/AGENTS.md` directory

Also adds unicode confusable detection to URL/path privilege escalation
prompts.

---

Release Notes:

- N/A or Added/Fixed/Improved ...

---------

Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-07-10 22:51:41 +00:00
Ben Brandt fbceb2823b acp: Enable ACP elicitations (#60749)
Removes the feature flag. The RFD is in Preview and I am confident it
will be stable without major changes by the time this hits Zed Stable.

Release Notes:

- acp: Allow ACP agents to use Elicitation capturing structure user
input.
2026-07-10 11:22:16 +00:00
Patryk 05530c9b35 acp_thread: Log error when checkpoint comparison fails (#59196)
`update_last_checkpoint` swallows `compare_checkpoints` errors with
`.unwrap_or(true)`. The "Restore checkpoint" button silently disappears
and nothing gets logged, which is what made the linked issue painful to
track down in the first place.

The sibling `update_last_checkpoint_if_changed` a few lines up already
handles the same call with `.context(...).log_err()` and an early
return, so I did the same here. On error the checkpoint's visibility is
left alone instead of being forced to hidden. I didn't propagate the
error because the task result gets `?`'d in `run_turn`'s cleanup, and
failing there would leave the panel stuck in its generating state.

Added a regression test that breaks the comparison mid-turn (recreating
`.git` makes the fake repo forget its checkpoints) and asserts an
already-visible checkpoint stays visible. It fails on main and passes
with this change. The new log line shows up when it runs: `failed to
compare checkpoints: invalid left checkpoint: ...`

Closes #59100

Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content is consistent with the [UI/UX
checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed checkpoint comparison errors silently hiding the "Restore
Checkpoint" button in the agent panel.

Co-authored-by: pstemporowski <110726755+pstemporowski@users.noreply.github.com>
Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
2026-07-08 13:44:41 +00:00
Guilherme Tavares 385e9c68ae Suggest language extensions for untitled buffers (#55263)
Fixes #53527.

## Summary

- Suggest `untitled.<extension>` when saving an untitled editor buffer
with a selected non-Plain Text language.
- Preserve the existing title-based suggestion for existing files, Plain
Text buffers, and buffers without a language extension.
- Add a regression test for an untitled Rust buffer suggesting
`untitled.rs`.

## Testing

- `mise exec rust@1.95.0 -- cargo fmt --check -p editor`
- `mise exec rust@1.95.0 -- cargo test -p editor
test_suggested_filename_uses_language_extension_for_untitled_buffer
--lib`

## Suggested .rules additions

None.

Release Notes:

- Fixed Save As suggestions for untitled buffers with a selected
language.

---------

Co-authored-by: Kirill Bulatov <kirill@zed.dev>
2026-07-08 12:29:04 +00:00
di404 6e9ff7a4f3 Fix agent hyperlinks do not open files (#56283)
## Summary

Fix agent message hyperlinks that point to Windows file paths but are
not parsed as openable project paths.

This covers links like:

```md
[Cargo.toml](</C:/Projects/Example Workspace/Cargo.toml:2>)
[filename.ext](C:\Projects\Example%20Workspace\path\to\filename.ext:42)
[AGENTS.md](</c/Projects/Example Workspace/AGENTS.md>)
```

## Problem

Agent responses can emit Markdown hyperlinks whose targets are Windows
paths rather than `file://` URLs. Some of those targets include a
leading slash before the drive (`/C:/...`), Git Bash/MSYS-style drive
prefixes (`/c/...`), percent-escaped spaces, or line suffixes. These
were not normalized before mention parsing, so clicking the hyperlink
could do nothing instead of opening the file.

## Solution

- Normalize hyperlink path targets before parsing them as `MentionUri`
paths.
- Decode percent escapes in bare path targets so `%20` becomes a literal
space before path/line parsing.
- Convert Windows-compatible hyperlink paths such as `/C:/...` and
`/c/...` into native Windows paths.
- Generate file resource links from `find_path_tool` through
`MentionUri::to_uri()` instead of hand-building `file://` strings.

## Result

Before: clicking agent path hyperlinks did not open the referenced file.

After:  


https://github.com/user-attachments/assets/6c7fad77-4a1e-4497-a4f9-4a4fdf86d527


## Validation

- `cargo test -p acp_thread test_parse_windows --features test-support`
- `cargo fmt --check`

## Follow-up changes

Additions on top of the original work above:

- Moved the hyperlink heuristics into a dedicated
`MentionUri::parse_hyperlink` entry point. `MentionUri::parse` stays
strict, so canonical mention URIs round-trip verbatim and other callers
(message editor, thread deserialization, resource links) are unaffected.
- Percent escapes that decode to path separators (`%2F`, `%5C`) are left
encoded, so decoding can never change which directories a path
traverses.
- Bare paths with escapes are ambiguous (a file may literally be named
`a%20b.rs`): `open_link` prefers the decoded interpretation and falls
back to `MentionUri::parse_hyperlink_literal` when the decoded path
doesn't resolve in the project but the literal one does.
- Links to files outside the project's worktrees now open, gated by an
async existence check through the project `Fs` (correct for remote
projects; broken links no longer create empty buffers or add worktrees).
`open_link` and the mention-crease open path are unified into one
`open_abs_path_at_point`, which now also places the cursor for
out-of-project selection/symbol links.
- `grep_tool` resource links also go through `MentionUri::to_uri()` now,
fixing malformed `file://C:\...` URIs and unencoded spaces.
- Added tests: percent-escape disambiguation, out-of-project link
opening, drive-letter normalization, UNC paths, and literal-path parsing
(`cargo test -p acp_thread mention`, `cargo test -p agent_ui open_link`,
`cargo test -p agent grep_tool`); manually verified the link spellings
above on Windows.

Release Notes:

- Fixed agent path hyperlinks on Windows when paths contain spaces or
shell-style drive prefixes.

---------

Co-authored-by: Martin Ye <martin@zed.dev>
2026-07-05 03:54:54 +00:00
Maja Backman 7ed553b391 acp_thread: Shrink ACP terminal scrollback to used on exit (#60019)
# Objective

ACP agents (Cursor, Claude Code, Codex, etc.) start a display-only
`terminal::Terminal` for each bash tool call. After the call exits, the
terminal stays alive so that its output stays visible. But the
`alacritty` `Grid` keeps a `Storage` cache that's never reclaimed.
Across a long session this memory adds up.

Partially fixes #57099

## Solution

Added `Terminal::shrink_to_used`, called from the `Exit` branch of
`on_terminal_provider_event`. This calls `Grid::truncate()` on the
alacritty grid, shrinking the `Storage` cache portion while leaving
user-visible scrollback.

## Testing

- `cargo nextest run -p terminal
shrink_to_used_preserves_user_visible_scrollback` passes — exercises the
path with >10K rows of scrollback.
- `./script/clippy` clean.
- Manually verified: ran a noisy bash tool call via an ACP agent,
observed exit, then scrolled back through the output, no regression.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Improved memory usage of ACP terminals after the tool call exits

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
2026-07-03 11:41:48 +00:00
Bennet Bo Fenner 4ff55d09e5 Refactor agent settings UI code (#60274)
This PR removes/simplifies some APIs that were leftover after moving the
agent settings from the agent panel into the agent settings UI.
Behavior/UI should be identical.

- Removed `ConfigurationViewTargetAgent` since only a single variant was
used
- Removed `configuration_view` and `configuration_view_v2` and replaced
it with `settings_view`
- Removed all the custom configuration views that were replaced by the
API key view abstraction
- Removed `intitial_title` and `initial_description` and moved it to
`ProviderSettingsView`

Release Notes:

- N/A
2026-07-02 14:32:34 +00:00
Cameron Mcloughlin 3648fe6f19 agent: Sandboxing polish (#60173)
Removes git sandbox feature

The reason is essentially:
- write access to a `.git` dir can be trivially escalated to unsandboxed
access
- therefore, it is misleading to offer git access separate from
unsandboxed access
- instead, we encourage the model to use `--no-optional-locks` to avoid
needing write access to `git status`, etc.


Adds sandboxing to fetch tool
 


---

Release Notes:

- N/A or Added/Fixed/Improved ...

---------

Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-07-01 14:55:30 +00:00
Ben Brandt fa66442a01 acp: Add experimental elicitation UI support (#58927)
Behind a feature flag as we iterate on the RFD

Release Notes:

- N/A

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
Co-authored-by: zed-zippy[bot] <234243425+zed-zippy[bot]@users.noreply.github.com>
2026-07-01 13:10:14 +00:00
Ben Brandt e783b2f063 acp_thread: Defer status updates until turn completion (#60148)
We were signaling this too early, causing the syncing generator to get
updated too soon.

Release Notes:

- N/A
2026-06-30 13:03:45 +00:00
Cameron Mcloughlin 4a99aa870e agent: More sandboxing changes (#60111)
Large change to sandboxing:
- fixes a nasty TOCTOU relating to a symlink swap attack, documented in
the `sandboxing/README.md`
- Adds UI and restrictions when in an untrusted workspace
- Adds tests for (soon to be removed) git support


---

Release Notes:

- N/A or Added/Fixed/Improved ...
2026-06-30 11:10:04 +00:00
Ben Brandt 45015f89d7 acp: Support boolean ACP config options (#59698)
Still behind a feature flag until the RFD is completed.

Release Notes:

- N/A

---------

Co-authored-by: Smit Barmase <heysmitbarmase@gmail.com>
2026-06-30 10:12:25 +00:00
Anant Goel a923597341 Fix agent terminal in headless eval sandbox (#59969)
# Objective

Fix the agent `terminal` tool in headless eval environments. In the eval
sandbox, terminal commands failed before the shell ran with `IOError:
Not a tty (os error 25)` because PTY setup attempted to acquire a
controlling terminal.

## Solution

- Add a `terminal::HeadlessTerminal` global that is set by `eval_cli`
only.
- When headless mode is enabled, run terminal task commands as plain
subprocesses with piped stdout/stderr instead of opening a PTY.
- Pump subprocess output through the existing terminal emulator/event
channel so output capture, completion, and task killing keep working.
- Build ACP terminal commands non-interactively in headless mode.
- Keep the normal editor terminal path unchanged when the global is
unset.
- Handle non-PTY output edge cases by preserving split CRLF sequences
and avoiding an indefinite wait if subprocess exit-status polling
errors.

## Testing

- `cargo fmt --all`
- `cargo test -p util non_interactive_omits_interactive_flag`
- `cargo test -p terminal test_no_pty_task_terminal_captures_output`
- `cargo test -p terminal test_convert_lf_to_crlf_preserves_split_crlf`
- `cargo test -p terminal test_write_output`
- `cargo check -p eval_cli`
- `git --no-pager diff --check`

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed the agent terminal tool failing with "Not a tty" in
headless/eval environments
2026-06-29 15:58:53 +00:00
MartinYe1234 3d1b26d683 Protect Git metadata in Windows sandboxes (#59799)
Summary:

- Protect Git metadata in Windows/WSL sandboxes by passing Git policy
into the WSL Bubblewrap wrapper.
- Map protected Git paths and overlay them read-only, while allowing
approved Git metadata paths to be writable.
- Update tool descriptions and sandboxing docs for platform-specific Git
metadata behavior.

Validation:

- cargo check -p sandbox
- cargo check -p sandbox --tests --target x86_64-pc-windows-msvc
- cargo check -p agent -p acp_thread
- git --no-pager diff --check

Release Notes:

- Improved Windows agent sandboxing to protect Git metadata unless
access is approved
2026-06-29 09:54:36 +00:00
David Scarpetti c3a4bda331 Emit agent thread status change events (#60057)
# Objective

Fix unreliable working/status indicators for ACP agent threads.

ACP threads update their internal running state when a turn starts,
completes, or is canceled, but those status-only changes were not being
emitted as thread events. The agent UI could miss transitions unless
another entry-related event happened nearby, making it particularly hard
to monitor the status of multiple agent threads running at once.

Hope this helps, and thanks for making Zed.

## Solution

- Add an `AcpThreadEvent::StatusChanged` event.
- Emit it when `running_turn` is set, cleared, or canceled.
- Have `ConversationView` handle the event by syncing the active thread
view's generating indicator.
- Treat status changes as UI state only, not root thread metadata
changes.

## Testing

- `cargo check -p sidebar -p project -p git_ui -p workspace`
- Manually verified in a local dev build on macOS that ACP agent
status/working indicators update reliably.

No automated test was added; this changes UI synchronization for ACP
thread status events.

## Self-Review Checklist:

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [ ] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

---

Release Notes:

- Fixed unreliable working indicators for ACP agent threads.
2026-06-29 09:28:21 +00:00
Ben Brandt 70fd3c5774 acp: Handle acp message ids when we get them (#59927)
This separates the two user-message identities we currently need in
agent threads:

- `protocol_id`: the ACP `messageId` used to group or split streamed
message chunks from ACP agents.
- `client_id`: the Zed-generated user message ID used by the native
agent for truncate, rewind, edit/regenerate, checkpoints, token usage,
and persistence.

The main behavior change is that ACP protocol message IDs now affect
message merging/rendering without leaking Zed-native client IDs into ACP
agents by default. Agents that can accept Zed-generated user message IDs
opt into that path through `AgentSessionClientUserMessageIds`, which
owns both ID generation and prompt submission. The native Zed agent
implements that capability; normal ACP agents continue through the
protocol-only `prompt` path.

In ACP v2 we'll have a mechanism for getting user message replays that
will allow the agent to adequately generate it's own opaque id that we
can then use for these other capabilities. But for now, this split at
least makes sure we keep the two concepts distinct.

Release Notes:

- N/A

---------

Co-authored-by: Bennet Bo Fenner <bennetbo@gmx.de>
2026-06-29 07:21:09 +00:00
Ben Brandt 2df74932bc acp: Support embedded resources in tool call content (#59821)
We weren't handling these really before, just rendering the URI. This
should provide best-effort support for what we can render.

<img width="800" height="359" alt="image"
src="https://github.com/user-attachments/assets/51f101c7-c3be-4801-9000-62000a71faa6"
/>

(I will remove the extra labels that was just for testing)

Release Notes:

- acp: Support embedded resources in tool calls.
2026-06-24 15:25:44 +00:00
Cameron Mcloughlin c49a29f461 sandbox: Linux domain filtering and some more cleanup (#59790)
---

Release Notes:

- N/A or Added/Fixed/Improved ...

---------

Co-authored-by: MartinYe1234 <martin@zed.dev>
Co-authored-by: Richard Feldman <oss@rtfeldman.com>
2026-06-24 01:42:52 +00:00