From 2d2b048f8be66889d894ccb0b8d28d09b462076b Mon Sep 17 00:00:00 2001 From: jiakeboge <28388982+jiakeboge@users.noreply.github.com> Date: Sun, 3 May 2026 18:38:26 +0800 Subject: [PATCH 1/2] feat: add "Unset Warp as Default Terminal" functionality This change allows users to revert the default terminal setting back to the macOS system Terminal (com.apple.Terminal). - Added `unset_warp_as_default_terminal` to macOS platform implementation. - Updated `DefaultTerminal` model to support unsetting the default status. - Modified the app menu to dynamically toggle between "Set" and "Unset" labels. - Enabled unsetting the default terminal from the Features settings page. --- app/src/app_menus.rs | 17 ++++++++++++----- app/src/default_terminal/mac.rs | 6 ++++++ app/src/default_terminal/mod.rs | 16 ++++++++++++++-- app/src/settings_view/features_page.rs | 25 +++++++++++++++++++------ 4 files changed, 51 insertions(+), 13 deletions(-) diff --git a/app/src/app_menus.rs b/app/src/app_menus.rs index da618eaaf..ea845921e 100644 --- a/app/src/app_menus.rs +++ b/app/src/app_menus.rs @@ -211,16 +211,23 @@ fn make_new_app_menu(ctx: &AppContext) -> Menu { "Set Warp as Default Terminal", move |ctx| { DefaultTerminal::handle(ctx).update(ctx, |default_terminal, ctx| { - default_terminal.make_warp_default(ctx) + if default_terminal.is_warp_default() { + default_terminal.unset_warp_default(ctx) + } else { + default_terminal.make_warp_default(ctx) + } }); }, move |_props, ctx| { let default_terminal = DefaultTerminal::handle(ctx).as_ref(ctx); + let is_warp_default = default_terminal.is_warp_default(); MenuItemPropertyChanges { - disabled: Some( - !DefaultTerminal::can_warp_become_default() - || default_terminal.is_warp_default(), - ), + name: Some(if is_warp_default { + "Unset Warp as Default Terminal".to_string() + } else { + "Set Warp as Default Terminal".to_string() + }), + disabled: Some(!DefaultTerminal::can_warp_become_default()), ..Default::default() } }, diff --git a/app/src/default_terminal/mac.rs b/app/src/default_terminal/mac.rs index db728064d..aebcaecd0 100644 --- a/app/src/default_terminal/mac.rs +++ b/app/src/default_terminal/mac.rs @@ -71,6 +71,12 @@ pub fn set_warp_as_default_terminal() -> Result<(), String> { set_default_terminal(&bundle_id) } +pub fn unset_warp_as_default_terminal() -> Result<(), String> { + log::debug!("Unsetting Warp as default terminal (reverting to Terminal.app)"); + + set_default_terminal("com.apple.Terminal") +} + fn set_default_terminal(bundle_id: &str) -> Result<(), String> { log::debug!("Setting default terminal to bundle ID: {bundle_id}"); diff --git a/app/src/default_terminal/mod.rs b/app/src/default_terminal/mod.rs index f5e421f54..d87589721 100644 --- a/app/src/default_terminal/mod.rs +++ b/app/src/default_terminal/mod.rs @@ -24,6 +24,11 @@ mod non_mac { pub fn set_warp_as_default_terminal() -> Result<(), String> { Err("Not implemented".to_string()) } + + /// Unsets Warp as the default terminal + pub fn unset_warp_as_default_terminal() -> Result<(), String> { + Err("Not implemented".to_string()) + } } #[allow(unused_imports)] @@ -90,8 +95,7 @@ impl DefaultTerminal { self.is_warp_default } - /// This is a one-way operation. Once we set the default terminal to Warp, we can't really - /// "unset" it unless we pick a new default terminal. Picking a new default is complicated. + /// Sets Warp as the default terminal. pub fn make_warp_default(&mut self, ctx: &mut ModelContext) { if let Err(e) = set_warp_as_default_terminal() { log::error!("Error setting Warp as default terminal: {e:#}"); @@ -99,6 +103,14 @@ impl DefaultTerminal { self.set_is_warp_default(true, ctx); } } + + pub fn unset_warp_default(&mut self, ctx: &mut ModelContext) { + if let Err(e) = unset_warp_as_default_terminal() { + log::error!("Error unsetting Warp as default terminal: {e:#}"); + } else { + self.set_is_warp_default(false, ctx); + } + } } pub enum DefaultTerminalEvent { diff --git a/app/src/settings_view/features_page.rs b/app/src/settings_view/features_page.rs index 884d02a9e..9a53f8475 100644 --- a/app/src/settings_view/features_page.rs +++ b/app/src/settings_view/features_page.rs @@ -645,6 +645,7 @@ pub enum FeaturesPageAction { ToggleShowTerminalInputMessageLine, ToggleAgentInAppNotifications, MakeWarpDefaultTerminal, + UnsetWarpDefaultTerminal, } lazy_static! { @@ -1138,6 +1139,10 @@ impl FeaturesPageAction { action: "MakeWarpDefaultTerminal".to_string(), value: to_string(DefaultTerminal::as_ref(ctx).is_warp_default()), }, + Self::UnsetWarpDefaultTerminal => TelemetryEvent::FeaturesPageAction { + action: "UnsetWarpDefaultTerminal".to_string(), + value: to_string(DefaultTerminal::as_ref(ctx).is_warp_default()), + }, Self::ToggleAutoOpenCodeReviewPane => TelemetryEvent::FeaturesPageAction { action: "ToggleAutoOpenCodeReviewPane".to_string(), value: to_string( @@ -1910,6 +1915,11 @@ impl TypedActionView for FeaturesPageView { default_terminal.make_warp_default(ctx); }); } + UnsetWarpDefaultTerminal => { + DefaultTerminal::handle(ctx).update(ctx, |default_terminal, ctx| { + default_terminal.unset_warp_default(ctx); + }); + } } send_telemetry_from_ctx!(action.telemetry_event(ctx), ctx); @@ -4793,13 +4803,16 @@ impl SettingsWidget for DefaultTerminalWidget { let default_terminal = DefaultTerminal::as_ref(app); if default_terminal.is_warp_default() { ui_builder - .wrappable_text("Warp is the default terminal", true) - .with_style(UiComponentStyles { - font_color: Some(appearance.theme().disabled_ui_text_color().into()), - margin: Some(Coords::default().bottom(16.)), - ..Default::default() - }) + .link( + "Unset Warp as the default terminal".to_string(), + None, + Some(Box::new(|ctx| { + ctx.dispatch_typed_action(FeaturesPageAction::UnsetWarpDefaultTerminal); + })), + self.link_state.clone(), + ) .build() + .with_margin_bottom(16.) .finish() } else { ui_builder From 35644b6bd837851f8ca0560673b00fbd6694fb25 Mon Sep 17 00:00:00 2001 From: jiakeboge <28388982+jiakeboge@users.noreply.github.com> Date: Sun, 3 May 2026 18:43:08 +0800 Subject: [PATCH 2/2] feat: add functionality to restore macOS Terminal as default - Added `unset_warp_as_default_terminal` to revert to Terminal.app. - Updated menu item label to "Restore macOS Terminal as Default" when Warp is the current default. - Added a corresponding link in the Features settings page for better discoverability. --- app/src/app_menus.rs | 2 +- app/src/settings_view/features_page.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/app_menus.rs b/app/src/app_menus.rs index ea845921e..13923e730 100644 --- a/app/src/app_menus.rs +++ b/app/src/app_menus.rs @@ -223,7 +223,7 @@ fn make_new_app_menu(ctx: &AppContext) -> Menu { let is_warp_default = default_terminal.is_warp_default(); MenuItemPropertyChanges { name: Some(if is_warp_default { - "Unset Warp as Default Terminal".to_string() + "Restore macOS Terminal as Default".to_string() } else { "Set Warp as Default Terminal".to_string() }), diff --git a/app/src/settings_view/features_page.rs b/app/src/settings_view/features_page.rs index 9a53f8475..626f9e563 100644 --- a/app/src/settings_view/features_page.rs +++ b/app/src/settings_view/features_page.rs @@ -4804,7 +4804,7 @@ impl SettingsWidget for DefaultTerminalWidget { if default_terminal.is_warp_default() { ui_builder .link( - "Unset Warp as the default terminal".to_string(), + "Restore macOS Terminal as the default terminal".to_string(), None, Some(Box::new(|ctx| { ctx.dispatch_typed_action(FeaturesPageAction::UnsetWarpDefaultTerminal);