Skip to content

Concept: Tell whether a build passed after its pane closes - #154

Merged
tony merged 3 commits into
masterfrom
concept-program-exit
Dec 6, 2026
Merged

tony merged 3 commits into
masterfrom
concept-program-exit

Conversation

@tony

@tony tony commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

Try it

Build the checkout rock and run the Program example in standalone Lua or Neovim. It reports a calculator's reply and exit 7, a stopped interactive program's signal 15, and a run that reaches its deadline and cleans up its pane. Program guide

What the example proves

Server:run_program(argv) returns a Request for the application's exit or signal, a bounded prefix of terminal bytes, the captured viewport and the cleanup result. Server:start_program(argv) returns a Request for a Program whose input, screen, wait and stop operations can run in the same runtime scope. The Program keeps its confirmed status after its pane closes.

The Linux supervisor qualifies process-tree cleanup with pidfds and a subreaper. A launch can require that scope before the application starts. Other configurations report direct-child cleanup. macOS process-tree cleanup and recovery when the Lua process exits before it can save a receipt remain open in #107. The separate test in #208 runs two programs whose final screens look the same. It reads their different exit codes and fails if the wrong code is returned.

If Lua or Neovim exits after starting a program, its temporary socket directory has already been removed. The live connections still carry the application's output and exit status.

If the runtime closes during start_program or run_program, inspect the Request’s error after it retires. It still reports cancelled. When libtmux cannot confirm removal of the pane, err.cleanup_error describes the cleanup failure and err.program_name identifies the session to inspect on the same tmux server. The session may already have closed. Startup cleanup evidence.

Test plan

  • Run the Program contract, exit prototype and runtime integrations under Lua 5.1.5 and Neovim 0.10.0 with tmux 3.3a on Linux ARM64 (11 s).
  • Repeat with Lua 5.5.1 and Neovim 0.12.5 with tmux 3.8 on Linux ARM64 (9 s).
  • Run the exact Program example outside the checkout against installed SCM rocks. Check its three output lines and empty private socket directory.
  • Start /bin/cat on a private tmux 3.8 server, then exit Lua or Neovim. The app and its pane go away, the earlier tmux session stays open, and the temporary Program directory is gone. Reproduction in #107.
  • Close the runtime during both start_program and run_program. The in-process Server test checks the cleanup error and the exact tmux session name, before and after the supervisor connects. On Lua 5.1.5 and 5.5.1, the previous numbered candidate failed at the missing cleanup error and the corrected private 0.1.2-1 install passed both launch methods.
  • On Lua 5.1.5 with tmux 3.3a and Lua 5.5.1 with tmux 3.8, restart Lua and use a saved startup session name to find the retained pane’s session on the original daemon. An empty lookup confirmed normal removal. Comparing the recorded daemon PID, start time and version detected a replacement at the same socket. Restart test in #107.
  • Check formatting, lint, LuaLS diagnostics, the documentation export and editor completion.
  • Verify the ordinary outer gate and required GitHub CI after rebasing onto the packaging changes in Check a published Lua rockspec against its source tag #165 and Check the development rock independently of numbered releases #168. Use the same rockspec for plain and explicit LuaRocks builds #166 also makes a plain LuaRocks build select the canonical SCM rockspec.

Refs #107, #150 and #27.

Selecting tmux

The checkout-only syntax-check example in examples/concepts/program_exit fell back to /usr/bin/tmux even when the user had another tmux on PATH. After #179, the staged launcher and guide let the runtime choose the executable. Both syntax checks used the selected tmux on 3.3a and 3.8 and retained their expected exit results. An explicit TMUX_BIN took precedence. Runtime PATH support.

@tony tony added enhancement New feature or request lua Pull requests that update Lua code area:core Shared Lua library values, operations, and behavior across runtime adapters. p2 Scoped runtime defects, compatibility gaps, or enabling improvements. topic:lifecycle Creating, selecting, canceling, cleaning up, or observing owned tmux state. labels Dec 5, 2026
@tony
tony deployed to docs-preview December 5, 2026 02:07 — with GitHub Actions Active
@tony
tony force-pushed the concept-program-exit branch from fde768a to d6986a0 Compare December 5, 2026 23:54
@tony
tony force-pushed the concept-program-exit branch from d6986a0 to d66efdc Compare December 6, 2026 01:17
tony added 3 commits December 6, 2026 08:35
why:
A build can exit before Lua reads its last line. Two builds can leave
the same screen and still return different exit codes.

what:
- Send the direct child’s exit result back to a standalone Lua caller.
- Run the commands in real panes and test early exits and replacement.
- Show how to use a retained screen sample when one is available.
why:
An application exit result and final terminal output must survive the
pane lifecycle. Standalone Lua and Neovim need the same ownership contract.

what:
- Start an interactive Program or run it to completion with a Request.
- Retain the application exit, terminal bytes, final screen and cleanup.
- Test input, deadlines, explicit stop and externally closed sessions.
why:
Readers need the entry points for running and interacting with an owned
application in tmux.

what:
- Summarize run_program and start_program under Unreleased.
@tony
tony changed the base branch from master to concept-read-pane-line December 6, 2026 14:35
@tony
tony force-pushed the concept-read-pane-line branch from 48b0380 to 751fee9 Compare December 6, 2026 14:35
@tony
tony force-pushed the concept-program-exit branch from d66efdc to f0681c8 Compare December 6, 2026 14:35
@tony
tony changed the base branch from concept-read-pane-line to master December 6, 2026 14:52
@tony
tony marked this pull request as ready for review December 6, 2026 14:53
@tony
tony merged commit 181c5d2 into master Dec 6, 2026
12 checks passed
@tony
tony deleted the concept-program-exit branch December 6, 2026 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:core Shared Lua library values, operations, and behavior across runtime adapters. enhancement New feature or request lua Pull requests that update Lua code p2 Scoped runtime defects, compatibility gaps, or enabling improvements. topic:lifecycle Creating, selecting, canceling, cleaning up, or observing owned tmux state.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant