Remove release channel from Zed URLs (#8863)
Also adds a new command `cli: Register Zed Scheme` that will cause URLs to be opened in the current zed version, and we call this implicitly if you install the CLI Also add some status reporting to install cli Fixes: #8857 Release Notes: - Added success/error reporting to `cli: Install Cli` ([#8857](https://github.com/zed-industries/zed/issues/8857)). - Removed `zed-{preview,nightly,dev}:` url schemes (used by channel links) - Added `cli: Register Zed Scheme` to control which zed handles the `zed://` scheme (defaults to the most recently installed, or the version that you last used `cli: Install Cli` with)
This commit is contained in:
parent
2201b9b116
commit
f53823c840
21 changed files with 178 additions and 113 deletions
|
@ -107,7 +107,7 @@ identifier = "dev.zed.Zed-Dev"
|
|||
name = "Zed Dev"
|
||||
osx_minimum_system_version = "10.15.7"
|
||||
osx_info_plist_exts = ["resources/info/*"]
|
||||
osx_url_schemes = ["zed-dev"]
|
||||
osx_url_schemes = ["zed"]
|
||||
|
||||
[package.metadata.bundle-nightly]
|
||||
icon = ["resources/app-icon-nightly@2x.png", "resources/app-icon-nightly.png"]
|
||||
|
@ -115,7 +115,7 @@ identifier = "dev.zed.Zed-Nightly"
|
|||
name = "Zed Nightly"
|
||||
osx_minimum_system_version = "10.15.7"
|
||||
osx_info_plist_exts = ["resources/info/*"]
|
||||
osx_url_schemes = ["zed-nightly"]
|
||||
osx_url_schemes = ["zed"]
|
||||
|
||||
[package.metadata.bundle-preview]
|
||||
icon = ["resources/app-icon-preview@2x.png", "resources/app-icon-preview.png"]
|
||||
|
@ -123,7 +123,7 @@ identifier = "dev.zed.Zed-Preview"
|
|||
name = "Zed Preview"
|
||||
osx_minimum_system_version = "10.15.7"
|
||||
osx_info_plist_exts = ["resources/info/*"]
|
||||
osx_url_schemes = ["zed-preview"]
|
||||
osx_url_schemes = ["zed"]
|
||||
|
||||
[package.metadata.bundle-stable]
|
||||
icon = ["resources/app-icon@2x.png", "resources/app-icon.png"]
|
||||
|
|
|
@ -5,7 +5,7 @@ use anyhow::{anyhow, Context as _, Result};
|
|||
use backtrace::Backtrace;
|
||||
use chrono::Utc;
|
||||
use cli::FORCE_CLI_MODE_ENV_VAR_NAME;
|
||||
use client::{Client, UserStore};
|
||||
use client::{parse_zed_link, Client, UserStore};
|
||||
use collab_ui::channel_view::ChannelView;
|
||||
use db::kvp::KEY_VALUE_STORE;
|
||||
use editor::Editor;
|
||||
|
@ -23,7 +23,7 @@ use assets::Assets;
|
|||
use mimalloc::MiMalloc;
|
||||
use node_runtime::RealNodeRuntime;
|
||||
use parking_lot::Mutex;
|
||||
use release_channel::{parse_zed_link, AppCommitSha, ReleaseChannel, RELEASE_CHANNEL};
|
||||
use release_channel::{AppCommitSha, ReleaseChannel, RELEASE_CHANNEL};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use settings::{
|
||||
default_settings, handle_settings_file_changes, watch_config_file, Settings, SettingsStore,
|
||||
|
@ -106,7 +106,7 @@ fn main() {
|
|||
let (listener, mut open_rx) = OpenListener::new();
|
||||
let listener = Arc::new(listener);
|
||||
let open_listener = listener.clone();
|
||||
app.on_open_urls(move |urls, _| open_listener.open_urls(&urls));
|
||||
app.on_open_urls(move |urls, cx| open_listener.open_urls(&urls, cx));
|
||||
app.on_reopen(move |cx| {
|
||||
if let Some(app_state) = AppState::try_global(cx).and_then(|app_state| app_state.upgrade())
|
||||
{
|
||||
|
@ -271,9 +271,9 @@ fn main() {
|
|||
#[cfg(not(target_os = "linux"))]
|
||||
upload_panics_and_crashes(http.clone(), cx);
|
||||
cx.activate(true);
|
||||
let urls = collect_url_args();
|
||||
let urls = collect_url_args(cx);
|
||||
if !urls.is_empty() {
|
||||
listener.open_urls(&urls)
|
||||
listener.open_urls(&urls, cx)
|
||||
}
|
||||
} else {
|
||||
upload_panics_and_crashes(http.clone(), cx);
|
||||
|
@ -282,7 +282,7 @@ fn main() {
|
|||
if std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_some()
|
||||
&& !listener.triggered.load(Ordering::Acquire)
|
||||
{
|
||||
listener.open_urls(&collect_url_args())
|
||||
listener.open_urls(&collect_url_args(cx), cx)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -921,13 +921,13 @@ fn stdout_is_a_pty() -> bool {
|
|||
std::env::var(FORCE_CLI_MODE_ENV_VAR_NAME).ok().is_none() && std::io::stdout().is_terminal()
|
||||
}
|
||||
|
||||
fn collect_url_args() -> Vec<String> {
|
||||
fn collect_url_args(cx: &AppContext) -> Vec<String> {
|
||||
env::args()
|
||||
.skip(1)
|
||||
.filter_map(|arg| match std::fs::canonicalize(Path::new(&arg)) {
|
||||
Ok(path) => Some(format!("file://{}", path.to_string_lossy())),
|
||||
Err(error) => {
|
||||
if let Some(_) = parse_zed_link(&arg) {
|
||||
if let Some(_) = parse_zed_link(&arg, cx) {
|
||||
Some(arg)
|
||||
} else {
|
||||
log::error!("error parsing path argument: {}", error);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
use anyhow::{anyhow, Context, Result};
|
||||
use cli::{ipc, IpcHandshake};
|
||||
use cli::{ipc::IpcSender, CliRequest, CliResponse};
|
||||
use client::parse_zed_link;
|
||||
use collections::HashMap;
|
||||
use editor::scroll::Autoscroll;
|
||||
use editor::Editor;
|
||||
|
@ -10,7 +11,6 @@ use futures::{FutureExt, SinkExt, StreamExt};
|
|||
use gpui::{AppContext, AsyncAppContext, Global};
|
||||
use itertools::Itertools;
|
||||
use language::{Bias, Point};
|
||||
use release_channel::parse_zed_link;
|
||||
use std::path::Path;
|
||||
use std::sync::atomic::Ordering;
|
||||
use std::sync::Arc;
|
||||
|
@ -66,13 +66,13 @@ impl OpenListener {
|
|||
)
|
||||
}
|
||||
|
||||
pub fn open_urls(&self, urls: &[String]) {
|
||||
pub fn open_urls(&self, urls: &[String], cx: &AppContext) {
|
||||
self.triggered.store(true, Ordering::Release);
|
||||
let request = if let Some(server_name) =
|
||||
urls.first().and_then(|url| url.strip_prefix("zed-cli://"))
|
||||
{
|
||||
self.handle_cli_connection(server_name)
|
||||
} else if let Some(request_path) = urls.first().and_then(|url| parse_zed_link(url)) {
|
||||
} else if let Some(request_path) = urls.first().and_then(|url| parse_zed_link(url, cx)) {
|
||||
self.handle_zed_url_scheme(request_path)
|
||||
} else {
|
||||
self.handle_file_urls(urls)
|
||||
|
|
|
@ -5,11 +5,12 @@ mod open_listener;
|
|||
pub use app_menus::*;
|
||||
use assistant::AssistantPanel;
|
||||
use breadcrumbs::Breadcrumbs;
|
||||
use client::ZED_URL_SCHEME;
|
||||
use collections::VecDeque;
|
||||
use editor::{Editor, MultiBuffer};
|
||||
use gpui::{
|
||||
actions, point, px, AppContext, Context, FocusableView, PromptLevel, TitlebarOptions, View,
|
||||
ViewContext, VisualContext, WindowBounds, WindowKind, WindowOptions,
|
||||
actions, point, px, AppContext, AsyncAppContext, Context, FocusableView, PromptLevel,
|
||||
TitlebarOptions, View, ViewContext, VisualContext, WindowBounds, WindowKind, WindowOptions,
|
||||
};
|
||||
pub use only_instance::*;
|
||||
pub use open_listener::*;
|
||||
|
@ -38,11 +39,11 @@ use util::{
|
|||
use uuid::Uuid;
|
||||
use vim::VimModeSetting;
|
||||
use welcome::BaseKeymap;
|
||||
use workspace::Pane;
|
||||
use workspace::{
|
||||
create_and_open_local_file, notifications::simple_message_notification::MessageNotification,
|
||||
open_new, AppState, NewFile, NewWindow, Workspace, WorkspaceSettings,
|
||||
open_new, AppState, NewFile, NewWindow, Toast, Workspace, WorkspaceSettings,
|
||||
};
|
||||
use workspace::{notifications::DetachAndPromptErr, Pane};
|
||||
use zed_actions::{OpenBrowser, OpenSettings, OpenZedUrl, Quit};
|
||||
|
||||
actions!(
|
||||
|
@ -232,7 +233,7 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
|||
cx.toggle_full_screen();
|
||||
})
|
||||
.register_action(|_, action: &OpenZedUrl, cx| {
|
||||
OpenListener::global(cx).open_urls(&[action.url.clone()])
|
||||
OpenListener::global(cx).open_urls(&[action.url.clone()], cx)
|
||||
})
|
||||
.register_action(|_, action: &OpenBrowser, cx| cx.open_url(&action.url))
|
||||
.register_action(move |_, _: &IncreaseBufferFontSize, cx| {
|
||||
|
@ -243,12 +244,50 @@ pub fn initialize_workspace(app_state: Arc<AppState>, cx: &mut AppContext) {
|
|||
})
|
||||
.register_action(move |_, _: &ResetBufferFontSize, cx| theme::reset_font_size(cx))
|
||||
.register_action(|_, _: &install_cli::Install, cx| {
|
||||
cx.spawn(|_, cx| async move {
|
||||
install_cli::install_cli(cx.deref())
|
||||
cx.spawn(|workspace, mut cx| async move {
|
||||
let path = install_cli::install_cli(cx.deref())
|
||||
.await
|
||||
.context("error creating CLI symlink")
|
||||
.context("error creating CLI symlink")?;
|
||||
workspace.update(&mut cx, |workspace, cx| {
|
||||
workspace.show_toast(
|
||||
Toast::new(
|
||||
0,
|
||||
format!(
|
||||
"Installed `zed` to {}. You can launch {} from your terminal.",
|
||||
path.to_string_lossy(),
|
||||
ReleaseChannel::global(cx).display_name()
|
||||
),
|
||||
),
|
||||
cx,
|
||||
)
|
||||
})?;
|
||||
register_zed_scheme(&cx).await.log_err();
|
||||
Ok(())
|
||||
})
|
||||
.detach_and_log_err(cx);
|
||||
.detach_and_prompt_err("Error installing zed cli", cx, |_, _| None);
|
||||
})
|
||||
.register_action(|_, _: &install_cli::RegisterZedScheme, cx| {
|
||||
cx.spawn(|workspace, mut cx| async move {
|
||||
register_zed_scheme(&cx).await?;
|
||||
workspace.update(&mut cx, |workspace, cx| {
|
||||
workspace.show_toast(
|
||||
Toast::new(
|
||||
0,
|
||||
format!(
|
||||
"zed:// links will now open in {}.",
|
||||
ReleaseChannel::global(cx).display_name()
|
||||
),
|
||||
),
|
||||
cx,
|
||||
)
|
||||
})?;
|
||||
Ok(())
|
||||
})
|
||||
.detach_and_prompt_err(
|
||||
"Error registering zed:// scheme",
|
||||
cx,
|
||||
|_, _| None,
|
||||
);
|
||||
})
|
||||
.register_action(|workspace, _: &OpenLog, cx| {
|
||||
open_log_file(workspace, cx);
|
||||
|
@ -2881,3 +2920,8 @@ mod tests {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn register_zed_scheme(cx: &AsyncAppContext) -> anyhow::Result<()> {
|
||||
cx.update(|cx| cx.register_url_scheme(ZED_URL_SCHEME))?
|
||||
.await
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue