Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions apps/maple-agent/app/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,14 @@ impl AgentBackend {
}
}

/// A UI test backend that reports itself as connected to `peer`.
#[cfg(test)]
pub fn remote_for_test(peer: &str) -> Result<Self, String> {
let mut backend = Self::for_test("http://127.0.0.1:9".into(), String::new())?;
backend.remote_host = Some(peer.to_string());
Ok(backend)
}

pub fn new(api_url: String, _harness_instructions: String) -> Result<Self, String> {
let api_url = maple_agent::maple_api::validate_api_url(&api_url)?;
let runtime = Runtime::new().map_err(|e| format!("Could not start host client: {e}"))?;
Expand Down
18 changes: 11 additions & 7 deletions apps/maple-agent/app/src/ui/chat/sidebar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2023,14 +2023,18 @@ impl Sidebar {
if target.computer.as_deref() != self.backend.remote_host() {
return items;
}
let open_root = root.clone();
let remove_root = root.clone();
items.push(SidebarMenuItem {
id: target.element_id("open-project"),
icon: "folder-open",
label: "Open folder",
on_click: Box::new(move |this, cx| this.open_folder(&open_root, cx)),
});
// The file manager runs on this computer, so a paired computer's
// folder cannot be revealed from here.
if self.backend.remote_host().is_none() {
let open_root = root.clone();
items.push(SidebarMenuItem {
id: target.element_id("open-project"),
icon: "folder-open",
label: "Open folder",
on_click: Box::new(move |this, cx| this.open_folder(&open_root, cx)),
});
}
if let Some(status) = self
.menu_trust
.as_ref()
Expand Down
34 changes: 34 additions & 0 deletions apps/maple-agent/app/src/ui/chat/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6333,6 +6333,40 @@ mod state_tests {
);
});
}
/// The file manager runs on this computer: a project on a paired
/// computer never offers "Open folder", even while that computer is
/// the active one.
#[gpui::test]
fn only_a_local_project_offers_open_folder(cx: &mut TestAppContext) {
cx.executor().allow_parking();
for (backend, computer) in [
(
crate::backend::AgentBackend::for_test("http://127.0.0.1:9".into(), String::new()),
None,
),
(
crate::backend::AgentBackend::remote_for_test("east"),
Some("east"),
),
] {
let backend = Arc::new(backend.expect("backend"));
let chat = cx.new(|cx| {
let _guard = SETTINGS_LOCK.lock();
ChatScreen::new_without_start(backend, "user".to_string(), cx)
});
chat.update(cx, |this, cx| {
let menu = this
.sidebar
.read(cx)
.project_menu_labels_for_test(&ProjectTarget {
computer: computer.map(str::to_string),
path: "/shared".into(),
});
assert_eq!(menu.contains(&"Open folder"), computer.is_none());
assert!(menu.contains(&"Remove project"));
});
}
}

#[gpui::test]
fn inactive_project_rename_previews_and_failures_are_isolated_by_computer(
Expand Down
Loading