Commit graph

29970 commits

Author SHA1 Message Date
Nathan Sobo
f81993574e Connect Native Agent responses to UI display
User-visible improvements:
- Native Agent now shows AI responses in the chat interface
- Uses configured default model from settings instead of random selection
- Streams responses in real-time as the model generates them

Technical changes:
- Implemented response stream forwarding from Thread to AcpThread
- Created Session struct to manage Thread and AcpThread together
- Added proper SessionUpdate handling for text chunks and tool calls
- Fixed model selection to use LanguageModelRegistry's default
- Added comprehensive logging for debugging model interactions
- Removed unused cwd parameter - native agent captures context differently than external agents
2025-08-02 09:58:33 -06:00
Nathan Sobo
bc1f861d3f Add Native Agent to UI and implement NativeAgentServer
- Created NativeAgentServer that implements AgentServer trait
- Added NativeAgent to ExternalAgent enum
- Added Native Agent option to both the + menu and empty state view
- Added necessary dependencies (agent_servers, ui) to agent2 crate
- Added agent2 dependency to agent_ui crate
- Temporarily removed feature flag check for testing
2025-08-02 09:17:26 -06:00
Nathan Sobo
4f2d6a9ea9 Rename Agent to NativeAgent and AgentConnection to NativeAgentConnection
- Renamed Agent struct to NativeAgent to better reflect its native implementation
- Renamed AgentConnection to NativeAgentConnection for consistency
- Updated all references and implementations
- Bumped agent-client-protocol version to 0.0.14
2025-08-02 08:59:16 -06:00
Nathan Sobo
604a88f6e3 Add comprehensive test for AgentConnection with ModelSelector
- Add public session_id() method to AcpThread to enable testing
- Fix ModelSelector methods to use async move closures properly to avoid borrow conflicts
- Add test_agent_connection that verifies:
  - Model selector is available for agent2
  - Can list available models
  - Can create threads with default model
  - Can query selected model for a session
  - Can send prompts using the selected model
  - Can cancel sessions
  - Handles errors for invalid sessions
- Remove unnecessary mut keywords from async closures
2025-08-02 08:45:51 -06:00
Nathan Sobo
a4fe8c6972 Add ModelSelector capability to AgentConnection
- Add ModelSelector trait to acp_thread crate with list_models, select_model, and selected_model methods
- Extend AgentConnection trait with optional model_selector() method returning Option<Rc<dyn ModelSelector>>
- Implement ModelSelector for agent2's AgentConnection using LanguageModelRegistry
- Make selected_model field mandatory on Thread struct
- Update Thread::new to require a default_model parameter
- Update agent2 to fetch default model from registry when creating threads
- Fix prompt method to use the thread's selected model directly
- All methods use &mut AsyncApp for async-friendly operations
2025-08-02 08:28:37 -06:00
Nathan Sobo
5d621bef78 WIP 2025-08-02 00:15:22 -06:00
Nathan Sobo
27877325bc Implement agent-client-protocol Agent trait for agent2
Added Agent struct that implements the acp::Agent trait with:
- Complete: initialize (protocol handshake) and authenticate (stub auth)
- Partial: new_session (creates ID but needs GPUI context for Thread)
- Partial: cancelled (removes session but needs GPUI cleanup)
- Stub: load_session and prompt (need GPUI context integration)

The implementation uses RefCell for session management since trait methods
take &self, and Cell for simple authentication state. Templates are Arc'd
for potential Send requirements.

