first pass of merging in warp (doesn't build)
This commit is contained in:
@@ -1,17 +1,21 @@
|
||||
use crate::terminal::{
|
||||
bootstrap::init_shell_script_for_shell, event_listener::ChannelEventListener,
|
||||
model::ansi::Processor, session_settings::SessionSettings, shell::ShellType,
|
||||
writeable_pty::Message as EventLoopMessage, SizeInfo, TerminalModel,
|
||||
};
|
||||
use std::io;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_channel::Receiver;
|
||||
use futures_util::SinkExt;
|
||||
use galaxyui::{Entity, ModelContext, SingletonEntity};
|
||||
use parking_lot::FairMutex;
|
||||
use serde::Serialize;
|
||||
use std::io;
|
||||
use std::sync::Arc;
|
||||
use websocket::{Message, Sink, Stream, WebSocket, WebsocketMessage as _};
|
||||
|
||||
use crate::terminal::bootstrap::init_shell_script_for_shell;
|
||||
use crate::terminal::event_listener::ChannelEventListener;
|
||||
use crate::terminal::model::ansi::Processor;
|
||||
use crate::terminal::session_settings::SessionSettings;
|
||||
use crate::terminal::shell::ShellType;
|
||||
use crate::terminal::writeable_pty::Message as EventLoopMessage;
|
||||
use crate::terminal::{SizeInfo, TerminalModel};
|
||||
|
||||
const CREATE_SESSION_ENDPOINT: &str = "ws://127.0.0.1:3030/create";
|
||||
|
||||
/// Contains info needed to resize the SSH terminal session. Is serialized and
|
||||
@@ -105,13 +109,16 @@ impl EventLoop {
|
||||
|
||||
let is_honor_ps1_enabled = *SessionSettings::as_ref(ctx).honor_ps1;
|
||||
|
||||
let terminal_model_for_init = self.terminal_model.clone();
|
||||
let receiver = self.event_loop_rx.clone();
|
||||
ctx.background_executor()
|
||||
.spawn(async move {
|
||||
if let Err(e) = Self::write_env_vars(&mut sink, is_honor_ps1_enabled).await {
|
||||
log::error!("Failed to write env vars to pty {e:?}");
|
||||
}
|
||||
if let Err(e) = Self::write_zsh_init_shell_script(&mut sink).await {
|
||||
if let Err(e) =
|
||||
Self::write_zsh_init_shell_script(&mut sink, &terminal_model_for_init).await
|
||||
{
|
||||
log::error!("Failed to write zsh bootstrap bytes to pty {e:?}");
|
||||
}
|
||||
|
||||
@@ -153,8 +160,14 @@ impl EventLoop {
|
||||
/// Writes the ZSH init shell script to the "PTY", mimicking how we send the init shell script
|
||||
/// when there is a local pty:
|
||||
/// <https://github.com/warpdotdev/warp-internal/blob/747da2df83f2caa97e781ce284ceb226fb97a66c/app/src/terminal/local_tty/unix.rs#L338-L347>.
|
||||
async fn write_zsh_init_shell_script(sink: &mut impl Sink) -> anyhow::Result<()> {
|
||||
let zsh_init_shell_script = init_shell_script_for_shell(ShellType::Zsh, &crate::ASSETS);
|
||||
async fn write_zsh_init_shell_script(
|
||||
sink: &mut impl Sink,
|
||||
terminal_model: &parking_lot::FairMutex<crate::terminal::TerminalModel>,
|
||||
) -> anyhow::Result<()> {
|
||||
let session_id = crate::terminal::bootstrap::generate_session_id();
|
||||
terminal_model.lock().register_session_id(session_id);
|
||||
let zsh_init_shell_script =
|
||||
init_shell_script_for_shell(ShellType::Zsh, &crate::ASSETS, session_id);
|
||||
sink.send(Message::new_binary(
|
||||
zsh_init_shell_script.as_bytes().to_vec(),
|
||||
))
|
||||
|
||||
@@ -1,27 +1,30 @@
|
||||
use std::any::Any;
|
||||
use std::sync::mpsc::SyncSender;
|
||||
use std::sync::Arc;
|
||||
|
||||
use async_channel::{Receiver, Sender, TrySendError};
|
||||
use parking_lot::FairMutex;
|
||||
use pathfinder_geometry::vector::Vector2F;
|
||||
use warpui::{AppContext, ModelHandle, ViewHandle, WindowId};
|
||||
|
||||
use crate::ai::blocklist::InputConfig;
|
||||
use crate::context_chips::prompt_type::PromptType;
|
||||
use crate::pane_group::TerminalViewResources;
|
||||
use crate::persistence::ModelEvent;
|
||||
use crate::terminal::event_listener::ChannelEventListener;
|
||||
use crate::terminal::model::session::Sessions;
|
||||
use crate::terminal::model_events::ModelEventDispatcher;
|
||||
use crate::terminal::remote_tty::event_loop::EventLoop;
|
||||
use crate::terminal::shell::{ShellName, ShellType};
|
||||
use crate::terminal::writeable_pty::pty_controller::{EventLoopSendError, EventLoopSender};
|
||||
use crate::terminal::writeable_pty::terminal_manager_util::{
|
||||
init_pty_controller_model, wire_up_pty_controller_with_view,
|
||||
init_pty_controller_model, wire_up_pty_controller_with_surface,
|
||||
};
|
||||
use crate::terminal::ShellLaunchState;
|
||||
use std::any::Any;
|
||||
|
||||
use crate::terminal::model_events::ModelEventDispatcher;
|
||||
use crate::terminal::writeable_pty::{self, Message};
|
||||
use crate::terminal::{terminal_manager, SizeInfo, TerminalModel, TerminalView};
|
||||
use async_channel::{Receiver, Sender, TrySendError};
|
||||
use galaxyui::{AppContext, ModelHandle, ViewHandle, WindowId};
|
||||
use parking_lot::FairMutex;
|
||||
use pathfinder_geometry::vector::Vector2F;
|
||||
use std::sync::mpsc::SyncSender;
|
||||
use std::sync::Arc;
|
||||
use crate::terminal::{
|
||||
terminal_manager, ShellLaunchState, SizeInfo, TerminalManager as TerminalManagerTrait,
|
||||
TerminalModel, TerminalView,
|
||||
};
|
||||
|
||||
type PtyController = writeable_pty::PtyController<Sender<Message>>;
|
||||
|
||||
@@ -34,7 +37,12 @@ pub struct TerminalManager {
|
||||
|
||||
_event_loop: ModelHandle<EventLoop>,
|
||||
|
||||
view: ViewHandle<TerminalView>,
|
||||
_view: ViewHandle<TerminalView>,
|
||||
}
|
||||
#[cfg_attr(not(feature = "remote_tty"), allow(dead_code))]
|
||||
pub struct TerminalManagerInit {
|
||||
pub(crate) manager: ModelHandle<Box<dyn TerminalManagerTrait>>,
|
||||
pub(crate) view: ViewHandle<TerminalView>,
|
||||
}
|
||||
|
||||
impl TerminalManager {
|
||||
@@ -46,7 +54,7 @@ impl TerminalManager {
|
||||
window_id: WindowId,
|
||||
initial_input_config: Option<InputConfig>,
|
||||
ctx: &mut AppContext,
|
||||
) -> ModelHandle<Box<dyn crate::terminal::TerminalManager>> {
|
||||
) -> TerminalManagerInit {
|
||||
// Create all the necessary channels we need for communication.
|
||||
let (wakeups_tx, wakeups_rx) = async_channel::unbounded();
|
||||
let (events_tx, events_rx) = async_channel::unbounded();
|
||||
@@ -122,11 +130,12 @@ impl TerminalManager {
|
||||
initial_input_config,
|
||||
None, // conversation_restoration - not used for remote
|
||||
None, // inactive_pty_reads_rx
|
||||
false,
|
||||
ctx,
|
||||
)
|
||||
});
|
||||
|
||||
wire_up_pty_controller_with_view(
|
||||
wire_up_pty_controller_with_surface(
|
||||
&pty_controller,
|
||||
&view,
|
||||
model.clone(),
|
||||
@@ -135,18 +144,26 @@ impl TerminalManager {
|
||||
ctx,
|
||||
);
|
||||
|
||||
// Clone the view before moving it into the manager so the caller can
|
||||
// receive it alongside the boxed manager.
|
||||
let terminal_view = view.clone();
|
||||
|
||||
// Create the terminal manager itself.
|
||||
let terminal_manager = Self {
|
||||
model,
|
||||
view,
|
||||
_view: view,
|
||||
_pty_controller: pty_controller,
|
||||
_event_loop: event_loop,
|
||||
};
|
||||
|
||||
ctx.add_model(|_ctx| {
|
||||
let manager: Box<dyn crate::terminal::TerminalManager> = Box::new(terminal_manager);
|
||||
let manager_model = ctx.add_model(|_ctx| {
|
||||
let manager: Box<dyn TerminalManagerTrait> = Box::new(terminal_manager);
|
||||
manager
|
||||
})
|
||||
});
|
||||
TerminalManagerInit {
|
||||
manager: manager_model,
|
||||
view: terminal_view,
|
||||
}
|
||||
}
|
||||
|
||||
fn create_and_start_event_loop(
|
||||
@@ -173,10 +190,6 @@ impl super::super::TerminalManager for TerminalManager {
|
||||
self.model.clone()
|
||||
}
|
||||
|
||||
fn view(&self) -> ViewHandle<TerminalView> {
|
||||
self.view.clone()
|
||||
}
|
||||
|
||||
fn as_any(&self) -> &dyn std::any::Any {
|
||||
self
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user