Skip to content

Wait for a complete reply line from a tmux pane #152

Done

Description

@tony

Summary

Let a Lua test wait up to five seconds for a complete answer from a program in a tmux pane.

Motivation

A test types sum 19 23 into a calculator. The terminal echoes the question, the calculator prints working, then tmux delivers result= and 42\r\n separately. A byte watch gives the test those pieces. The test has to join them, ignore the echo, and keep track of the time left. Repeating a five-second wait after each progress message lets a slow command run past five seconds. Current watch example

Proposal

Open a line watch before sending the question. A Lua or Neovim test could then wait like this.

local reply, err = lines:next({ prefix = "result=", timeout = 5000 }):await()
  • Return result=42 after its newline arrives, even if tmux splits it across events. Leave a second answer available for the next read.
  • Ignore earlier lines that do not start with the chosen prefix. A busy pane must still use up the original five seconds.
  • If the wait expires halfway through an answer, allow a later read to finish that line. If tmux loses output or the watch fills up, tell the caller that it missed data.
  • Keep existing byte watches available for callers that need the terminal's original bytes. A queued answer also needs a deadline check. Existing byte-watch deadline issue

The prefix belongs to the program's output format. An application can choose result= because its calculator reserves that text for answers.

Tested complete-line reader

The rebased PR tree passed 89 Control and Runtime tests on each of Lua 5.1.5 and 5.5.1. All five observation cases passed on tmux 3.8, including the partial-timeout reply in Lua and Neovim. On tmux 3.3a the example reported its tmux 3.7 minimum and four live control cases skipped. Line-watch PR · Deadline prerequisite

Activity

  1. added
    enhancement
    lua
    area:core
    p2
    topic:api
    topic:control-mode
    topic:timeouts
    on Dec 5, 2026
  2. tony commented on Dec 5, 2026

    @tony
    ContributorAuthor

    Draft PR 153 includes a working calculator, the line-watch implementation and tests with standalone Lua and Neovim. The example waits five seconds for result=42, even if the program prints progress first. Run the example

  3. tony commented on Dec 5, 2026

    @tony
    ContributorAuthor

    The installed example waits for the calculator’s complete answer. Its updated PR builds on the byte-read timeout fix so an expired wait preserves output for the next read. The combined branch passed the full outer check and ran the control tests on tmux 3.7. Byte-read deadline fix.

    Pull request #153.

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:coreenhancementluap2topic:apitopic:control-modetopic:timeouts

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions