Skip to content

Command queue: prepare the next commands while one runs - #357

Draft
raiseCatError wants to merge 24 commits into
feature/input-awarenessfrom
feature/command-queue
Draft

raiseCatError wants to merge 24 commits into
feature/input-awarenessfrom
feature/command-queue

Conversation

@raiseCatError

@raiseCatError raiseCatError commented Oct 10, 2026 •

Copy link
Copy Markdown
Owner

Commands composed while a foreground command runs queue in the same persistent shell, preserving cwd, variables, functions and native syntax. Fresh/confirmed program replies retain input ownership. Ctrl+Q explicitly composes a queued entry, Ctrl+S sends to the program, failure/interruption pause dependent work, and detach/reattach does not submit entries twice.

The additive source retains authenticated foreground input ownership, native shell grouping, early attach privacy, authored NO_COLOR policy with raw program SGR preserved, immediate authenticated cwd snapshots and the corrected fullscreen/ordinary journal boundaries. Session helpers validate private runtime ownership before connecting; cancelled pre-start socket clients drain EOF without exposing withheld output. Assertions and production deadlines remain intact.

Published head: 45a0c071ea390d8c01ad33c8eb55ab2012e40c94. macOS arm64/Node 26.10.0 npm run verify passed with one worker and private T7 roots, including full runtime/ranking, build, lifecycle cleanup and diff gates. Actions 38277962735 passed Quality, full macOS/Ubuntu shards, Node 22 compatibility and aggregate checks. Timing/Fedora are skipped on the PR event. Later-head canonical, final Linux/Fish 3.7 and whole-frontend acceptance remain pending in #359.

Physical validation remains required in Ghostty and Terminal.app across zsh, Bash and Fish: hidden/function reads, immediate typing after read/Ctrl+C/Ctrl+Z, same-shell multiline queue state, failure pause, direct compose/send, detach/reattach and narrow/Safe/NO_COLOR. Automated evidence does not claim physical QA. The PR remains draft; no master/release merge, tag or release is authorized. Global interface acceptance and known limitations are tracked in #359.

Refs #356
Refs #359

…order in the same shell

While a command runs, Enter adds the composer's command to the session's queue (Ctrl+Q always queues,
Ctrl+S sends the line to the running program). Entries run one at a time through the session's own
shell, each only after the previous command reached its prompt, so directory, variables, functions
and options carry over. A failure, Ctrl+C or a shell switch pauses the rest with the reason;
/queue resume continues and /queue clear drops them, and nothing runs twice.

- The queue belongs to the session service (in-process client alike): it keeps running while no
  window is attached, and the exec event says which command came from the queue, so a window that
  attaches later shows "from queue" for it too.
- Input ownership first: a program known to wait for input, or one that left a question open on
  its line ("Password: ", "Continue? [y/N] ") before any probe looked, gets Enter; a reply is never
  queued or run as a command. After Ctrl+C or Ctrl+Z, typing goes to the shell prompt as type-ahead.
- Ctrl+Q during single-key input composes an entry the program never sees; Enter adds it.
- /queue opens a manager to edit, reorder, remove, pause and clear; the queue line by the composer
  shows what runs next or why it waits. Settings, Setup, Ask and settings export know about it.
- Live tests over zsh, Bash and Fish: ordering and state, failure and interrupt pauses, prompts,
  hidden replies, multi-line entries, detach and reattach, narrow/NO_COLOR/Safe glyphs. A live
  start that never becomes ready now ends its sandbox instead of hanging the test file.
Entry previews, pause reasons and the panel's block preview show control characters visibly (␛, ·)
instead of writing them to the terminal: a pasted OSC 52 or screen clear inside a queued command
can no longer act on the host terminal.
…the rest of the command

Typing after a stop goes to the shell prompt only for two seconds. A program that survives the
signal (a REPL, a remote shell, a trap) gets the ordinary routing again, so later typing queues as
usual and is never written into that program's input unasked.
…er-read files so shards do not stack them

These files take 17 to 68 seconds each but counted as 1, so a shard could run several heavy PTY files together on a 4-core runner and starve the timing-sensitive Fish and alternate-screen tests (17 to 24 second budgets), which then failed only on Ubuntu from this branch up.
…xt command only once the last one completed

With the queue, Enter while a command runs and nothing asks a question queues the next command. These tests typed their answer as soon as the command's own echo contained the prompt text (it does), or typed the next command before the previous one had completed, so on a slower runner the answer or command was queued instead of sent. They now wait for the program's own prompt (the second occurrence of its text, or NMSh's waiting headline) and for the previous completion.
…he command text NMSh echoes

In Classic wording NMSh's live line reads "Running read -P 'Name: ' x…", so waiting for "Name: " (or a second copy of it) was satisfied by NMSh's own line before Fish drew anything, and the answer was typed too early. The prompt is now produced by printf inside the command, so the text only appears when the shell prints it.
…ng command or the type-ahead window early

The first test queued five commands behind sleep 3 and the Ctrl+C test typed 0.6 seconds after a 2 second type-ahead window; on a loaded macOS runner either margin was lost and the typing was treated as type-ahead or the queue had already started.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant