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
mobile: close buttons on the current pills, and a whole overview transition
RoversX96ec64b92310
diff --git a/android/app/src/main/java/com/roversx/thinkterm/TerminalScreen.kt b/android/app/src/main/java/com/roversx/thinkterm/TerminalScreen.ktindex b846714d..8556137a 100644--- a/android/app/src/main/java/com/roversx/thinkterm/TerminalScreen.kt+++ b/android/app/src/main/java/com/roversx/thinkterm/TerminalScreen.kt@@ -44,7 +44,9 @@ import androidx.compose.material.icons.filled.Warningimport androidx.compose.material.icons.filled.CheckCircleimport androidx.compose.material.icons.outlined.Circleimport androidx.compose.material.icons.outlined.PowerOff+import androidx.compose.material3.AlertDialogimport androidx.compose.material3.Button+import androidx.compose.material3.TextButtonimport androidx.compose.material3.CircularProgressIndicatorimport androidx.compose.material3.DropdownMenuimport androidx.compose.material3.DropdownMenuItem@@ -74,6 +76,7 @@ import androidx.compose.ui.graphics.Colorimport androidx.compose.ui.graphics.TransformOriginimport androidx.compose.ui.graphics.drawscope.clipRectimport androidx.compose.ui.graphics.graphicsLayer+import androidx.compose.ui.graphics.lerpimport androidx.compose.ui.input.pointer.pointerInputimport androidx.compose.ui.layout.boundsInRootimport androidx.compose.ui.layout.onGloballyPositioned@@ -125,6 +128,8 @@ fun TerminalScreen(host: Host, store: HostStore, onBack: () -> Unit) {// Once in the card the terminal fades into the card's own preview,// so the live card looks like every other one.val fade = remember { Animatable(0f) }+ // Once the terminal has faded, the live card shows its preview rows.+ var livePreview by remember { mutableStateOf(false) }val overviewOpen = overviewShown && zoom.value > 0fvar zoomTarget by remember { mutableStateOf<Rect?>(null) }@@ -166,6 +171,7 @@ fun TerminalScreen(host: Host, store: HostStore, onBack: () -> Unit) {fun closeOverview() {if (!overviewShown) returnscope.launch {+ livePreview = falsefade.animateTo(0f, tween(150))zoom.animateTo(0f, spring(dampingRatio = 0.9f, stiffness = 400f))overviewShown = false@@ -198,7 +204,10 @@ fun TerminalScreen(host: Host, store: HostStore, onBack: () -> Unit) {zoomTarget = framescope.launch {zoom.animateTo(1f, spring(dampingRatio = 0.85f, stiffness = 300f))- if (overviewShown) fade.animateTo(1f, tween(250))+ if (overviewShown) {+ fade.animateTo(1f, tween(180))+ livePreview = overviewShown+ }}}@@ -214,7 +223,7 @@ fun TerminalScreen(host: Host, store: HostStore, onBack: () -> Unit) {Box(Modifier.fillMaxSize()- .background(if (overviewOpen) Color(0xFF0F0F0F) else model.background)+ .background(lerp(model.background, Color(0xFF0F0F0F), zoom.value)).safeDrawingPadding()) {if (overviewShown) {@@ -222,6 +231,7 @@ fun TerminalScreen(host: Host, store: HostStore, onBack: () -> Unit) {OverviewScreen(model = model,liveThread = currentThread?.id,+ livePreview = livePreview,onCardBounds = { cardLaidOut(it) },onDismiss = { closeOverview() },)@@ -232,7 +242,14 @@ fun TerminalScreen(host: Host, store: HostStore, onBack: () -> Unit) {// strips and bars leave while the overview is up, so the cards get// the taps; the terminal's own touches close it.Column(Modifier.fillMaxSize().zIndex(1f).imePadding()) {- if (!overviewOpen) {+ // The strips fade with the zoom and stop taking touches; their+ // room stays, so the terminal's own place does not move under+ // the zoom that was measured from it.+ Column(+ Modifier+ .graphicsLayer { alpha = 1f - zoom.value }+ .then(if (overviewOpen) Modifier.pointerInput(Unit) { awaitPointerEventScope { while (true) awaitPointerEvent().changes.forEach { it.consume() } } } else Modifier)+ ) {TopBar(model = model,twoLevel = twoLevel,@@ -242,10 +259,6 @@ fun TerminalScreen(host: Host, store: HostStore, onBack: () -> Unit) {onEditHost = { editingHost = model.host },)if (twoLevel) TabSubstrip(model, onPinchOut = { openOverview() })- } else {- // Their room stays, so the terminal's own place does not- // move under the zoom that was measured from it.- Spacer(Modifier.height(if (twoLevel) 80.dp else 48.dp))}// The terminal, scaled to the card's width and moved into it as@@ -442,6 +455,21 @@ private fun NewTabButton(model: TerminalModel) {@Composableprivate fun ThreadPill(model: TerminalModel, thread: ThreadView, onTree: () -> Unit) {var menu by remember { mutableStateOf(false) }+ var confirmDelete by remember { mutableStateOf(false) }+ if (confirmDelete) {+ // Deleting ends every program in the thread: it is asked first.+ AlertDialog(+ onDismissRequest = { confirmDelete = false },+ title = { Text(tr("thread.delete.title", thread.name)) },+ text = { Text(tr("thread.delete.body")) },+ confirmButton = {+ TextButton(onClick = { confirmDelete = false; model.sideClick("delete", thread.id) }) {+ Text(tr("delete"), color = MaterialTheme.colorScheme.error)+ }+ },+ dismissButton = { TextButton(onClick = { confirmDelete = false }) { Text(tr("cancel")) } },+ )+ }Box {Row(Modifier@@ -454,7 +482,7 @@ private fun ThreadPill(model: TerminalModel, thread: ThreadView, onTree: () -> U).widthIn(min = 64.dp).height(26.dp)- .padding(horizontal = 10.dp),+ .padding(start = 10.dp, end = if (thread.current) 4.dp else 10.dp),verticalAlignment = Alignment.CenterVertically,horizontalArrangement = Arrangement.spacedBy(5.dp),) {@@ -467,6 +495,7 @@ private fun ThreadPill(model: TerminalModel, thread: ThreadView, onTree: () -> UmaxLines = 1,overflow = TextOverflow.Ellipsis,)+ if (thread.current) CloseX { confirmDelete = true }}AppContextMenu(model, "thread", thread.id, expanded = menu, onDismiss = { menu = false })}@@ -493,30 +522,52 @@ private fun TabPills(for (tab in model.tabs?.tabs ?: emptyList()) {var menu by remember(tab.tab) { mutableStateOf(false) }Box(Modifier.onGloballyPositioned { positions["tab:" + tab.tab] = it.positionInParent().x.toInt() }) {- Text(- text = tab.label.ifEmpty { tr("tab.num", tab.tab) },- color = if (tab.current) Color.White else Color.White.copy(alpha = 0.62f),- fontSize = size,- fontWeight = if (tab.current) FontWeight.SemiBold else FontWeight.Normal,- maxLines = 1,- overflow = TextOverflow.Ellipsis,- textAlign = TextAlign.Center,- modifier = Modifier+ Row(+ Modifier.clip(RoundedCornerShape(50)).background(Color.White.copy(alpha = if (tab.current) 0.18f else 0.06f)).combinedClickable(onClick = { model.chromeClick("pane", pane = tab.target) },onLongClick = { menu = true },)- .widthIn(min = 76.dp, max = 140.dp)+ .widthIn(min = 76.dp, max = 160.dp).heightIn(min = height)- .padding(horizontal = 10.dp, vertical = 4.dp),- )+ .padding(start = 10.dp, end = if (tab.current) 4.dp else 10.dp, top = 4.dp, bottom = 4.dp),+ verticalAlignment = Alignment.CenterVertically,+ horizontalArrangement = Arrangement.spacedBy(4.dp),+ ) {+ Text(+ text = tab.label.ifEmpty { tr("tab.num", tab.tab) },+ color = if (tab.current) Color.White else Color.White.copy(alpha = 0.62f),+ fontSize = size,+ fontWeight = if (tab.current) FontWeight.SemiBold else FontWeight.Normal,+ maxLines = 1,+ overflow = TextOverflow.Ellipsis,+ textAlign = TextAlign.Center,+ modifier = Modifier.weight(1f, fill = false),+ )+ if (tab.current) CloseX { model.chromeClick("close-tab", tab = tab.tab) }+ }AppContextMenu(model, "tab", tab.tab.toString(), expanded = menu, onDismiss = { menu = false })}}}+/// The × at the end of the current pill: what the desktop's tabs carry.+@Composable+private fun CloseX(onClick: () -> Unit) {+ Icon(+ Icons.Default.Close,+ contentDescription = tr("closetab"),+ tint = Color.White.copy(alpha = 0.7f),+ modifier = Modifier+ .size(18.dp)+ .clip(CircleShape)+ .clickable(onClick = onClick)+ .padding(3.dp),+ )+}+@OptIn(ExperimentalFoundationApi::class)@Composableprivate fun PlusButton(onClick: () -> Unit, onLongClick: (() -> Unit)? = null) {diff --git a/android/app/src/main/java/com/roversx/thinkterm/TreeSheet.kt b/android/app/src/main/java/com/roversx/thinkterm/TreeSheet.ktindex 582bdd00..4e86bb0b 100644--- a/android/app/src/main/java/com/roversx/thinkterm/TreeSheet.kt+++ b/android/app/src/main/java/com/roversx/thinkterm/TreeSheet.kt@@ -66,6 +66,9 @@ import androidx.compose.ui.graphics.Colorimport androidx.compose.ui.input.pointer.PointerInputScopeimport androidx.compose.ui.input.pointer.pointerInputimport androidx.compose.ui.layout.boundsInRoot+import androidx.compose.animation.core.animateFloatAsState+import androidx.compose.animation.core.tween+import androidx.compose.ui.graphics.graphicsLayerimport androidx.compose.ui.layout.onGloballyPositionedimport androidx.compose.ui.text.AnnotatedStringimport androidx.compose.ui.text.SpanStyle@@ -527,6 +530,7 @@ private const val OVERVIEW_COLS = 38fun OverviewScreen(model: TerminalModel,liveThread: String?,+ livePreview: Boolean,onCardBounds: (Rect?) -> Unit,onDismiss: () -> Unit,) {@@ -576,6 +580,7 @@ fun OverviewScreen(model = model,thread = thread,live = thread.id == liveThread,+ livePreview = livePreview,onCardBounds = onCardBounds,onDismiss = onDismiss,modifier = Modifier.weight(1f),@@ -612,6 +617,7 @@ private fun ThreadCard(model: TerminalModel,thread: ThreadView,live: Boolean,+ livePreview: Boolean,onCardBounds: (Rect?) -> Unit,onDismiss: () -> Unit,modifier: Modifier = Modifier,@@ -690,13 +696,16 @@ private fun ThreadCard(.background(if (thread.live) model.background else Color.Black.copy(alpha = 0.4f)).clipToBounds()) {+ // The live card's rows wait until the terminal has faded out of+ // it, so the two never show at once.+ val rowsAlpha by animateFloatAsState(if (!live || livePreview) 1f else 0f, tween(150), label = "rows")Text(previewText(model, thread),fontSize = 7.sp,lineHeight = 8.5.sp,fontFamily = FontFamily.Monospace,color = Color.White,- modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 7.dp),+ modifier = Modifier.fillMaxWidth().padding(horizontal = 8.dp, vertical = 7.dp).graphicsLayer { alpha = rowsAlpha },)if (live) {// The terminal itself lands over this, then fades into thediff --git a/ios/Resources/strings.json b/ios/Resources/strings.jsonindex 8c9e1825..1ee860ac 100644--- a/ios/Resources/strings.json+++ b/ios/Resources/strings.json@@ -194,6 +194,8 @@"theme.search": "Farbschemas durchsuchen","theme.system": "System","thismac": "Dieser Mac",+ "thread.delete.body": "Seine Tabs werden geschlossen und die Programme darin beendet.",+ "thread.delete.title": "„%@“ löschen?","thread.new": "Neuer Thread","thread.off": "aus","threads": "Threads",@@ -398,6 +400,8 @@"theme.search": "Search schemes","theme.system": "System","thismac": "This Mac",+ "thread.delete.body": "Its tabs close and the programs in them end.",+ "thread.delete.title": "Delete “%@”?","thread.new": "New Thread","thread.off": "off","threads": "Threads",@@ -602,6 +606,8 @@"theme.search": "Rechercher un thème","theme.system": "Système","thismac": "Ce Mac",+ "thread.delete.body": "Ses onglets se ferment et les programmes qu’ils contiennent s’arrêtent.",+ "thread.delete.title": "Supprimer « %@ » ?","thread.new": "Nouvelle session","thread.off": "arrêté","threads": "Fils",@@ -806,6 +812,8 @@"theme.search": "配色を検索","theme.system": "システム","thismac": "このMac",+ "thread.delete.body": "タブは閉じられ、実行中のプログラムは終了します。",+ "thread.delete.title": "「%@」を削除しますか?","thread.new": "新しいセッション","thread.off": "停止中","threads": "スレッド",@@ -1010,6 +1018,8 @@"theme.search": "搜索配色","theme.system": "跟随系统","thismac": "本机",+ "thread.delete.body": "它的标签会关闭,其中的程序会结束。",+ "thread.delete.title": "删除“%@”?","thread.new": "新建会话","thread.off": "已关","threads": "线程",diff --git a/ios/Sources/TerminalScreen.swift b/ios/Sources/TerminalScreen.swiftindex ae772765..4e771e23 100644--- a/ios/Sources/TerminalScreen.swift+++ b/ios/Sources/TerminalScreen.swift@@ -33,6 +33,9 @@ struct TerminalScreen: View {@State private var zoomClip: CGFloat?/// Once in the card the terminal fades into the card's own preview.@State private var zoomFade: Double = 1+ /// Once the terminal has faded, the live card shows its preview rows.+ @State private var livePreview = false+ @State private var deletingThread: ThreadView?init(host: Host?, store: HostStore?) {_model = StateObject(wrappedValue: TerminalModel(host: host, store: store))@@ -44,7 +47,7 @@ struct TerminalScreen: View {var body: some View {ZStack(alignment: .topLeading) {if overviewVisible {- OverviewScreen(model: model, isPresented: $overviewShown, cardFrame: $cardFrame, liveThread: currentThreadId)+ OverviewScreen(model: model, isPresented: $overviewShown, cardFrame: $cardFrame, liveThread: currentThreadId, livePreview: livePreview).opacity(overviewOpen ? 1 : 0).onChange(of: overviewShown) { _, shown in if !shown { closeOverview() } }}@@ -126,6 +129,18 @@ struct TerminalScreen: View {MenuList(model: model, sheet: sheet) { menu = nil }.presentationDetents([.medium, .large])}+ .confirmationDialog(+ tr("thread.delete.title", deletingThread?.name ?? ""),+ isPresented: Binding(get: { deletingThread != nil }, set: { if !$0 { deletingThread = nil } }),+ titleVisibility: .visible,+ presenting: deletingThread+ ) { thread in+ // Deleting ends every program in the thread: it is asked first.+ Button(tr("delete"), role: .destructive) { model.sideClick("delete", id: thread.id) }+ Button(tr("cancel"), role: .cancel) {}+ } message: { _ in+ Text(tr("thread.delete.body"))+ }.sheet(item: $editingHost) { host inHostEditView(host: host) { edited, secret, passphrase inif !secret.isEmpty { Keychain.save(secret, account: edited.id.uuidString) }@@ -222,8 +237,12 @@ struct TerminalScreen: View {Text(thread.name).font(.system(size: 12, weight: thread.current ? .semibold : .regular)).lineLimit(1)+ if thread.current {+ closeX { deletingThread = thread }+ }}- .padding(.horizontal, 10)+ .padding(.leading, 10)+ .padding(.trailing, thread.current ? 4 : 10).frame(minWidth: 64, minHeight: 26).background(thread.current ? Color.white.opacity(0.18) : Color.white.opacity(0.06)).clipShape(Capsule())@@ -287,14 +306,20 @@ struct TerminalScreen: View {Button {model.chromeClick("pane", pane: tab.target)} label: {- Text(tab.label.isEmpty ? tr("tab.num", tab.tab) : tab.label)- .font(.system(size: size, weight: tab.current ? .semibold : .regular))- .lineLimit(1)- .padding(.horizontal, 10)- .frame(minWidth: 76, maxWidth: 140, minHeight: height)- .foregroundColor(tab.current ? .white : Color.white.opacity(0.62))- .background(tab.current ? Color.white.opacity(0.18) : Color.white.opacity(0.06))- .clipShape(Capsule())+ HStack(spacing: 4) {+ Text(tab.label.isEmpty ? tr("tab.num", tab.tab) : tab.label)+ .font(.system(size: size, weight: tab.current ? .semibold : .regular))+ .lineLimit(1)+ if tab.current {+ closeX { model.chromeClick("close-tab", tab: tab.tab) }+ }+ }+ .padding(.leading, 10)+ .padding(.trailing, tab.current ? 4 : 10)+ .frame(minWidth: 76, maxWidth: 160, minHeight: height)+ .foregroundColor(tab.current ? .white : Color.white.opacity(0.62))+ .background(tab.current ? Color.white.opacity(0.18) : Color.white.opacity(0.06))+ .clipShape(Capsule())}.buttonStyle(.plain).contextMenu {@@ -304,6 +329,18 @@ struct TerminalScreen: View {}}+ /// The × at the end of the current pill: what the desktop's tabs carry.+ private func closeX(_ action: @escaping () -> Void) -> some View {+ Button(action: action) {+ Image(systemName: "xmark")+ .font(.system(size: 9, weight: .bold))+ .foregroundColor(Color.white.opacity(0.7))+ .frame(width: 18, height: 18)+ .contentShape(Circle())+ }+ .buttonStyle(.plain)+ }+/// "+" opens a tab; held, it offers the splits too.private var newTabButton: some View {Button { model.chromeClick("new-tab") } label: {@@ -364,11 +401,15 @@ struct TerminalScreen: View {}DispatchQueue.main.asyncAfter(deadline: .now() + 0.4) {guard overviewOpen else { return }- withAnimation(.easeOut(duration: 0.25)) { zoomFade = 0 }+ withAnimation(.easeOut(duration: 0.18)) { zoomFade = 0 }+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.18) {+ if overviewOpen { withAnimation(.easeOut(duration: 0.15)) { livePreview = true } }+ }}}private func closeOverview() {+ withAnimation(.easeOut(duration: 0.1)) { livePreview = false }withAnimation(.easeOut(duration: 0.15)) { zoomFade = 1 }DispatchQueue.main.asyncAfter(deadline: .now() + 0.15) {withAnimation(.spring(response: 0.35, dampingFraction: 0.9)) {diff --git a/ios/Sources/TreeSheet.swift b/ios/Sources/TreeSheet.swiftindex d4607429..b990e5ee 100644--- a/ios/Sources/TreeSheet.swift+++ b/ios/Sources/TreeSheet.swift@@ -276,6 +276,8 @@ struct OverviewScreen: View {/// The thumbnail box of the thread on show, in the screen's space.@Binding var cardFrame: CGRect?var liveThread: String?+ /// The live card's rows wait until the terminal has faded out of it.+ var livePreview: Bool = trueprivate let dots = 4private let rows = 9private let columns = [GridItem(.flexible(), spacing: 10), GridItem(.flexible(), spacing: 10)]@@ -402,6 +404,7 @@ struct OverviewScreen: View {.frame(maxWidth: .infinity, alignment: .topLeading).padding(.horizontal, 8).padding(.vertical, 7)+ .opacity(!live || livePreview ? 1 : 0)if live {// The terminal itself lands over this, then fades into// the same preview as every other card; the frame isdiff --git a/ios/tools/gen-strings.py b/ios/tools/gen-strings.pyindex 3326745d..b4ae73fb 100644--- a/ios/tools/gen-strings.py+++ b/ios/tools/gen-strings.py@@ -28,6 +28,14 @@ EXTRA = {"ok": ["OK", "好", "OK", "OK", "OK"],"copy": ["Copy", "复制", "コピー", "Copier", "Kopieren"],"p.layout": ["Layout", "布局", "レイアウト", "Disposition", "Layout"],+ "thread.delete.title": ["Delete “%@”?", "删除“%@”?", "「%@」を削除しますか?", "Supprimer « %@ » ?", "„%@“ löschen?"],+ "thread.delete.body": [+ "Its tabs close and the programs in them end.",+ "它的标签会关闭,其中的程序会结束。",+ "タブは閉じられ、実行中のプログラムは終了します。",+ "Ses onglets se ferment et les programmes qu’ils contiennent s’arrêtent.",+ "Seine Tabs werden geschlossen und die Programme darin beendet.",+ ],"more": ["More…", "更多…", "その他…", "Plus…", "Mehr…"],"rename": ["Rename", "重命名", "名前を変更", "Renommer", "Umbenennen"],"none": ["None", "无", "なし", "Aucun", "Keine"],