Repository navigation
Description
Summary
Add an owned terminal application API shared by the core and Async gems. A caller should pass literal argv, interact with a returned program, await exit and a bounded final screen, and close its owned resources explicitly or through a block scope.
Motivation
Server#run dispatches tmux commands, while Session#new_window supplies application creation primitives. Neither gives a program owner combining launch, application completion and cleanup. The MCP enrolled-shell runner has its own borrowed-shell and input-authority rules.
A command that writes final UTF-8 output and exits 7 needs completion evidence after fast exit. An interactive application needs input, resize, independent waiter cancellation and explicit termination through the same owner.
Proposal
- Add
start_program(argv, ...), a block-scoped form andrun_program, returning aProgramwith wait, screen, input and explicit close operations. Reuse literal command encoding, physical references and daemon binding. Support cwd, environment, geometry and retention; preserve singleton executables, empty arguments and shell syntax as data. - Arm retention and observation before launch. Return immutable typed exit/status, signal, uncertain-dispatch, lost-generation and cleanup results. Guard destructive operations against the accepted daemon and program generation in the daemon queue, including respawn. A previous pane-ID read cannot authorize later destruction.
- Share one owner with the Async facade. Preserve fiber-aware I/O and bounded queues. Give each wait its own cancellation while retaining a shared completion; owning-run cancellation and block exit settle their declared cleanup policy. Explicit close failures stay inspectable and retryable. State the owner-process failure/recovery policy rather than relying on garbage collection.
- Extend
Internal::Capabilitiesand reuse Expose the capability map through the public API #112 for public discovery andtmux_capabilitiesdoes not report the optional features a daemon refuses #56 for MCP reporting. Evaluate program support against the bound daemon before pane/helper creation or input.supports_control?alone is insufficient. Record every primitive's actual minimum, including any selected 3.8 event path, without raising older primitive floors. Refuse below requirements unless an evidenced fallback passes the same workload; test patch/prerelease/unknown versions, client/daemon mismatch, replacement and manifest drift. - Wrap the core owner in distinct MCP owned-program operations with opaque handles, bounded output pages, explicit cleanup and the same capability decisions. Keep the existing enrolled-shell
tmux_runprotocol and its process-cursor requirements explicit. Define the initial PR's exact gem/tool scope before implementation.
Acceptance needs private-daemon tests for literal argv, PTY/cwd/environment/geometry, fast exit and final output, status versus signal, input, cancelled setup/wait/owning run, concurrent waiters, retention, failed cleanup, respawn/restart refusal and observer release. Prove critical ownership, subscription and version-gate tests fail under deliberate breaks, and show sibling Async tasks remain responsive. Execute standalone command/interactive examples, installed-gem consumers, RBS/public API and documentation checks, and final-head CI for the affected gems.
Document merged stdout/stderr, screen/history bounds versus terminal bytes, stream gaps/backpressure, process-group/daemonization limits, owner-death recovery and filesystem locality. Terminal ownership does not provide filesystem, network or privilege confinement.
References
- Lifecycle(feat): Add owned tmux resource scopes #27 adds resource scopes; reconcile ownership seams without silently requiring unmerged code.
- Refuse Async::Server.open and make internal constructors private #96 changes Async constructor inheritance; coordinate factories with that work.
- Core library cannot wait for pane text on tmux 3.3a–3.6 #53 tracks core visible-text waits and Add a standalone, CI-run example program for each core capability #86 requests standalone examples; readiness and application completion remain separate.
Activity