All your machines, one app. For you and your AI agents: agent sessions, desktops, files, logs and GitHub across your Macs, Linux and Windows machines, with an MCP server.
New box: GitHub or a folder on a machine, with results that read well
Adib Hanna1e5c7ae59497
diff --git a/src/ui/box_dialog.rs b/src/ui/box_dialog.rsindex e1e8833..660b3c2 100644--- a/src/ui/box_dialog.rs+++ b/src/ui/box_dialog.rs@@ -1,35 +1,60 @@//! New box: a task for an agent that works on it by itself, in a container-//! of its own on one of your machines, from one of your repositories or a-//! checkout on that machine (a local project).+//! of its own on one of your machines, from one of your GitHub repositories+//! or a folder on that machine (a local project).use std::sync::Arc;-use gpui::{AnyElement, App, Context, Entity, EventEmitter, FocusHandle, Focusable, FontWeight, SharedString, Subscription, Window, div, prelude::*, px};+use gpui::{AnyElement, App, Context, Entity, EventEmitter, FocusHandle, Focusable, FontWeight, KeyBinding, SharedString, Subscription, Window, actions, div, prelude::*, px};use super::dialogs::{DialogEvent, MODAL_CHROME, error_line, field, footer, frame};use super::input::{InputEvent, TextInput};use super::kit::{self, Button, ButtonStyle};-use super::theme::{ActiveTheme, Theme, mono_font};+use super::theme::{ActiveTheme, Theme};use crate::fleet::Engine;use crate::fleet::boxes::{BOX_AGENTS, CreateBox};use crate::fleet::model::{Checkout, Machine};use crate::github::hub;-/// How many of each the Repository field suggests.-const SHOW_CHECKOUTS: usize = 4;-const SHOW_REPOS: usize = 6;+actions!(box_dialog, [PickUp, PickDown]);++const CONTEXT: &str = "BoxDialog";+/// Results shown under the Repository field at most.+const SHOWN: usize = 6;++pub fn bind_keys(cx: &mut App) {+ cx.bind_keys([KeyBinding::new("up", PickUp, Some(CONTEXT)), KeyBinding::new("down", PickDown, Some(CONTEXT))]);+}++/// Where the box's code comes from.+#[derive(Clone, Copy, PartialEq, Eq)]+enum Source {+ /// One of your GitHub repositories (or any git URL), cloned fresh.+ GitHub,+ /// A folder on one of your machines (a checkout there): the box goes on that machine.+ Folder,+}++/// A result under the Repository field.+#[derive(Clone)]+enum Found {+ Repo(hub::Repo),+ Checkout(Checkout),+}pub struct BoxDialog {engine: Arc<Engine>,+ source: Source,repo: Entity<TextInput>,task: Entity<TextInput>,agent: String,- /// None: the machine with Docker and the most free memory.+ /// Where a GitHub box runs; None: the machine with Docker and the most free memory.machine: Option<String>,+ /// The machine whose folder a box starts from.+ folder_machine: Option<String>,/// Your GitHub repositories (favorites first), once they're read.repos: Option<Vec<hub::Repo>>,- /// A checkout picked from the list: the box goes on its machine, made from it.- checkout: Option<Checkout>,+ /// The result the arrows are on.+ highlight: usize,error: Option<String>,_subscriptions: Vec<Subscription>,}@@ -41,27 +66,55 @@ fn can_run(m: &Machine) -> bool {m.status == "online" && !m.platform.starts_with("windows") && m.probe.as_ref().is_some_and(|p| p.docker.is_some())}+/// "~/Developer/app" for "/Users/me/Developer/app" (or /home/me/...).+fn tilde(path: &str) -> String {+ for home in ["/Users/", "/home/"] {+ if let Some(rest) = path.strip_prefix(home) {+ return match rest.split_once('/') {+ Some((_, under)) => format!("~/{under}"),+ None => "~".into(),+ };+ }+ }+ path.to_string()+}++/// A folder's own name: "app" for "~/Developer/app".+fn folder_name(path: &str) -> &str {+ path.trim_end_matches('/').rsplit('/').next().unwrap_or(path)+}++const GITHUB_HINT: &str = "Search your repositories, or owner/name or a git URL";+const FOLDER_HINT: &str = "Search its checkouts, or a folder like ~/code/app";+impl BoxDialog {/// `repo` and `task`, when something opened it with them (an issue to fix).pub fn new(engine: Arc<Engine>, repo: Option<String>, task: Option<String>, window: &mut Window, cx: &mut Context<Self>) -> Self {- let repo = cx.new(|cx| TextInput::new(cx, "Search your repositories and checkouts, or owner/name, a git URL, a folder").mono().with_text(repo.unwrap_or_default()));+ let repo = cx.new(|cx| TextInput::new(cx, GITHUB_HINT).mono().with_text(repo.unwrap_or_default()));let task = cx.new(|cx| TextInput::new(cx, "Fix the login redirect loop, add a test, and open a pull request").with_text(task.unwrap_or_default()));- let mut subs = Vec::new();- for i in [&repo, &task] {- subs.push(cx.subscribe_in(i, window, |this: &mut Self, _, e: &InputEvent, _, cx| match e {+ let subs = vec![+ cx.subscribe_in(&repo, window, |this: &mut Self, _, e: &InputEvent, _, cx| match e {+ // Enter on a result picks it; on what's picked, starts the box.+ InputEvent::Submit => match this.found(cx).get(this.highlight).cloned() {+ Some(f) => this.pick(f, cx),+ None => this.submit(cx),+ },+ InputEvent::Cancel => cx.emit(DialogEvent::Dismissed),+ InputEvent::Changed => {+ this.error = None;+ this.highlight = 0;+ cx.notify()+ }+ }),+ cx.subscribe_in(&task, window, |this: &mut Self, _, e: &InputEvent, _, cx| match e {InputEvent::Submit => this.submit(cx),InputEvent::Cancel => cx.emit(DialogEvent::Dismissed),InputEvent::Changed => {this.error = None;- // Typed over the checkout picked: it's what's typed now.- let typed = this.repo.read(cx).text().trim().to_string();- if this.checkout.as_ref().is_some_and(|c| c.path != typed) {- this.checkout = None;- }cx.notify()}- }));- }+ }),+ ];// Your repositories, and the checkouts on the machines boxes can run on.let job = engine.runtime().spawn({let engine = engine.clone();@@ -80,32 +133,103 @@ impl BoxDialog {});}).detach();- BoxDialog { engine, repo, task, agent: "claude".into(), machine: None, repos: None, checkout: None, error: None, _subscriptions: subs }+ BoxDialog {+ engine,+ source: Source::GitHub,+ repo,+ task,+ agent: "claude".into(),+ machine: None,+ folder_machine: None,+ repos: None,+ highlight: 0,+ error: None,+ _subscriptions: subs,+ }}pub fn first_focus(&self, cx: &App) -> FocusHandle {if self.repo.read(cx).text().trim().is_empty() { self.repo.focus_handle(cx) } else { self.task.focus_handle(cx) }}- fn pick_repo(&mut self, name: String, cx: &mut Context<Self>) {- self.checkout = None;- self.repo.update(cx, |i, cx| i.set_text(name, cx));+ fn set_source(&mut self, source: Source, window: &mut Window, cx: &mut Context<Self>) {+ if self.source == source {+ return;+ }+ self.source = source;+ self.highlight = 0;+ // A folder's machine: one with checkouts, else any that can run a box.+ if source == Source::Folder && self.folder_machine.is_none() {+ let s = self.engine.current();+ let runs: Vec<&Machine> = s.machines.iter().filter(|m| can_run(m)).collect();+ self.folder_machine = runs.iter().find(|m| s.checkouts.iter().any(|c| c.machine_id == m.id)).or(runs.first()).map(|m| m.id.clone());+ }+ let hint = if source == Source::GitHub { GITHUB_HINT } else { FOLDER_HINT };+ self.repo.update(cx, |i, cx| {+ i.set_text("", cx);+ i.set_placeholder(hint, cx)+ });+ window.focus(&self.repo.focus_handle(cx));cx.notify();}- fn pick_checkout(&mut self, c: Checkout, cx: &mut Context<Self>) {- self.machine = Some(c.machine_id.clone());- let path = c.path.clone();- self.checkout = Some(c);- self.repo.update(cx, |i, cx| i.set_text(path, cx));+ /// The results for what's typed (none once one is picked).+ fn found(&self, cx: &App) -> Vec<Found> {+ let typed = self.repo.read(cx).text().trim().to_string();+ let q = typed.to_lowercase();+ match self.source {+ Source::GitHub => {+ // Nothing typed: the favorites show instead.+ let repos = self.repos.iter().flatten();+ if q.is_empty() || repos.clone().any(|r| r.full_name.eq_ignore_ascii_case(&typed)) {+ return Vec::new();+ }+ let mut hits: Vec<&hub::Repo> = repos.filter(|r| !r.archived && r.full_name.to_lowercase().contains(&q)).collect();+ // Names that start with it first ("open" finds acme/openrunner before acme/reopen).+ hits.sort_by_key(|r| !r.full_name.to_lowercase().split('/').any(|part| part.starts_with(&q)));+ hits.into_iter().take(SHOWN).cloned().map(Found::Repo).collect()+ }+ Source::Folder => {+ let s = self.engine.current();+ let Some(machine) = &self.folder_machine else { return Vec::new() };+ let here: Vec<&Checkout> = s.checkouts.iter().filter(|c| &c.machine_id == machine).collect();+ if here.iter().any(|c| c.path == typed) {+ return Vec::new();+ }+ let mut hits: Vec<&Checkout> =+ here.into_iter().filter(|c| q.is_empty() || c.path.to_lowercase().contains(&q) || c.repo.as_deref().is_some_and(|r| r.to_lowercase().contains(&q))).collect();+ hits.sort_by_key(|c| (!folder_name(&c.path).to_lowercase().starts_with(&q), std::cmp::Reverse(c.last_commit_at)));+ hits.into_iter().take(SHOWN).cloned().map(Found::Checkout).collect()+ }+ }+ }++ fn pick(&mut self, found: Found, cx: &mut Context<Self>) {+ let text = match found {+ Found::Repo(r) => r.full_name,+ Found::Checkout(c) => c.path,+ };+ self.repo.update(cx, |i, cx| i.set_text(text, cx));+ self.highlight = 0;cx.notify();}+ fn move_highlight(&mut self, by: isize, cx: &mut Context<Self>) {+ let n = self.found(cx).len();+ if n > 0 {+ self.highlight = (self.highlight as isize + by).rem_euclid(n as isize) as usize;+ cx.notify();+ }+ }+fn submit(&mut self, cx: &mut Context<Self>) {let repo = self.repo.read(cx).text().trim().to_string();let task = self.task.read(cx).text().trim().to_string();if repo.is_empty() {- self.error = Some("Which repository? Pick one, or type owner/name, a git URL or a folder.".into());+ self.error = Some(match self.source {+ Source::GitHub => "Which repository? Search for one, or type owner/name or a git URL.".into(),+ Source::Folder => "Which folder? Pick a checkout, or type its folder.".into(),+ });cx.notify();return;}@@ -114,7 +238,15 @@ impl BoxDialog {cx.notify();return;}- let machine = self.checkout.as_ref().map(|c| c.machine_id.clone()).or_else(|| self.machine.clone());+ let machine = match self.source {+ Source::GitHub => self.machine.clone(),+ Source::Folder => self.folder_machine.clone(),+ };+ if self.source == Source::Folder && machine.is_none() {+ self.error = Some("Which machine is the folder on?".into());+ cx.notify();+ return;+ }let req = CreateBox { repo, prompt: task, agent: self.agent.clone(), machine, ..Default::default() };match self.engine.box_create(req) {Ok((op, _)) => cx.emit(DialogEvent::BoxStarted(op)),@@ -125,90 +257,48 @@ impl BoxDialog {}}- /// The Repository field's suggestions: checkouts on the machines boxes- /// can run on, then your GitHub repositories, matching what's typed.- fn suggestions(&self, theme: &Theme, typed: &str, cx: &mut Context<Self>) -> Option<AnyElement> {- let q = typed.to_lowercase();- // Picked (or typed exactly): nothing more to suggest.- if self.checkout.as_ref().is_some_and(|c| c.path == typed) || self.repos.iter().flatten().any(|r| r.full_name.eq_ignore_ascii_case(typed)) {- return None;- }- let s = self.engine.current();- let machine_name = |id: &str| s.machines.iter().find(|m| m.id == id).map(|m| m.name.clone()).unwrap_or_else(|| id.to_string());- let runs = |id: &str| s.machines.iter().any(|m| m.id == id && can_run(m));- let checkouts: Vec<Checkout> = s- .checkouts- .iter()- .filter(|c| runs(&c.machine_id))- .filter(|c| q.is_empty() || c.path.to_lowercase().contains(&q) || c.repo.as_deref().is_some_and(|r| r.to_lowercase().contains(&q)) || machine_name(&c.machine_id).to_lowercase().contains(&q))- .take(SHOW_CHECKOUTS)- .cloned()- .collect();- let repos: Vec<hub::Repo> = self.repos.iter().flatten().filter(|r| !r.archived && (q.is_empty() || r.full_name.to_lowercase().contains(&q))).take(SHOW_REPOS).cloned().collect();- let row = |id: SharedString, icon: &'static str, title: String, detail: String| {- div()- .id(id)- .flex()- .items_center()- .gap(px(8.))- .px(px(8.))- .py(px(5.))- .rounded(px(6.))- .cursor_pointer()- .hover(|st| st.bg(theme.ghost_hover))- .child(kit::icon(icon, 13., theme.text_placeholder))- .child(div().flex_none().max_w(px(260.)).truncate().font_family(mono_font()).text_size(px(12.)).text_color(theme.text).child(title))- .child(div().flex_1().min_w(px(0.)).truncate().text_size(px(11.5)).text_color(theme.text_placeholder).child(detail))- };- let heading = |text: &'static str| div().px(px(8.)).pt(px(4.)).text_size(px(11.)).text_color(theme.text_placeholder).child(text);- let mut list: Vec<AnyElement> = Vec::new();- if !checkouts.is_empty() {- list.push(heading("On your machines").into_any_element());- for (i, c) in checkouts.into_iter().enumerate() {- let mut detail = vec![machine_name(&c.machine_id)];+ /// One result: its name first, then where it is.+ fn result_row(&self, theme: &Theme, i: usize, found: &Found, cx: &mut Context<Self>) -> AnyElement {+ let (icon, name, detail) = match found {+ Found::Repo(r) => {+ let mut detail = Vec::new();+ if r.private {+ detail.push("private".to_string());+ }+ if let Some(d) = r.description.clone().filter(|d| !d.is_empty()) {+ detail.push(d);+ }+ ("agent-github", r.full_name.clone(), detail.join(" · "))+ }+ Found::Checkout(c) => {+ let mut detail = vec![tilde(&c.path)];if !c.branch.is_empty() {detail.push(c.branch.clone());}if c.dirty > 0 {detail.push(format!("{} uncommitted", c.dirty));}- if let Some(r) = &c.repo {- detail.push(r.clone());- }- let pick = c.clone();- list.push(- row(SharedString::from(format!("bx-co-{i}")), "folder", c.path.clone(), detail.join(" · "))- .on_click(cx.listener(move |this, _, _, cx| this.pick_checkout(pick.clone(), cx)))- .into_any_element(),- );- }- }- match &self.repos {- None => list.push(div().px(px(8.)).py(px(4.)).text_size(px(11.5)).text_color(theme.text_placeholder).child("Reading your repositories…").into_any_element()),- Some(_) if repos.is_empty() => {}- Some(_) => {- list.push(heading("On GitHub").into_any_element());- for r in repos {- let mut detail = Vec::new();- if r.favorite {- detail.push("favorite".to_string());- }- if r.private {- detail.push("private".into());- }- if let Some(d) = r.description.clone().filter(|d| !d.is_empty()) {- detail.push(d);- }- let name = r.full_name.clone();- list.push(- row(SharedString::from(format!("bx-gh-{}", r.full_name)), "agent-github", r.full_name.clone(), detail.join(" · "))- .on_click(cx.listener(move |this, _, _, cx| this.pick_repo(name.clone(), cx)))- .into_any_element(),- );- }+ ("folder", folder_name(&c.path).to_string(), detail.join(" · "))}- }- (!list.is_empty()).then(|| div().flex().flex_col().gap(px(1.)).p(px(4.)).rounded(px(8.)).border_1().border_color(theme.border_variant).bg(theme.surface).children(list).into_any_element())+ };+ let on = i == self.highlight;+ let pick = found.clone();+ div()+ .id(("bx-found", i))+ .flex()+ .items_center()+ .gap(px(8.))+ .h(px(30.))+ .px(px(8.))+ .rounded(px(6.))+ .cursor_pointer()+ .when(on, |d| d.bg(theme.element_selected))+ .when(!on, |d| d.hover(|st| st.bg(theme.ghost_hover)))+ .child(kit::icon(icon, 14., theme.text_muted))+ .child(div().flex_none().text_size(px(13.)).font_weight(FontWeight::MEDIUM).text_color(theme.text).child(name))+ .child(div().flex_1().min_w(px(0.)).truncate().text_size(px(11.5)).text_color(theme.text_placeholder).child(detail))+ .on_click(cx.listener(move |this, _, _, cx| this.pick(pick.clone(), cx)))+ .into_any_element()}}@@ -221,7 +311,7 @@ impl Focusable for BoxDialog {impl Render for BoxDialog {fn render(&mut self, window: &mut Window, cx: &mut Context<Self>) -> impl IntoElement {let theme = cx.theme();- let base = |id: SharedString, selected: bool, enabled: bool| {+ let chip = |id: SharedString, selected: bool, enabled: bool| {div().id(id).h(px(26.))@@ -238,25 +328,111 @@ impl Render for BoxDialog {.when(enabled, |d| d.cursor_pointer())};let s = self.engine.current();-+ let machine_name = |id: &str| s.machines.iter().find(|m| m.id == id).map(|m| m.name.clone()).unwrap_or_else(|| id.to_string());let typed = self.repo.read(cx).text().trim().to_string();- let picked = self.checkout.clone().filter(|c| c.path == typed);- let note = match &picked {- Some(c) => Some(format!(- "A checkout on {}: the box starts from it{}, on a branch of its own. Your checkout isn't touched.",- s.machines.iter().find(|m| m.id == c.machine_id).map(|m| m.name.clone()).unwrap_or_else(|| c.machine_id.clone()),- if c.dirty > 0 { format!(", with its {} uncommitted files", c.dirty) } else { String::new() }- )),- None if typed.starts_with('/') || typed.starts_with("~/") => Some("A folder: a git checkout on the machine picked below, which the box starts from (with its uncommitted changes).".to_string()),- None => None,- };- let repo = div()+ let quiet = |text: String| div().text_size(px(11.5)).text_color(theme.text_placeholder).child(text);++ // Where the code comes from.+ let sources = div().flex()- .flex_col()- .gap(px(8.))- .child(self.repo.clone())- .children(self.suggestions(&theme, &typed, cx))- .children(note.map(|n| div().text_size(px(11.5)).text_color(theme.text_placeholder).child(n)));+ .gap(px(6.))+ .child(chip("bx-src-gh".into(), self.source == Source::GitHub, true).pl(px(6.)).child(kit::icon("agent-github", 13., theme.text_muted)).child("GitHub").on_click(cx.listener(+ |this, _, window, cx| this.set_source(Source::GitHub, window, cx),+ )))+ .child(chip("bx-src-folder".into(), self.source == Source::Folder, true).pl(px(6.)).child(kit::icon("folder", 13., theme.text_muted)).child("A folder on a machine").on_click(+ cx.listener(|this, _, window, cx| this.set_source(Source::Folder, window, cx)),+ ));++ let found = self.found(cx);+ let rows: Vec<AnyElement> = found.iter().enumerate().map(|(i, f)| self.result_row(&theme, i, f, cx)).collect();+ let results = (!rows.is_empty()).then(|| div().flex().flex_col().p(px(4.)).rounded(px(8.)).border_1().border_color(theme.border_variant).bg(theme.surface).children(rows));++ let code: AnyElement = match self.source {+ Source::GitHub => {+ // Nothing typed yet: your favorites, one click away.+ let favorites: Vec<AnyElement> = if typed.is_empty() {+ self.repos+ .iter()+ .flatten()+ .filter(|r| r.favorite)+ .take(6)+ .map(|r| {+ let name = r.full_name.clone();+ chip(SharedString::from(format!("bx-fav-{name}")), false, true)+ .child(r.full_name.clone())+ .on_click(cx.listener(move |this, _, _, cx| {+ this.repo.update(cx, |i, cx| i.set_text(name.clone(), cx));+ cx.notify()+ }))+ .into_any_element()+ })+ .collect()+ } else {+ Vec::new()+ };+ let status = match &self.repos {+ None if !typed.is_empty() => Some(quiet("Reading your repositories…".into())),+ Some(_) if !typed.is_empty() && found.is_empty() && !self.repos.iter().flatten().any(|r| r.full_name.eq_ignore_ascii_case(&typed)) => {+ Some(quiet("None of your repositories match; it's used as typed (owner/name or a git URL).".into()))+ }+ _ => None,+ };+ div()+ .flex()+ .flex_col()+ .gap(px(8.))+ .child(self.repo.clone())+ .children(results)+ .when(!favorites.is_empty(), |d| d.child(div().flex().flex_wrap().items_center().gap(px(6.)).child(quiet("Favorites".into())).children(favorites)))+ .children(status)+ .into_any_element()+ }+ Source::Folder => {+ let machines: Vec<AnyElement> = s+ .machines+ .iter()+ .filter(|m| m.status == "online" && !m.platform.starts_with("windows"))+ .map(|m| {+ let id = m.id.clone();+ let ok = can_run(m);+ let (from, to) = super::format::machine_tile(m);+ chip(SharedString::from(format!("bx-fm-{id}")), self.folder_machine.as_deref() == Some(id.as_str()), ok)+ .pl(px(4.))+ .child(kit::tile(super::format::machine_icon(m), from, to, 18.))+ .child(m.name.clone())+ .when(!ok, |d| d.child(div().text_size(px(11.)).child("no Docker")))+ .when(ok, |d| {+ d.on_click(cx.listener(move |this, _, _, cx| {+ this.folder_machine = Some(id.clone());+ this.highlight = 0;+ cx.notify()+ }))+ })+ .into_any_element()+ })+ .collect();+ let checkouts = self.folder_machine.as_ref().map(|m| s.checkouts.iter().filter(|c| &c.machine_id == m).count()).unwrap_or(0);+ let picked = self.folder_machine.as_ref().and_then(|m| s.checkouts.iter().find(|c| &c.machine_id == m && c.path == typed));+ let note = match (picked, &self.folder_machine) {+ (Some(c), _) => Some(format!(+ "The box starts from this checkout as it is now{}, on a branch of its own. Your checkout isn't touched.",+ if c.dirty > 0 { format!(", with its {} uncommitted files", c.dirty) } else { String::new() }+ )),+ (None, Some(m)) if !typed.is_empty() && found.is_empty() => Some(format!("A git checkout in this folder on {}: the box starts from it, with its uncommitted changes.", machine_name(m))),+ (None, Some(m)) if checkouts == 0 => Some(format!("Muxin hasn't found checkouts on {} (Settings › General › Code folders): type the folder.", machine_name(m))),+ _ => None,+ };+ div()+ .flex()+ .flex_col()+ .gap(px(8.))+ .child(div().flex().flex_wrap().gap(px(6.)).children(machines))+ .child(self.repo.clone())+ .children(results)+ .children(note.map(quiet))+ .into_any_element()+ }+ };let agents: Vec<AnyElement> = BOX_AGENTS.iter()@@ -264,7 +440,7 @@ impl Render for BoxDialog {.map(|a| {let id = a.id.to_string();let (glyph, (from, to)) = kit::agent_look(a.id);- base(SharedString::from(format!("bx-a-{id}")), self.agent == id, true)+ chip(SharedString::from(format!("bx-a-{id}")), self.agent == id, true).pl(px(4.)).child(kit::tile(glyph, from, to, 18.)).child(a.name)@@ -281,63 +457,57 @@ impl Render for BoxDialog {.flex_col().gap(px(8.)).child(div().flex().flex_wrap().gap(px(6.)).children(agents))- .child(div().text_size(px(11.5)).text_color(theme.text_placeholder).child(format!(- "{name} is signed in as it is on that machine. If it isn't signed in there, sign it in once from the box's terminal."- )));-- // Where: the best machine, or one picked (a checkout's own, when one is).- let fixed = picked.as_ref().map(|c| c.machine_id.clone());- let mut machines: Vec<AnyElement> = Vec::new();- if fixed.is_none() {- machines.push(- base("bx-m-auto".into(), self.machine.is_none(), true)- .child("Best one")- .on_click(cx.listener(|this, _, _, cx| {- this.machine = None;- cx.notify()- }))- .into_any_element(),- );- }- machines.extend(s.machines.iter().filter(|m| m.status == "online" && !m.platform.starts_with("windows")).filter(|m| fixed.as_ref().is_none_or(|f| *f == m.id)).map(|m| {- let id = m.id.clone();- let ok = can_run(m);- let (from, to) = super::format::machine_tile(m);- base(SharedString::from(format!("bx-m-{id}")), self.machine.as_deref() == Some(id.as_str()) || fixed.as_deref() == Some(id.as_str()), ok)- .pl(px(4.))- .child(kit::tile(super::format::machine_icon(m), from, to, 18.))- .child(m.name.clone())- .when(!ok, |d| d.child(div().text_size(px(11.)).child("no Docker")))- .when(ok, |d| {- d.on_click(cx.listener(move |this, _, _, cx| {- this.machine = Some(id.clone());- cx.notify()- }))- })- .into_any_element()- }));+ .child(quiet(format!("{name} is signed in as it is on that machine. If it isn't signed in there, sign it in once from the box's terminal.")));++ // Where a GitHub box runs (a folder's box runs on the folder's machine).let any = s.machines.iter().any(can_run);- let place = div()- .flex()- .flex_col()- .gap(px(8.))- .child(div().flex().flex_wrap().gap(px(6.)).children(machines))- .child(div().text_size(px(11.5)).text_color(if any { theme.text_placeholder } else { theme.warning }).child(match (any, fixed.is_some()) {- (false, _) => "Boxes run in Docker: install it on a Linux machine or a Mac (Docker Desktop, OrbStack or Colima).",- (true, true) => "On the checkout's machine, in a Docker container there. The first box on a machine builds Muxin's image (a few minutes).",- (true, false) => "In a Docker container there, on a new branch of a fresh checkout. The first box on a machine builds Muxin's image (a few minutes).",+ let place = (self.source == Source::GitHub).then(|| {+ let mut machines: Vec<AnyElement> = vec![chip("bx-m-auto".into(), self.machine.is_none(), true)+ .child("Best one")+ .on_click(cx.listener(|this, _, _, cx| {+ this.machine = None;+ cx.notify()+ }))+ .into_any_element()];+ machines.extend(s.machines.iter().filter(|m| m.status == "online" && !m.platform.starts_with("windows")).map(|m| {+ let id = m.id.clone();+ let ok = can_run(m);+ let (from, to) = super::format::machine_tile(m);+ chip(SharedString::from(format!("bx-m-{id}")), self.machine.as_deref() == Some(id.as_str()), ok)+ .pl(px(4.))+ .child(kit::tile(super::format::machine_icon(m), from, to, 18.))+ .child(m.name.clone())+ .when(!ok, |d| d.child(div().text_size(px(11.)).child("no Docker")))+ .when(ok, |d| {+ d.on_click(cx.listener(move |this, _, _, cx| {+ this.machine = Some(id.clone());+ cx.notify()+ }))+ })+ .into_any_element()}));+ div().flex().flex_col().gap(px(8.)).child(div().flex().flex_wrap().gap(px(6.)).children(machines)).child(+ div().text_size(px(11.5)).text_color(if any { theme.text_placeholder } else { theme.warning }).child(if any {+ "In a Docker container there, on a new branch of a fresh clone. The first box on a machine builds Muxin's image (a few minutes)."+ } else {+ "Boxes run in Docker: install it on a Linux machine or a Mac (Docker Desktop, OrbStack or Colima)."+ }),+ )+ });let body_max = (f32::from(window.viewport_size().height) - MODAL_CHROME).max(220.);let fields = div().flex().flex_col().gap(px(14.))- .child(field(&theme, "Repository", repo, None))+ .child(field(&theme, "Code", div().flex().flex_col().gap(px(10.)).child(sources).child(code), None)).child(field(&theme, "Task", self.task.clone(), Some("What the agent works on. It can push its branch and open a pull request."))).child(field(&theme, "Agent", agent, None))- .child(field(&theme, "On", place, None));+ .children(place.map(|p| field(&theme, "On", p, None)));frame(&theme, "New box", Some("An agent works on the task by itself, in a container of its own with its permission prompts off. The box pauses when it's been quiet a while and picks up again when you ask it more.".into()))+ .key_context(CONTEXT)+ .on_action(cx.listener(|this, _: &PickUp, _, cx| this.move_highlight(-1, cx)))+ .on_action(cx.listener(|this, _: &PickDown, _, cx| this.move_highlight(1, cx))).child(div().id("bx-body").max_h(px(body_max)).overflow_y_scroll().child(fields)).children(error_line(&theme, &self.error)).child(footer(vec![@@ -347,3 +517,17 @@ impl Render for BoxDialog {.font_weight(FontWeight::NORMAL)}}++#[cfg(test)]+mod tests {+ use super::*;++ #[test]+ fn folders_show_by_name_with_short_paths() {+ assert_eq!(tilde("/Users/adib/Developer/opensource/openrunner"), "~/Developer/opensource/openrunner");+ assert_eq!(tilde("/home/adib/code/api"), "~/code/api");+ assert_eq!(tilde("/srv/app"), "/srv/app");+ assert_eq!(folder_name("/Users/adib/Developer/opensource/openrunner"), "openrunner");+ assert_eq!(folder_name("~/code/api/"), "api");+ }+}diff --git a/src/ui/mod.rs b/src/ui/mod.rsindex 1e878a2..291fce8 100644--- a/src/ui/mod.rs+++ b/src/ui/mod.rs@@ -64,6 +64,7 @@ pub fn run(engine: Arc<Engine>, initial_view: Option<String>) {cx.set_global(appearance.resolve(cx.window_appearance()));cx.set_global(appearance);input::bind_keys(cx);+ box_dialog::bind_keys(cx);terminal::bind_keys(cx);desktop::bind_keys(cx);root::bind_keys(cx);diff --git a/src/ui/shortcuts.rs b/src/ui/shortcuts.rsindex ec007e4..949c9e0 100644--- a/src/ui/shortcuts.rs+++ b/src/ui/shortcuts.rs@@ -176,6 +176,7 @@ pub fn ctrl_keys(cx: &App) -> Vec<String> {pub fn apply(cx: &mut App) {cx.clear_key_bindings();super::input::bind_keys(cx);+ super::box_dialog::bind_keys(cx);super::terminal::bind_keys(cx);super::desktop::bind_keys(cx);super::root::bind_keys(cx);