Skip to content

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.

feat(import): offer folders cmux worked in

RoversX60d10c3ac111
diff --git a/assets/ui/cmux.svg b/assets/ui/cmux.svg
new file mode 100644
index 00000000..2046aba0
--- /dev/null
+++ b/assets/ui/cmux.svg
@@ -0,0 +1,3 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24">
+ <path d="M6.2 3.6 19.4 12 6.2 20.4V15.5L12.4 12 6.2 8.5Z" fill="#fff" stroke="#fff" stroke-width="1.2" stroke-linejoin="round"/>
+</svg>
diff --git a/wezterm-gui/src/editor_projects.rs b/wezterm-gui/src/editor_projects.rs
index 70b9a8b8..6607b2ec 100644
--- a/wezterm-gui/src/editor_projects.rs
+++ b/wezterm-gui/src/editor_projects.rs
@@ -1,5 +1,5 @@
//! The folders VS Code and the editors built from it have opened, and the
-//! ones coding agents -- Claude Code, Codex, Pi -- worked in, for
+//! ones coding agents -- Claude Code, Codex, Pi -- and cmux worked in, for
//! the Import page and first-run setup to offer as projects.
//!
//! Each of these editors keeps a directory per opened folder under
@@ -55,6 +55,7 @@ pub(crate) enum EditorKind {
Claude,
Codex,
Pi,
+ Cmux,
}
impl EditorKind {
@@ -69,12 +70,22 @@ impl EditorKind {
}
}
- /// The glyph drawn white where it has no mark in colour.
+ /// The colour its glyph is drawn in: white, but for cmux's blue
+ /// chevron on its light tile.
+ fn glyph_color(self) -> LinearRgba {
+ match self {
+ Self::Cmux => LinearRgba::with_srgba(0x3B, 0x7B, 0xF6, 0xFF),
+ _ => LinearRgba::with_srgba(0xFF, 0xFF, 0xFF, 0xFF),
+ }
+ }
+
+ /// The glyph drawn where it has no mark in colour, in `glyph_color`.
fn glyph(self) -> SvgIcon {
match self {
Self::VsCode => SvgIcon::VsCode,
Self::Codex => SvgIcon::AgentCodex,
Self::Pi => SvgIcon::AgentPi,
+ Self::Cmux => SvgIcon::Cmux,
_ => SvgIcon::CodeXml,
}
}
@@ -90,6 +101,7 @@ impl EditorKind {
Self::Claude => (0x2B, 0x2B, 0x30),
Self::Codex => (0x14, 0x14, 0x14),
Self::Pi => (0x1F, 0x1F, 0x22),
+ Self::Cmux => (0xEE, 0xEF, 0xF2),
};
LinearRgba::with_srgba(r, g, b, 0xFF)
}
@@ -176,7 +188,7 @@ pub(crate) fn draw_stack(
mark_x,
mark_y,
mark,
- LinearRgba::with_srgba(0xFF, 0xFF, 0xFF, 0xFF),
+ kind.glyph_color(),
)?,
}
}
@@ -285,7 +297,7 @@ pub(crate) fn draw_ring(
mark_x,
mark_y,
mark,
- LinearRgba::with_srgba(0xFF, 0xFF, 0xFF, 0xFF),
+ kind.glyph_color(),
)?,
}
}
@@ -429,9 +441,10 @@ fn scan_roots(
merge(editors, opened, resolve)
}
-/// A coding agent: what to call it, whether this machine has used it, and
-/// the folders it worked in with when each was last used. Only where each
-/// keeps its record of those folders is read -- never a conversation.
+/// A coding agent, or a terminal kept for them: what to call it, whether
+/// this machine has used it, and the folders it worked in with when each
+/// was last used. Only where each keeps its record of those folders is read
+/// -- never a conversation.
struct Agent {
name: &'static str,
kind: EditorKind,
@@ -458,6 +471,12 @@ const AGENTS: &[Agent] = &[
present: |home| pi_sessions(home).is_dir(),
read: pi_folders,
},
+ Agent {
+ name: "cmux",
+ kind: EditorKind::Cmux,
+ present: |home| cmux_session(home).is_file(),
+ read: cmux_folders,
+ },
];
/// A file read whole for a list of folders is not one past this.
@@ -566,6 +585,78 @@ fn pi_folders(home: &Path) -> Vec<(PathBuf, SystemTime)> {
.collect()
}
+fn cmux_session(home: &Path) -> PathBuf {
+ home.join("Library")
+ .join("Application Support")
+ .join("cmux")
+ .join("session-com.cmuxterm.app.json")
+}
+
+/// cmux saves its windows to one file to bring back on relaunch: each
+/// workspace's folder, and each of its terminals'. The file's last save is
+/// when they were last used.
+fn cmux_folders(home: &Path) -> Vec<(PathBuf, SystemTime)> {
+ #[derive(serde::Deserialize)]
+ struct Session {
+ #[serde(default)]
+ windows: Vec<Window>,
+ }
+ #[derive(serde::Deserialize)]
+ #[serde(rename_all = "camelCase")]
+ struct Window {
+ tab_manager: Option<TabManager>,
+ }
+ #[derive(serde::Deserialize)]
+ struct TabManager {
+ #[serde(default)]
+ workspaces: Vec<Workspace>,
+ }
+ #[derive(serde::Deserialize)]
+ #[serde(rename_all = "camelCase")]
+ struct Workspace {
+ current_directory: Option<String>,
+ #[serde(default)]
+ panels: Vec<Panel>,
+ }
+ #[derive(serde::Deserialize)]
+ struct Panel {
+ directory: Option<String>,
+ }
+ let path = cmux_session(home);
+ let Some(saved) = path
+ .metadata()
+ .ok()
+ .filter(|meta| meta.len() <= MAX_AGENT_FILE)
+ .and_then(|meta| meta.modified().ok())
+ else {
+ return Vec::new();
+ };
+ let Some(session) = std::fs::read(&path)
+ .ok()
+ .and_then(|text| serde_json::from_slice::<Session>(&text).ok())
+ else {
+ return Vec::new();
+ };
+ let mut folders: Vec<PathBuf> = Vec::new();
+ for workspace in session
+ .windows
+ .into_iter()
+ .filter_map(|window| window.tab_manager)
+ .flat_map(|tabs| tabs.workspaces)
+ {
+ let dirs = workspace
+ .current_directory
+ .into_iter()
+ .chain(workspace.panels.into_iter().filter_map(|panel| panel.directory));
+ for dir in dirs.filter(|dir| !dir.is_empty()).map(PathBuf::from) {
+ if !folders.contains(&dir) {
+ folders.push(dir);
+ }
+ }
+ }
+ folders.into_iter().map(|dir| (dir, saved)).collect()
+}
+
/// The folder a session file's first line names, as `"cwd": "..."`, read
/// from at most the start of the file. It is near the start, so a little
/// is read first and more only when that falls short.
@@ -965,6 +1056,19 @@ mod tests {
);
let pi: Vec<_> = pi_folders(home).into_iter().map(|(p, _)| p).collect();
assert_eq!(pi, [PathBuf::from("/home/user/cli")]);
+ // cmux: each workspace's folder and its terminals', once each.
+ write(
+ home.join("Library/Application Support/cmux/session-com.cmuxterm.app.json"),
+ r#"{"version":1,"windows":[{"tabManager":{"workspaces":[
+ {"currentDirectory":"/home/user/site","panels":[
+ {"directory":"/home/user/site"},{"directory":"/home/user/site/docs"}]},
+ {"currentDirectory":"","panels":[{"type":"browser"}]}]}}]}"#,
+ );
+ let cmux: Vec<_> = cmux_folders(home).into_iter().map(|(p, _)| p).collect();
+ assert_eq!(
+ cmux,
+ [PathBuf::from("/home/user/site"), PathBuf::from("/home/user/site/docs")]
+ );
}
#[test]
diff --git a/wezterm-gui/src/termwindow/ui/icons.rs b/wezterm-gui/src/termwindow/ui/icons.rs
index dfccea37..e062c3db 100644
--- a/wezterm-gui/src/termwindow/ui/icons.rs
+++ b/wezterm-gui/src/termwindow/ui/icons.rs
@@ -149,6 +149,8 @@ pub enum SvgIcon {
// VS Code's mark, from the Material Icon Theme's file icons. Its own
// blue is ignored like any glyph's colour: it takes the caller's tint.
VsCode,
+ // cmux's chevron, drawn here rather than taken from its app.
+ Cmux,
}
impl SvgIcon {
@@ -426,6 +428,7 @@ impl SvgIcon {
include_bytes!("../../../../third_party/lobe-icons/opencode.svg")
}
Self::AgentPi => include_bytes!("../../../../third_party/lobe-icons/pi.svg"),
+ Self::Cmux => include_bytes!("../../../../assets/ui/cmux.svg"),
Self::VsCode => {
include_bytes!("../../../../third_party/material-icon-theme/icons/vscode.svg")
}
@@ -949,6 +952,7 @@ mod tests {
SvgIcon::AgentOpenCode,
SvgIcon::AgentPi,
SvgIcon::VsCode,
+ SvgIcon::Cmux,
] {
let data: Vec<u8> = icon.rasterize(24).unwrap().into();
assert_eq!(data.len(), 24 * 24 * 4);