Next steps:
- Integrate GPUI context for Thread creation/management
- Implement content type conversions between acp and agent2
- Add proper session persistence for load_session
- Stream responses back through the protocol
2025-08-01 23:22:21 -06:00
Nathan Sobo
9e1c7fdfea Rename agent to thread in tests to avoid confusion
Preparing for the introduction of a new Agent type that will implement
the agent-client-protocol Agent trait. The existing Thread type represents
individual conversation sessions, while Agent will manage multiple sessions.
2025-08-01 23:14:21 -06:00
Nathan Sobo
387ee1be8d Clean up warnings in agent2
- Remove underscore prefix from BasePrompt struct name
- Remove unused imports and variables in tests
- Fix unused parameter warning in async closure
- Rename AgentToolErased to AnyAgentTool for clarity
2025-08-01 22:54:34 -06:00
Nathan Sobo
afc8cf6098 Refactor agent2 tests structure
- Move tests from thread/tests.rs to tests/mod.rs
- Move test_tools from thread/tests/test_tools.rs to tests/test_tools.rs
- Update imports and fix compilation errors in tests
- Fix private field access by using public messages() method
- Add necessary imports for test modules
2025-08-01 22:48:35 -06:00
Nathan Sobo
84d6a0fae9 Fix agent2 compilation errors and warnings
- Add cloud_llm_client dependency for CompletionIntent and CompletionMode
- Fix LanguageModelRequest initialization with missing thinking_allowed field
- Update StartMessage handling to use Assistant role
- Fix MessageContent conversions to use enum variants directly
- Fix input_schema implementation to use schemars directly
- Suppress unused variable and dead code warnings
2025-08-01 22:39:08 -06:00
Nathan Sobo
afb5c4147a WIP: Add agent2 crate from test-driven-agent branch 2025-08-01 22:32:36 -06:00
Nathan Sobo
8890f590b1 Fix some breakages against agent-client-protocol/main 2025-08-01 22:25:04 -06:00
Agus Zubiaga
76f0f9163d Merge branch 'main' into new-acp 2025-08-01 18:17:48 -03:00
Agus Zubiaga
8acb58b6e5 Fix types 2025-08-01 18:15:26 -03:00
Michael Sloan
6052115825
zeta: Add CLI tool for querying edit predictions and related context (#35491)
Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
2025-08-01 21:08:09 +00:00
Ben Kunkle
561ccf86aa
onboarding: Serialize onboarding page (#35490)
Closes #ISSUE

Serializes the onboarding page to the database to ensure that if Zed is
closed during onboarding, re-opening Zed restores the onboarding state
and the most recently active page (Basics, Editing, etc) restored. Also
has the nice side effect of making dev a bit nicer as it removes the
need to re-open onboarding and navigate to the correct page on each
build.

Release Notes:

- N/A *or* Added/Fixed/Improved ...
2025-08-01 20:45:29 +00:00
Agus Zubiaga
8563ed2252 Compiling 2025-08-01 17:07:50 -03:00
Ben Kunkle
ac75593198
onboarding: Actions for page navigation (#35484)
Closes #ISSUE

Release Notes:

- N/A *or* Added/Fixed/Improved ...
2025-08-01 19:30:25 +00:00
Marshall Bowers
a3a3f111f8
zeta: Rename binding back to user_store (#35486)
This PR renames a binding from `cloud_user_store` to `user_store` now
that we've consolidated the two into the `UserStore`.

Release Notes:

- N/A
2025-08-01 18:44:17 +00:00
Danilo Leal
faa45c53d7
onboarding: Add design adjustments (#35480)
Release Notes:

- N/A

---------

Co-authored-by: Anthony <anthony@zed.dev>
2025-08-01 15:08:15 -03:00
Max Brunsfeld
b31f893408
Rasterize glyphs without D2D (#35376)
This allows debugging Zed with Renderdoc, and also fixes an issue where
glyphs' bounds were miscalculated for certain sizes and scale factors.

Release Notes:

- N/A

---------

Co-authored-by: Kate <kate@zed.dev>
Co-authored-by: Julia <julia@zed.dev>
Co-authored-by: Junkui Zhang <364772080@qq.com>
2025-08-01 19:46:09 +02:00
Antonio Scandurra
f888f3fc0b
Start separating authentication from connection to collab (#35471)
This pull request should be idempotent, but lays the groundwork for
avoiding to connect to collab in order to interact with AI features
provided by Zed.

Release Notes:

- N/A

---------

Co-authored-by: Marshall Bowers <git@maxdeviant.com>
Co-authored-by: Richard Feldman <oss@rtfeldman.com>
2025-08-01 17:37:38 +00:00
Finn Evers
b01d1872cc
onboarding: Add the AI page (#35351)
This PR starts the work on the AI onboarding page as well as the
configuration modal

Release Notes:

- N/A

---------

Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
Co-authored-by: Anthony <anthony@zed.dev>
2025-08-01 10:43:59 -04:00
Ben Brandt
e5c6a596a9
agent_ui: More agent notifications (#35441)
Release Notes:

- N/A
2025-08-01 14:29:02 +00:00
Joseph T. Lyons
106aa0d9cc
Add default binding to open settings profile selector (#35459)
Release Notes:

- N/A
2025-08-01 05:53:40 +00:00
Marshall Bowers
f7f90593ac
inline_completion_button: Replace UserStore with CloudUserStore (#35456)
This PR replaces usages of the `UserStore` in the inline completion
button with the `CloudUserStore`.

Release Notes:

- N/A
2025-08-01 03:25:23 +00:00
Marshall Bowers
8be3f48f37
client: Remove unused subscription_period from UserStore (#35454)
This PR removes the `subscription_period` field from the `UserStore`, as
its usage has been replaced by the `CloudUserStore`.

Release Notes:

- N/A
2025-08-01 03:10:16 +00:00
Peter Tripp
76a8293cc6
editor_tests: Fix for potential race loading editor languages (#35453)
Fix for potential race when loading HTML and JS languages (JS is
slower). Wait for both to load before continue tests.
Observed failure on linux:
[job](https://github.com/zed-industries/zed/actions/runs/16662438526/job/47162345259)
as part of https://github.com/zed-industries/zed/pull/35436

```
    thread 'editor_tests::test_autoclose_with_embedded_language' panicked at crates/editor/src/editor_tests.rs:8724:8:
    assertion failed: `(left == right)`: unexpected buffer text

    Diff < left / right > :
     <body><>
         <script>
    <        var x = 1;<>
    >        var x = 1;<
         </script>
     </body><>
```

Inserted `<` incorrect gets paired bracket inserted `>`.
I believe because the JS language injection hasn't fully loaded.

Release Notes:

- N/A
2025-08-01 03:05:03 +00:00
Marshall Bowers
2315962e18
cloud_api_client: Add accept_terms_of_service method (#35452)
This PR adds an `accept_terms_of_service` method to the
`CloudApiClient`.

Release Notes:

- N/A
2025-08-01 02:50:38 +00:00
Marshall Bowers
f8673dacf5
ai_onboarding: Read the plan from the CloudUserStore (#35451)
This PR updates the AI onboarding to read the plan from the
`CloudUserStore` so that we don't need to connect to Collab.

Release Notes:

- N/A
2025-08-01 02:08:21 +00:00
Marshall Bowers
72d354de6c
Update Agent panel to work with CloudUserStore (#35436)
This PR updates the Agent panel to work with the `CloudUserStore`
instead of the `UserStore`, reducing its reliance on being connected to
Collab to function.

Release Notes:

- N/A

---------

Co-authored-by: Richard Feldman <oss@rtfeldman.com>
2025-08-01 01:44:43 +00:00
Marshall Bowers
09b93caa9b
Rework authentication for local Cloud/Collab development (#35450)
This PR reworks authentication for developing Zed against a local
version of Cloud and/or Collab.

You will still connect the same way—using the `zed-local` script—but
will need to be running an instance of Cloud locally.

Release Notes:

- N/A
2025-08-01 00:55:17 +00:00
Cole Miller
7c169fc9b5
debugger: Send initialized event from fake server at a more realistic time (#35446)
The spec says:

> ⬅️ Initialized Event
> This event indicates that the debug adapter is ready to accept
configuration requests (e.g. setBreakpoints, setExceptionBreakpoints).
>
> A debug adapter is expected to send this event when it is ready to
accept configuration requests (but not before the initialize request has
finished).

Previously in tests, `intercept_debug_sessions` was just spawning off a
background task to send the event after setting up the client, so the
event wasn't actually synchronized with the flow of messages in the way
the spec says it should be. This PR makes it so that the `FakeTransport`
injects the event right after a successful response to the initialize
request, and doesn't send it otherwise.

Release Notes:

- N/A
2025-07-31 19:45:02 -04:00
Mikayla Maki
2b36d4ec94
Add a field to MultiLSPQuery span showing the current request (#35372)
Release Notes:

- N/A
2025-07-31 22:40:19 +00:00
Peter Tripp
4a82b6c5ee
jetbrains: Unmap cmd-k in Jetbrains keymap (#35443)
This only works after a delay in most situations because of the all
chorded `cmd-k` mappings in the so disable them for now.

Reported by @jer-k:
https://x.com/J_Kreutzbender/status/1951033355434336606

Release Notes:

- Undo mapping of `cmd-k` for Git Panel in default Jetbrains keymap
(thanks [@jer-k](https://github.com/jer-k))
2025-07-31 18:29:51 -04:00
Joseph T. Lyons
5feb759c20
Additions for settings profile selector (#35439)
- Added profile selector to `zed > settings` submenu.
- Added examples to the `default.json` docs.
- Reduced length of the setting description that shows on autocomplete,
since it was cutoff in the autocomplete popover.


Release Notes:

- N/A
2025-07-31 22:20:35 +00:00
Marshall Bowers
410348deb0
Acquire LLM token from Cloud instead of Collab for Edit Predictions (#35431)
This PR updates the Zed Edit Prediction provider to acquire the LLM
token from Cloud instead of Collab to allow using Edit Predictions even
when disconnected from or unable to connect to the Collab server.

Release Notes:

- N/A

---------

Co-authored-by: Richard Feldman <oss@rtfeldman.com>
2025-07-31 22:12:04 +00:00
Mikayla Maki
8e7f1899e1
Revert "Increase the number of parallel request handlers per connection" (#35435)
Reverts zed-industries/zed#35046

This made the problem worse ;-;

Release Notes:

- N/A
2025-07-31 17:31:29 -04:00
Marshall Bowers
aea1d48184
cloud_api_client: Add create_llm_token method (#35428)
This PR adds a `create_llm_token` method to the `CloudApiClient`.

Release Notes:

- N/A
2025-07-31 21:01:21 +00:00
Ben Kunkle
c946b98ea1
onboarding: Expand power of theme selector (#35421)
Closes #ISSUE

The behavior of the theme selector is documented above the function,
copied here for reference:
```rust
/// separates theme "mode" ("dark" | "light" | "system") into two separate states
/// - appearance = "dark" | "light"
/// - "system" true/false
/// when system selected:
///  - toggling between light and dark does not change theme.mode, just which variant will be changed
/// when system not selected:
///  - toggling between light and dark does change theme.mode
/// selecting a theme preview will always change theme.["light" | "dark"] to the selected theme,
///
/// this allows for selecting a dark and light theme option regardless of whether the mode is set to system or not
/// it does not support setting theme to a static value
```

Release Notes:

- N/A *or* Added/Fixed/Improved ...
2025-07-31 16:21:58 -04:00
Anthony Eid
c6947ee4f0
onboarding ui: Add theme preview tiles and button functionality to basic page (#35413)
This PR polishes and adds functionality to the onboarding UI with a
focus on the basic page. It added theme preview tiles, got the Vim,
telemetry, crash reporting, and sign-in button working.

The theme preview component was moved to the UI crate and it now can
have a click handler on it.

Finally, this commit also changed `client::User.github_login` and
`client::UserStore.by_github_login` to use `SharedStrings` instead of
`Strings`. This change was made because user.github_login was cloned in
several areas including the UI, and was cast to a shared string in some
cases too.

Release Notes:

- N/A

---------

Co-authored-by: Remco Smits <djsmits12@gmail.com>
2025-07-31 18:40:41 +00:00
Marshall Bowers
b59f992928
cloud_api_types: Add types for POST /client/llm_tokens endpoint (#35420)
This PR adds some types for the new `POST /client/llm_tokens` endpoint.

Release Notes:

- N/A

Co-authored-by: Richard <richard@zed.dev>
2025-07-31 18:00:29 +00:00
Joseph T. Lyons
0a21b845fa
Tighten up settings profile selector modal width (#35419)
Release Notes:

- N/A
2025-07-31 17:31:12 +00:00
Kirill Bulatov
6a8be1714e
Fix panic with completion ranges and autoclose regions interop (#35408)
As reported [in
Discord](https://discord.com/channels/869392257814519848/1106226198494859355/1398470747227426948)
C projects with `"` as "brackets" that autoclose, may invoke panics when
edited at the end of the file.

With a single selection-caret (`ˇ`), at the end of the file,
```c
ifndef BAR_H
#define BAR_H

#include <stdbool.h>

int fn_branch(bool do_branch1, bool do_branch2);

#endif // BAR_H
#include"ˇ"
```
gets an LSP response from clangd
```jsonc
{
  "filterText": "AGL/",
  "insertText": "AGL/",
  "insertTextFormat": 1,
  "kind": 17,
  "label": " AGL/",
  "labelDetails": {},
  "score": 0.78725427389144897,
  "sortText": "40b67681AGL/",
  "textEdit": {
    "newText": "AGL/",
    "range": { "end": { "character": 11, "line": 8 }, "start": { "character": 10, "line": 8 } }
  }
}
```

which replaces `"` after the caret (character/column 11, 0-indexed).
This is reasonable, as regular follow-up (proposed in further
completions), is a suffix + a closing `"`:

<img width="842" height="259" alt="image"
src="https://github.com/user-attachments/assets/ea56f621-7008-4ce2-99ba-87344ddf33d2"
/>

Yet when Zed handles user input of `"`, it panics due to multiple
reasons:

* after applying any snippet text edit, Zed did a selection change:
5537987630/crates/editor/src/editor.rs (L9539-L9545)
which caused eventual autoclose region invalidation:
5537987630/crates/editor/src/editor.rs (L2970)

This covers all cases that insert the `include""` text.

* after applying any user input and "plain" text edit, Zed did not
invalidate any autoclose regions at all, relying on the "bracket" (which
includes `"`) autoclose logic to rule edge cases out

* bracket autoclose logic detects previous `"` and considers the new
user input as a valid closure, hence no autoclose region needed.
But there is an autoclose bracket data after the plaintext completion
insertion (`AGL/`) really, and it's not invalidated after `"` handling

* in addition to that, `Anchor::is_valid` method in `text` panicked, and
required `fn try_fragment_id_for_anchor` to handle "pointing at odd,
after the end of the file, offset" cases as `false`

A test reproducing the feedback and 2 fixes added: proper, autoclose
region invalidation call which required the invalidation logic tweaked a
bit, and "superficial", "do not apply bad selections that cause panics"
fix in the editor to be more robust

Release Notes:

- Fixed panic with completion ranges and autoclose regions interop

---------

Co-authored-by: Max Brunsfeld <maxbrunsfeld@gmail.com>
2025-07-31 16:18:26 +00:00
Cole Miller
a2aea00253
Bump livekit-rust-sdks with another attempt to fix build failures (#35344)
Includes https://github.com/zed-industries/livekit-rust-sdks/pull/7

Release Notes:

- N/A
2025-07-31 11:39:46 -04:00
张小白
98c66eddb8
windows: Don't create directx device with debug flag when debug layer is missing (#35405)
Release Notes:

- N/A
2025-07-31 14:42:44 +00:00
Marshall Bowers
558bbfffae
title_bar: Show the plan from the CloudUserStore (#35401)
This PR updates the user menu in the title bar to show the plan from the
`CloudUserStore` instead of the `UserStore`.

We're still leveraging the RPC connection to listen for `UpdateUserPlan`
messages so that we can get live-updates from the server, but we are
merely using this as a signal to re-fetch the information from Cloud.

Release Notes:

- N/A
2025-07-31 13:56:53 +00:00
Smit Barmase
89ed0b9601
workspace: Fix multiple remote projects not restoring on reconnect or restart and not visible in recent projects (#35398)
Closes #33787

We were not updating SSH paths after initial project was created. Now we
update paths when worktrees are added/removed and serialize these
updated paths. This is separate from workspace because unlike local
paths, SSH paths are not part of the workspace table, but the SSH table
instead. We don't need to update SSH paths every time we serialize the
workspace.

<img width="400"
src="https://github.com/user-attachments/assets/9e1a9893-e08e-4ecf-8dab-1e9befced58b"
/>

Release Notes:

- Fixed issue where multiple remote folders in a project were lost on
reconnect, not restored on restart, and not visible in recent projects.
2025-07-31 16:32:31 +05:30
Julia Ryan
4b9334b910
Fix vim cw at end of words (#35300)
Fixes #35269

Release Notes:

- N/A
2025-07-31 03:48:36 -07:00