Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@

## Unreleased

- Server ownership: accept and clean up created daemons through their private endpoints. Retain the published socket alias after daemon exit or startup rollback so cleanup cannot unlink a concurrent replacement. Reusing a stale path requires caller-coordinated alias retirement or a different path.
- Discovery: use the same first `TMUX_TMPDIR` value as connection defaults, including an empty value that selects `/tmp`.

- Add task-scoped ownership and explicit adoption for servers, sessions, windows and panes, generation-guarded cleanup, retryable owners and complete-receipt rollback.
- Add foreground server startup, bounded discovery and created/reused results for server, session, window and keyed-pane lookup.

- Connections: select an existing daemon through captured path/name defaults,
tmux context or the default named socket. Explicit selectors still take
precedence. Resolve omitted executables through captured `PATH`; accept
copied `client_env` overrides and remove nested tmux context from clients.
- Runtime: add `defer` for asynchronous task cleanup after success, body errors
and cancellation, with body and teardown failures retained in the result.
- Examples: add an ordinary default-connection example and an external private
harness that verifies its session cleanup. Use owned server scopes for
fresh-daemon creation and cleanup.

- Docs: add complete common API examples with private tmux setup and cleanup.

## 0.1.0alpha2-1
Expand Down
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,28 @@ tmux or an event loop. CI runs unit tests on Lua 5.1–5.5 and LuaJIT, plus live
tests across tmux 3.2a–3.7c. See the [compatibility matrix](docs/compatibility.md)
for exact versions and remaining platform coverage.

## Ordinary defaults

With tmux already running, the [ordinary example](examples/ordinary.lua)
connects without socket arguments, creates a session, reads it, and removes
that session when the runtime body finishes or fails:

```console
$ lua examples/ordinary.lua
```

`runtime:connect()` selects `LIBTMUX_SOCKET_PATH`, `LIBTMUX_SOCKET_NAME`, the
current `TMUX` context, or tmux's default named socket, in that order. Explicit
API selectors take precedence. The library captures the endpoint and client
environment at the call. See [connection defaults](docs/snapshots.md) for
validation, named roots and per-client overrides. Connect requires an existing
daemon. [Owned scopes, server startup and discovery](docs/lifecycle.md) add
explicit lifecycle operations without changing borrowed connections.

The [external test harness](tests/integration/test_lifecycle.py) runs the exact
example file at owned private endpoints and checks cleanup after injected
failure. Private socket setup belongs to that harness.

## Read a server

Connect to an existing server by its explicit socket path. This is the full
Expand Down Expand Up @@ -218,6 +240,7 @@ server running. See [runtime ownership and cancellation](docs/runtime.md).
## Guides

- **Clients:** [switch sessions and detach terminals](docs/clients.md).
- **Ownership:** [owned scopes, discovery and find-or-create](docs/lifecycle.md).
- **Read and watch:** [snapshots](docs/snapshots.md),
[session notifications and pane streams](docs/control.md).
- **Run and arrange:** [commands and batches](docs/commands.md),
Expand Down
8 changes: 8 additions & 0 deletions docs/commands.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,11 @@ reported with byte counts and truncation metadata; it is not silently kept.
The raw API is an escape hatch. Named domain operations, owned command
completion and observation APIs are still under development. A successful
`send-keys` process does not report the exit of a pane application.

## Client environment

Commands inherit the connection's captured client environment. A command's
`env` option supplies a complete replacement sequence of `NAME=value` strings
for that client. The library copies the sequence and removes `TMUX` and
`TMUX_PANE`; the pinned socket still selects the accepted daemon. These
values do not edit the host process or tmux's persistent environment store.
7 changes: 7 additions & 0 deletions docs/creation.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ made from tmux's returned IDs. Its `created` sequence names the objects this
operation created: all four for a session, window/pane/link for a window, and
only the pane for a split. Other handles describe the containing context.
Creating a pane proves neither application readiness nor command success.
Use [deferred cleanup](runtime.md#deferred-cleanup) for a session that should
end with its task. The [ordinary example](../examples/ordinary.lua) includes
imports, default connection and cleanup.

## Commands and literal values

Expand Down Expand Up @@ -60,3 +63,7 @@ state. Closing the Server connection leaves created sessions running.
The [public creation fixture](../tests/integration/domain.lua) exercises the
same API through luv and Neovim with literal arguments, environment and
directory values, returned IDs, explicit shell text and missing directories.

## Owned creation

Use [owned lifecycle operations](lifecycle.md) to destroy created sessions, windows or panes at task exit, or to accept destruction responsibility for an existing handle. The borrowed creation methods above keep their existing lifetime semantics.
4 changes: 4 additions & 0 deletions docs/environment.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Persistent environment

Connection `client_env` and command `env` configure the launched tmux client;
see [connection defaults](snapshots.md). Those copied values leave the host
environment unchanged. There is no `LIBTMUX_SOCKET_ENV` variable.

Server methods address tmux's global environment store. Session methods address
that session's local store. Each method returns a Request; reads never evaluate
shell text. Window and Pane handles reject these operations with `invalid_scope`.
Expand Down
Loading
Loading