#5664·zellij

Background-created session can become unattachable after scripted pane creation

Author: chris-caldCreated Sep 29, 2026Updated Sep 29, 2026

Issue description

A Zellij session created with zellij attach --create-background <name> can become unattachable after scripted tab/pane setup. In the observed case, Zellij accepted action new-tab and action new-pane commands against the background session and spawned child processes, but later:

  • zellij attach <name> hung indefinitely in an interactive terminal.
  • zellij --session <name> action list-panes --json --all either returned only the default Tab #1 panes or reported There is no active session!.
  • zellij list-sessions output was inconsistent over time: it showed the session shortly after creation, but later omitted it while the server and child processes still existed.

This appears inconsistent with the documented background-session workflow, where a session can be created with attach --create-background and then controlled with zellij --session <name> action ... commands.

Expected behavior

A session created with zellij attach --create-background <name> should remain attachable with zellij attach <name> after scripted tab/pane creation.

Panes created with zellij --session <name> action new-pane ... should be visible in zellij --session <name> action list-panes --json --all, or the new-pane command should fail instead of returning success.

Actual behavior

In an anonymized real workflow:

  1. A background target session was created.
  2. A tab named ttr was created.
  3. Several panes were opened in that tab using new-pane --tab-id ... -- <long-running interactive command>.
  4. new-pane returned success (terminal_<id>), and OS process inspection showed the child processes under the Zellij server.
  5. list-panes --json --all did not show those panes, only the default Tab #1 panes.
  6. Attempting to attach to the target session hung.
  7. Shortly after, commands targeting the same session reported There is no active session! or No session with the name '<name>' found!, while a Zellij server process for that session name could still be present.

Steps to reproduce

The original commands used private session names and project paths; below is the anonymized shape.

bash
SESSION="target-session"
PROJECT_DIR="/path/to/project"

zellij attach --create-background "$SESSION"

TAB_ID=$(zellij --session "$SESSION" action new-tab \
  --name ttr \
  --cwd "$PROJECT_DIR")

zellij --session "$SESSION" action new-pane \
  --tab-id "$TAB_ID" \
  --cwd "$PROJECT_DIR" \
  --name "worker: project-a" \
  --stacked \
  --no-focus \
  -- \
  pi --session /path/to/existing/pi-session.jsonl

zellij --session "$SESSION" action list-panes --json --all
zellij attach "$SESSION"

Notes:

  • The command after -- was a long-running interactive TUI process (pi --session ...).
  • new-pane returned success, and ps showed the child process parented to the Zellij server.
  • The pane was not visible in list-panes --json --all.
  • Attaching hung.

A simpler local probe with a non-interactive command behaved differently, so this may require an interactive child process or TTY expectations to trigger.

Diagnostics captured

Anonymized representative observations:

$ zellij list-sessions
current-session [Created ...] (current)
target-session [Created ...]

$ zellij --session target-session action query-tab-names
Tab #1

$ zellij --session target-session action list-panes --json --all
# Only default Tab #1/plugin/shell panes were reported.
# The child processes returned by new-pane were not present.

$ ps -axo pid,ppid,pgid,stat,etime,command | grep target-session
... /opt/homebrew/bin/zellij --server .../contract_version_1/target-session
... zellij a target-session   # hung attach client
... pi                        # child processes under the target-session server

An attempted non-interactive attach probe from a non-TTY failed separately with:

could not enable raw mode: Os { code: 6, kind: Uncategorized, message: "Device not configured" }

That raw-mode error is expected for the non-TTY probe and is not the main issue; the main issue was the interactive terminal attach hanging.

Environment

zellij 0.45.1
macOS 26.6.2 / Darwin 25.6.0 arm64
SHELL=/bin/zsh
TERM=xterm-ghostty

stty size could not be collected from the automated diagnostic context because stdin was not a terminal.

Documentation references checked

  • The CLI Recipes page documents zellij attach --create-background my-session, then controlling it with zellij --session my-session action ..., including action new-pane.
  • The Commands page documents trailing -- <command> for attach --create-background as an initial command when creating a background session.

Based on those docs, the expectation that a background-created session can be controlled and later attached seems valid.