first pass of merging in warp (doesn't build)

This commit is contained in:
Ryan Ward
2026-07-01 16:08:58 -05:00
parent 2f64909469
commit 4770ac06b5
3662 changed files with 414574 additions and 89772 deletions
+25 -120
View File
@@ -1,71 +1,25 @@
use galaxyui::{
elements::{
Align, ConstrainedBox, Container, CrossAxisAlignment, Flex, HighlightedHyperlink,
MouseStateHandle, ParentElement, Shrinkable,
},
fonts::Weight,
keymap::Keystroke,
ui_components::{
button::ButtonVariant,
components::{Coords, UiComponent, UiComponentStyles},
},
AppContext, Element,
};
use pathfinder_color::ColorU;
use crate::{
appearance::Appearance,
terminal::{
ssh::warpify::warpify_description,
view::{RememberForWarpification, TerminalAction},
},
themes::theme::Fill,
ui_components::blended_colors,
use galaxyui::elements::{
Align, Container, CrossAxisAlignment, Flex, MouseStateHandle, ParentElement, Shrinkable,
};
use galaxyui::fonts::Weight;
use galaxyui::keymap::Keystroke;
use galaxyui::ui_components::button::ButtonVariant;
use galaxyui::ui_components::components::{Coords, UiComponent, UiComponentStyles};
use galaxyui::Element;
use super::{render_block_banner, BLOCK_BANNER_DESCRIPTION_MAX_HEIGHT};
use super::render_block_banner;
use crate::appearance::Appearance;
use crate::terminal::view::{RememberForWarpification, TerminalAction};
use crate::themes::theme::Fill;
use crate::ui_components::blended_colors;
const CLOSE_BUTTON_DIAMETER: f32 = 20.0;
const STANDARD_PADDING: f32 = 8.0;
#[derive(Clone)]
pub enum WarpificationMode {
Ssh {
command: String,
host: Option<String>,
hyperlink_index: HighlightedHyperlink,
},
Subshell {
command: String,
},
}
impl WarpificationMode {
pub fn ssh(command: String, host: Option<String>) -> Self {
Self::Ssh {
command,
host,
hyperlink_index: Default::default(),
}
}
pub fn has_host(&self) -> bool {
matches!(self, Self::Ssh { host: Some(_), .. })
}
pub fn subshell(command: String) -> Self {
Self::Subshell { command }
}
}
impl WarpificationMode {
pub fn is_ssh(&self) -> bool {
matches!(self, Self::Ssh { .. })
}
}
pub struct WarpifyBannerState {
pub mode: WarpificationMode,
/// The subshell command that triggered the banner.
pub command: String,
pub height: f32,
pub accept_button_mouse_state: MouseStateHandle,
pub dont_ask_button_mouse_state: MouseStateHandle,
@@ -79,9 +33,9 @@ pub struct WarpifyBannerState {
}
impl WarpifyBannerState {
pub fn new(mode: WarpificationMode, initialize_warpify_keybinding: Option<Keystroke>) -> Self {
pub fn new(command: String, initialize_warpify_keybinding: Option<Keystroke>) -> Self {
Self {
mode,
command,
height: 0.0,
initialize_warpify_keybinding,
accept_button_mouse_state: Default::default(),
@@ -91,59 +45,29 @@ impl WarpifyBannerState {
}
}
pub fn is_ssh(&self) -> bool {
self.mode.is_ssh()
}
pub fn title(&self) -> &str {
match &self.mode {
WarpificationMode::Ssh { .. } => "Wormhole SSH session",
WarpificationMode::Subshell { .. } => "Wormhole subshell",
}
"Warpify subshell"
}
pub fn action(&self) -> TerminalAction {
match &self.mode {
WarpificationMode::Ssh { .. } => TerminalAction::WarpifySSHSession,
WarpificationMode::Subshell { .. } => TerminalAction::TriggerSubshellBootstrap,
}
TerminalAction::TriggerSubshellBootstrap
}
fn remember_for_warpification(&self, should_remember: bool) -> RememberForWarpification {
match &self.mode {
WarpificationMode::Ssh { command, host, .. } => {
let Some(host) = host else {
if should_remember {
return RememberForWarpification::RememberSubshellCommand(
command.to_owned(),
);
}
return RememberForWarpification::DoNotRememberSSHHost;
};
if should_remember {
RememberForWarpification::RememberSSHHost(host.to_owned())
} else {
RememberForWarpification::DoNotRememberSSHHost
}
}
WarpificationMode::Subshell { command } => {
if should_remember {
RememberForWarpification::RememberSubshellCommand(command.to_owned())
} else {
RememberForWarpification::DoNotRememberSubshellCommand
}
}
if should_remember {
RememberForWarpification::RememberSubshellCommand(self.command.to_owned())
} else {
RememberForWarpification::DoNotRememberSubshellCommand
}
}
}
/// This banner is shown when the user runs a command which is recognized as a subshell-compatible
/// command. It asks if they want to boostrap a subshell and, if so, whether we should ask again
/// command. It asks if they want to bootstrap a subshell and, if so, whether we should ask again
/// next time they run the same command.
pub fn render_warpification_banner(
state: &WarpifyBannerState,
appearance: &Appearance,
app: &AppContext,
) -> Box<dyn Element> {
let yes_button = render_yes_button(
state,
@@ -187,7 +111,7 @@ pub fn render_warpification_banner(
})
.finish();
let mut col = Flex::column()
let col = Flex::column()
.with_child(
Flex::row()
.with_child(Align::new(yes_button).finish())
@@ -201,26 +125,7 @@ pub fn render_warpification_banner(
.with_cross_axis_alignment(CrossAxisAlignment::Start);
render_block_banner(
|hover_state| {
if let WarpificationMode::Ssh {
hyperlink_index, ..
} = &state.mode
{
let description = Container::new(warpify_description(app, hyperlink_index))
.with_uniform_margin(STANDARD_PADDING)
.with_margin_top(4.)
.finish();
let description = if hover_state.is_hovered() {
description
} else {
ConstrainedBox::new(description)
.with_max_height(2. * BLOCK_BANNER_DESCRIPTION_MAX_HEIGHT)
.finish()
};
col.add_child(description);
}
col.finish()
},
|_hover_state| col.finish(),
state.hover_state.clone(),
appearance.theme(),
)