Commit graph

1810 commits

Author SHA1 Message Date
Marshall Bowers
c709b66f35
collab: Don't record billing events if billing is not enabled (#19102)
This PR adjusts the billing logic to not write any records to
`billing_events` if:

- The user is staff, as we don't want to bill staff members
- Billing is disabled (we currently enable billing based on the presence
of the Stripe API key)

Release Notes:

- N/A
2024-10-11 17:54:10 -04:00
Richard Feldman
12c9f0f723
Test some billing events logic (#19094)
Release Notes:

- N/A

Co-authored-by: Marshall <marshall@zed.dev>
2024-10-11 16:21:21 -04:00
Marshall Bowers
f280b29859
collab: Make the StripeBilling object long-lived (#19090)
This PR makes the `StripeBilling` object long-lived so that we can make
better use of the cached data on it.

We now hold it on the `AppState` and spawn a background task to
initialize the cache on startup.

Release Notes:

- N/A

Co-authored-by: Richard <richard@zed.dev>
2024-10-11 15:15:08 -04:00
Marshall Bowers
f33b8abc72
collab: Sort LLM database ID types (#19083)
This PR sorts the order of the LLM database ID type declarations.

Release Notes:

- N/A
2024-10-11 13:57:48 -04:00
Marshall Bowers
22ea7cef7a
collab: Add usage-based billing for LLM interactions (#19081)
This PR adds usage-based billing for LLM interactions in the Assistant.

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Richard <richard@zed.dev>
Co-authored-by: Richard Feldman <oss@rtfeldman.com>
2024-10-11 13:36:54 -04:00
Thorsten Ball
b75532fad7
ssh remote: Handle disconnect on project and show overlay (#19014)
Demo:



https://github.com/user-attachments/assets/e5edf8f3-8c15-482e-a792-6eb619f83de4


Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
2024-10-10 12:59:09 +02:00
Kirill Bulatov
5841ac406d
Fix the completions being too slow (#19013)
Closes https://github.com/zed-industries/zed/issues/19005

Release Notes:

- Fixed completion items inserted with a delay
([#19005](https://github.com/zed-industries/zed/issues/19005))

---------

Co-authored-by: Antonio Scandurra <antonio@zed.dev>
2024-10-10 12:53:02 +03:00
Marshall Bowers
cae548a50d
collab: Fix issues with syncing LLM usage to Stripe (#18970)
This PR fixes some issues with our previous approach to synching LLM
usage over to Stripe.

We now have a separate LLM access price in Stripe that is a marker price
to allow us to create the initial subscription with that as its
subscription item

We then dynamically set the LLM usage price during the reconciliation
sync based on the usage for the current month.

Release Notes:

- N/A

---------

Co-authored-by: Antonio <antonio@zed.dev>
Co-authored-by: Richard <richard@zed.dev>
2024-10-09 19:15:38 -04:00
Marshall Bowers
69711660ab
collab: Make LLM billing fields required in LlmTokenClaims (#18959)
This PR makes the `has_llm_subscription` and
`max_monthly_spend_in_cents` fields in the `LlmTokenClaims` required.

This change will be safe to deploy in ~45 minutes.

Release Notes:

- N/A
2024-10-09 18:42:22 -04:00
Marshall Bowers
3db789ed90
collab: Include max monthly spend preference in LLM token (#18955)
This PR updates the LLM token claims to include the maximum monthly
spend.

Release Notes:

- N/A
2024-10-09 17:39:34 -04:00
Marshall Bowers
d316577fd5
collab: Add billing preferences for maximum LLM monthly spend (#18948)
This PR adds a new `billing_preferences` table.

Right now there is a single preference: the maximum monthly spend for
LLM usage.

Release Notes:

- N/A

---------

Co-authored-by: Richard <richard@zed.dev>
2024-10-09 16:29:07 -04:00
Kirill Bulatov
49c75eb062
Rework remote task synchronization (#18746)
Reworks the way tasks are stored, accessed and synchronized in the
`project`.
Now both collab and ssh remote projects use the same TaskStorage kind to
get the task context from the remote host, and worktree task templates
are synchronized along with other worktree settings.

Release Notes:

- Adds ssh support to tasks, improves collab-remote projects' tasks sync
2024-10-09 22:28:42 +03:00
Marshall Bowers
f1053ff525
collab: Clarify naming around free tier spending limits (#18936)
This PR renames the `MONTHLY_SPENDING_LIMIT` constant to
`FREE_TIER_MONTHLY_SPENDING_LIMIT` to clarify it.

This will help distinguish it from the user's specified limit on their
paid monthly spending.

Release Notes:

- N/A
2024-10-09 15:05:53 -04:00
Marshall Bowers
817a41c4dc
collab: Add a Cents type (#18935)
This PR adds a new `Cents` type that can be used to represent a monetary
value in cents.

This cuts down on the primitive obsession we were using when dealing
with money in the billing code.

Release Notes:

- N/A
2024-10-09 14:22:32 -04:00
Joseph T. Lyons
1cbaca667f
Remove historical_event column in editor events (#18932)
We have a lot of data in Clickhouse. This column was used when migrating
the events dataset between analytics databases and has no purpose today.

Naive maths: 257,170,993 editor event rows * 1 byte per boolean =
257,170,993 bytes, or ~0.24 GB

I'll drop the column after deploying a new collab.

Going forward, I'd like to remove more data that we never touch, to try
to keep things more focused. We should discuss some TTL at some point.

Release Notes:

- N/A
2024-10-09 13:19:13 -04:00
Kirill Bulatov
a62a2fa8f7
Always wait for completion resolve before applying the completion edits (#18907)
After https://github.com/rust-lang/rust-analyzer/pull/18167 and certain
people who type and complete rapidly, it turned out that we have not
waited for `completionItem/resolve` to finish before applying the
completion results.

Release Notes:

- Fixed completion items applied improperly on fast typing
2024-10-09 17:18:20 +03:00
Mikayla Maki
5d5c4b6677
Revert http client changes (#18892)
These proved to be too unstable. Will restore these changes once the issues have been fixed.

Release Notes:

- N/A
2024-10-09 01:07:18 -07:00
Marshall Bowers
801210cd50
collab: Make github_user_login required in LlmTokenClaims (#18882)
This PR makes the `github_user_login` field required in the
`LlmTokenClaims`.

We previously added this in
https://github.com/zed-industries/zed/pull/16316 and made it optional
for backwards-compatibility.

It's been more than long enough for all of the previous LLM tokens to
have expired, so we can now make the field required.

Release Notes:

- N/A
2024-10-08 20:03:33 -04:00
Marshall Bowers
f861479890
collab: Update billing code for LLM usage billing (#18879)
This PR reworks our existing billing code in preparation for charging
based on LLM usage.

We aren't yet exercising the new billing-related code outside of
development.

There are some noteworthy changes for our existing LLM usage tracking:

- A new `monthly_usages` table has been added for tracking usage
per-user, per-model, per-month
- The per-month usage measures have been removed, in favor of the
`monthly_usages` table
- All of the per-month metrics in the Clickhouse rows have been changed
from a rolling 30-day window to a calendar month

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Richard <richard@zed.dev>
Co-authored-by: Max <max@zed.dev>
2024-10-08 18:29:38 -04:00
Marshall Bowers
3f2de172ae
collab: Set cached token values when initially creating lifetime usage records (#18865)
This PR fixes an issue where we weren't setting the cached token fields
when initially creating a lifetime usage record.

Release Notes:

- N/A
2024-10-08 13:16:17 -04:00
Joseph T. Lyons
77bf2ad0f1
Add is_via_ssh field to edit events (#18867)
Release Notes:

- N/A
2024-10-08 13:13:40 -04:00
Joseph T. Lyons
d295c46433
Remove deprecated copilot event (#18862)
`CopilotEvent` was succeeded by `InlineCompletionEvent` 5 months ago.

Release Notes:

- N/A
2024-10-08 11:10:20 -04:00
Joseph T. Lyons
4c7a6f5e7f
Add is_via_ssh field to editor events (#18837)
Release Notes:

- N/A
2024-10-08 10:30:04 -04:00
Marshall Bowers
3c91184726
collab: Drop mistakenly-added columns from the usages table (#18835)
This PR drops the `cache_creation_input_tokens_this_month ` and
`cache_read_input_tokens_this_month ` columns from the `usages` table in
the LLM database.

We mistakenly added these in #18834, but these aren't necessary due to
the structure of the `usages` table. We weren't actually using these
columns anywhere.

Release Notes:

- N/A
2024-10-07 18:21:48 -04:00
Marshall Bowers
d55f025906
collab: Track cache writes/reads in LLM usage (#18834)
This PR extends the LLM usage tracking to support tracking usage for
cache writes and reads for Anthropic models.

Release Notes:

- N/A

---------

Co-authored-by: Antonio Scandurra <me@as-cii.com>
Co-authored-by: Antonio <antonio@zed.dev>
2024-10-07 17:32:49 -04:00
Thorsten Ball
c03b8d6c48
ssh remoting: Enable reconnecting after connection losses (#18586)
Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
2024-10-07 11:40:59 +02:00
Marshall Bowers
6f4385e737
Sort dependencies in Cargo.toml files (#18657)
This PR sorts the dependencies in various `Cargo.toml` files after
#18414.

Release Notes:

- N/A
2024-10-02 16:26:48 -04:00
Marshall Bowers
9565a90528
collab: Revert changes to Clickhouse event rows (#18654)
This PR reverts the changes to the Clickhouse event rows that were
included in https://github.com/zed-industries/zed/pull/18414.

The changes don't seem to be correct, as they make the row structs
differ from the underlying table schema.

Release Notes:

- N/A
2024-10-02 16:10:25 -04:00
Conrad Irwin
3a5deb5c6f
Replace isahc with async ureq (#18414)
REplace isahc with ureq everywhere gpui is used.

This should allow us to make http requests without libssl; and avoid a
long-tail of panics caused by ishac.

Release Notes:

- (potentially breaking change) updated our http client

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-10-02 12:30:48 -07:00
Kirill Bulatov
778dedec6c
Prepare to sync other kinds of settings (#18616)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
This PR does not change how things work for settings, but lays the
ground work for the future functionality.
After this change, Zed is prepared to sync more than just
`settings.json` files from local worktree and user config.

* ssh tasks

Part of this work is to streamline the task sync mechanism.
Instead of having an extra set of requests to fetch the task contents
from the server (as remote-via-collab does now and does not cover all
sync cases), we want to reuse the existing mechanism for synchronizing
user and local settings.

* editorconfig

Part of the task is to sync .editorconfig file changes to everyone which
involves sending and storing those configs.


Both ssh (and remove-over-collab) .zed/tasks.json and .editorconfig
files behave similar to .zed/settings.json local files: they belong to a
certain path in a certain worktree; may update over time, changing Zed's
functionality; can be merged hierarchically.
Settings sync follows the same "config file changed -> send to watchers
-> parse and merge locally and on watchers" path that's needed for both
new kinds of files, ergo the messaging layer is extended to send more
types of settings for future watch & parse and merge impls to follow.

Release Notes:

- N/A
2024-10-02 22:00:40 +03:00
Marshall Bowers
167af4bc1d
Use const over static for string literals (#18635)
I noticed a few places where we were storing `&'static str`s in
`static`s instead of `const`s.

This PR updates them to use `const`.

Release Notes:

- N/A
2024-10-02 12:33:13 -04:00
Thorsten Ball
7ce8797d78
ssh remoting: Add infrastructure to handle reconnects (#18572)
Some checks are pending
CI / Check formatting and spelling (push) Waiting to run
CI / (macOS) Run Clippy and tests (push) Waiting to run
CI / (Linux) Run Clippy and tests (push) Waiting to run
CI / (Windows) Run Clippy and tests (push) Waiting to run
CI / Create a macOS bundle (push) Blocked by required conditions
CI / Create a Linux bundle (push) Blocked by required conditions
CI / Create arm64 Linux bundle (push) Blocked by required conditions
Deploy Docs / Deploy Docs (push) Waiting to run
Docs / Check formatting (push) Waiting to run
This restructures the code in `remote` so that it's easier to replace
the current SSH connection with a new one in case of
disconnects/reconnects.

Right now, it successfully reconnects, BUT we're still missing the big
piece on the server-side: keeping the server process alive and
reconnecting to the same process that keeps the project-state.

Release Notes:

- N/A

---------

Co-authored-by: Bennet <bennet@zed.dev>
2024-10-01 12:16:44 +02:00
Tom Wieczorek
77df7e56f7
settings: Make external formatter arguments optional (#18340)
If specifying a formatter in the settings like this:

    "languages": {
      "foo": {
        "formatter": {
          "external": {
            "command": "/path/to/foo-formatter"
          }
        }
      }
    }

Zed will show an error like this:

    Invalid user settings file
    data did not match any variant of untagged enum SingleOrVec

This is because the arguments are not optional. The error is hard to
understand, so let's make the arguments actually optional, which makes
the above settings snippet valid.

Release Notes:

- Make external formatter arguments optional
2024-09-30 09:34:41 +03:00
Richard Feldman
caaa9a00a9
Remove Qwen2 model (#18444)
Removed deprecated Qwen2 7B Instruct model from zed.dev provider (staff
only).

Release Notes:

- N/A
2024-09-27 13:30:25 -04:00
Max Brunsfeld
c1a039a5d7
Remove old project search code path, bump min-supported zed version for collaboration (#18404)
Release Notes:

- N/A
2024-09-26 12:10:39 -07:00
Mikayla Maki
71da81c743
SSH Remoting: Fix bugs in worktree syncing (#18406)
Release Notes:

- N/A

---------

Co-authored-by: conrad <conrad@zed.dev>
2024-09-26 12:03:57 -07:00
Max Brunsfeld
21a023980d
Expand git diffs when clicking the gutter strip, display their controls in a block above (#18313)
Todo:

* [x] Tooltips for hunk buttons
* [x] Buttons to go to next and previous hunk
* [x] Ellipsis button that opens a context menu with `Revert all`

/cc @iamnbutler @danilo-leal for design 👀 

Release Notes:

- Changed the behavior of the git gutter so that diff hunk are expanded
immediately when clicking the gutter, and hunk controls are displayed
above the hunk.

---------

Co-authored-by: Marshall <marshall@zed.dev>
Co-authored-by: Marshall Bowers <elliott.codes@gmail.com>
2024-09-25 12:50:38 -07:00
Conrad Irwin
bbf5ed2ba1
Fix collab filtering panics better (#18344)
Release Notes:

- N/A
2024-09-25 09:42:07 -06:00
Conrad Irwin
d33600525e
ssh remoting: Fix cmd-o (#18308)
Release Notes:

- ssh-remoting: Cmd-O now correctly opens files on the remote host

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-09-24 16:23:08 -06:00
Conrad Irwin
c4e0f5e0ee
Rebuild buffer store to be aware of remote/local distinction (#18303)
Release Notes:

- N/A

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-09-24 14:52:30 -07:00
Max Brunsfeld
da1ef13442
Fix detection that a diff hunk is expanded (#18302)
Release Notes:

- N/A

---------

Co-authored-by: Marshall <marshall@zed.dev>
2024-09-24 17:39:44 -04:00
Marshall Bowers
d2ffad0f34
collab: Seed GitHub users from static data (#18301)
This PR updates the collab seed script to seed the GitHub users from a
set of static data.

This removes the need to hit the GitHub API to retrieve these users.

Release Notes:

- N/A
2024-09-24 16:35:09 -04:00
Marshall Bowers
692590bff4
collab: Fix GitHub user retrieval in seed script (#18296)
This PR fixes the GitHub user retrieval in the database seed script.

The users returned from the [list
users](https://docs.github.com/en/rest/users/users?apiVersion=2022-11-28#list-users)
endpoint don't have a `created_at` timestamp, so we need to fetch them
individually.

I want to rework this further at a later date, this is just a bandaid to
get things working again.

Release Notes:

- N/A
2024-09-24 15:44:55 -04:00
Conrad Irwin
b69c6ee7df
Exclude initialization failed errors from slack (#18232)
Release Notes:

- N/A
2024-09-24 10:17:43 -06:00
Conrad Irwin
3ba071b993
Allow using system node (#18172)
Release Notes:

- (Potentially breaking change) Zed will now use the node installed on
your $PATH (if it is more recent than v18) instead of downloading its
own. You can disable the new behavior with `{"node":
{"disable_path_lookup": true}}` in your settings. We do not yet use
system/project-local node_modules.

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-09-23 15:28:04 -06:00
Conrad Irwin
e4080ef565
Move formatting to LSP store (#18242)
Release Notes:

- ssh-remoting: Fixed format on save

---------

Co-authored-by: Mikayla <mikayla@zed.dev>
2024-09-23 13:33:28 -07:00
Antonio Scandurra
7051bc00c2
Add "Fix with Assistant" code action on lines with diagnostics (#18163)
Release Notes:

- Added a new "Fix with Assistant" action on code with errors or
warnings.

---------

Co-authored-by: Nathan <nathan@zed.dev>
2024-09-23 11:40:34 -06:00
Conrad Irwin
4f227fd3bf
Use LanguageServerName in more places (#18167)
Some checks failed
CI / Check formatting and spelling (push) Has been cancelled
CI / (macOS) Run Clippy and tests (push) Has been cancelled
CI / (Linux) Run Clippy and tests (push) Has been cancelled
CI / (Windows) Run Clippy and tests (push) Has been cancelled
Deploy Docs / Deploy Docs (push) Has been cancelled
Docs / Check formatting (push) Has been cancelled
CI / Create a macOS bundle (push) Has been cancelled
CI / Create a Linux bundle (push) Has been cancelled
CI / Create arm64 Linux bundle (push) Has been cancelled
This pushes the new LanguageServerName type to more places.

As both languages and language servers were identified by Arc<str>, it
was
sometimes hard to tell which was intended.

Release Notes:

- N/A
2024-09-20 18:51:34 -06:00
Joseph T. Lyons
601090511b
Remove system_id from all events but editor_events (#18154)
Release Notes:

- N/A
2024-09-20 13:25:06 -04:00
Marshall Bowers
ab1d466c5f
Remove replica_id from MultiBuffers (#18141)
This PR removes the `replica_id` field from the `MultiBuffer` struct.

We were only ever referencing this field to pass when constructing a
`MultiBuffer`, and never used it outside of that.

Release Notes:

- N/A
2024-09-20 10:48:27 -04:00