Skip to main content
Version: 0.18.0

Interactive Mode

Interactive mode (-i / --ivk-interactive) runs commands in an alternate screen buffer with full PTY (pseudo-terminal) support, enabling rich terminal interactions.

Overview​

When you run a command with -i, Invowk:

  1. Creates a pseudo-terminal (PTY) for the command
  2. Displays output in an alternate screen buffer (terminal stays clean)
  3. Draws the command's output as a terminal screen, so prompts that repaint and full-screen programs render correctly
  4. Forwards all keyboard input to the running command
  5. Allows scrolling and reviewing output after completion
  6. Supports embedded TUI components as modal overlays

Basic Usage​

# Run a command in interactive mode
invowk cmd build --ivk-interactive

When to Use Interactive Mode​

Interactive mode is especially useful for:

# Commands with password prompts
invowk cmd deploy --ivk-interactive

# Commands with sudo
invowk cmd system-update --ivk-interactive

# SSH sessions
invowk cmd remote-shell --ivk-interactive

# Any command with interactive input
invowk cmd database-cli --ivk-interactive

Why These Commands Need It​

Without interactive mode, stdin is not connected to a TTY, which breaks:

  • Password prompts (they can't read your input securely)
  • sudo (requires a TTY for password entry)
  • SSH sessions (need full terminal control)
  • Any program using readline or similar libraries

Enabling by Default​

You can enable interactive mode by default in your configuration:

// In config file: ~/.config/invowk/config.cue
ui: {
interactive: true // Enable by default
}

This is equivalent to always passing --ivk-interactive on the command line.

note

Interactive mode works with all runtimes: native, virtual-sh, virtual-lua, and container.

Key Bindings​

During Command Execution​

During command execution:
All keys → Encoded for the command's terminal and forwarded
Ctrl+A…Z → Sent as control characters (Ctrl+Shift+letter too)
Paste → Forwarded, bracketed when the command enabled it
Ctrl+C → Interrupt: SIGINT to the command's foreground job (Unix)
Ctrl+D → End of file, as in any terminal
Ctrl+Z → Forwarded; does not suspend the command
Ctrl+\ → Force quit: leave the viewer and hang up the command

All keyboard input is forwarded to the running command, encoded as a terminal in the command's current modes would send it (for example application cursor keys once the command enables them, and Alt as an ESC prefix), allowing full interaction with password prompts, editors, and other interactive programs. Every Ctrl+letter is forwarded as its control character, Caps Lock and Num Lock do not change a key, and a special key with a modifier the terminal encoding cannot express (such as Ctrl+Left) is sent as the plain key. Pasted text is forwarded, bracketed when the command enabled bracketed paste.

The Command's Terminal​

The viewer's pseudo-terminal is the command's terminal: on Unix the command starts in a new session whose controlling terminal is that PTY, which is also its stdin, stdout and stderr. A program that opens /dev/tty gets the viewer, so invowk tui * components without the TUI server, sudo and ssh prompts draw and read inside the viewer, never on the terminal invowk runs in.

Because the PTY is a real controlling terminal, the usual terminal signals reach the command on Unix:

  • Ctrl+C reaches the command as the interrupt character, so its foreground job gets SIGINT (a program in raw mode reads the key instead). The viewer stays open and shows the completion.
  • Resizing your terminal resizes the command's terminal to the viewer's command area (your terminal's width, and its height minus the viewer's header and footer rows) and delivers SIGWINCH.
  • Ctrl+\ leaves the viewer at once and hangs up the command's terminal: its session gets SIGHUP.
  • Background jobs that a script starts with & end with SIGHUP when the command's main process exits, as when a terminal window closes. Detach a job that must keep running (nohup, setsid). Runs without -i are not affected.
  • Ctrl+Z does not suspend the command (the command's session has no job control); a program in raw mode reads the key. Ctrl+D is end-of-file, as in any terminal.

For a container command, the engine CLI (docker or podman) is the process on the PTY: the hang-up reaches the engine CLI, and what then happens to the processes inside the container is the engine's behavior. On Windows the command runs on the pseudo-console invowk creates for it, as before; none of the session setup above applies there.

Screen, History and Terminal Queries​

The viewer emulates a terminal screen the size of the command area. Cursor movement, erasing, scrolling regions, colors and the alternate screen are applied, so a prompt that repaints itself (an inline invowk tui component, a progress bar that rewrites its line with \r) shows one current frame, and a full-screen program such as less or an editor renders in the command area; when it exits, the main screen comes back as it was.

  • History: lines that scroll off the top of the main screen are kept, up to the last 10,000 lines. Full-screen (alternate-screen) content is not added. While the command runs the viewer shows the live screen and keys go to the command; mouse events are not passed to the command, and the mouse wheel does not scroll the history then; after the command ends, the history, the final screen and the completion banner are browsable with the keys below.
  • Completion banner: the banner appears after the output the viewer read before the command ended, and it stays last: output that arrives later (from a process the command left running, or flushed late by the Windows pseudo-console) is drawn above it.
  • Terminal queries (device attributes, cursor position, mode reports, colors) are answered by the viewer's terminal; the command never talks to your real terminal. Colors are reported as the viewer's defaults, not your terminal's. When the command does not read its input, replies and keys that do not fit are dropped instead of freezing the viewer, and Ctrl+\ always quits.

After Command Completion​

Once the command finishes, you can review the output:

After command completion (history: the last 10,000 lines):
↑/k → Scroll up one line
↓/j → Scroll down one line
PgUp/b → Scroll up half page
PgDown/f/Space→ Scroll down half page
Home/g → Go to top
End/G → Go to bottom
q/Esc/Enter → Exit and return to terminal

The status bar shows:

  • Command exit code
  • Execution duration
  • Scroll position indicator

Embedded TUI Components​

When running in interactive mode, TUI components called from your scripts are rendered as modal overlays on top of the command output, rather than in a separate screen:

{
name: "interactive-setup"
description: "Setup with embedded TUI prompts"
implementations: [{
script: {content: """
# When run with --ivk-interactive, TUI components appear as overlays
NAME=$(invowk tui input --title "Project name:")
TYPE=$(invowk tui choose --title "Type:" api cli library)

if invowk tui confirm "Create $TYPE project '$NAME'?"; then
mkdir -p "$NAME"
echo "Created $NAME"
fi
"""}
runtimes: [{name: "native"}]
platforms: [{name: "linux"}, {name: "macos"}]
}]
}

This creates a seamless experience where:

  1. Your script runs in the alternate screen
  2. When a TUI component is needed, it appears as an overlay
  3. After the user completes the interaction, the overlay closes
  4. Script execution continues with the captured value

How It Works​

When a command runs with -i:

  1. Invowk starts a local TUI server
  2. Child processes detect the INVOWK_TUI_ADDR environment variable
  3. Instead of rendering directly, TUI components send requests to the parent
  4. The parent renders them as modal overlays
  5. Results are sent back to the child process

This happens automatically - no changes needed to your scripts.

Alternate Screen Buffer​

The alternate screen buffer is a terminal feature that:

  • Provides a separate "screen" for the command
  • Preserves your terminal history
  • Automatically restores when the command exits

This means after exiting interactive mode:

  • Your terminal looks exactly as it did before
  • No output pollution in your scrollback
  • Clean separation between invowk output and normal terminal use

Limitations​

  • Single command: Can't run multiple commands in parallel in interactive mode
  • History limit: the viewer keeps the last 10,000 lines of history; the mouse wheel scrolls it only after the command ends
  • PTY required: The terminal must support PTY operations
  • Debian-based containers only: Alpine and Windows container images are not supported

Container Runtime Support​

Interactive mode works seamlessly with the container runtime. Container runs already use the auto-provisioned image layer (enabled by default), which installs invowk inside the container when it is a Linux executable for the image's architecture; interactive mode adds the TUI plumbing. On a macOS or Windows host, set container.auto_provision.binary_path to a Linux build, or invowk tui calls inside the container do not work. See Container Runtime for details. When you run a container command with -i:

  1. Provisioned image layer: Invowk installs its binary when it can run in the container (same as non-interactive runs)
  2. TUI server: A local server handles TUI requests from the container (see Network exposure)
  3. Modal overlays: TUI components render on your terminal, not inside the container
# Run a container command interactively
invowk cmd myproject build -i -r container

Inside your container scripts, you can use all TUI components:

{
name: "deploy"
implementations: [{
script: {content: """
# TUI components work inside containers!
ENV=$(invowk tui choose "Select environment" "dev" "staging" "prod")

if invowk tui confirm "Deploy to $ENV?"; then
./deploy.sh "$ENV"
fi
"""}
runtimes: [{
name: "container"
image: "debian:stable-slim"
}]
platforms: [{name: "linux"}]
}]
}

:::warning Linux Containers Only Alpine-based images are not supported — musl-based environments have subtle behavioral differences that reduce runtime reliability. Use debian:stable-slim for generic container examples; language-specific images belong only in language-specific runtime demonstrations. :::

Network exposure of the TUI server​

The TUI server never listens on every interface by default. Where it listens depends on the container engine mode, and the container is pointed at an address the server actually binds:

Engine modeServer bindsINVOWK_TUI_ADDR host
Local rootful Docker on Linux127.0.0.1 and the default bridge gateway (for example 172.17.0.1)the gateway IP
Docker Desktop (local)127.0.0.1host.docker.internal
Ephemeral rootless Podman with pasta (passt)127.0.0.1, with one forwarded port (--network=pasta:-T,<port>)127.0.0.1
Anything else (see below)nothing: the interactive run is refusednot set

Treat INVOWK_TUI_ADDR as an opaque URL; it can be an IP literal.

Modes without a narrow route refuse interactive runs: a remote engine (any Docker endpoint other than a local unix://, npipe:// or fd:// socket, so tcp://, ssh:// and a scheme-less host:port; podman-remote, Podman machine), rootful Podman (also when the docker CLI talks to Podman's Docker-compatible socket), a persistent container under rootless Podman, rootless Podman without pasta, rootless Docker, Snap, a failed engine query, and any mode not listed above. invowk cmd … -i exits with status 1 before it opens a listener or starts the command's container, and the error names the reason and the opt-in. The same command without -i runs as before. If interactive mode comes only from ui.interactive: true in your config, invowk instead runs the command non-interactively and prints one warning (--ivk-interactive=false silences it). The check runs before dependency checks, so no probe container starts either. Invowk does not run such commands without a TUI server, because a prompt whose answer a script captures (name=$(invowk tui input)) would then draw nothing and hand the script terminal control codes instead of the answer. For rootless Podman, an ephemeral container with pasta installed gets the narrow plan.

Opt-in. To restore the previous wide bind knowingly, set container.tui_server_bind: "all-interfaces" in your invowk config. In the modes above (and under Docker Desktop) the server then binds 0.0.0.0 and uses the engine's host alias, and invowk warns at every such run that the port is reachable from the network. For a remote engine this helps only if its host alias leads back to this machine. The key is read only from the config file invowk selects: the --ivk-config or INVOWK_CONFIG file when one is given (your user config file is then not read), otherwise your user config file. An invowkfile or module cannot set it.

Flatpak without --share=network. The sandbox's network is private, so no bind is reachable from the engine's containers. Interactive container runs are refused, and the opt-in does not apply; grant --share=network or run without -i.

Unreachable server. If invowk tui * inside a container reports that the TUI server is unreachable, the engine does not route to the address the server binds (for example under Docker Desktop, or when a host firewall drops bridge-to-host traffic to the port). The command fails within a few seconds with an error that names the opt-in. That includes an engine proxy that accepts the connection but cannot reach the host: before every component request, the client sends a short, authenticated health check, so a reset, closed or silent connection fails fast too. The client never sends TUI requests through an HTTP_PROXY from the container's environment, so the session token does not reach a proxy.

Residual exposure. Under rootful Docker the gateway port is also reachable from other containers on the same bridge, and from hosts on the same network segment that route the bridge subnet through this machine. Every request still needs the per-session bearer token, and the port lives only for the interactive run.

Host pasta options. For the pasta plan, invowk forwards one port and nothing else. Podman also applies pasta_options from your containers.conf; options such as --map-gw or --map-host-loopback there give the container more of host loopback than invowk asks for.

External persistent containers (--ivk-container-name naming a container invowk did not create) get the plan of their engine mode. If such a container sits on a network that cannot reach the bound address, its invowk tui * calls fail as unreachable; the bind never widens because of it.

Best Practices​

  1. Use for commands that need input: Deploy scripts with confirmations, database migrations, etc.

  2. Don't use for simple commands: Quick commands without interaction don't benefit from interactive mode

  3. Combine with TUI components: Create rich interactive workflows with embedded prompts

  4. Consider config default: If most of your commands need interaction, enable it in config

Examples​

Deployment Script​

{
name: "deploy"
description: "Deploy with confirmations"
implementations: [{
script: {content: """
echo "Deploying to production..."

# This sudo prompt works because we're in interactive mode
sudo systemctl restart myapp

echo "Deployment complete!"
"""}
runtimes: [{name: "native"}]
platforms: [{name: "linux"}, {name: "macos"}]
}]
}

Run with: invowk cmd myproject deploy -i

Database Migration​

{
name: "db migrate"
description: "Run database migrations"
implementations: [{
script: {content: """
echo "=== Database Migration ==="

# Interactive confirmation
if invowk tui confirm "Apply migrations to production?"; then
# Password prompt works in interactive mode
psql -h prod-db -U admin -W -f migrations.sql
fi
"""}
runtimes: [{name: "native"}]
platforms: [{name: "linux"}, {name: "macos"}]
}]
}

Next Steps​