Attaching tmux sessions without taking them over

How attached panes share window sizing with other clients, and how to pick a tmux window without switching anyone else.

AIAgent Interface team 3 min read guidetmux

You already have tmux sessions: a dev server you left running, an agent started from another terminal, a long build you check on now and then. Agent Interface can show any of them in a pane. Attaching never takes a session away from anyone else, and the app never sends a command that ends it.

This guide covers how to attach, how sizing works when other clients are watching too, and how to look at a different tmux window without moving anyone else.

Two kinds of terminal

A pane can hold an ordinary shell or an attached session. Ordinary shells run on your library's own persistent tmux server, so the app manages them for you. Attached sessions are sessions that already exist on any tmux server on your computer. The pane remembers which server and session it points to.

Closing the window only detaches its clients; it never sends a command that ends either kind. The difference is who owns them: an attached session keeps living by its own tmux rules, not the app's.

Attach a session

Choose Attach a session in an empty pane, Attach session in tab options, or press Command-Shift-A (Ctrl+Shift+A on Linux). The chooser lists the tmux sessions it can find. Type to filter, use Up and Down, then press Enter or click a row.

Confirming saves the pane first and then connects it. The pane keeps its identity and saved directory, so if it replaced an ordinary terminal, that shell is still waiting on the library server for later.

Sharing the window size

tmux decides one size for each window, based on the clients looking at it and its window-size option. A pane that is on screen takes part in that decision like any other client.

how a pane takes part in sizingper tmux window
on screen     counts toward window-size
hidden        steps out with ignore-size
shown again   rejoins at its current size
larger client text scales down to fit, only while it stays

When you switch to another tab, the pane stays connected but steps out of sizing, so a session you are not looking at never squeezes someone else's terminal. Dragging a divider does declare a new size to tmux, so under some window-size settings other clients will see the window change too.

Pick a window, privately

An attached pane starts on the session's current window. A single row above the terminal names the session, and when it has several windows their names sit in that row too. Click a name to view that window without switching it for any other client.

Your choice is remembered while you move between tabs and workspaces. Reopening the library starts from the session's current window again. The list follows tmux, checking every two seconds, so new and renamed windows appear on their own.

Leaving cleanly

Detach in tab options, Command-Shift-X (Ctrl+Shift+X on Linux), returns the pane to its chooser. Close Pane, Close Tab and closing the window detach too. None of them sends a command that ends a session.

The session keeps its own lifetime policy. If you set tmux's destroy-unattached option on it, tmux applies that choice when the last client leaves; the app never overrides it.

When a session comes back

If an attached session goes away, for example because its server restarted, the pane keeps its place. It retries every two seconds and reconnects as soon as the same session returns on the same server. Reconnect retries immediately.

Retries only ever look for the saved session. They never create a session and never start an agent, so a pane can't bring back something you meant to stop.

honest limits

Sessions must run on the same computer as the app. Custom tmux prefix bindings are not wired into panes yet.

The user guide covers attaching, detaching and every shortcut.

share
all posts →
v0.1.1
releases
Agent Interface 0.1.1: what’s new
tmux -C
how it works
Close the window, keep the work: how Agent Interface uses tmux
layouts.db
how it works
Inside a workspace: how layouts are saved and merged between windows