A modern terminal with a built-in multiplexer: close it and your sessions keep running. Run shells and tons of AI agents across your machines, then pick them up from desktop, browser, TUI and more. Written in Rust with no UI framework: interface drawn straight on the GPU. No Electron, GPUI or webview.
Rust agentagent-orchestrationaiai-agentsclaude-codecodexcoding-agentlinuxmacosmultiplayermultiplexerrustterminalterminal-emulatorterminal-multiplexertmuxtuiweztermwindows
better remote workspace ui
RoversX733314110aba
diff --git a/wezterm-gui/src/overlay/prompt.rs b/wezterm-gui/src/overlay/prompt.rsindex ba42e2cf..e4b3490f 100644--- a/wezterm-gui/src/overlay/prompt.rs+++ b/wezterm-gui/src/overlay/prompt.rs@@ -3,9 +3,11 @@ use config::keyassignment::{KeyAssignment, PromptInputLine};use mux::termwiztermtab::TermWizTerminal;use mux_lua::MuxPane;use std::rc::Rc;-use termwiz::input::{InputEvent, KeyCode, KeyEvent};+use termwiz::cell::{unicode_column_width, AttributeChange, CellAttributes};+use termwiz::color::ColorAttribute;+use termwiz::input::{InputEvent, KeyCode, KeyEvent, Modifiers, MouseButtons, MouseEvent};use termwiz::lineedit::*;-use termwiz::surface::Change;+use termwiz::surface::{Change, Position};use termwiz::terminal::Terminal;struct PromptHost {@@ -93,6 +95,187 @@ pub fn read_line_prompt_overlay(Ok(editor.read_line_with_optional_initial_value(&mut host, initial_value)?)}+/// Does the typed text read as a filesystem path (rather than a filter term+/// for the candidate list)?+fn looks_like_path(input: &str) -> bool {+ let input = input.trim_start();+ input.starts_with('/') || input.starts_with('~') || input.starts_with('.')+}++/// An interactive line prompt with a candidate list: Up/Down (or Ctrl-P/N)+/// moves the selection, typing fuzzy-filters the candidates, and text that+/// looks like a path (`~/...`, `/...`, `./...`) is offered verbatim as the+/// first entry. Enter confirms the highlighted entry; Esc or Ctrl-C cancels.+/// Returns the chosen string, or None when cancelled.+pub fn pick_path_prompt_overlay(+ mut term: TermWizTerminal,+ description: &str,+ prompt: &str,+ candidates: Vec<String>,+) -> anyhow::Result<Option<String>> {+ term.set_raw_mode()?;++ let description = description.replace("\r\n", "\n");+ let description_rows = description.split('\n').count();+ let hint = "Up/Down select, Enter confirm, Esc cancel";++ fn picked_value(path_input: bool, input: &str, filtered: &[&String], idx: usize) -> String {+ if path_input && idx == 0 {+ input.trim().to_string()+ } else {+ filtered[idx - usize::from(path_input)].to_string()+ }+ }++ let mut input = String::new();+ let mut active = 0usize;+ let mut top_row = 0usize;++ loop {+ let filtered: Vec<&String> = if input.trim().is_empty() {+ candidates.iter().collect()+ } else {+ let pattern = super::selector::matcher_pattern(input.trim());+ let mut scored: Vec<(u32, &String)> = candidates+ .iter()+ .filter_map(|c| super::selector::matcher_score(&pattern, c).map(|s| (s, c)))+ .collect();+ scored.sort_by(|a, b| b.0.cmp(&a.0));+ scored.into_iter().map(|(_, c)| c).collect()+ };+ let path_input = looks_like_path(&input);+ let n_rows = filtered.len() + usize::from(path_input);+ if active >= n_rows {+ active = n_rows.saturating_sub(1);+ }++ let size = term.get_screen_size()?;+ let max_width = size.cols.saturating_sub(2).max(8);+ let list_capacity = size+ .rows+ .saturating_sub(description_rows + 2)+ .max(1)+ .min(n_rows);+ if active < top_row {+ top_row = active;+ } else if active >= top_row + list_capacity {+ top_row = active + 1 - list_capacity;+ }++ let mut changes = vec![+ Change::ClearScreen(ColorAttribute::Default),+ Change::CursorPosition {+ x: Position::Absolute(0),+ y: Position::Absolute(0),+ },+ Change::Text(format!("{}\r\n", description.replace('\n', "\r\n"))),+ Change::Attribute(AttributeChange::Intensity(+ termwiz::cell::Intensity::Half,+ )),+ Change::Text(format!("{hint}\r\n")),+ Change::AllAttributes(CellAttributes::default()),+ Change::Text(format!("{prompt}{input}\r\n")),+ ];+ for (row, idx) in (top_row..(top_row + list_capacity).min(n_rows)).enumerate() {+ let _ = row;+ let label = if path_input && idx == 0 {+ format!("Use path: {}", input.trim())+ } else {+ filtered[idx - usize::from(path_input)].to_string()+ };+ let label: String = label.chars().take(max_width).collect();+ if idx == active {+ changes.push(Change::Attribute(AttributeChange::Reverse(true)));+ changes.push(Change::Text(format!(" {label} \r\n")));+ changes.push(Change::Attribute(AttributeChange::Reverse(false)));+ } else {+ changes.push(Change::Text(format!(" {label} \r\n")));+ }+ }+ changes.push(Change::CursorPosition {+ x: Position::Absolute(unicode_column_width(prompt, None) + unicode_column_width(&input, None)),+ y: Position::Absolute(description_rows + 1),+ });+ term.render(&changes)?;++ let Some(event) = term.poll_input(None)? else {+ return Ok(None);+ };+ match event {+ InputEvent::Key(KeyEvent { key, modifiers }) => match (key, modifiers) {+ (KeyCode::Escape, _) => return Ok(None),+ (KeyCode::Char('c'), Modifiers::CTRL)+ | (KeyCode::Char('g'), Modifiers::CTRL) => return Ok(None),+ (KeyCode::UpArrow, _) | (KeyCode::Char('p'), Modifiers::CTRL) => {+ active = active.saturating_sub(1);+ }+ (KeyCode::DownArrow, _) | (KeyCode::Char('n'), Modifiers::CTRL) => {+ if n_rows > 0 {+ active = (active + 1).min(n_rows - 1);+ }+ }+ (KeyCode::Enter, _) => {+ if n_rows == 0 {+ let text = input.trim();+ if !text.is_empty() {+ return Ok(Some(text.to_string()));+ }+ } else {+ return Ok(Some(picked_value(path_input, &input, &filtered, active)));+ }+ }+ (KeyCode::Backspace, _) => {+ input.pop();+ active = 0;+ top_row = 0;+ }+ (KeyCode::Char('u'), Modifiers::CTRL) => {+ input.clear();+ active = 0;+ top_row = 0;+ }+ (KeyCode::Char(c), mods)+ if !mods.intersects(+ Modifiers::CTRL | Modifiers::ALT | Modifiers::SUPER,+ ) =>+ {+ input.push(c);+ active = 0;+ top_row = 0;+ }+ _ => {}+ },+ InputEvent::Mouse(MouseEvent {+ mouse_buttons, ..+ }) if mouse_buttons.contains(MouseButtons::VERT_WHEEL) => {+ if mouse_buttons.contains(MouseButtons::WHEEL_POSITIVE) {+ top_row = top_row.saturating_sub(1);+ } else {+ top_row = (top_row + 1).min(n_rows.saturating_sub(list_capacity));+ }+ active = active.clamp(top_row, top_row + list_capacity.saturating_sub(1));+ }+ InputEvent::Mouse(MouseEvent {+ y, mouse_buttons, ..+ }) => {+ // Rows above the list: description, hint, then the input line.+ let list_top = description_rows + 2;+ if let Some(row) = (y as usize).checked_sub(list_top) {+ let idx = top_row + row;+ if idx < n_rows {+ active = idx;+ if mouse_buttons == MouseButtons::LEFT {+ return Ok(Some(picked_value(path_input, &input, &filtered, idx)));+ }+ }+ }+ }+ InputEvent::Resized { .. } => {}+ _ => {}+ }+ }+}+fn trampoline(name: String, window: GuiWin, pane: MuxPane, line: Option<String>) {promise::spawn::spawn(async move {config::with_lua_config_on_main_thread(move |lua| do_event(lua, name, window, pane, line))diff --git a/wezterm-gui/src/termwindow/mod.rs b/wezterm-gui/src/termwindow/mod.rsindex 7662a413..2a0b5b3a 100644--- a/wezterm-gui/src/termwindow/mod.rs+++ b/wezterm-gui/src/termwindow/mod.rs@@ -4183,30 +4183,23 @@ impl TermWindow {}}- let mut description =- format!("Add a project on {domain_name}: enter a remote directory path");- if !candidates.is_empty() {- description.push_str("\nKnown remote directories:");- for (idx, path) in candidates.iter().enumerate() {- description.push_str(&format!("\n {}. {}", idx + 1, path));- }- description.push_str("\nType a number to pick one, or type a path.");+ if !candidates.iter().any(|c| c == "~") {+ candidates.push("~".to_string());}+ let description = format!(+ "Add a project on {domain_name}: pick a remote directory below,\n\+ type to filter, or type a path (~/dir or /dir)."+ );+let (overlay, future) = start_overlay(self, &tab, move |_tab_id, term| {- let line = crate::overlay::prompt::read_line_prompt_overlay(+ let picked = crate::overlay::prompt::pick_path_prompt_overlay(term,&description,"path> ",- Some("~/"),+ candidates,)?;- if let Some(input) = line.map(|s| s.trim().to_string()).filter(|s| !s.is_empty())- {- let path = input- .parse::<usize>()- .ok()- .and_then(|n| candidates.get(n.checked_sub(1)?).cloned())- .unwrap_or(input);+ if let Some(path) = picked.filter(|path| !path.is_empty()) {window.notify(TermWindowNotif::OpenProjectPath(PathBuf::from(path)));}Ok(())