mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-30 14:17:02 +00:00
Add Sign Out link for Supermaven (#14834)
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
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
Adds a menu item to sign out from a linked Supermaven account. ![image](https://github.com/user-attachments/assets/6af3c39f-9ca4-4ac2-a5c0-c7cb3c3aaac2) Release Notes: - Added the ability to sign out of a Supermaven account ([#12715(https://github.com/zed-industries/zed/issues/12715))
This commit is contained in:
parent
022e662815
commit
46b7fa9bcb
3 changed files with 28 additions and 2 deletions
|
@ -298,7 +298,9 @@ impl InlineCompletionButton {
|
||||||
|
|
||||||
fn build_supermaven_context_menu(&self, cx: &mut ViewContext<Self>) -> View<ContextMenu> {
|
fn build_supermaven_context_menu(&self, cx: &mut ViewContext<Self>) -> View<ContextMenu> {
|
||||||
ContextMenu::build(cx, |menu, cx| {
|
ContextMenu::build(cx, |menu, cx| {
|
||||||
self.build_language_settings_menu(menu, cx).separator()
|
self.build_language_settings_menu(menu, cx)
|
||||||
|
.separator()
|
||||||
|
.action("Sign Out", supermaven::SignOut.boxed_clone())
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,6 +14,7 @@ pub enum OutboundMessage {
|
||||||
StateUpdate(StateUpdateMessage),
|
StateUpdate(StateUpdateMessage),
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
UseFreeVersion,
|
UseFreeVersion,
|
||||||
|
Logout,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
|
|
@ -9,7 +9,9 @@ use client::{proto, Client};
|
||||||
use collections::BTreeMap;
|
use collections::BTreeMap;
|
||||||
|
|
||||||
use futures::{channel::mpsc, io::BufReader, AsyncBufReadExt, StreamExt};
|
use futures::{channel::mpsc, io::BufReader, AsyncBufReadExt, StreamExt};
|
||||||
use gpui::{AppContext, AsyncAppContext, EntityId, Global, Model, ModelContext, Task, WeakModel};
|
use gpui::{
|
||||||
|
actions, AppContext, AsyncAppContext, EntityId, Global, Model, ModelContext, Task, WeakModel,
|
||||||
|
};
|
||||||
use language::{
|
use language::{
|
||||||
language_settings::all_language_settings, Anchor, Buffer, BufferSnapshot, ToOffset,
|
language_settings::all_language_settings, Anchor, Buffer, BufferSnapshot, ToOffset,
|
||||||
};
|
};
|
||||||
|
@ -25,6 +27,8 @@ use std::{path::PathBuf, process::Stdio, sync::Arc};
|
||||||
use ui::prelude::*;
|
use ui::prelude::*;
|
||||||
use util::ResultExt;
|
use util::ResultExt;
|
||||||
|
|
||||||
|
actions!(supermaven, [SignOut]);
|
||||||
|
|
||||||
pub fn init(client: Arc<Client>, cx: &mut AppContext) {
|
pub fn init(client: Arc<Client>, cx: &mut AppContext) {
|
||||||
let supermaven = cx.new_model(|_| Supermaven::Starting);
|
let supermaven = cx.new_model(|_| Supermaven::Starting);
|
||||||
Supermaven::set_global(supermaven.clone(), cx);
|
Supermaven::set_global(supermaven.clone(), cx);
|
||||||
|
@ -46,6 +50,12 @@ pub fn init(client: Arc<Client>, cx: &mut AppContext) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
.detach();
|
.detach();
|
||||||
|
|
||||||
|
cx.on_action(|_: &SignOut, cx| {
|
||||||
|
if let Some(supermaven) = Supermaven::global(cx) {
|
||||||
|
supermaven.update(cx, |supermaven, _cx| supermaven.sign_out());
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
pub enum Supermaven {
|
pub enum Supermaven {
|
||||||
|
@ -175,6 +185,19 @@ impl Supermaven {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn sign_out(&mut self) {
|
||||||
|
if let Self::Spawned(agent) = self {
|
||||||
|
agent
|
||||||
|
.outgoing_tx
|
||||||
|
.unbounded_send(OutboundMessage::Logout)
|
||||||
|
.ok();
|
||||||
|
// The account status will get set to RequiresActivation or Ready when the next
|
||||||
|
// message from the agent comes in. Until that happens, set the status to Unknown
|
||||||
|
// to disable the button.
|
||||||
|
agent.account_status = AccountStatus::Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_relevant_completion<'a>(
|
fn find_relevant_completion<'a>(
|
||||||
|
|
Loading…
Reference in a new issue