Skip to content

Lifecycle roadmap: overlaps, conflicts, blockers and tmux version gates #925

In progress

Description

@tony

Summary

libtmux's server and session lifecycle is being extended in several directions at once: keeping a server running before any session exists, making with blocks safe, get-or-create helpers, cleanup ownership, private servers, discovery, leases, and tracking launched programs. Several of these overlap or conflict. This issue names each feature, the conflicts between them, the order they have to land in, and which need a newer tmux than libtmux's 3.3a floor. Issue and PR numbers appear only as pointers to where each feature is tracked today; the feature descriptions are meant to stay true if those threads change.

Motivation

  • A with block on a session, window or pane destroys things it did not create (Server.__exit__ was fixed in 0.69.0 via Scoping a Server no longer kills it #728 so with Server() leaves running servers alive unless kill_on_exit=True). Session.__exit__ still kills whenever has_session(self.session_name) is true (src/libtmux/session.py L233-L234), and Window.__exit__ (src/libtmux/window.py L242-L246) and Pane.__exit__ (src/libtmux/pane.py L246-L250) unconditionally kill their target the same way. Any helper that returns an existing session, window or pane (get_or_create_session(), get_or_create_window(), Session.new_window(..., select_existing=True)) inherits that: with server.get_or_create_session("build") or with session.new_window("logs", select_existing=True) kills a session or window someone else made (0.68.0 documents that Window.__exit__ caveat on select_existing=True in Session(docs[new_window]): Note Window.__exit__ on select_existing reuse #926, while safe runtime __exit__ behavior is scheduled for 0.72.0 after 0.71.0's non-breaking fixes).
  • The same feature is being built more than once under different names: session get-or-create three ways, server teardown four ways, server discovery three ways, capability reporting two ways.
  • There is no call that keeps a server running with no sessions, so global options, environment and hooks cannot be set before the first session.

Evidence

Features

Feature What it is State
Server that stays up with no sessions Server.connect_or_start(): start if absent, keep alive with zero sessions, report whether this call started it Proposed for 0.72.0; a working startup proof exists in a draft branch. Tracked in #923
Safe server with block Leaving with Server() must not kill a server the block did not start Shipped in 0.69.0 (#728 / #724) via Server(..., kill_on_exit=True)
Safe session, window and pane with blocks Leaving with on a session, window or pane that was looked up or reused must not kill it Staged across 0.72.0 (FutureWarning + created / kill_on_exit in #963 / #959) and 0.73.0 (enforced preservation in #964); raised in #916 and #804
Teardown-safe pane formatting repr(pane) and str(pane) format the stored pane_id without spawning tmux clients or raising after teardown Drafted in #950 (0.72.0 alongside safe with blocks). Tracked in #945
Session and window get-or-create Return the named session or window, creating it only when missing Drafted and green as get_or_create_session() / get_or_create_window(), scheduled for 0.72.0 after naming and safe __exit__. Tracked in #916
Created-vs-reused result and cleanup ownership Tell the caller whether a resource was created or reused, and clean up only what the call created Drafted for sessions as FoundOrCreated, scheduled for 0.72.0 after 0.71.0's single-reply new_session() parsing (#942). Tracked in #804
Private throwaway server A context manager that makes an isolated server on a temporary socket and removes it afterwards Proposed for 0.72.0 as Server.private(). Tracked in #872
Server discovery List the tmux servers on this machine without starting or changing any Three drafts, scheduled for 0.72.0. Tracked in #924
Default socket choice Which server a bare Server() talks to when $TMUX is inherited, and keeping returned handles on that socket Staged across 0.72.0 (FutureWarning + Server.from_env() guidance in #961 / #960) and 0.73.0 (-L default + isolated child env in #962 / #840, with socket retention stacked in #954 without libtmux.engine). Tracked in #840
Session leases A server-side timer that removes a session whose owner disappeared Experimental proposal (0.73.0+). Tracked in #805
Launched-program lifetime Start a program in a pane and own it through exit status, output collection and cleanup Drafted (0.73.0+); needs tmux 3.8. Tracked in #823
Wait for a pane the caller did not launch Block until an existing pane exits, with a polling fallback Proposed (0.73.0+). Tracked in #869
Per-call client environment Pass env and cwd to one tmux client call without changing os.environ, and preserve UTF-8 text under an ASCII locale UTF-8 text retargeted directly onto master in #953 for 0.72.0 without libtmux.engine (#739). Tracked in #882
Capability reporting Ask which optional tmux features the connected server supports, built on src/libtmux/_internal/support/capabilities.py (libtmux-capabilities/1) Competing public proposals atop the internal table (0.73.0+). Tracked in #871

Conflicts

Conflict What collides What it needs
A reused session, window or pane dies on with exit get_or_create_session(), get_or_create_window() and new_window(select_existing=True) return existing objects; Session.__exit__, Window.__exit__ and Pane.__exit__ kill any live target; the ownership rule says reuse never grants permission to delete Warn on unowned handles and add created / kill_on_exit in 0.72.0 (#963 / #959), then preserve unowned handles on __exit__ in 0.73.0 (#964)
Formatting a retired pane raises during teardown Pane.__repr__ looks up self.window and self.session in tmux, spawning two clients on live handles and raising TmuxObjectDoesNotExist after window teardown (#902) Format Pane from its stored pane_id in 0.72.0 (#945 / #950)
Uncertain session creation on multiline paths A newline in start_directory or after-new-session hook output splits new-session -P output so new_session() raises after tmux created the session, obscuring creator ownership (#804) Parse the delimited creation reply in 0.71.0 (#942, unstacking #951 onto master) ahead of session ownership (#831)
A joined server dies on with exit Server.connect_or_start() returns servers it did not start; Server.__exit__ used to kill any live server Resolved in 0.69.0 (#728): Server.__exit__ preserves running servers unless kill_on_exit=True
Two get-or-create vocabularies get_or_create_session() returning the session, against find_or_create_session() / create_session() / reuse_session() returning a FoundOrCreated wrapper One naming family and one way to report "created" (0.72.0)
One wrapper type defined twice FoundOrCreated and find_or_create_session exist in two separate drafts Keep one implementation (0.72.0)
Server teardown spelled four ways kill_on_exit=True, resource.own(), Server.owned(), Server.private() Server(..., kill_on_exit=True) shipped in 0.69.0 (#728); align Server.private() (#872) and ownership (#804) onto it in 0.72.0
Discovery spelled three ways TmuxLobby.servers, Server.discover(), discover_servers() One API (0.72.0)
Capabilities spelled multiple ways Server.capabilities(), module-level capabilities(), libtmux.capabilities module One public API over _internal.support.capabilities (0.73.0+)
Socket defaults decided by side effect LIBTMUX_SOCKET_PATH / LIBTMUX_SOCKET_NAME defaults in a draft, while the default-socket question is open Decide the default socket first (0.72.0)
Lifecycle drafts stacked on libtmux.engine Qualification drafts #951, #952, #953, #954, and #955 previously targeted engine-seam-minimal (#739), while engine operations land last (0.74.0+) Resolved: #951, #952, and #955 (0.71.0) and #953 (0.72.0) target master directly, and #954 stacks on #962 without libtmux.engine
Command timeouts built three times Server-wide timeout, per-call deadline, and a bundle carrying both Shipped in 0.70.0 via #807 (superseding #809, #735, and #757)
Log redaction built twice Mask-by-default against caller-chosen redactor Shipped in 0.70.0 via #748 (with #898; closing #905 and #906)

Where these live today: get-or-create #920; FoundOrCreated #831 and #771; handle with ownership #963 (#959) -> #964 (#804); creation reply #951 (#942); strict session lookup #955 (#704); pane repr #950 (#945); teardown #728, #771, #872; discovery #764, #771; capabilities #833, #871, #739; connected-daemon version fence #965 (#958) -> #966 (#777); socket defaults and pinning #771, #840, #961 (#960) -> #962, #954; client locale #953 (#882); timeouts #807 (superseded: #809, #735, #757); redaction #748 and #898 (closed: #905, #906).

Release sequencing

  1. 0.70.0 (shipped — logging, failure ownership, timeouts, and strict typing): Structured logging, failure ownership, and symmetric environment masking (logging(feat): Document logging and define failure ownership #748, closing common(feat[logging]): Mask typed keys and buffer data in logs #905 and common(feat[logging]): Let callers choose the logged argv redactor #906), unified command, wait-for, and listing timeouts (Command(feat[timeout]): Bound commands, waits, and listings #807, superseding server(feat[wait]) Bound ordinary channel waits #809, Bound a tmux command that may never return #735, and Bound every tmux command from a server-wide timeout, listings included #757), non-breaking fixes and docs, and ty + Ruff ANN (dev(ty): Replace mypy with strict ty and Ruff ANN #682).
  2. 0.71.0 (non-breaking fixes, opt-in checks, CI, and conformance tests): Ship harmless master-ready fixes and opt-in checks first so pins below 0.72.0 keep them: REVIEW.md + check-workarounds (docs(policy): Add REVIEW.md, PR template, and workaround gate #967, shipped), setup-tmux CI (Replace .github/scripts/tmux_build.py with libtmux/setup-tmux #941 / Replace .github/scripts/tmux_build.py with libtmux/setup-tmux #940, shipped), Server.attached_sessions (List sessions with one or more attached clients #949 / Server.attached_sessions omits sessions with attached clients #943), Pane.send_keys status check (Check the text send before pressing Enter #948 / Pane.send_keys() proceeds to Enter after a silent client failure #946), unstacked new_session multiline reply parsing (Read the session ID and path from the creation reply #951 / new_session() raises after creating a session in a newline path #942), opt-in Pane.capture_pane(check=True) (Distinguish blank pane captures from failed reads #952 / Add a checked Pane.capture_pane() for callers that need a real read #944), opt-in Server.has_session_strict() (Confirm exact session absence before removing saved state #955 / Server liveness, list error handling, and EnvironmentMixin errors #704), the FIRE conformance suite (Verify pane job results with the FIRE suite #957 / Add a FIRE test for pane output, input delivery and job exit #956), and ready docs/test PRs.
  3. 0.72.0 (deprecation wave, pane formatting, and server/session get-or-create): Render Pane from its stored ID (Format pane handles using their stored ID #950 / repr(pane) launches tmux clients and can raise during teardown #945); ship FutureWarning deprecation windows and MIGRATION tables for bare Server() inside non-default $TMUX (Server(feat[socket]): Warn when bare Server() follows $TMUX #961 / Warn with FutureWarning when bare Server() follows non-default $TMUX #960), unowned {Session, Window, Pane}.__enter__ with created / kill_on_exit (Session/Window/Pane(feat[ctx]): Warn on unowned __enter__ #963 / Warn with FutureWarning before __exit__ preserves unowned handles #959), and < 3.3a connected-daemon reads (Server(feat[versions]): Warn on < 3.3a lenient daemon reads #965 / Warn with FutureWarning on < 3.3a daemon reads ahead of VersionTooLow #958); unstack socket pinning (Keep session creation and returned handles on the selected socket #954) and per-call client env / UTF-8 text (Support per-call client flags, clean env/cwd, and spawn_client #882 / Keep typed tmux text in UTF-8 under an ASCII locale #953) onto master; add sessionless Server.connect_or_start() (Add Server.connect_or_start() to keep a server up with no sessions #923, extracted from Lifecycle(feat): Add server defaults and owned scopes #771), get-or-create (libtmux(feat[get_or_create]): Add window and session helpers #920), session ownership (Track ownership when creating or reusing sessions #831), Server.private() (Add Server.private() context manager #872), and server discovery (Lobby(feat): Discover local tmux servers #764 / Discover local tmux servers without starting them #924).
  4. 0.73.0+ (enforcement cuts, observation, optional libtmux[vt], program lifetime, and tmux 3.8+ lifecycle features): Enforce -L default on bare Server() (Server(feat[socket]): Target default server on bare Server() #962 / Server() without a socket follows an inherited $TMUX to another server #840), unowned handle preservation on __exit__ (Session/Window/Pane(feat[ctx]): Preserve unowned handles #964 / Create or reuse tmux resources with explicit cleanup ownership #804), and VersionTooLow on < 3.3a lenient reads (Server(feat[versions]): Raise VersionTooLow on < 3.3a reads #966 / Verify connected tmux daemon meets the 3.3a minimum before dispatch #777); land optional libtmux[vt] capture and -C observation (vt(feat[libvt]): Add optional VT integration #934, tests(vt): Exercise interactive picker lifecycle #937, tests(vt): Verify captured paste state #947, Window(feat[vt]): Add multi-pane window VT capture #939 for Add optional libtmux[vt] pane capture and live observation on Python 3.12+ #932 / Prototype libtmux[vt] capture, -C sync, input, and test helpers #933), public capability reporting (Package capabilities.json in distributions and expose Server.capabilities() #871), explicit program arguments (Preserve explicit program arguments across launches #830), launched-program lifetime (session(feat): Track fresh program lifetimes #833), unowned pane waits (Add Pane.wait() to wait for exit of an existing unowned pane #869), observation / capture cursors (Retain immutable pane capture observations #810, Add bounded visible-text presence and absence waits #829, Add Pane.capture_since() for cursor-based incremental pane reads #741 / Capture retained history with counter-backed cursors #832), and remaining non-engine tracks in 0.63.x and beyond Roadmap #907.
  5. 0.74.0+ (last — engine seam, async dispatch, and transport operations): Land libtmux.engine (Engine(feat): Add raw-byte libtmux.engine seam and capabilities #739) and libtmux.aio / ReplayEngine (Aio(feat): Add libtmux.aio and offline ReplayEngine tapes #738) last, alongside ExecEngine (Run tmux commands through a caller-supplied transport (docker exec, ssh, sandbox exec) #841), ControlClient (Add ControlClient with %subscription-changed and hook-safe guards #884), command chains (Typed command descriptors for native tmux command chains #683), and async wait-for cancellation (Reap AsyncServer.wait_for on task cancel and expose tmux 3.8 wait-for -l / -w #870).

tmux version gates

libtmux's floor is TMUX_MIN_VERSION = "3.3a" (src/libtmux/common.py L34). "First in" is the tmux release that first contained the mechanism, read from tmux's git history; rows marked "stated" repeat what the tracking issue says.

Feature tmux mechanism it depends on First in Above the 3.3a floor?
Server that stays up with no sessions exit-empty option; format lookup falling back to the server environment; if-shell -F 2.7; 2.2; 2.0 or earlier No
Safe with blocks none any No
Session and window get-or-create new-window -S 3.2 No
Created-vs-reused and ownership for sessions new-session -P -F, format-guarded command queues 3.2a (stated) No
Server discovery #{version}, #{pid} formats 3.1 No
Session leases run-shell -d timers, if-shell -F 3.2 No
Launched-program lifetime wait-for -E pane-exit events 3.8 Yes, 3.8
Wait for a pane the caller did not launch wait-for -E; polls pane_dead below 3.8 3.8 Partly
Event-driven waits for text or completion wait-for -E 3.8 (stated) Yes, 3.8
Incremental capture with cursors history counters 3.8 (stated) Yes, 3.8
wait-for -l and -w new wait-for flags 3.8 (stated) Yes, 3.8
Monitor hooks set-hook -B/-T/-E 3.8 (stated) Yes, 3.8
tmux 3.8 formats, modal new-pane flags, JSON layouts new formats and flags 3.8 (stated) Yes, 3.8
Capture line numbers and flags capture-pane -L/-F 3.7 (stated) Yes, 3.7
Library-managed control-mode features control-client stability fixes 3.7 (stated) Yes, 3.7
run_shell returning output run-shell output behavior 3.5 (shipped in #918) Yes, 3.5
Native program status, popup option removal OSC 7501 pane_program_*; removed popup-* options 3.9-dev (stated) Yes, 3.9

The sessionless-server recipe was run on tmux 3.3a, 3.6 and 3.8a: under no config, a config that creates a session, and a config with exit-unattached on plus a session, the first call reported created, the second existing, and the server stayed up. Twelve parallel starters on one socket, 20 rounds per version, gave exactly one created every round.

Tracked in: launched programs #823, #833; unowned pane wait #869; event waits #673; capture cursors #740; wait-for -l/-w #870; monitor hooks #875; 3.8 formats #874; capture flags #876; control mode #884; run_shell #911; 3.9-dev #877, #878.

Proposal

Decisions:

Ordering:

Consolidation:

Tracking:

References

Activity

  1. added
    area: lifecycle
    roadmap
    on Nov 24, 2026
  2. pinned this issue on Nov 24, 2026
  3. moved this to In Progress in libtmuxon Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: lifecycleroadmap

    Type

    No type

    Projects

    • Status
      In Progress

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions