Skip to content
Merged
2 changes: 1 addition & 1 deletion crates/agent_ui/src/agent_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1907,7 +1907,7 @@ impl AgentPanel {
Err(error) => {
log::error!("failed to spawn agent panel terminal: {error:#}");
workspace
.update(cx, |workspace, cx| workspace.show_error(&error, cx))
.update(cx, |workspace, cx| workspace.show_error(error, cx))
.log_err();
this.update(cx, |this, cx| {
if this.pending_terminal_spawn == Some(terminal_id) {
Expand Down
27 changes: 22 additions & 5 deletions crates/auto_update_ui/src/auto_update_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ use util::{ResultExt as _, maybe};
use workspace::{
Workspace,
notifications::{
ErrorMessagePrompt, Notification, NotificationId, SuppressEvent, show_app_notification,
Notification, NotificationId, SuppressEvent, show_app_notification,
simple_message_notification::MessageNotification,
},
workspace_error::{ErrorAction, ErrorSeverity, WorkspaceError},
};
use zed_actions::ShowUpdateNotification;

Expand Down Expand Up @@ -71,11 +72,27 @@ fn notify_release_notes_failed_to_show(
|cx| {
cx.new(move |cx| {
let url = release_notes_url(cx);
let mut prompt = ErrorMessagePrompt::new("Couldn't load release notes", cx);
if let Some(url) = url {
prompt = prompt.with_link_button("View in Browser".to_string(), url);

struct ReleaseNotesError {
url: Option<String>,
}
impl WorkspaceError for ReleaseNotesError {
fn primary_message(&self) -> SharedString {
"Couldn't load release notes".into()
}
fn severity(&self) -> ErrorSeverity {
ErrorSeverity::Error
}
fn primary_action(&self) -> ErrorAction {
self.url
.clone()
.map(|url| ErrorAction::link("View in Browser", url))
.unwrap_or_else(ErrorAction::dismiss)
}
}
prompt

let error = ReleaseNotesError { url };
MessageNotification::from_workspace_error(error, cx)
})
},
);
Expand Down
2 changes: 1 addition & 1 deletion crates/collab_ui/src/collab_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub fn init(cx: &mut App) {
})
.detach_and_notify_err(workspace_handle, window, cx);
} else {
workspace.show_error(&"There’s no active call; join one first.", cx);
workspace.show_error("There's no active call; join one first.".to_string(), cx);
}
});
workspace.register_action(|workspace, _: &ShareProject, window, cx| {
Expand Down
2 changes: 1 addition & 1 deletion crates/command_palette/src/command_palette.rs
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ impl PickerDelegate for CommandPaletteDelegate {
CommandInterceptResult {
results: vec![CommandInterceptItem {
action: OpenZedUrl {
url: query_for_link.clone(),
url: query_for_link.clone().into(),
}
.boxed_clone(),
string: query_for_link,
Expand Down
2 changes: 1 addition & 1 deletion crates/copilot_ui/src/sign_in.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub fn initiate_sign_out(copilot: Entity<Copilot>, window: &mut Window, cx: &mut
Err(err) => cx.update(|window, cx| {
if let Some(workspace) = Workspace::for_window(window, cx) {
workspace.update(cx, |workspace, cx| {
workspace.show_error(&err, cx);
workspace.show_error(format!("Error: {err}"), cx);
})
} else {
log::error!("{:?}", err);
Expand Down
31 changes: 26 additions & 5 deletions crates/edit_prediction/src/zeta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ use language::{
use release_channel::AppVersion;
use text::{Anchor, Bias, Point};
use ui::SharedString;
use workspace::notifications::{ErrorMessagePrompt, NotificationId, show_app_notification};
use workspace::notifications::simple_message_notification::MessageNotification;
use workspace::notifications::{NotificationId, show_app_notification};
use workspace::workspace_error::{ErrorAction, ErrorSeverity, WorkspaceError};
use zeta_prompt::{ParsedOutput, ZetaPromptInput};

use std::{ops::Range, path::Path, sync::Arc};
Expand Down Expand Up @@ -491,14 +493,33 @@ fn handle_api_response<T>(
})
.ok();

let error_message: SharedString = err.to_string().into();
let message: SharedString = err.to_string().into();

struct UpdateRequiredError {
message: SharedString,
}
impl WorkspaceError for UpdateRequiredError {
fn primary_message(&self) -> SharedString {
self.message.clone()
}
fn severity(&self) -> ErrorSeverity {
ErrorSeverity::Error
}
fn primary_action(&self) -> ErrorAction {
ErrorAction::link("Update Zed", "https://zed.dev/releases")
}
}

show_app_notification(
NotificationId::unique::<ZedUpdateRequiredError>(),
cx,
move |cx| {
cx.new(|cx| {
ErrorMessagePrompt::new(error_message.clone(), cx)
.with_link_button("Update Zed", "https://zed.dev/releases")
cx.new({
let message = message.clone();
move |cx| {
let error = UpdateRequiredError { message };
MessageNotification::from_workspace_error(error, cx)
}
})
},
);
Expand Down
16 changes: 7 additions & 9 deletions crates/edit_prediction_ui/src/edit_prediction_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1117,7 +1117,7 @@ impl EditPredictionButton {
.link_with_handler(
"Learn More",
OpenBrowser {
url: zed_urls::edit_prediction_docs(cx),
url: zed_urls::edit_prediction_docs(cx).into(),
}
.boxed_clone(),
|_window, _cx| {
Expand Down Expand Up @@ -1630,12 +1630,10 @@ fn emit_edit_prediction_menu_opened(
);
}

fn copilot_settings_url(enterprise_uri: Option<&str>) -> String {
fn copilot_settings_url(enterprise_uri: Option<&str>) -> Arc<str> {
match enterprise_uri {
Some(uri) => {
format!("{}{}", uri.trim_end_matches('/'), COPILOT_SETTINGS_PATH)
}
None => COPILOT_SETTINGS_URL.to_string(),
Some(uri) => format!("{}{}", uri.trim_end_matches('/'), COPILOT_SETTINGS_PATH).into(),
None => COPILOT_SETTINGS_URL.into(),
}
}

Expand Down Expand Up @@ -1671,7 +1669,7 @@ mod tests {
)
});

assert_eq!(url, "https://my-company.ghe.com/settings/copilot");
assert_eq!(url.as_ref(), "https://my-company.ghe.com/settings/copilot");
}

#[gpui::test]
Expand Down Expand Up @@ -1701,7 +1699,7 @@ mod tests {
)
});

assert_eq!(url, "https://my-company.ghe.com/settings/copilot");
assert_eq!(url.as_ref(), "https://my-company.ghe.com/settings/copilot");
}

#[gpui::test]
Expand All @@ -1722,6 +1720,6 @@ mod tests {
)
});

assert_eq!(url, "https://github.com/settings/copilot");
assert_eq!(url.as_ref(), "https://github.com/settings/copilot");
}
}
11 changes: 8 additions & 3 deletions crates/editor/src/navigation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1082,7 +1082,10 @@ impl Editor {
if let Some(url) = url {
cx.update(|window, cx| {
if parse_zed_link(&url, cx).is_some() {
window.dispatch_action(Box::new(zed_actions::OpenZedUrl { url }), cx);
window.dispatch_action(
Box::new(zed_actions::OpenZedUrl { url: url.into() }),
cx,
);
} else {
cx.open_url(&url);
}
Expand Down Expand Up @@ -1727,8 +1730,10 @@ impl Editor {
Some(Either::Left(url)) => {
cx.update(|window, cx| {
if parse_zed_link(&url, cx).is_some() {
window
.dispatch_action(Box::new(zed_actions::OpenZedUrl { url }), cx);
window.dispatch_action(
Box::new(zed_actions::OpenZedUrl { url: url.into() }),
cx,
);
} else {
cx.open_url(&url);
}
Expand Down
13 changes: 9 additions & 4 deletions crates/extensions_ui/src/extensions_ui.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,12 @@ pub fn init(cx: &mut App) {
Err(err) => {
workspace_handle
.update(cx, |workspace, cx| {
workspace.show_portal_error(err.to_string(), cx);
workspace.show_error(
workspace::workspace_error::PortalError::new(
err.to_string(),
),
cx,
);
})
.ok();
return None;
Expand All @@ -149,10 +154,10 @@ pub fn init(cx: &mut App) {
log::error!("Failed to install dev extension: {:?}", err);
workspace_handle
.update(cx, |workspace, cx| {
// NOTE: using `anyhow::context` here ends up not printing
// the error
workspace.show_error(
// NOTE: using `anyhow::context` here ends up not printing
// the error
&format!("Failed to install dev extension: {}", err),
format!("Failed to install dev extension: {}", err),
cx,
);
})
Expand Down
15 changes: 3 additions & 12 deletions crates/git_ui/src/git_panel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ use workspace::SERIALIZATION_THROTTLE_TIME;
use workspace::{
Item, Workspace,
dock::{DockPosition, Panel, PanelEvent},
notifications::{DetachAndPromptErr, ErrorMessagePrompt, NotificationId, NotifyTaskExt},
notifications::{DetachAndPromptErr, NotificationId, NotifyTaskExt},
};
use zed_actions::{DecreaseBufferFontSize, IncreaseBufferFontSize, ResetBufferFontSize};

Expand Down Expand Up @@ -838,7 +838,7 @@ impl GitPanel {
GitStoreEvent::IndexWriteError(error) => {
this.workspace
.update(cx, |workspace, cx| {
workspace.show_error(error, cx);
workspace.show_error(format!("{error}"), cx);
})
.ok();
}
Expand Down Expand Up @@ -4075,16 +4075,7 @@ impl GitPanel {
{
if let Ok(Some(workspace)) = weak_this.update(cx, |this, _cx| this.workspace.upgrade()) {
let _ = workspace.update(cx, |workspace, cx| {
struct CommitMessageError;
let notification_id = NotificationId::unique::<CommitMessageError>();
workspace.show_notification(notification_id, cx, |cx| {
cx.new(|cx| {
ErrorMessagePrompt::new(
format!("Failed to generate commit message: {err}"),
cx,
)
})
});
workspace.show_error(format!("Failed to generate commit message: {err}"), cx);
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/recent_projects/src/remote_connections.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ pub async fn open_remote_project(
workspace.update(cx, |workspace, cx| {
for item in open_results.iter().flatten() {
if let Err(e) = item {
workspace.show_error(&e, cx);
workspace.show_error(format!("{e}"), cx);
}
}
});
Expand Down
Loading
Loading