Skip to content

pty attach needs an explicit attach-only/no-restart mode #122

Description

@schickling-assistant

pty attach currently has two behaviors for retained dead-session metadata:

  • --auto-restart restarts immediately.
  • without that flag, it prompts Restart? [Y/n], where every response except exactly n restarts the stored command.

That leaves no explicit attach-only CLI mode for a relay or supervisor that must connect only while the existing daemon is alive and must never execute stored launch metadata. A TTY-backed relay can remain at the prompt after its target dies; later input intended for the target is then consumed as the answer and can restart it.

Minimal reproduction

https://github.com/schickling-repros/2026-07-pty-attach-only-mode/tree/schickling-assistant/2026-07-30-pty-attach-only-mode

PTY_BIN="$(nix build --no-link --print-out-paths \
  github:compoundingtech/pty/face607b443b3ff35e934434a28f575822392aa8)/bin/pty" \
  ./repro.sh

The repro uses a synthetic command and a fresh temporary PTY_ROOT. It shows the command execution count changing from 1 to 2 after future relay input reaches the dead-session prompt, despite --auto-restart being absent.

Desired contract

Add an explicit attach-only mode, for example:

pty attach --no-restart <session>

Under that mode:

  • a currently running daemon is attached normally;
  • a missing, exited, or vanished session exits nonzero without prompting;
  • if the attached daemon exits, the client exits and never evaluates stored command metadata.

The library-level attach() API already has the desired after-connect behavior. The missing boundary is in the CLI's pre-attach dead-session path.

Related but distinct work

Version

  • PTY main: face607b443b3ff35e934434a28f575822392aa8 (2026-07-27)
  • Linux
Posted on behalf of @schickling
field value
agent_name co2-bear
agent_session_id a078daee-6f98-4916-91a8-d21291407789
agent_tool Codex CLI
agent_tool_version 0.145.0
agent_runtime Codex CLI 0.145.0
agent_model unknown
runtime_profile /nix/store/mnx8agbdq3wiyb6vz63lhgscgazkrn98-coding-agent-runtime-profile/share/coding-agents/profile.json
skills_manifest /nix/store/5r69m9k2llmri3na81518zx0a7y0d3cn-agent-skills-corpus/share/agent-skills/manifest.json
worktree 2026-07-pty-attach-only-mode/main
machine dev3
tooling_profile dotfiles@0fb7e03

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions