Commit Graph

21331 Commits

Author SHA1 Message Date
Bennet Bo Fenner
821ce2fc7c
assistant panel: Fix panel not reloading after entering credentials (#15531)
This is the revised version of #15527.

We also added new events to notify subscribers when new providers are
added or removed.

Co-Authored-by: Thorsten <thorsten@zed.dev>

Release Notes:

- N/A

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
Co-authored-by: Thorsten Ball <mrnugget@gmail.com>
2024-07-31 14:12:17 +02:00
Kirill Bulatov
a31dba9fc1
Reflect token limit errors and warnings in the assistant panel Send button style (#15529)
When used token count is below 80%, the Send button is displayed as
usual: no tooltip, regular style:


![image](https://github.com/user-attachments/assets/06198869-c49e-4231-b0cb-53b8f678c547)

When it exceeds 80% but below the `max_tokens` threshold, the button
starts to show as a warning, with the corresponding tooltip:

![warning](https://github.com/user-attachments/assets/83b02059-9610-4af7-97c6-9bca14364511)

When it is over the `max_token` threshold, the button starts to show as
an error, with another tooltip:

![error](https://github.com/user-attachments/assets/380d426a-cda9-4479-83e0-e018771291b6)

The buttons are not blocked in any case, in case the token calculation
is wrong, to allow using the assistant panel nonetheless.


Release Notes:

- N/A
2024-07-31 14:37:39 +03:00
Bennet Bo Fenner
380a19fcf2
Revert "assistant panel: Fix entering credentials not updating view" (#15528)
Reverts zed-industries/zed#15527

We broke the assistant panel in the process...

Release Notes:

- N/A
2024-07-31 13:26:27 +02:00
Thorsten Ball
b571bc800d
assistant panel: Fix entering credentials not updating view (#15527)
Co-authored-by: Bennet <bennet@zed.dev>

Release Notes:

- N/A

Co-authored-by: Bennet <bennet@zed.dev>
2024-07-31 12:51:41 +02:00
Thorsten Ball
c78ea0df7e
assistant panel: Ensure we prompt for creds when panel is activated (#15524)
Something seems to have broke on `main` in last few days.

Bug was reproducible like this:

- Open assistant panel
- Choose provider that wasn't authenticated
- See auth prompt
- Close the tab (!) in the assistant panel
- Reactivate the assistant panel
- Bug: panel is blank!

This fixes the bug by consolidating the behavior of checking credentials
and showing auth prompt.

Release Notes:

- N/A
2024-07-31 11:48:31 +02:00
Thorsten Ball
d8f7322725
assistant panel: Show provider name in model selector (#15523)
With zed.dev provider becoming more popular, it helps alleviate
confusion when showing not only the model name but also the provider
name.

Release Notes:

- N/A
2024-07-31 11:05:16 +02:00
apricotbucket28
8e6af73784
x11: Do not check hover state on properties change (#15518)
This fixes an issue where the window's hovered state would be incorrect,
causing the cursor not to update because it would think the window
wasn't hovered ([relevant
check](a03beeeb5b/crates/gpui/src/window.rs (L3016-L3017))).

The code here doesn't really seem to make sense, since there's already
the `XinputEnter` and `XinputLeave` events that indicate mouse focus
state on the window. The properties change event wouldn't necessarily
indicate when mouse focus changes.

Thanks @Emc2356 for reporting this on the Discord and helping figure out
the issue!
 
Release Notes:

- Linux: Fixed the cursor sometimes not changing on X11
2024-07-30 19:02:48 -07:00
Marshall Bowers
2b019ff9e2
collab: Add GET /billing/subscriptions endpoint (#15516)
This PR adds a new `GET /billing/subscriptions` endpoint to collab for
retrieving the subscriptions to display on the account settings page.

Release Notes:

- N/A
2024-07-30 21:17:35 -04:00
Marshall Bowers
a08e020e32
extension: Always use a real HTTP client in the ExtensionBuilder (#15514)
This PR makes it so we always construct a real HTTP client in the
`ExtensionBuilder`.

This used to be the case, but was inadvertently changed in
https://github.com/zed-industries/zed/pull/15470.

Release Notes:

- N/A
2024-07-30 18:04:53 -04:00
Marshall Bowers
a7ffc2b6f3
Show current plan in user menu (#15513)
This PR updates the user menu to show the user's current plan.

Also adds a new RPC message to send this information down to the client
when Zed starts.

This is behind a feature flag.

Release Notes:

- N/A

---------

Co-authored-by: Max <max@zed.dev>
2024-07-30 17:38:16 -04:00
Peter Tripp
161c6ca6a4
terminal: Fix ctrl-a keybind on Linux (#15512)
- Disable Terminal ctrl-a (conflicts with readline).
- Standardize modifier order to use ctrl-shift instead of shift-ctrl to match existing keys.
- Move ctrl-shift-c (collab) to \!Terminal context (fix flickering in terminal right click menu).
- Consolidate two Terminal blocks in linux keybind
2024-07-30 17:18:06 -04:00
Marshall Bowers
7c5f4b72fb
collab: Rework Stripe event processing (#15510)
This PR reworks how we process Stripe events for reconciliation
purposes.

The previous approach in #15480 turns out to not be workable, on account
of the Stripe event IDs not being strictly in order. This meant that we
couldn't reliably compare two arbitrary event IDs and determine which
one was more recent.

This new approach leans on the guidance that Stripe provides for
webhooks events:

> Webhook endpoints might occasionally receive the same event more than
once. You can guard against duplicated event receipts by logging the
[event IDs](https://docs.stripe.com/api/events/object#event_object-id)
you’ve processed, and then not processing already-logged events.
>
> https://docs.stripe.com/webhooks#handle-duplicate-events

We now record processed Stripe events in the `processed_stripe_events`
table and use this to filter out events that have already been
processed, so we do not process them again.

When retrieving events from the Stripe events API we now buffer the
unprocessed events so that we can sort them by their `created` timestamp
and process them in (roughly) the order they occurred.

Release Notes:

- N/A
2024-07-30 16:35:11 -04:00
Bennet Bo Fenner
dca9400edf
assistant: Ensure that zed provider is listed as first option (#15496)
Release Notes:

- N/A
2024-07-30 19:38:52 +02:00
Kirill Bulatov
eedef487ac
Add more context to the terminal assistant (#15492)
Release Notes:

- N/A
2024-07-30 20:21:45 +03:00
Peter Tripp
73e3dfc0c3
Switch editor::AcceptPartialInlineCompletion keybind to match VSCode (#15495)
Release Notes:

- Fixed editor::AcceptPartialInlineCompletion keybind to match VSCode
([#15487](https://github.com/zed-industries/zed/issues/15487)).
2024-07-30 13:12:07 -04:00
Piotr Osiewicz
4bf2826655
Assistant Panel: add keybinds for history and prompt library (#15486)
Release Notes:

- N/A
2024-07-30 17:13:10 +02:00
Jason Lee
1982a5aed1
gpui: Improve img element to support load from Assets (#15482)
Release Notes:

- N/A


Currently, the `img` element provided by GPUI only supports FilePath or
URL, but in actual applications we need to let `img` load an image
embedded in Assets.

The `svg` element can currently support this, but `img` cannot.

For example:

We have such an Assets directory:

```
assets
|- icons
|- images
|--- foo.png
```

```rs
// If give a path, considered an Asset
img("images/foo.png");
// If give a URI, considered a Remote image
img("https://foo.bar/images/foo.png");
// If give a PathBuf, considered a Local file
img(PathBuf::from("path/to/foo.png"));
```


## Example test

```
cargo run -p gpui --example image 
```

<img width="827" alt="image"
src="https://github.com/user-attachments/assets/e45dcf7f-4626-4fb0-aca9-9b6e1045a952">

---------

Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-07-30 10:55:48 -04:00
Antonio Scandurra
99bc90a372
Allow customization of the model used for tool calling (#15479)
We also eliminate the `completion` crate and moved its logic into
`LanguageModelRegistry`.

Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
2024-07-30 16:18:53 +02:00
Kirill Bulatov
1bfea9d443
Show "full" paths in the /file command output (#15483)
Same as /tabs command outputs them

Before:
![Screenshot 2024-07-30 at 16 52
11](https://github.com/user-attachments/assets/acf1c79e-4607-41fc-bd5e-b20dc668eff4)

![Screenshot 2024-07-30 at 16 52
03](https://github.com/user-attachments/assets/dd7fa42f-3ba8-4f1c-9420-2a0246df64b7)

After:
![Screenshot 2024-07-30 at 16 53
16](https://github.com/user-attachments/assets/ee866ecb-2142-4303-9385-c6b856310d43)

![Screenshot 2024-07-30 at 16 53
21](https://github.com/user-attachments/assets/d42b9c77-d5e9-4aaf-8de9-3b160078e622)


Release Notes:

- N/A
2024-07-30 17:03:16 +03:00
Marshall Bowers
b160e13f20
collab: Keep track of last seen Stripe event for each record (#15480)
This PR improves our Stripe event handling by keeping track of the last
event we've seen for each record.

The `billing_customers` and `billing_subscriptions` tables both have a
new `last_stripe_event_id` column. When we apply an event to one of
these records, we store the event ID that was applied.

Then, when we are going through events we can ignore any event that has
an ID that came before the `last_stripe_event_id` (based on the
lexicographical ordering of the IDs).

Release Notes:

- N/A
2024-07-30 10:00:16 -04:00
Bennet Bo Fenner
2ada2964c5
assistant: Make it easier to define custom models (#15442)
This PR makes it easier to specify custom models for the Google, OpenAI,
and Anthropic provider:

Before (google):

```json
{
  "language_models": {
    "google": {
      "available_models": [
        {
          "custom": {
            "name": "my-custom-google-model",
            "max_tokens": 12345
          }
        }
      ]
    }
  }
}
```

After (google):

```json
{
  "language_models": {
    "google": {
      "available_models": [
        {
          "name": "my-custom-google-model",
          "max_tokens": 12345
        }
      ]
    }
  }
}
```

Before (anthropic):

```json
{
  "language_models": {
    "anthropic": {
      "available_models": [
        {
          "custom": {
            "name": "my-custom-anthropic-model",
            "max_tokens": 12345
          }
        }
      ]
    }
  }
}
```

After (anthropic):

```json
{
  "language_models": {
    "anthropic": {
      "version": "1",
      "available_models": [
        {
          "name": "my-custom-anthropic-model",
          "max_tokens": 12345
        }
      ]
    }
  }
}

```

The settings will be auto-upgraded so the old versions will continue to
work (except for Google since that one has not been released).

/cc @as-cii 

Release Notes:

- N/A

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
2024-07-30 15:46:39 +02:00
Santeri Salmijärvi
13dcb42c1c
Change PathLikeWithPosition<P> into a non-generic type and replace ad-hoc Windows path parsing (#15373)
This simplifies `PathWithPosition` by making the common use case
concrete and removing the manual, incomplete Windows path parsing.
Windows paths also don't get '/'s replaced by '\\'s anymore to limit the
responsibility of the code to just parsing out the suffix and creating
`PathBuf` from the rest. `Path::file_name()` is now used to extract the
filename and potential suffix instead of manual parsing from the full
input. This way e.g. Windows paths that begin with a drive letter are
handled correctly without platform-specific hacks.

Release Notes:

- N/A
2024-07-30 16:39:33 +03:00
Thorsten Ball
41c550cbe1
assistant panel: Avoid auth prompt on provider switch (#15478)
Previously, the following lead to a bug:

1. Set OpenAI key
2. Switch to Anthropic
3. Restart Zed
4. Switch provider to OpenAI -> get prompted for authentication prompt

With this change, you won't get prompted for the OpenAI key again.

Release Notes:

- N/A

Co-authored-by: Bennet <bennet@zed.dev>
2024-07-30 14:25:02 +02:00
Piotr Osiewicz
21ebbc387a
Inline Assist: replace "accept" action on generation error with "restart" (#15476)
Release Notes:

- N/A
2024-07-30 13:40:22 +02:00
Piotr Osiewicz
530feecdaa
tab_switcher: Add support for tab switcher in assistant panel (#15475)
Additionally, I've generalized the implementation of tab switcher so
that - instead of explicitly listing panels it supports (at the time of
writing it was just the terminal panel and nothing else), it now relies
on Panel::pane trait method. As long as that's implemented, you get a
tab switcher support for free.

Release Notes:

- Added support for tab switcher in Assistant panel.
2024-07-30 13:32:13 +02:00
Bennet Bo Fenner
0540291204
settings: Introduce PRESERVED_KEYS to write default values (#15474)
This adds the optional `PRESERVED_KEYS` constant to the `Settings`
trait,
which allows users of the trait to specify which keys should be written
to
the settings file, even if their current value matches the default
value.

That's useful for tagged settings that have, for example, a `"version"`
field
that should always be present in the user settings file, so we can then
reparse
the user settings based on the version.

Co-Authored-By: Thorsten <thorsten@zed.dev>

Release Notes:

- N/A

---------

Co-authored-by: Thorsten <thorsten@zed.dev>
2024-07-30 13:09:50 +02:00
Antonio Scandurra
fa19bc98ac
Provide user agent when performing HTTP requests (#15470)
Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
2024-07-30 11:12:37 +02:00
Bennet Bo Fenner
2a649fa824
language model: Fix missing use_tool method in CopilotChatLanguageModel (#15466)
Broke CI after merging #14842 

Release Notes:

- N/A

Co-authored-by: Thorsten <thorsten@zed.dev>
2024-07-30 09:54:42 +02:00
Jason Lee
0c8b17d252
Hide blinking cursor when window is deactivated (#15408)
## Before 

https://github.com/user-attachments/assets/affb8407-a20e-4258-a8f7-b271da5d7b77

## After

https://github.com/user-attachments/assets/654fe7b9-330a-40c8-8885-72e69fa85b0a

Release Notes:

- Hide blinking cursor when window is deactivated ([4710](https://github.com/zed-industries/zed/issues/4710))
2024-07-30 10:49:15 +03:00
Ryan Hawkins
6f0655810e
Add GitHub Copilot Chat Support (#14842)
# Summary

This commit implements Github Copilot Chat support within the existing
Assistant panel/framework. It required a little bit of trickery and
internal API modification, as Copilot doesn't use the same
authentication-style as all of the existing providers, opting to use
OAuth and a short lived API key instead of a straight API key. All
existing Assistant features should work.

Release Notes:
- Added Github Copilot Chat support
([#4673](https://github.com/zed-industries/zed/issues/4673)).

## Screenshots
<img width="1552" alt="A screenshot showing a conversation between a
user and Github Copilot Chat within the Zed editor."
src="https://github.com/user-attachments/assets/73eaf6a2-792b-4c40-a7fe-f763bd6417d7">

---------

Co-authored-by: Bennet Bo Fenner <bennet@zed.dev>
2024-07-30 09:32:58 +02:00
Marshall Bowers
d93891ba63
collab: Lay groundwork for reconciling with Stripe using the events API (#15459)
This PR lays the initial groundwork for using the Stripe events API to
reconcile the data in our system with what's in Stripe.

We're using the events API over webhooks so that we don't need to stand
up the associated infrastructure needed to handle webhooks effectively
(namely an asynchronous job queue).

Since we haven't configured the Stripe API keys yet, we won't actually
spawn the reconciliation background task yet, so this is currently a
no-op.

Release Notes:

- N/A
2024-07-29 23:50:07 -04:00
Marshall Bowers
28c14cdee4
collab: Add separate billing_customers table (#15457)
This PR adds a new `billing_customers` table to hold the billing
customers.

Previously we were storing both the `stripe_customer_id` and
`stripe_subscription_id` in the `billable_subscriptions` table. However,
this creates problems when we need to correlate subscription events back
to the subscription record, as we don't know the user that the Stripe
event corresponds to.

By moving the `stripe_customer_id` to a separate table we can create the
Stripe customer earlier in the flow—before we create the Stripe Checkout
session—and associate that customer with a user. This way when we
receive events down the line we can use the Stripe customer ID to
correlate it back to the user.

We're doing some destructive actions to the `billing_subscriptions`
table, but this is fine, as we haven't started using them yet.

Release Notes:

- N/A
2024-07-29 22:48:21 -04:00
Marshall Bowers
66121fa0e8
collab: Add endpoint for managing a billing subscription (#15455)
This PR adds a new `POST /billing/subscriptions/manage` endpoint that
can be used to manage a billing subscription.

The endpoint accepts a `github_user_id` to identify the user, as well as
an optional `subscription_id` for managing a specific subscription. If
`subscription_id` is not provided, it try and use the active
subscription, if there is only one.

Right now the endpoint only supports cancelling an active subscription.
This is done by passing `"intent": "cancel"` in the request body.

The endpoint will return the URL to a Stripe customer portal session,
which the caller can redirect the user to.

Here's an example of how to call it:

```sh
curl -X POST "http://localhost:8080/billing/subscriptions/manage" \
     -H "Authorization: <ADMIN_TOKEN>" \
     -H "Content-Type: application/json" \
     -d '{"github_user_id": 12345, "intent": "cancel"}'
```

Release Notes:

- N/A
2024-07-29 20:05:17 -04:00
Peter Tripp
4d8ad7ae42
docs: Update youtube link to new @zeddotdev channel name (#15453) 2024-07-29 17:55:35 -04:00
Marshall Bowers
e15d59c445
collab: Add endpoint for initiating a billing subscription (#15452)
This PR adds a new `POST /billing/subscriptions` endpoint that can be
used to initiate a billing subscription.

The endpoint will use the provided `github_user_id` to look up a user,
generate a Stripe Checkout session, and then return the URL.

The caller would then redirect the user to the URL to initiate the
checkout flow.

Here's an example of how to call it:

```sh
curl -X POST "http://localhost:8080/billing/subscriptions" \
     -H "Authorization: <ADMIN_TOKEN>" \
     -H "Content-Type: application/json" \
     -d '{"github_user_id": 12345}'
```

Release Notes:

- N/A
2024-07-29 17:31:36 -04:00
Kyle Kelley
8bb34fd93e
repl: Log Jupyter kernel process stderr and stdout (#15391)
Super simple piping of logs from the Jupyter kernels to the Zed logs.

Release Notes:

- Added logging of stderr from Jupyter kernels to the Zed logs
2024-07-29 14:23:35 -07:00
Antonio Scandurra
02c51c9b56
Fix rendering of focused offscreen block when scrolled to bottom (#15449)
This change fixes a bug when a block is focused but offscreen.
Previously, we used the last row, but this caused a spurious block to be
rendered when scrolled to the end of the file. With this change we
always render off-screen blocks below the editor's clipping box.

Release Notes:

- Fixed a bug that caused the inline assistant to be displayed twice in
certain circumstances.

Co-authored-by: Nathan <nathan@zed.dev>
2024-07-29 20:39:21 +02:00
Marshall Bowers
085d41b121
collab: Add billing_subscriptions table (#15448)
This PR adds a new `billing_subscriptions` table to the database, as
well as some accompanying models/queries.

In this table we store a minimal amount of data from Stripe:

- The Stripe customer ID
- The Stripe subscription ID
- The status of the Stripe subscription

This should be enough for interactions with the Stripe API (e.g., to
[create a customer portal
session](https://docs.stripe.com/api/customer_portal/sessions/create)),
as well as determine whether a subscription is active (based on the
`status`).

Release Notes:

- N/A
2024-07-29 14:32:13 -04:00
Joseph T. Lyons
0702ed5cd6
Add is_staff and destination to download events (#15445)
Release Notes:

- N/A
2024-07-29 14:21:29 -04:00
Antonio Scandurra
2b871a631a
Use fuzzy-matching to locate symbols when resolving edit steps (#15447)
Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
2024-07-29 20:21:19 +02:00
Michael Angerman
5e1aa898d4
workspace: Remove unused code (#15440)
Release Notes:

- N/A
2024-07-29 12:12:10 -04:00
Marshall Bowers
aa1633ba40
assistant: Allow guests to create new contexts on the host (#15439)
This PR extends collaboration in the Assistant to allow guests to create
new contexts on the host when collaborating.

Release Notes:

- N/A
2024-07-29 12:01:09 -04:00
Thorsten Ball
2b0c60043d
file finder: Fix ./ breaking new-path prompt (#15438)
Fixes #15426.

The `./` was implicitly assumed to be there by the prompt, so we'd end
up with `././foobar` when typing in an explicit `./`.

This fixes the issue by stripping `./` from the query, like we also
strip `/`.

Release Notes:

- Fixed paths starting with `./` breaking the new-path file picker when
the system prompts are disabled.
([#15426](https://github.com/zed-industries/zed/issues/15426)).
2024-07-29 17:46:52 +02:00
Bennet Bo Fenner
0b4afe518b
assistant: Remove feature flag for terminal inline assistant (#15432)
This PR removes the feature flag for the terminal inline assistant,
making it available to everyone.

Release Notes:

- Use Ctrl+Enter to summon the inline assistant in the terminal, which
let's you generate terminal commands based on your description
([demo](https://twitter.com/thorstenball/status/1814241447383605329))
2024-07-29 17:37:11 +02:00
Suhun Han
f124ca6474
project_panel: Double-click on blank space in project panel to create a new file (#15353)
Similar feature implemented in VSCode.


https://github.com/user-attachments/assets/ae250b5f-283c-4211-8947-d5d5703eb2d0


Release Notes:

- Added double-click to create a new file when clicking on blank space
in the project panel.
2024-07-29 18:33:13 +03:00
Peter Tripp
b8f20053d8
docs: Remove availability via homebrew on Linux (linuxbrew) (#15437)
- See: https://github.com/zed-industries/zed/issues/14108
2024-07-29 11:31:35 -04:00
Conrad Irwin
6db33b83d8
vim: Fix >... (#15404)
Co-Authored-By: @Alextopher

Release Notes:

- vim: Fixed a hang when repeating an aborted operation
([#15399](https://github.com/zed-industries/zed/issues/15399)).
2024-07-29 09:22:25 -06:00
Thorsten Ball
f58ef9b82b
zed: Persist window stack order across restarts (#15419)
This changes the workspace/session serialization to also persist the
order of windows across restarts.

Release Notes:

- Improved restoring of windows across restarts: the order of the
windows is now also restored. That means windows that were in the
foreground when Zed was quit will be in the foreground after restart.
(Right now only supported on Linux/X11, not on Linux/Wayland.)

Demo:



https://github.com/user-attachments/assets/0b8162f8-f06d-43df-88d3-c45d8460fb68
2024-07-29 17:05:56 +02:00
Antonio Scandurra
6e1f7c6e1d
Use tool calling instead of XML parsing to generate edit operations (#15385)
Release Notes:

- N/A

---------

Co-authored-by: Nathan <nathan@zed.dev>
2024-07-29 16:42:08 +02:00
Bennet Bo Fenner
f6012cd86e
assistant: Improve discoverability of terminal inline assist (#15431)
This adds a button to the terminal tab bar:

<img width="444" alt="image"
src="https://github.com/user-attachments/assets/71baadae-0ecf-493f-853c-34d4d6a48310">


Release Notes:

- N/A
2024-07-29 15:38:25 +02:00