Commit Graph

14 Commits

Author SHA1 Message Date
Antonio Scandurra
8944af7406
Lay the groundwork for collaborating on assistant panel (#13991)
This pull request introduces collaboration for the assistant panel by
turning `Context` into a CRDT. `ContextStore` is responsible for sending
and applying operations, as well as synchronizing missed changes while
the connection was lost.

Contexts are shared on a per-project basis, and only the host can share
them for now. Shared contexts can be accessed via the `History` tab in
the assistant panel.

<img width="1819" alt="image"
src="https://github.com/zed-industries/zed/assets/482957/c7ae46d2-cde3-4b03-b74a-6e9b1555c154">


Please note that this doesn't implement following yet, which is
scheduled for a subsequent pull request.

Release Notes:

- N/A
2024-07-10 17:36:22 +02:00
Marshall Bowers
68accaeb00
assistant: Improve /docs argument completions (#13876)
This PR improves the completions for arguments in the `/docs` slash
command.

We achieved this by extending the `complete_argument` method on the
`SlashCommand` trait to return a `Vec<ArgumentCompletion>` instead of a
`Vec<String>`.

In addition to the completion `label`, `ArgumentCompletion` has two new
fields that are can be used to customize the completion behavior:

- `new_text`: The actual text that will be inserted when the completion
is accepted, which may be different from what is shown by the completion
label.
- `run_command`: Whether the command is run when the completion is
accepted. This can be set to `false` to allow accepting a completion
without running the command.

Release Notes:

- N/A

---------

Co-authored-by: Antonio <antonio@zed.dev>
2024-07-05 13:29:17 -04:00
Bennet Bo Fenner
04a79780d8
assistant: Include worktree name in diagnostics slash command (#13354)
Files included with the diagnostics command now include the worktree
name, making it more consistent with the way other commands work
(`/active`, `/tabs`, `/file`). Also, the diagnostics command will now
insert nothing when there are no diagnostics.

Release Notes:

- N/A
2024-06-21 11:48:52 +02:00
Marshall Bowers
db0d843fb1
Allow completing slash command arguments from extensions (#13240)
This PR extends the extension API with support for completing slash
command arguments for slash commands defined in extensions.

Release Notes:

- N/A
2024-06-18 17:58:57 -04:00
Antonio Scandurra
e4ba336971
Preserve sections generated by slash commands when reloading a context (#13199)
Release Notes:

- N/A
2024-06-18 14:49:53 +02:00
Antonio Scandurra
27e9c68988
Autocomplete commands that don't require access to workspace in prompt library (#12674)
This is useful to autocomplete prompts when writing a new one in the
prompt library.

Release Notes:

- N/A
2024-06-05 10:07:43 +02:00
Antonio Scandurra
c5b22eee2d
Polish prompt library UX (#12647)
This could still use some improvement UI-wise but the user experience
should be a lot better.

- [x] Show in "Window" application menu
- [x] Load prompt as it's selected in the picker
- [x] Refocus picker on `esc`
- [x] When creating a new prompt, if a new prompt already exists and is
unedited, activate it instead
- [x] Add `/default` command
- [x] Evaluate /commands on prompt insertion
- [x] Autocomplete /commands (but don't evaluate) during prompt editing
- [x] Show token count using the settings model, right-aligned in the
editor
- [x] Picker 
- [x] Sorted alpha
- [x] 2 sublists
    - Default
        - Empty state: Star a prompt to add it to your default prompt
        - Otherwise show prompts with star on hover
    - All
        - Move prompts with star on hover

Release Notes:

- N/A
2024-06-04 18:36:54 +02:00
Antonio Scandurra
a259042f92
Make slash commands more discoverable (#12480)
<img width="648" alt="image"
src="https://github.com/zed-industries/zed/assets/482957/a63df904-fbbe-4e0a-80b2-c98ebee90690">

Release Notes:

- N/A

Co-authored-by: Nathan <nathan@zed.dev>
2024-05-30 16:45:05 +02:00
Antonio Scandurra
66affa969a
Show recently-opened files when autocompleting /file without arguments (#12434)
<img width="1588" alt="image"
src="https://github.com/zed-industries/zed/assets/482957/ea63b046-64d6-419e-8135-4863748b58fa">


Release Notes:

- N/A
2024-05-29 17:46:18 +02:00
Antonio Scandurra
a0644ac601
Allow specifying a custom limit for /search results (#12423)
<img width="497" alt="image"
src="https://github.com/zed-industries/zed/assets/482957/94e94326-fb3c-4f9b-b4d9-7dd6f6f8d537">


e.g.

```
/search --9 foobar
```

Release Notes:

- N/A
2024-05-29 14:11:05 +02:00
Antonio Scandurra
59662fbeb6
Introduce /search command to assistant (#12372)
This pull request introduces semantic search to the assistant using a
slash command:


https://github.com/zed-industries/zed/assets/482957/62f39eae-d7d5-46bf-a356-dd081ff88312

Moreover, this also adds a status to pending slash commands, so that we
can show when a query is running or whether it failed:

<img width="1588" alt="image"
src="https://github.com/zed-industries/zed/assets/482957/e8d85960-6275-4552-a068-85efb74cfde1">

I think this could be better design-wise, but seems like a pretty good
start.

Release Notes:

- N/A
2024-05-28 16:06:09 +02:00
Antonio Scandurra
7e3ab9acc9
Rework context insertion UX (#12360)
- Confirming a completion now runs the command immediately
- Hitting `enter` on a line with a command now runs it
- The output of commands gets folded away and replaced with a custom
placeholder
- Eliminated ambient context

<img width="1588" alt="image"
src="https://github.com/zed-industries/zed/assets/482957/b1927a45-52d6-4634-acc9-2ee539c1d89a">

Release Notes:

- N/A

---------

Co-authored-by: Nathan Sobo <nathan@zed.dev>
2024-05-27 17:44:54 -06:00
Marshall Bowers
82f5f36422
Allow defining slash commands in extensions (#12255)
This PR adds initial support for defining slash commands for the
Assistant from extensions.

Slash commands are defined in an extension's `extension.toml`:

```toml
[slash_commands.gleam-project]
description = "Returns information about the current Gleam project."
requires_argument = false
```

and then executed via the `run_slash_command` method on the `Extension`
trait:

```rs
impl Extension for GleamExtension {
    // ...

    fn run_slash_command(
        &self,
        command: SlashCommand,
        _argument: Option<String>,
        worktree: &zed::Worktree,
    ) -> Result<Option<String>, String> {
        match command.name.as_str() {
            "gleam-project" => Ok(Some("Yayyy".to_string())),
            command => Err(format!("unknown slash command: \"{command}\"")),
        }
    }
}
```

Release Notes:

- N/A
2024-05-24 15:44:32 -04:00
Marshall Bowers
8040e43520
Extract SlashCommand trait from assistant (#12252)
This PR extracts the `SlashCommand` trait (along with the
`SlashCommandRegistry`) from the `assistant` crate.

This will allow us to register slash commands from extensions without
having to make `extension` depend on `assistant`.

Release Notes:

- N/A
2024-05-24 13:03:41 -04:00