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
feat(import): bring herdr layouts over on Windows
RoversX89d5b23f63c2
diff --git a/thinkterm-i18n/i18n/de-DE.ftl b/thinkterm-i18n/i18n/de-DE.ftlindex 6824b0ae..773f88b2 100644--- a/thinkterm-i18n/i18n/de-DE.ftl+++ b/thinkterm-i18n/i18n/de-DE.ftl@@ -1348,6 +1348,7 @@ settings-import-reload = Quelle neu ladensession-import-requirements-local = Erforderlich ist eine lokale Sitzung desselben Benutzers mit zugänglichem Sitzungsverzeichnis.herdr-requirements-live = Die Live-Übertragung benötigt Herdrs live_handoff-Funktion und gemeinsamen Zugriff auf temporäre Dateien, Sockets und die ThinkTerm-Datei.herdr-requirements-linux = Unter Linux muss /tmp die Skriptausführung erlauben; noexec wird nicht unterstützt.+herdr-windows-layout-only = Unter Windows kann Herdr laufende Sitzungen nicht übergeben. Übernommen wird nur das von Herdr gespeicherte Layout: Tabs, Teilungen und Verzeichnisse, jeweils mit einer neuen Shell. Herdr kann geöffnet bleiben; die darin laufenden Sitzungen bleiben unberührt.session-import-requirements-layout = Gespeicherte Layouts beendeter Sitzungen benötigen keine Live-Übergabe. Arbeitsverzeichnisse müssen existieren und ThinkTerm muss das Layoutformat unterstützen.session-import-requirements-refresh = Aktualisieren Sie die Vorschau, wenn sich Sitzungsstruktur oder Layout ändern.session-import-refresh-preview = Vorschau aktualisierendiff --git a/thinkterm-i18n/i18n/en-US.ftl b/thinkterm-i18n/i18n/en-US.ftlindex 1468cf90..c9ea98b7 100644--- a/thinkterm-i18n/i18n/en-US.ftl+++ b/thinkterm-i18n/i18n/en-US.ftl@@ -1348,6 +1348,7 @@ settings-import-reload = Reload sourcesession-import-requirements-local = Use a local session owned by the same user, with an accessible session directory.herdr-requirements-live = Live migration requires Herdr’s live_handoff capability and shared access to temporary files, sockets, and the ThinkTerm executable.herdr-requirements-linux = On Linux, /tmp must allow script execution; noexec mounts are unsupported.+herdr-windows-layout-only = On Windows, Herdr cannot hand over running sessions, so only the layout it saved comes over: tabs, splits and folders, each with a fresh shell. Herdr can stay open; the sessions running in it are left alone.session-import-requirements-layout = Saved layouts from stopped sessions need no live handoff. Working directories must exist and ThinkTerm must support the layout format.session-import-requirements-refresh = Refresh the preview if the session structure or layout changes.session-import-refresh-preview = Refresh previewdiff --git a/thinkterm-i18n/i18n/fr-FR.ftl b/thinkterm-i18n/i18n/fr-FR.ftlindex 46988230..42aee0d4 100644--- a/thinkterm-i18n/i18n/fr-FR.ftl+++ b/thinkterm-i18n/i18n/fr-FR.ftl@@ -1342,6 +1342,7 @@ settings-import-reload = Recharger la sourcesession-import-requirements-local = La session doit être locale, appartenir au même utilisateur et avoir un répertoire accessible.herdr-requirements-live = Le transfert à chaud nécessite live_handoff dans Herdr et un accès partagé aux fichiers temporaires, aux sockets et à l’exécutable ThinkTerm.herdr-requirements-linux = Sous Linux, /tmp doit autoriser les scripts ; les montages noexec ne sont pas pris en charge.+herdr-windows-layout-only = Sous Windows, Herdr ne peut pas transférer les sessions en cours : seule la disposition qu’il a enregistrée est reprise (onglets, divisions et répertoires), chacun avec un nouveau shell. Herdr peut rester ouvert ; les sessions qui y tournent ne sont pas touchées.session-import-requirements-layout = Les dispositions de sessions arrêtées ne nécessitent pas de transfert à chaud. Les répertoires doivent exister et ThinkTerm doit prendre en charge le format.session-import-requirements-refresh = Actualisez l’aperçu si la structure de la session ou la disposition change.session-import-refresh-preview = Actualiser l’aperçudiff --git a/thinkterm-i18n/i18n/ja-JP.ftl b/thinkterm-i18n/i18n/ja-JP.ftlindex 8158e7cd..3e52a0ea 100644--- a/thinkterm-i18n/i18n/ja-JP.ftl+++ b/thinkterm-i18n/i18n/ja-JP.ftl@@ -1302,6 +1302,7 @@ settings-import-reload = 読み直すsession-import-requirements-local = 同じユーザーのローカルセッションと、アクセス可能なセッションディレクトリが必要です。herdr-requirements-live = ライブ移行には Herdr の live_handoff 対応と、一時ファイル、ソケット、ThinkTerm 実行ファイルへの双方からのアクセスが必要です。herdr-requirements-linux = Linux の /tmp ではスクリプト実行が必要です(noexec は不可)。+herdr-windows-layout-only = Windows の Herdr は実行中のセッションを引き継げないため、Herdr が保存したレイアウト(タブ、分割、ディレクトリ)だけを取り込み、それぞれ新しいシェルで開きます。Herdr は開いたままで構いません。その中で実行中のセッションには影響しません。session-import-requirements-layout = 停止中の保存済みレイアウトにはライブ引き継ぎは不要です。作業ディレクトリが存在し、ThinkTerm が形式に対応している必要があります。session-import-requirements-refresh = セッション構造やレイアウトが変わったら、プレビューを更新してください。session-import-refresh-preview = プレビューを更新diff --git a/thinkterm-i18n/i18n/zh-CN.ftl b/thinkterm-i18n/i18n/zh-CN.ftlindex e8b490a3..c49df027 100644--- a/thinkterm-i18n/i18n/zh-CN.ftl+++ b/thinkterm-i18n/i18n/zh-CN.ftl@@ -1302,6 +1302,7 @@ settings-import-reload = 重新读取session-import-requirements-local = 仅支持本机同一用户的会话,需能访问会话目录。herdr-requirements-live = 实时迁移需 Herdr 支持 live_handoff,且两端能访问相同的临时目录、socket 和 ThinkTerm 程序。herdr-requirements-linux = Linux 的 /tmp 必须允许执行脚本(不能以 noexec 挂载)。+herdr-windows-layout-only = Windows 上的 Herdr 无法交出运行中的会话,只能导入它保存的布局:标签、分屏和目录,每个窗格新开一个 shell。Herdr 开着也能导入,它里面正在运行的会话不受影响。session-import-requirements-layout = 未运行会话的布局导入无需实时交接能力;工作目录必须存在,布局格式须受当前 ThinkTerm 支持。session-import-requirements-refresh = 预览后会话结构或布局有变动,请重新预览。session-import-refresh-preview = 重新预览diff --git a/thinkterm-import-herdr/Cargo.toml b/thinkterm-import-herdr/Cargo.tomlindex fd03011c..749986e6 100644--- a/thinkterm-import-herdr/Cargo.toml+++ b/thinkterm-import-herdr/Cargo.toml@@ -4,14 +4,17 @@ version = "0.1.0"edition = "2021"publish = false-[target.'cfg(unix)'.dependencies]+[dependencies]anyhow.workspace = true-log.workspace = trueserde = { workspace = true, features = ["derive"] }serde_json.workspace = truesha2.workspace = true-tempfile.workspace = truethinkterm-import.workspace = true++# Only unix hosts a live handoff; Windows imports the saved layout.+[target.'cfg(unix)'.dependencies]+log.workspace = true+tempfile.workspace = trueuuid = { workspace = true, features = ["v4"] }rustix = { version = "1.1.2", features = ["net", "termios", "fs", "process"] }diff --git a/thinkterm-import-herdr/src/lib.rs b/thinkterm-import-herdr/src/lib.rsindex 0d3c56dc..aee3f549 100644--- a/thinkterm-import-herdr/src/lib.rs+++ b/thinkterm-import-herdr/src/lib.rs@@ -1,17 +1,26 @@//! Herdr's saved-layout and live-handoff adapter. No mux or GUI dependency.-#![cfg(unix)]+//! Herdr's Windows server cannot hand its terminals over, so Windows imports+//! the saved layout only.mod model;+#[cfg(unix)]mod seed;mod source;+#[cfg(unix)]mod transport;-use anyhow::{ensure, Context, Result};-use model::{Runtime, Snapshot};+#[cfg(unix)]+use anyhow::Context;+use anyhow::{ensure, Result};+#[cfg(unix)]+use model::Runtime;+use model::Snapshot;use thinkterm_import::{- ImportContext, ImportMode, ImportPlan, ImportRequest, ImportSource, LiveTerminal,- PreparedImport, Preview, Project, Selection, Session, SourceInfo, TerminalSeed, Thread,+ ImportContext, ImportMode, ImportPlan, ImportRequest, ImportSource, PreparedImport, Preview,+ Project, Selection, Session, SourceInfo, Thread,};+#[cfg(unix)]+use thinkterm_import::{LiveTerminal, TerminalSeed};struct Herdr;static HERDR: Herdr = Herdr;@@ -62,30 +71,14 @@ impl ImportSource for Herdr {handoff: None,});}- let mut transfer =- transport::receive(&dir, &context.executable).context("Receive Herdr handoff")?;- let plan = into_plan(transfer.manifest.snapshot.clone(), request.mode);- let terminals = transfer- .manifest- .panes- .iter()- .zip(transfer.fds.drain(..))- .map(|(runtime, pty)| LiveTerminal {- pane_id: runtime.pane_id,- seed: terminal_seed(runtime),- pty,- })- .collect();- Ok(PreparedImport {- plan,- terminals,- handoff: Some(Box::new(transfer)),- })+ receive_live(context, &dir, request.mode)}fn notes(&self, mode: Option<ImportMode>) -> Vec<&'static str> {let mut notes = vec![];- if mode != Some(ImportMode::Layout) {+ #[cfg(windows)]+ notes.push("herdr-windows-layout-only");+ if cfg!(unix) && mode != Some(ImportMode::Layout) {notes.push("herdr-requirements-live");#[cfg(target_os = "linux")]notes.push("herdr-requirements-linux");@@ -106,10 +99,46 @@ impl ImportSource for Herdr {}fn run_helper(&self) -> Option<Result<()>> {- transport::maybe_run_relay()+ #[cfg(unix)]+ return transport::maybe_run_relay();+ #[cfg(windows)]+ None}}+#[cfg(unix)]+fn receive_live(+ context: &ImportContext,+ dir: &std::path::Path,+ mode: ImportMode,+) -> Result<PreparedImport> {+ let mut transfer =+ transport::receive(dir, &context.executable).context("Receive Herdr handoff")?;+ let plan = into_plan(transfer.manifest.snapshot.clone(), mode);+ let terminals = transfer+ .manifest+ .panes+ .iter()+ .zip(transfer.fds.drain(..))+ .map(|(runtime, pty)| LiveTerminal {+ pane_id: runtime.pane_id,+ seed: terminal_seed(runtime),+ pty,+ })+ .collect();+ Ok(PreparedImport {+ plan,+ terminals,+ handoff: Some(Box::new(transfer)),+ })+}++#[cfg(windows)]+fn receive_live(_: &ImportContext, _: &std::path::Path, _: ImportMode) -> Result<PreparedImport> {+ anyhow::bail!("Herdr on Windows cannot hand over running terminals")+}++#[cfg(unix)]impl thinkterm_import::Handoff for transport::Transfer {fn commit(&mut self) -> Result<()> {transport::Transfer::commit(self)@@ -119,6 +148,7 @@ impl thinkterm_import::Handoff for transport::Transfer {}}+#[cfg(unix)]fn terminal_seed(runtime: &Runtime) -> TerminalSeed {TerminalSeed {child_pid: runtime.child_pid,@@ -269,5 +299,5 @@ fn error_key(message: &str) -> Option<&'static str> {})}-#[cfg(test)]+#[cfg(all(test, unix))]mod tests;diff --git a/thinkterm-import-herdr/src/model.rs b/thinkterm-import-herdr/src/model.rsindex 5b3ff969..6845ebd4 100644--- a/thinkterm-import-herdr/src/model.rs+++ b/thinkterm-import-herdr/src/model.rs@@ -1,4 +1,6 @@-use anyhow::{bail, ensure, Context, Result};+#[cfg(unix)]+use anyhow::bail;+use anyhow::{ensure, Context, Result};use serde::{Deserialize, Serialize};use std::collections::{BTreeMap, HashSet};@@ -73,6 +75,7 @@ pub enum Direction {Vertical,}+#[cfg(unix)]#[derive(Debug, Deserialize)]pub struct Manifest {pub version: u32,@@ -81,6 +84,7 @@ pub struct Manifest {pub panes: Vec<Runtime>,}+#[cfg(unix)]#[derive(Debug, Deserialize)]pub struct Runtime {pub pane_id: u32,@@ -103,6 +107,7 @@ pub struct Runtime {pub initial_history_ansi: Option<String>,}+#[cfg(unix)]#[derive(Debug, Default, Deserialize)]#[serde(default)]pub struct InputState {@@ -232,7 +237,7 @@ impl Snapshot {Ok(())}- #[cfg(test)]+ #[cfg(all(test, unix))]pub fn pane_count(&self) -> usize {self.workspaces.iter()@@ -242,6 +247,7 @@ impl Snapshot {}}+#[cfg(unix)]impl Manifest {pub fn validate(&self) -> Result<()> {ensure!(self.version == 1, "Unsupported Herdr handoff version");diff --git a/thinkterm-import-herdr/src/source.rs b/thinkterm-import-herdr/src/source.rsindex 1f6c5ea2..7f4679d5 100644--- a/thinkterm-import-herdr/src/source.rs+++ b/thinkterm-import-herdr/src/source.rs@@ -1,14 +1,19 @@use super::model::{Layout, Snapshot, Tab};-use anyhow::{bail, ensure, Context, Result};-use serde_json::{json, Value};+use anyhow::{ensure, Context, Result};use sha2::{Digest, Sha256};use std::fs;-use rustix::net::RecvFlags;-use std::io::{Read, Write};-use std::os::unix::fs::{FileTypeExt, MetadataExt};-use std::os::unix::net::UnixStream;+use std::io::Read;use std::path::{Path, PathBuf};-use std::time::Duration;+#[cfg(unix)]+use {+ anyhow::bail,+ rustix::net::RecvFlags,+ serde_json::{json, Value},+ std::io::Write,+ std::os::unix::fs::{FileTypeExt, MetadataExt},+ std::os::unix::net::UnixStream,+ std::time::Duration,+};pub const MAX_BYTES: usize = 16 * 1024 * 1024;@@ -20,16 +25,43 @@ pub fn config_root(context: &ImportContext) -> Result<PathBuf> {.config_home.clone().filter(|path| path.is_absolute())- .unwrap_or_else(|| context.home.join(".config"));+ .unwrap_or_else(|| default_config_home(context));Ok(config.join("herdr"))}+#[cfg(unix)]+fn default_config_home(context: &ImportContext) -> PathBuf {+ context.home.join(".config")+}++/// Herdr's Windows build keeps its folder under %APPDATA%.+#[cfg(windows)]+fn default_config_home(context: &ImportContext) -> PathBuf {+ std::env::var_os("APPDATA")+ .map(PathBuf::from)+ .filter(|path| path.is_absolute())+ .unwrap_or_else(|| context.home.join("AppData").join("Roaming"))+}++#[cfg(unix)]+fn owned(metadata: &fs::Metadata) -> bool {+ metadata.uid() == rustix::process::geteuid().as_raw()+}++/// Windows has no uid to compare. Herdr's folder there is in this user's+/// own profile, which other users cannot write to.+#[cfg(windows)]+fn owned(_: &fs::Metadata) -> bool {+ true+}+pub fn session_dir(context: &ImportContext, name: &str) -> Result<PathBuf> {ensure!(!name.is_empty()&& name.len() <= 128&& !name.contains('/')&& !name.contains('\\')+ && !name.contains(':')&& name != "."&& name != ".."&& !name.chars().any(char::is_control),@@ -47,16 +79,22 @@ pub fn session_dir(context: &ImportContext, name: &str) -> Result<PathBuf> {"Herdr session must be a directory");ensure!(- metadata.uid() == rustix::process::geteuid().as_raw(),+ owned(&metadata),"Herdr session belongs to a different user");Ok(path)}+/// A saved layout, or on unix a running server to hand its terminals+/// over. Windows imports the saved layout alone.+fn importable(dir: &Path) -> bool {+ dir.join("session.json").exists() || (cfg!(unix) && dir.join("herdr.sock").exists())+}+pub fn discover(context: &ImportContext) -> Result<Vec<Session>> {let root = config_root(context)?;let mut sessions = Vec::new();- if root.join("session.json").exists() || root.join("herdr.sock").exists() {+ if importable(&root) {sessions.push(Session {name: "default".into(),});@@ -65,10 +103,7 @@ pub fn discover(context: &ImportContext) -> Result<Vec<Session>> {Ok(entries) => {for entry in entries.take(256) {let entry = entry?;- if entry.file_type()?.is_dir()- && (entry.path().join("session.json").exists()- || entry.path().join("herdr.sock").exists())- {+ if entry.file_type()?.is_dir() && importable(&entry.path()) {if let Some(name) = entry.file_name().to_str() {if session_dir(context, name).is_ok() {sessions.push(Session { name: name.into() });@@ -84,6 +119,7 @@ pub fn discover(context: &ImportContext) -> Result<Vec<Session>> {Ok(sessions)}+#[cfg(unix)]pub fn read_line(stream: &mut UnixStream, limit: usize) -> Result<Vec<u8>> {let mut bytes = Vec::new();let mut byte = [0];@@ -100,6 +136,7 @@ pub fn read_line(stream: &mut UnixStream, limit: usize) -> Result<Vec<u8>> {/// `read_line` for replies that can run to megabytes: a chunk at a time/// instead of a read per byte. It peeks first and consumes only through the/// newline, so whatever follows (descriptors on a handoff) stays queued.+#[cfg(unix)]pub fn read_large_line(stream: &mut UnixStream, limit: usize) -> Result<Vec<u8>> {let mut line = Vec::new();let mut chunk = vec![0; limit.saturating_add(1).min(64 * 1024)];@@ -125,6 +162,7 @@ pub fn read_large_line(stream: &mut UnixStream, limit: usize) -> Result<Vec<u8>>}}+#[cfg(unix)]fn connect(path: &Path, timeout: Duration) -> Result<UnixStream> {let metadata = fs::symlink_metadata(path)?;ensure!(@@ -137,6 +175,7 @@ fn connect(path: &Path, timeout: Duration) -> Result<UnixStream> {Ok(stream)}+#[cfg(unix)]pub fn request(dir: &Path, method: &str, params: Value, timeout: Duration) -> Result<Value> {let mut stream = connect(&dir.join("herdr.sock"), timeout)?;serde_json::to_writer(@@ -164,9 +203,7 @@ pub fn saved_snapshot(dir: &Path) -> Result<(Snapshot, String)> {let path = dir.join("session.json");let metadata = fs::symlink_metadata(&path)?;ensure!(- metadata.is_file()- && !metadata.file_type().is_symlink()- && metadata.uid() == rustix::process::geteuid().as_raw(),+ metadata.is_file() && !metadata.file_type().is_symlink() && owned(&metadata),"Invalid Herdr snapshot owner or type");let mut bytes = Vec::new();@@ -178,6 +215,7 @@ pub fn saved_snapshot(dir: &Path) -> Result<(Snapshot, String)> {Ok((Snapshot::parse(&bytes)?, fingerprint))}+#[cfg(unix)]pub(super) fn live_fingerprint(mut identity: Value) -> Result<String> {// GUI and mux builds may enable different serde_json map ordering.identity.sort_all_objects();@@ -201,6 +239,7 @@ fn preview_text(text: &str, limit: usize) -> Option<String> {(!result.is_empty()).then_some(result)}+#[cfg(unix)]pub(super) fn live_projects(workspaces: &[Value],tabs: &[Value],@@ -291,9 +330,33 @@ pub(super) fn saved_projects(snapshot: &Snapshot) -> Vec<PreviewProject> {pub fn preview(context: &ImportContext, name: &str) -> Result<Preview> {let dir = session_dir(context, name)?;- let ping = request(&dir, "ping", json!({}), Duration::from_secs(3));+ // Herdr's Windows server cannot hand its terminals over. Windows reads+ // the layout it saves a few seconds after each change, running or not.+ #[cfg(unix)]+ if let Some(preview) = live_preview(&dir, name)? {+ return Ok(preview);+ }+ let (snapshot, fingerprint) = saved_snapshot(&dir)?;+ let unavailable = snapshot+ .check_working_directories()+ .err()+ .map(|error| error.to_string());+ Ok(Preview {+ session: name.into(),+ live: false,+ version: None,+ fingerprint,+ projects: saved_projects(&snapshot),+ unavailable,+ })+}++/// The session as a running server reports it, or `None` when none answers.+#[cfg(unix)]+fn live_preview(dir: &Path, name: &str) -> Result<Option<Preview>> {+ let ping = request(dir, "ping", json!({}), Duration::from_secs(3));let ping = match ping {- Ok(ping) => Some(ping),+ Ok(ping) => ping,Err(error)if error.chain()@@ -305,62 +368,46 @@ pub fn preview(context: &ImportContext, name: &str) -> Result<Preview> {)}) =>{- None+ return Ok(None)}Err(error) => return Err(error.context("Cannot inspect Herdr; no session was changed")),};- if let Some(ping) = ping {- let result = request(&dir, "session.snapshot", json!({}), Duration::from_secs(5))?;- let snapshot = result- .get("snapshot")- .context("Herdr did not return its session structure")?;- let workspaces = snapshot["workspaces"]- .as_array()- .context("Missing Herdr workspaces")?;- let tabs = snapshot["tabs"].as_array().context("Missing Herdr tabs")?;- let panes = snapshot["panes"]- .as_array()- .context("Missing Herdr panes")?;- ensure!(- panes.len() <= super::model::MAX_PANES,- "Herdr session has too many panes"- );- let identity = json!({- "workspaces": workspaces.iter().map(|w| json!([w["workspace_id"], w["label"]])).collect::<Vec<_>>(),- "tabs": tabs.iter().map(|t| json!([t["tab_id"], t["workspace_id"], t["label"]])).collect::<Vec<_>>(),- "panes": panes.iter().map(|p| json!([p["pane_id"], p["terminal_id"], p["tab_id"]])).collect::<Vec<_>>()- });- let projects = live_projects(workspaces, tabs, panes);- let available = ping["capabilities"]["live_handoff"]- .as_bool()- .unwrap_or(false);- Ok(Preview {- session: name.into(),- live: true,- version: ping["version"].as_str().map(str::to_string),- fingerprint: live_fingerprint(identity)?,- projects,- unavailable: if panes.is_empty() {- Some("Herdr session is empty".into())- } else if !available {- Some("This running Herdr server does not support live handoff".into())- } else {- None- },- })- } else {- let (snapshot, fingerprint) = saved_snapshot(&dir)?;- let unavailable = snapshot- .check_working_directories()- .err()- .map(|error| error.to_string());- Ok(Preview {- session: name.into(),- live: false,- version: None,- fingerprint,- projects: saved_projects(&snapshot),- unavailable,- })- }+ let result = request(dir, "session.snapshot", json!({}), Duration::from_secs(5))?;+ let snapshot = result+ .get("snapshot")+ .context("Herdr did not return its session structure")?;+ let workspaces = snapshot["workspaces"]+ .as_array()+ .context("Missing Herdr workspaces")?;+ let tabs = snapshot["tabs"].as_array().context("Missing Herdr tabs")?;+ let panes = snapshot["panes"]+ .as_array()+ .context("Missing Herdr panes")?;+ ensure!(+ panes.len() <= super::model::MAX_PANES,+ "Herdr session has too many panes"+ );+ let identity = json!({+ "workspaces": workspaces.iter().map(|w| json!([w["workspace_id"], w["label"]])).collect::<Vec<_>>(),+ "tabs": tabs.iter().map(|t| json!([t["tab_id"], t["workspace_id"], t["label"]])).collect::<Vec<_>>(),+ "panes": panes.iter().map(|p| json!([p["pane_id"], p["terminal_id"], p["tab_id"]])).collect::<Vec<_>>()+ });+ let projects = live_projects(workspaces, tabs, panes);+ let available = ping["capabilities"]["live_handoff"]+ .as_bool()+ .unwrap_or(false);+ Ok(Some(Preview {+ session: name.into(),+ live: true,+ version: ping["version"].as_str().map(str::to_string),+ fingerprint: live_fingerprint(identity)?,+ projects,+ unavailable: if panes.is_empty() {+ Some("Herdr session is empty".into())+ } else if !available {+ Some("This running Herdr server does not support live handoff".into())+ } else {+ None+ },+ }))}diff --git a/thinkterm-import/src/lib.rs b/thinkterm-import/src/lib.rsindex e5ed2030..6817a090 100644--- a/thinkterm-import/src/lib.rs+++ b/thinkterm-import/src/lib.rs@@ -3,9 +3,9 @@mod model;pub use model::*;-#[cfg(unix)]+#[cfg(any(unix, windows))]mod source;-#[cfg(unix)]+#[cfg(any(unix, windows))]pub use source::*;#[cfg(test)]diff --git a/thinkterm-import/src/source.rs b/thinkterm-import/src/source.rsindex c11eecf0..d431219b 100644--- a/thinkterm-import/src/source.rs+++ b/thinkterm-import/src/source.rs@@ -1,7 +1,6 @@use crate::{ImportMode, ImportPlan, ImportRequest, PaneId, Preview, Session, MAX_PANES};use anyhow::{ensure, Context, Result};use std::collections::HashSet;-use std::os::fd::OwnedFd;use std::path::PathBuf;use std::sync::Mutex;@@ -32,10 +31,17 @@ pub struct TerminalSeed {pub ansi: String,}+/// The terminal a live handoff passes over. No Windows source hands one over+/// yet, so there it only keeps the plan's shape.+#[cfg(unix)]+pub type Pty = std::os::fd::OwnedFd;+#[cfg(windows)]+pub type Pty = std::os::windows::io::OwnedHandle;+pub struct LiveTerminal {pub pane_id: PaneId,pub seed: TerminalSeed,- pub pty: OwnedFd,+ pub pty: Pty,}/// The adapter keeps its source paused until the owner has prepared everydiff --git a/wezterm-gui/src/main.rs b/wezterm-gui/src/main.rsindex 16765ce3..31ea661a 100644--- a/wezterm-gui/src/main.rs+++ b/wezterm-gui/src/main.rs@@ -1670,12 +1670,9 @@ pub(crate) const RESTARTED_ENV: &str = "THINKTERM_RESTARTED";static RESTARTED: std::sync::atomic::AtomicBool = std::sync::atomic::AtomicBool::new(false);fn main() {- #[cfg(unix)]- {- thinkterm_import_herdr::register().expect("register built-in session importer");- if let Some(result) = thinkterm_import::maybe_run_helper() {- std::process::exit(if result.is_ok() { 0 } else { 1 });- }+ thinkterm_import_herdr::register().expect("register built-in session importer");+ if let Some(result) = thinkterm_import::maybe_run_helper() {+ std::process::exit(if result.is_ok() { 0 } else { 1 });}#[cfg(feature = "dhat-heap")]let _profiler = dhat::Profiler::new_heap();diff --git a/wezterm-gui/src/settings_window.rs b/wezterm-gui/src/settings_window.rsindex 894396cd..bf9d8dc5 100644--- a/wezterm-gui/src/settings_window.rs+++ b/wezterm-gui/src/settings_window.rs@@ -49,7 +49,6 @@ use crate::native_settings::{};use fluent_bundle::FluentArgs;-#[cfg(unix)]mod session_import;mod editor_import;mod import;@@ -976,7 +975,6 @@ fn initial_section() -> SettingsSection {"backup" => SettingsSection::Backup,"update" => SettingsSection::Update,"about" => SettingsSection::About,- #[cfg(unix)]id if thinkterm_import::source(id).is_ok() => SettingsSection::Import,_ => SettingsSection::Appearance,};@@ -1808,19 +1806,12 @@ enum SettingsAction {ImportContinue,ImportBack,ImportStartOver,- #[cfg(unix)]SessionImportDetect,- #[cfg(unix)]SessionImportPreview(u64),- #[cfg(unix)]SessionImportHost(u64),- #[cfg(unix)]SessionImportBack,- #[cfg(unix)]SessionImportConfirm,- #[cfg(unix)]SessionImportRecover,- #[cfg(unix)]SessionImportOpen,WindowHide,WindowMaximize,@@ -2502,7 +2493,6 @@ struct SettingsUiState {import_source: ImportSource,import_step: ImportStep,import_result: Option<String>,- #[cfg(unix)]session_import: session_import::ImportUi,tokens: UiTokens,sidebar: ResizablePaneState,@@ -2629,20 +2619,12 @@ impl SettingsUiState {fn new(dpi: usize) -> Self {let tokens = UiTokens::for_dpi(dpi);Self {- #[cfg(unix)]session_import: session_import::ImportUi::default(),import_source: ImportSource::initial(),- import_step: {- #[cfg(unix)]- if session_import::remembered_source().is_some() {- ImportStep::Review- } else {- ImportStep::Source- }- #[cfg(not(unix))]- {- ImportStep::Source- }+ import_step: if session_import::remembered_source().is_some() {+ ImportStep::Review+ } else {+ ImportStep::Source},import_result: None,sidebar: ResizablePaneState::new(@@ -3426,7 +3408,6 @@ fn remember_origin(mux_window_id: MuxWindowId, space_id: &str) {OPENED_FROM.with(|slot| slot.set(Some(mux_window_id)));let changed = OPENED_FROM_SPACE.with(|slot| slot.replace(Some(space_id.to_string())).as_deref() != Some(space_id));- #[cfg(unix)]if changed {SETTINGS_WINDOW.with(|slot| {if let SettingsWindowSlot::Open { settings, .. } = &*slot.borrow() {@@ -3439,8 +3420,6 @@ fn remember_origin(mux_window_id: MuxWindowId, space_id: &str) {}});}- #[cfg(not(unix))]- let _ = changed;}pub fn show() {@@ -5878,7 +5857,6 @@ impl SettingsWindow {match action {SettingsAction::SelectImportSource(source) => {if self.import_busy() { return; }- #[cfg(unix)]if self.ui.import_source != source {self.ui.session_import.abandon();self.ui.session_import = session_import::ImportUi::default();@@ -5890,7 +5868,6 @@ impl SettingsWindow {SettingsAction::ImportContinue| SettingsAction::ImportBack| SettingsAction::ImportStartOver => self.perform_import_navigation(action, window),- #[cfg(unix)]SettingsAction::SessionImportDetect| SettingsAction::SessionImportPreview(_)| SettingsAction::SessionImportHost(_)diff --git a/wezterm-gui/src/settings_window/import.rs b/wezterm-gui/src/settings_window/import.rsindex 923031ba..b64c4554 100644--- a/wezterm-gui/src/settings_window/import.rs+++ b/wezterm-gui/src/settings_window/import.rs@@ -12,7 +12,6 @@ pub(super) enum ImportSource {WezTerm,/// The folders VS Code and the editors built from it have opened.Editors,- #[cfg(unix)]Session(&'static str),}@@ -25,7 +24,6 @@ impl ImportSource {if !crate::editor_projects::installed().is_empty() {sources.push(Self::Editors);}- #[cfg(unix)]sources.extend(thinkterm_import::sources().into_iter()@@ -40,18 +38,14 @@ impl ImportSource {match id {None => Some(Self::WezTerm),Some(EDITORS_SOURCE) => Some(Self::Editors),- #[cfg(unix)]Some(id) => thinkterm_import::sources().into_iter().find(|source| source.id == id).map(|source| Self::Session(source.id)),- #[cfg(not(unix))]- Some(_) => None,}}pub(super) fn initial() -> Self {- #[cfg(unix)]if let Some(source) = session_import::remembered_source() {return source;}@@ -59,7 +53,6 @@ impl ImportSource {if selected.as_deref() == Some(EDITORS_SOURCE) {return Self::Editors;}- #[cfg(unix)]if let Some(selected) = selected {if let Some(source) = thinkterm_import::sources().into_iter()@@ -76,7 +69,6 @@ impl ImportSource {fn is_beta(self) -> bool {match self {Self::WezTerm | Self::Editors => false,- #[cfg(unix)]Self::Session(_) => true,}}@@ -85,7 +77,6 @@ impl ImportSource {match self {Self::WezTerm => "WezTerm".to_string(),Self::Editors => crate::i18n::tr("settings-import-editors"),- #[cfg(unix)]Self::Session(id) => thinkterm_import::source(id).map(|s| s.info().name).unwrap_or(id)@@ -97,7 +88,6 @@ impl ImportSource {crate::i18n::tr(match self {Self::WezTerm => "settings-import-wezterm-description",Self::Editors => "settings-import-editors-description",- #[cfg(unix)]Self::Session(_) => "settings-import-session-description",})}@@ -107,14 +97,12 @@ impl ImportSource {Self::WezTerm => Some(BrandIcon::WezTerm),// Drawn as its editors' marks, see `paint_editor_stack`.Self::Editors => None,- #[cfg(unix)]Self::Session(id) => {BrandIcon::for_import_source(thinkterm_import::source(id).ok()?.info().icon)}}}- #[cfg(unix)]pub(super) fn provider(self) -> anyhow::Result<&'static dyn thinkterm_import::ImportSource> {match self {Self::Session(id) => thinkterm_import::source(id),@@ -155,7 +143,6 @@ struct ImportSourceLayout {impl SettingsWindow {pub(super) fn import_busy(&self) -> bool {- #[cfg(unix)]if matches!(self.ui.import_source, ImportSource::Session(_)) {return self.ui.session_import.busy();}@@ -190,14 +177,12 @@ impl SettingsWindow {let space = OPENED_FROM_SPACE.with(|slot| slot.borrow().clone());self.start_editor_import(space);}- #[cfg(unix)]ImportSource::Session(_) => {self.perform_session_import_action(SettingsAction::SessionImportDetect)}}}SettingsAction::ImportBack => {- #[cfg(unix)]if matches!(self.ui.import_source, ImportSource::Session(_))&& self.ui.session_import.has_preview(){@@ -211,11 +196,8 @@ impl SettingsWindow {self.ui.import_step = ImportStep::Source;self.ui.import_result = None;self.ui.editor_import.release();- #[cfg(unix)]- {- self.ui.session_import.abandon();- self.ui.session_import = session_import::ImportUi::default();- }+ self.ui.session_import.abandon();+ self.ui.session_import = session_import::ImportUi::default();}_ => {}}@@ -276,7 +258,6 @@ impl SettingsWindow {ImportStep::Review => match self.ui.import_source {ImportSource::WezTerm => self.paint_wezterm_import(layers, x, top, width)?,ImportSource::Editors => self.paint_editor_import(layers, x, top, width)?,- #[cfg(unix)]ImportSource::Session(_) => self.paint_session_import(layers, x, top, width)?,},ImportStep::Result => match self.ui.import_source {@@ -304,7 +285,6 @@ impl SettingsWindow {)?}ImportSource::Editors => self.paint_editor_result(layers, x, top, width)?,- #[cfg(unix)]ImportSource::Session(_) => self.paint_session_result(layers, x, top, width)?,},};diff --git a/wezterm-gui/src/termwindow/onboarding/found.rs b/wezterm-gui/src/termwindow/onboarding/found.rsindex 625d5a04..59186840 100644--- a/wezterm-gui/src/termwindow/onboarding/found.rs+++ b/wezterm-gui/src/termwindow/onboarding/found.rs@@ -11,9 +11,7 @@use crate::termwindow::ui::icons::BrandIcon;use std::sync::{Arc, Mutex};-/// One program whose sessions Settings can import. Session import is-/// Unix-only, so elsewhere there are none.-#[cfg_attr(not(unix), allow(dead_code))]+/// One program whose sessions Settings can import.pub(super) struct FoundSessions {/// The import source's id, which the Import page is opened on.pub id: &'static str,@@ -132,7 +130,6 @@ fn editors() -> Option<FoundEditors> {})}-#[cfg(unix)]fn sessions() -> Vec<FoundSessions> {let Ok(context) = wezterm_mux_server_impl::session_import::context() else {return Vec::new();@@ -182,7 +179,6 @@ fn sessions() -> Vec<FoundSessions> {/// How many of `names` `live` says are running. A source that panics on one/// (a malformed session, say) still gets an answer, none running, so the/// page stops polling for it.-#[cfg(unix)]fn count_running(names: &[String], live: impl Fn(&str) -> bool) -> usize {std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {names.iter().filter(|name| live(name)).count()@@ -190,11 +186,6 @@ fn count_running(names: &[String], live: impl Fn(&str) -> bool) -> usize {.unwrap_or(0)}-#[cfg(not(unix))]-fn sessions() -> Vec<FoundSessions> {- Vec::new()-}-#[cfg(test)]impl FoundSessions {pub fn for_test(id: &'static str, count: usize, running: Option<usize>) -> Self {@@ -208,7 +199,7 @@ impl FoundSessions {}}-#[cfg(all(test, unix))]+#[cfg(test)]mod tests {use super::*;diff --git a/wezterm-gui/src/termwindow/ui/icons.rs b/wezterm-gui/src/termwindow/ui/icons.rsindex e062c3db..27d2a275 100644--- a/wezterm-gui/src/termwindow/ui/icons.rs+++ b/wezterm-gui/src/termwindow/ui/icons.rs@@ -602,7 +602,6 @@ const MIN_BRAND_LUMA: f32 = 40.0;impl BrandIcon {/// The mark an import source names in its `SourceInfo::icon`.- #[cfg(unix)]pub fn for_import_source(icon: &str) -> Option<Self> {match icon {"herdr" => Some(Self::Herdr),diff --git a/wezterm-mux-server-impl/src/lib.rs b/wezterm-mux-server-impl/src/lib.rsindex ef0a9333..1c187953 100644--- a/wezterm-mux-server-impl/src/lib.rs+++ b/wezterm-mux-server-impl/src/lib.rs@@ -11,7 +11,6 @@ pub mod dispatch;pub mod handoff;#[cfg(target_os = "macos")]pub mod hold;-#[cfg(unix)]pub mod session_import;pub mod local;pub mod pki;diff --git a/wezterm-mux-server-impl/src/session_import/mod.rs b/wezterm-mux-server-impl/src/session_import/mod.rsindex ca719e41..8dc17d14 100644--- a/wezterm-mux-server-impl/src/session_import/mod.rs+++ b/wezterm-mux-server-impl/src/session_import/mod.rs@@ -2,9 +2,10 @@//! register outside this crate and retain their own discovery and protocols.mod layout;mod pending;+#[cfg(unix)]mod pty;mod receipt;-#[cfg(test)]+#[cfg(all(test, unix))]mod tests;use anyhow::{ensure, Context, Result};@@ -17,6 +18,8 @@ use mux::window::Window;use mux::Mux;pub(crate) use pending::ensure_not_pending;pub use pending::wait_for_workspace;+#[cfg(unix)]+use portable_pty::adopted_child;use portable_pty::{CommandBuilder, MasterPty};use promise::spawn::spawn_into_new_thread;use std::collections::HashMap;@@ -31,7 +34,7 @@ struct LivePane {id: PaneId,pid: u32,terminal: Terminal,- master: pty::ImportedPty,+ master: Box<dyn MasterPty>,}struct Prepared {@@ -96,6 +99,24 @@ pub fn preview(})}+#[cfg(unix)]+fn prepare_pty(pty: thinkterm_import::Pty) -> Result<Box<dyn MasterPty>> {+ Ok(Box::new(pty::ImportedPty::prepare(pty)?))+}++/// No Windows source hands its terminals over; see `thinkterm_import::Pty`.+#[cfg(windows)]+fn prepare_pty(_: thinkterm_import::Pty) -> Result<Box<dyn MasterPty>> {+ anyhow::bail!("Live session import needs macOS or Linux")+}++/// `prepare_pty` turns down every Windows terminal, so no live pane gets+/// this far there.+#[cfg(windows)]+fn adopted_child(_: u32) -> Box<dyn portable_pty::Child + Send + Sync> {+ unreachable!("Windows prepares no live terminals")+}+fn initial_size(seed: &TerminalSeed) -> TerminalSize {TerminalSize {rows: seed.rows as usize,@@ -121,7 +142,7 @@ fn prepare(request: &thinkterm_import::ImportRequest) -> Result<Prepared> {.collect();let mut panes = HashMap::new();for live in imported.terminals {- let master = pty::ImportedPty::prepare(live.pty).context("Prepare imported PTY")?;+ let master = prepare_pty(live.pty).context("Prepare imported PTY")?;let size = initial_size(&live.seed);// Restoring saved output cannot send a reply to a process still owned// by the source. Only the final terminal receives the live writer.@@ -244,6 +265,66 @@ fn make_tree(plan: &ImportPlan, name: &str) -> ThinkTermTree {tree}+/// default_prog may be an agent or other saved command. A layout import+/// only starts a login shell at the saved cwd.+#[cfg(unix)]+fn layout_shell() -> CommandBuilder {+ let shell = CommandBuilder::new_default_prog().get_shell();+ let mut command = CommandBuilder::new(&shell);+ command.arg("-l");+ command.env("SHELL", &shell);+ command+}++/// Windows has no login shell to ask for. The shell chosen in Settings, when+/// this is the app's own process; where that is not known, as in the session+/// server, the configured default_prog when it names a shell, and else the+/// system's command processor.+#[cfg(windows)]+fn layout_shell() -> CommandBuilder {+ let argv = mux::default_prog::preferred_argv().or_else(|| {+ config::configuration()+ .default_prog+ .clone()+ .filter(|argv| names_a_shell(argv))+ });+ match argv {+ Some(argv) => CommandBuilder::from_argv(argv.into_iter().map(Into::into).collect()),+ None => CommandBuilder::new(CommandBuilder::new_default_prog().get_shell()),+ }+}++/// Whether `argv` runs a shell, by its program's name.+#[cfg(any(windows, test))]+fn names_a_shell(argv: &[String]) -> bool {+ let Some(program) = argv.first() else {+ return false;+ };+ // By hand rather than with `Path`, which on unix would not split a+ // Windows path at its backslashes.+ let name = program.rsplit(['/', '\\']).next().unwrap_or(program);+ let name = name.to_ascii_lowercase();+ let name = name.strip_suffix(".exe").unwrap_or(&name);+ matches!(+ name,+ "cmd"+ | "powershell"+ | "pwsh"+ | "bash"+ | "sh"+ | "zsh"+ | "fish"+ | "nu"+ | "wsl"+ | "elvish"+ | "xonsh"+ | "dash"+ | "ksh"+ | "tcsh"+ | "csh"+ )+}+/// Receipts take a file lock, so the lookup runs on a blocking thread.pub async fn status(request_id: String) -> Result<codec::ImportSessionStatus> {smol::unblock(move || receipt::Store::owner().status(&request_id)).await@@ -326,12 +407,7 @@ whereif prepared.transfer.is_none() {for tab in prepared.plan.tabs() {for (id, saved) in &tab.panes {- // default_prog may be an agent or other saved command. A- // layout import only starts a login shell at the saved cwd.- let shell = CommandBuilder::new_default_prog().get_shell();- let mut command = CommandBuilder::new(&shell);- command.arg("-l");- command.env("SHELL", &shell);+ let mut command = layout_shell();command.set_require_cwd(true);command.cwd(&saved.cwd);match domain@@ -484,8 +560,8 @@ wherelet pane: Arc<dyn Pane> = Arc::new(LocalPane::new(live.id,live.terminal,- portable_pty::adopted_child(live.pid),- Box::new(live.master),+ adopted_child(live.pid),+ live.master,writer,domain.domain_id(),"Imported terminal".into(),diff --git a/wezterm-mux-server-impl/src/session_import/receipt.rs b/wezterm-mux-server-impl/src/session_import/receipt.rsindex 42a49da7..a384fd79 100644--- a/wezterm-mux-server-impl/src/session_import/receipt.rs+++ b/wezterm-mux-server-impl/src/session_import/receipt.rs@@ -3,6 +3,7 @@ use codec::{ImportSessionRequest, ImportSessionResponse, ImportSessionStatus};use serde::{Deserialize, Serialize};use std::collections::{BTreeMap, HashSet};use std::io::{Read, Write};+#[cfg(unix)]use std::os::unix::fs::OpenOptionsExt;use std::path::PathBuf;use std::sync::Mutex;@@ -84,13 +85,12 @@ impl Store {.parent().context("Import receipt directory is missing")?;std::fs::create_dir_all(parent)?;- let lock = std::fs::OpenOptions::new()- .read(true)- .write(true)- .create(true)- .mode(0o600)- .open(self.path.with_extension("lock"))?;- rustix::fs::flock(&lock, rustix::fs::FlockOperation::LockExclusive)?;+ let mut options = std::fs::OpenOptions::new();+ options.read(true).write(true).create(true);+ #[cfg(unix)]+ options.mode(0o600);+ let lock = options.open(self.path.with_extension("lock"))?;+ lock.lock()?;let mut records = match std::fs::File::open(&self.path) {Ok(file) => {let mut bytes = Vec::new();@@ -118,6 +118,8 @@ impl Store {file.write_all(&bytes)?;file.as_file().sync_all()?;file.persist(&self.path)?;+ // Windows cannot open a directory as a file to sync it.+ #[cfg(unix)]std::fs::File::open(parent)?.sync_all()?;}Ok(result)diff --git a/wezterm-mux-server-impl/src/session_import/tests.rs b/wezterm-mux-server-impl/src/session_import/tests.rsindex 1b937cbf..bb8de061 100644--- a/wezterm-mux-server-impl/src/session_import/tests.rs+++ b/wezterm-mux-server-impl/src/session_import/tests.rs@@ -302,3 +302,28 @@ fn preserves_split_direction_ratio_focus_and_zoom() {panic!("missing split");}}++/// A Windows layout import starts default_prog only when it is a shell: it+/// may as well be an agent.+#[test]+fn a_shell_is_known_by_its_program_name() {+ let argv = |args: &[&str]| args.iter().map(|arg| arg.to_string()).collect::<Vec<_>>();+ for shell in [+ argv(&["pwsh.exe", "-NoLogo"]),+ argv(&[r"C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe"]),+ argv(&["cmd"]),+ argv(&[r"C:\Program Files\Git\bin\bash.exe", "--login"]),+ argv(&["wsl.exe", "-d", "Ubuntu"]),+ argv(&["/usr/bin/fish"]),+ ] {+ assert!(names_a_shell(&shell), "{:?}", shell);+ }+ for program in [+ argv(&["claude"]),+ argv(&[r"C:\Tools\codex.exe"]),+ argv(&["htop"]),+ argv(&[]),+ ] {+ assert!(!names_a_shell(&program), "{:?}", program);+ }+}diff --git a/wezterm-mux-server-impl/src/sessionhandler.rs b/wezterm-mux-server-impl/src/sessionhandler.rsindex 8c1a6250..31181e7c 100644--- a/wezterm-mux-server-impl/src/sessionhandler.rs+++ b/wezterm-mux-server-impl/src/sessionhandler.rs@@ -2281,7 +2281,6 @@ impl SessionHandler {)));return;}- #[cfg(unix)]smol::spawn(async move {let result = promise::spawn::spawn_into_new_thread(move || {crate::session_import::discover(request)@@ -2290,11 +2289,6 @@ impl SessionHandler {send_response(result.map(Pdu::ListImportSessionsResponse));}).detach();- #[cfg(not(unix))]- {- let _ = request;- send_response(Err(anyhow!("Session import is supported on macOS and Linux")));- }}Pdu::PreviewImportSession(request) => {@@ -2304,7 +2298,6 @@ impl SessionHandler {)));return;}- #[cfg(unix)]smol::spawn(async move {let result = promise::spawn::spawn_into_new_thread(move || {crate::session_import::preview(request)@@ -2313,11 +2306,6 @@ impl SessionHandler {send_response(result.map(Pdu::PreviewImportSessionResponse));}).detach();- #[cfg(not(unix))]- {- let _ = request;- send_response(Err(anyhow!("Session import is supported on macOS and Linux")));- }}Pdu::GetImportSessionStatus(request) => {@@ -2325,17 +2313,11 @@ impl SessionHandler {send_response(Err(anyhow!("Session import requires an authenticated desktop connection")));return;}- #[cfg(unix)]spawn_into_main_thread(async move {send_response(crate::session_import::status(request.request_id).await.map(|status| {Pdu::GetImportSessionStatusResponse(codec::GetImportSessionStatusResponse { status })}));}).detach();- #[cfg(not(unix))]- {- let _ = request;- send_response(Err(anyhow!("Session import is supported on macOS and Linux")));- }}Pdu::ImportSessionRequest(request) => {@@ -2345,7 +2327,6 @@ impl SessionHandler {)));return;}- #[cfg(unix)]spawn_into_main_thread(async move {promise::spawn::spawn(async move {let result = crate::session_import::execute(request, |tree, add, _layouts| {@@ -2358,11 +2339,6 @@ impl SessionHandler {.detach();}).detach();- #[cfg(not(unix))]- {- let _ = request;- send_response(Err(anyhow!("Session import is supported on macOS and Linux")));- }}Pdu::MutateThinkTermTree(MutateThinkTermTree { ops }) => {@@ -3071,7 +3047,6 @@ async fn ensure_thinkterm_thread(request: EnsureThinkTermThread) -> anyhow::Resu// awaits below would leak the requesting identity to unrelated// main-thread work. See `Mux::with_identity`.let landing = crate::thinkterm_tree::ensure_landing(request.preferred_thread_id.as_deref())?;- #[cfg(unix)]crate::session_import::wait_for_workspace(&landing.workspace).await?;let _materialize = THINKTERM_MATERIALIZE.lock().await;@@ -3286,7 +3261,6 @@ async fn split_pane(split: SplitPane) -> anyhow::Result<Pdu> {}async fn domain_spawn_v2(spawn: SpawnV2) -> anyhow::Result<Pdu> {- #[cfg(unix)]crate::session_import::ensure_not_pending(&spawn.workspace)?;let mux = Mux::get();// No identity: `spawn.workspace` is an explicit non-optional string ondiff --git a/wezterm-mux-server/src/main.rs b/wezterm-mux-server/src/main.rsindex 52da1bdb..23840663 100644--- a/wezterm-mux-server/src/main.rs+++ b/wezterm-mux-server/src/main.rs@@ -103,12 +103,9 @@ fn main() {if let Some(watch) = wezterm_mux_server_impl::hold::requested() {wezterm_mux_server_impl::hold::run(&watch, env_bootstrap::setup_logger);}- #[cfg(unix)]- {- thinkterm_import_herdr::register().expect("register built-in session importer");- if let Some(result) = thinkterm_import::maybe_run_helper() {- std::process::exit(if result.is_ok() { 0 } else { 1 });- }+ thinkterm_import_herdr::register().expect("register built-in session importer");+ if let Some(result) = thinkterm_import::maybe_run_helper() {+ std::process::exit(if result.is_ok() { 0 } else { 1 });}if let Err(err) = run() {wezterm_blob_leases::clear_storage();