Commit Graph

16699 Commits

Author SHA1 Message Date
Thorsten Ball
0eb96c72e3
context inspector: Log when no suggestions (#16208)
Release Notes:

- N/A
2024-08-14 14:58:32 +02:00
Danilo Leal
55563831c5
assistant: Adjust slash command popover padding (#16181)
I've looked for other instances of the popover component where this change could cause a spacing regression but couldn't find any yet. Let me know if you do! Intuitively, I wouldn't change this padding directly on the component container, but I didn't find any other way to tackle it.

Release Notes:

- N/A
2024-08-14 09:48:48 -03:00
Piotr Osiewicz
e28681c27e
outline: Match on full item path in Outline::find_most_similar (#16206)
Previously, we were only looking at a simple syntax node name at a time
and not the full path to an item. E.g. in a rust-toolchain.toml file:
```rs
[toolchain]
targets = [ "x86_64-apple-darwin", "aarch64-apple-darwin", "x86_64-unknown-linux-gnu", "wasm32-wasi" ]
```
When matching against a query "toolchain targets" from the Assistant,
we'd try to match it against "toolchain" and "targets" and not against
"toolchain targets" - we only look at the name of the innermost node and
not it's full path.
I'd expect it to significantly improve precision of outline item
matching.

Release Notes:

- N/A

Co-authored-by: Bennet Bo <bennet@zed.dev>
2024-08-14 14:03:28 +02:00
Thorsten Ball
b7dcd4e4d6
assistant panel: Fix pending completions not being cleaned up (#16201)
Turns out that you could always cancel a completion, even if it was
already done and completed, because it was never cleaned up.

Release Notes:

- N/A
2024-08-14 12:13:09 +02:00
Thorsten Ball
8b8335f449
assistant panel: Stop animation & show explicit state if canceled (#16200)
This fixes a bug by stopping the animation when a completion is canceled
and it also makes the state more explicit, which I think is very
valuable.



https://github.com/user-attachments/assets/9ede9b25-86ac-4901-8434-7407896bb799


Release Notes:

- N/A
2024-08-14 11:18:40 +02:00
Mikayla Maki
97469cd049
Improve slash commands (#16195)
This PR:

- Makes slash commands easier to compose by adding a concept,
`CompletionIntent`. When using `tab` on a completion in the assistant
panel, that completion item will be expanded but the associated command
will not be run. Using `enter` will still either run the completion item
or continue command composition as before.
- Fixes a bug where running `/diagnostics` on a project with no
diagnostics will delete the entire command, rather than rendering an
empty header.
- Improves the autocomplete rendering for files, showing when
directories are selected and re-arranging the results to have the file
name or trailing directory show first.

<img width="642" alt="Screenshot 2024-08-13 at 8 12 43 PM"
src="https://github.com/user-attachments/assets/97c96cd2-741f-4f15-ad03-7cf78129a71c">


Release Notes:

- N/A
2024-08-13 23:06:07 -07:00
Nathan Sobo
5cb4de4ec6
Fix regression: Restore creation of multiple assist editors on ctrl-enter when selections span across multiple excerpts (#16190)
Release Notes:

- N/A
2024-08-13 17:19:10 -06:00
Marshall Bowers
47628515e1
assistant: Put /docs and /project behind a setting (#16186)
This PR puts the availability of the `/docs` and `/project` slash
commands behind their respective settings.

Release Notes:

- N/A
2024-08-13 17:32:24 -04:00
Marshall Bowers
aa12ae0e3c
Allow extensions to suggest packages for /docs completions (#16185)
This PR gives extensions the ability to suggest packages to show up in
`/docs` completions by default.

Release Notes:

- N/A
2024-08-13 16:50:57 -04:00
Danilo Leal
c6a1d9aa33
assistant: Polish terms of service toast design (#16183)
Pushing in tiny design tweaks and wording change on the button so it's a bit more explicit.

Release Notes:

- N/A
2024-08-13 17:31:46 -03:00
Danilo Leal
07c21bb8ee
assistant: Change the quote selection crease icon (#16180)
Felt like this icon was more fitting to the idea of selected text, and looked less like a document.

Release Notes:

- N/A
2024-08-13 17:31:23 -03:00
Danilo Leal
2f5031bd28
Adjust pulsating animation ranges (#16179)
Just a fine-grain refinement to the pulsating animation range.

Release Notes:

- N/A
2024-08-13 17:31:10 -03:00
Danilo Leal
170ad46f5e
assistant: Add gap to the context toolbar (#16178)
Not the ideal solution yet, but just a small treatment so these two blocks don't collide.

Release Notes:

- N/A
2024-08-13 17:30:57 -03:00
Marshall Bowers
a81e355dc5
Promote package suggestions to a first-class concept on IndexedDocsProviders (#16177)
This PR promotes package suggestions to a first-class concept on the
`IndexedDocsProvider` trait.

This will allow any implementer of `IndexedDocsProvider` to provide a
list of package names to suggest for use with `/docs`.

For the docs.rs provider we use the 250 most popular Rust crates (as
identified [here](https://lib.rs/std)), and for the rustdoc provider we
use the packages in the Cargo workspace.

Release Notes:

- N/A
2024-08-13 16:01:58 -04:00
Piotr Osiewicz
7eeb37262a
assistant: Fix nested slash command rendering (#16173)
/rant on
We have this issue where if a prompt starts with a slash command (e.g.
/workflow), the rendering is a bit messed up. The nested slash command
gets picked up as the parent of a command that includes it (/prompt).
This is due to how we parse slash commands; their output is obtained
asynchronously. When we run `/prompt "My prompt"` whose contents are
`/workflow`, we first include the prompt content verbatim and then
reparse the whole buffer, picking up /workflow as a new command (as if
it was typed by an user). The problem with that is that the range of
parent /prompt does not include the expanded range of a /workflow; in
fact, after doing full expansion of "My prompt", we lose track of the
parent-children relationship of these two slash commands and treat them
as if top-level user prompt was `/workflow/prompt "My prompt"` and not
`/prompt "My prompt"` (which, by the way, would not be parsable for us).

The "proper" fix would be to update the parent range whenever we parse a
new children within it. We could do that. But then, the question is;
what do we gain from it? Slash command output is put behind a crease,
which is fundamentally a fold. Given "My prompt", we'd have to put two
fold indicators on a single line even if the ranges were set up
correctly. So that merely moves the target elsewhere into yet another
issue. Even if we did solve two-fold problem somehow (by e.g. sorting
same-line folds by the end point), we would still be stuck with
suboptimal render. What do we gain from all that anyways? Proper
handling of a relatively obscure (although - at the same time - quite
common) edge case which may as well be handled by having /prompt insert
a new line if there's a slight chance that the edge case could occur.
And that hacky, "inproper" solution is what this PR does; in fact, it's
not the first time it was done, as /default also has the same issue
which it solves in precisely the same manner.

/rant off

Release Notes:

- N/A
2024-08-13 20:50:51 +02:00
Athish Pranav D
d4761a3296
Recognize Cuda files as C++ (#16098)
Signed-off-by: Athish Pranav D <athishanna@gmail.com>
2024-08-13 14:44:48 -04:00
Marshall Bowers
ac30ed0754
assistant: Populate /docs rustdoc with workspace crates (#16172)
This PR makes the `/docs` slash command populate the list with all of
the workspace crates when using the local rustdoc provider.

The workspace crates are shown in the search results when a crate is not
already indexed:

<img width="577" alt="Screenshot 2024-08-13 at 2 18 39 PM"
src="https://github.com/user-attachments/assets/39bee576-8e1a-4b21-a9f8-7951ebae4cc3">

These crates are shown with an `(unindexed)` suffix to convey this:

<img width="570" alt="Screenshot 2024-08-13 at 2 18 45 PM"
src="https://github.com/user-attachments/assets/4eeb07f7-378f-44d4-ae11-4ffe45a23964">

Release Notes:

- N/A
2024-08-13 14:31:34 -04:00
Richard Feldman
b1a581e81b
Copy/paste images into editors (Mac only) (#15782)
For future reference: WIP branch of copy/pasting a mixture of images and
text: https://github.com/zed-industries/zed/tree/copy-paste-images -
we'll come back to that one after landing this one.

Release Notes:

- You can now paste images into the Assistant Panel to include them as
context. Currently works only on Mac, and with Anthropic models. Future
support is planned for more models, operating systems, and image
clipboard operations.

---------

Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Mikayla <mikayla@zed.dev>
Co-authored-by: Jason <jason@zed.dev>
Co-authored-by: Kyle <kylek@zed.dev>
2024-08-13 13:18:25 -04:00
Marshall Bowers
e3b0de5dda
assistant: Auto-suggest crates for /docs when using the docs.rs provider (#16169)
This PR improves the initial experience of using `/docs docs-rs` with an
empty index.

We now show a brief explainer of what is expected (a crate name) as well
as list some popular Rust crates to try:

<img width="540" alt="Screenshot 2024-08-13 at 12 25 39 PM"
src="https://github.com/user-attachments/assets/942de250-2901-45df-9e3e-52ff3b3fc517">

Release Notes:

- N/A
2024-08-13 12:37:13 -04:00
张小白
03796e79b0
repl: Don't show cmd window on Windows (#16016)
Closes #15955 .

Release Notes:

- Fixed `cmd` window showing when repl executing
commands([#15955](https://github.com/zed-industries/zed/issues/15955) ).
2024-08-13 09:12:42 -07:00
Piotr Osiewicz
fa51651d06
assistant: Fix debug inspector removing workflow step it's applied to (#16166)
Debug inspector broke immediately after merge as #16036 landed in
parallel; one of the changes of that PR is removing any steps whose
content was edited, which is what debug inspector happened to do. The
fix is to make the edit right past the step block.


Release Notes:

- N/A
2024-08-13 18:01:55 +02:00
Kirill Bulatov
7aed240729
Improve /tabs completion workflow (#16168)
Follow-up of https://github.com/zed-industries/zed/pull/16154

Reworks /tabs arguments to allow:
* current tab by default, if no arguments are present
* fuzzy-matching over paths of the related tabs
* `all` case to insert all tabs at once

Release Notes:

- N/A
2024-08-13 18:40:24 +03:00
Marshall Bowers
7b613cb169
Revert "Remove extra empty space for files when file icons are turned off (#16142) (#16167)
This PR reverts #16142, as it isn't what we want from a design
standpoint.

Having the file names misaligned from the folder names is not the
desired behavior:

<img width="243" alt="Screenshot 2024-08-13 at 11 16 53 AM"
src="https://github.com/user-attachments/assets/12914e89-2641-4932-96c2-00e89e56d6d7">

We can revisit when we have design bandwidth.

This reverts commit ee6a40137f.

Release Notes:

- Reverted #16142.
  - @JosephTLyons @notpeter for release notes curation
2024-08-13 11:37:29 -04:00
Marshall Bowers
8a9c58e515
zed_extension_api: Add HttpRequestBuilder (#16165)
This PR adds an `HttpRequestBuilder` to the extension API to allow for a
more ergonomic way for constructing HTTP requests within extensions.

The HTTP client functionality is now also exposed via the
`zed_extension_api::http_client` module instead of top-level.

Release Notes:

- N/A
2024-08-13 11:12:10 -04:00
Piotr Osiewicz
0dbecee03f
assistant: Refine workflow step labels (#16161)
https://github.com/user-attachments/assets/f6325507-091a-482e-ac28-dd09877ebaa2


Release Notes:

- N/A

---------

Co-authored-by: Danilo <daniloleal09@gmail.com>
2024-08-13 17:08:55 +02:00
Marshall Bowers
82529499df
Fix min and max versions for v0.1.0 of the extension API (#16163)
Missed this in #16158.

Release Notes:

- N/A
2024-08-13 10:40:29 -04:00
Marshall Bowers
4450ebff6b
Allow extensions to control the redirect policy for the HTTP client (#16162)
This PR extends the extension API with support for controlling the
redirect policy used by the HTTP client.

Release Notes:

- N/A
2024-08-13 10:40:21 -04:00
Marshall Bowers
98a2ab0686
zed_extension_api: Bump to v0.1.0 (#16158)
This PR changes v0.0.7 of the extension API to v0.1.0.

We had a false-start in releasing v0.0.7, which has since been yanked,
so we need a new version number. We'll publish v0.1.0 to crates.io once
the Preview build is out tomorrow.

We're incrementing the minor version so that we have some leeway in
putting out patch releases of the crate within a given extension API
release.

Release Notes:

- N/A
2024-08-13 10:04:34 -04:00
Rudolf Kastl
47eed12f77
Update zed.desktop.in to include the MimeType for empty files by default (#15623)
Update zed.desktop.in to include the MimeType for empty files.
Seems to be the default for all "text editors" .desktop files.

Release Notes:

- Improved MimeType list in XDG .desktop file
2024-08-13 16:56:44 +03:00
Marshall Bowers
cade9fbd3d
assistant: Show a better error when /docs is used without a package name (#16157)
This PR makes it so that running `/docs` without providing a package
name gives a better error message:

<img width="248" alt="Screenshot 2024-08-13 at 9 24 58 AM"
src="https://github.com/user-attachments/assets/c1cc794e-0fa0-490a-871a-a56702b03d42">

<img width="228" alt="Screenshot 2024-08-13 at 9 25 05 AM"
src="https://github.com/user-attachments/assets/45dca2d7-171f-48f0-a03c-254b552cb50d">

Release Notes:

- N/A
2024-08-13 09:39:26 -04:00
CharlesChen0823
fe190359d5
editor: Add revert file action to command palette (#16012)
Release Notes:

- Added an `editor::RevertFile` action
2024-08-13 14:44:41 +03:00
张小白
ac6bff12b9
windows: Remove unused dependencies (#15857)
I have removed some unused dependencies, reducing the total number of
packages during the build from 1141 to 1112. This should slightly
decrease the build time.

![Screenshot 2024-08-06
230726](https://github.com/user-attachments/assets/58a49fd4-4a0a-4026-b6b7-79b95529ec74)


Release Notes:

- N/A
2024-08-13 13:31:02 +03:00
Kirill Bulatov
081cbcebd9
Merge /active command into /tabs one (#16154)
Now, tabs have arguments, `active` (default, applied also for no
arguments case) and `all` to insert the active tab only or all tabs.

Release Notes:

- N/A
2024-08-13 13:15:57 +03:00
Stanislav Alekseev
c2b254a67a
Fallback to using tree-sitter when determining ranges for info popovers (#16062)
Closes #15382

Release Notes:

- Added fallback to a smallest tree sitter node when hovering over a
symbol
2024-08-13 12:01:14 +02:00
Thorsten Ball
af36d4934c
assistant panel: Animate assistant label if message is pending (#16152)
This adds a pulsating effect to the assistant header in case the message
is pending.

The pulsating effect is capped between 0.2 and 1.0 and I tried (with the
help of Claude) to give it a "breathing" effect, since I found the
normal bounce a bit too much.

Also opted for setting the `alpha` on the `LabelLike` things, vs.
overwriting the color, since I think that's cleaner instead of exposing
the color and mutating that.


https://github.com/user-attachments/assets/4a94a1c5-8dc7-4c40-b30f-d92d112db7b5


Release Notes:

- N/A
2024-08-13 11:41:44 +02:00
Kirill Bulatov
b36d1386a9
Fix editor::Cancel action not inline assistant inputs created for empty selections (#16150)
Release Notes:

- N/A
2024-08-13 12:11:57 +03:00
Uladzislau Kaminski
ee6a40137f
Remove extra empty space for files when file icons are turned off (#16142)
Closes #16073

<img width="269" alt="image" src="https://github.com/user-attachments/assets/88b7ff9f-17ec-4764-b37a-c218d7ad14ec">

Release Notes:

- Removed extra empty space for files when file icons are turned off ([#16073](https://github.com/zed-industries/zed/issues/16073))
2024-08-13 12:09:13 +03:00
Nathan Sobo
1c189e82a0
Improve tooltip text (#16147)
![image](https://github.com/user-attachments/assets/90faf9ce-0515-4a99-92ca-c69b17b5149e)

Release Notes:

- Include a count of the context tokens when hovering token counts in
the inline assist.
2024-08-12 23:24:27 -06:00
Nathan Sobo
a515442a36
Rely on model to determine indentation level and always rewrite the full line (#16145)
This PR simplifies our approach to indentation in the inline assistant
in hopes of improving our experience for Python. We tell the model to
generate the correct indentation in the prompt, and always start
generating at the start of the line. This may fall down for less capable
models, but I want to get a solid experience on the best models and then
figure the rest out later.

Also: We now prefer `./assets/prompts` as an overrides directory when
stdout is a PTY, so you can do `cargo run` and then iterate prompts for
the current run inside the current working copy.

cc @trishume @dsp-ant 

Release Notes:

- Zed now allows the model to control indentation when performing inline
transformation. We're hoping this improves the indentation experience in
Python and other indentation-sensitive languages, but it does require
more from the model.

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-08-12 22:41:24 -06:00
Marshall Bowers
b4c22cc861
collab: Add ability to revoke LLM service access tokens (#16143)
This PR adds the ability to revoke access tokens for the LLM service.

There is a new `revoked_access_tokens` table that contains the
identifiers (`jti`) of revoked access tokens.

To revoke an access token, insert a record into this table:

```sql
insert into revoked_access_tokens (jti) values ('1e887b9e-37f5-49e8-8feb-3274e5a86b67');
```

We now attach the `jti` as `authn.jti` to the tracing spans so that we
can associate an access token with a given request to the LLM service.

Release Notes:

- N/A
2024-08-12 21:47:05 -04:00
Piotr Osiewicz
0bc9fc9487
assistant: Slash command tweaks (#16140)
Release Notes:

- N/A
2024-08-13 02:34:03 +02:00
Max Brunsfeld
dbcd06642c
Track lifetime spending for each user and model (#16137)
Release Notes:

- N/A

Co-authored-by: Marshall <marshall@zed.dev>
2024-08-12 20:15:26 -04:00
Piotr Osiewicz
68ae347077
chore: Remove a bunch of unused structs (#16139)
Found by beta clippy.

Release Notes:

- N/A
2024-08-13 01:43:19 +02:00
Marshall Bowers
8a148f3a13
Add feature-flagged access to LLM service (#16136)
This PR adds feature-flagged access to the LLM service.

We've repurposed the `language-models` feature flag to be used for
providing access to Claude 3.5 Sonnet through the Zed provider.

The remaining RPC endpoints that were previously behind the
`language-models` feature flag are now behind a staff check.

We also put some Zed Pro related messaging behind a feature flag.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
2024-08-12 18:13:40 -04:00
Kirill Bulatov
3bebb8b401
Allow to cycle through center/top/bot scroll positions (#16134)
On top of `editor::ScrollCursorCenter`, `editor::ScrollCursorTop`,
`editor::ScrollCursorBottom` actions, adds an
`editor::ScrollCursorCenterTopBottom` one, that allows using a single
keybinding to scroll between positions on the screen.

The implementation matches a corresponding Emacs feature: there's a
timeout (1s) that is kept after every switch, to allow continuously
changing the positions, center (initial) -> top -> bottom
Scrolling behavior is the same as the existing actions (e.g. editor will
ignore scroll to bottom, if there's not enough space above).

After 1s, next position is reset to the initial, center, one.


Release Notes:

- Added an `editor::ScrollCursorCenterTopBottom` action for toggling
scroll position with a single keybinding

---------

Co-authored-by: Alex Kladov <aleksey.kladov@gmail.com>
2024-08-13 00:32:30 +03:00
Marshall Bowers
98516b5527
collab: Restrict usage of the LLM service to accounts older than 30 days (#16133)
This PR restricts usage of the LLM service to accounts older than 30
days.

We now store the GitHub user's `created_at` timestamp to check the
GitHub account age. If this is not set—which it won't be for existing
users—then we use the `created_at` timestamp in the Zed database.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
2024-08-12 17:27:21 -04:00
Kirill Bulatov
f398ecc3fb
Allow inserting text into the editor via the action (#16131)
Improves workflows, based on the keymaps that group actions behind a
certain symbol.
E.g.

```json5
", o k": "zed::OpenKeymap",
", o K": "zed::OpenDefaultKeymap",
// other `,`-based keymaps
```

Now, it's possible to do 
```json
", ,": ["editor::HandleInput", ","]
```

and type `,` without waiting for the timeout due to `,`-based bindings.

Release Notes:

- Add an `editor::HandleInput` action to ease typing symbols that are
part of keymaps. E.g. if `, o k` keybinding is bound, `", ,":
["editor::HandleInput", ","]` would allow to type `,` without timeouts.

---------

Co-authored-by: Alex Kladov <aleksey.kladov@gmail.com>
2024-08-13 00:02:52 +03:00
Max Brunsfeld
a3c79218c4
Report telemetry events for rate limit errors (#16130)
clickhouse telemetry schema:

```
CREATE TABLE default.llm_rate_limit_events
(
    `time` DateTime64(3),
    `user_id` Int32,
    `is_staff` Bool,
    `plan` LowCardinality(String),
    `model` String,
    `provider` LowCardinality(String),
    `usage_measure` LowCardinality(String),
    `requests_this_minute` UInt64,
    `tokens_this_minute` UInt64,
    `tokens_this_day` UInt64,
    `max_requests_per_minute` UInt64,
    `max_tokens_per_minute` UInt64,
    `max_tokens_per_day` UInt64,
    `users_in_recent_minutes` UInt64,
    `users_in_recent_days` UInt64
)
ORDER BY tuple()
```

Release Notes:

- N/A

Co-authored-by: Marshall <marshall@zed.dev>
2024-08-12 16:31:11 -04:00
Max Brunsfeld
1674e12ccb
Expose anthropic API errors to the client (#16129)
Now, when an anthropic request is invalid or anthropic's API is down,
we'll expose that to the user instead of just returning a generic 500.

Release Notes:

- N/A

Co-authored-by: Marshall <marshall@zed.dev>
2024-08-12 13:11:48 -07:00
Marshall Bowers
f3ec8d425f
collab: Use a separate Anthropic API key for Zed staff (#16128)
This PR makes it so Zed staff can use a separate Anthropic API key for
the LLM service.

We also added an `is_staff` column to the `usages` table so that we can
exclude staff usage from the "active users" metrics that influence the
rate limits.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
2024-08-12 15:20:34 -04:00