Background-created session can become unattachable after scripted pane creation
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 --alleither returned only the defaultTab #1panes or reportedThere is no active session!.zellij list-sessionsoutput 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:
- A background target session was created.
- A tab named
ttrwas created. - Several panes were opened in that tab using
new-pane --tab-id ... -- <long-running interactive command>. new-panereturned success (terminal_<id>), and OS process inspection showed the child processes under the Zellij server.list-panes --json --alldid not show those panes, only the defaultTab #1panes.- Attempting to attach to the target session hung.
- Shortly after, commands targeting the same session reported
There is no active session!orNo 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.
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-panereturned success, andpsshowed 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 serverAn 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-ghosttystty 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 withzellij --session my-session action ..., includingaction new-pane. - The Commands page documents trailing
-- <command>forattach --create-backgroundas 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.
Source: zellij-org/zellij