IW-599: start and open exit 0 without a terminal instead of failing the attach #688

Merged
mph merged 14 commits from IW-599 into main 2026-10-06 21:15:12 +00:00
Member

Summary

iw start and iw open no longer exit non-zero when standard input is not a terminal (CI container, agent shell). Before, they did all their work, then tried tmux attach, tmux refused, and the command reported exit 1.

Now the session join checks for a terminal first. With no terminal it prints that the session is ready, why it does not attach, and the command to attach with, and exits 0. With a terminal, and inside a workspace, the behaviour is unchanged. The --prompt path with no terminal still exits 5.

Defects fixed

  • Phase 1 (#686): The session join attaches without checking for a terminal, and reports tmux's refusal as a command failure.
    • Root cause: WorkspaceSession.join called env.workspace.attach with no terminal check, and entered mapped the refusal to CommandResult.error.
    • Fix: Stdin.isTerminal capability (live probe: test -t 0 with inherited stdin); join guards only the attach branch.

Testing

  • Unit: 5 new cases in WorkspaceSessionTest, 1 each in StartHarnessTest and OpenHarnessTest.
  • E2E: start.bats, open.bats, open-prompt.bats, start-prompt.bats, analyze.bats now run with </dev/null and assert the exit status (the old workaround comment in start.bats is gone). A new pty test in open.bats (script -qec) covers the live probe returning true; a mutation check turned it red.
  • Phase PR CI was green.

Follow-ups filed

  • #687 — an attached session is killed after 5 minutes (attach runs under the default process timeout).
  • #585 — comment added: another phase-pr push failure that matches the push timeout pattern.

Release notes

See project-management/issues/IW-599/release-notes.md (Czech).

Closes #599

🤖 Generated with Claude Code

## Summary `iw start` and `iw open` no longer exit non-zero when standard input is not a terminal (CI container, agent shell). Before, they did all their work, then tried `tmux attach`, tmux refused, and the command reported exit 1. Now the session join checks for a terminal first. With no terminal it prints that the session is ready, why it does not attach, and the command to attach with, and exits 0. With a terminal, and inside a workspace, the behaviour is unchanged. The `--prompt` path with no terminal still exits 5. ## Defects fixed - **Phase 1 (#686):** The session join attaches without checking for a terminal, and reports tmux's refusal as a command failure. - Root cause: `WorkspaceSession.join` called `env.workspace.attach` with no terminal check, and `entered` mapped the refusal to `CommandResult.error`. - Fix: `Stdin.isTerminal` capability (live probe: `test -t 0` with inherited stdin); `join` guards only the attach branch. ## Testing - Unit: 5 new cases in `WorkspaceSessionTest`, 1 each in `StartHarnessTest` and `OpenHarnessTest`. - E2E: `start.bats`, `open.bats`, `open-prompt.bats`, `start-prompt.bats`, `analyze.bats` now run with `</dev/null` and assert the exit status (the old workaround comment in `start.bats` is gone). A new pty test in `open.bats` (`script -qec`) covers the live probe returning `true`; a mutation check turned it red. - Phase PR CI was green. ## Follow-ups filed - #687 — an attached session is killed after 5 minutes (attach runs under the default process timeout). - #585 — comment added: another `phase-pr` push failure that matches the push timeout pattern. ## Release notes See `project-management/issues/IW-599/release-notes.md` (Czech). Closes #599 🤖 Generated with [Claude Code](https://claude.com/claude-code)
start and open try to attach without a TTY and fail, so a BATS test cannot assert their exit status

Artifacts:
- analysis.md
- issue.md

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
start and open try to attach without a TTY and fail, so a BATS test cannot assert their exit status

Artifacts:
- tasks.md
- review-state.json (tasks_ready)

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Issue: IW-599
Phase: 1 - The session join attaches without checking for a terminal, and reports tmux's refusal as a command failure

This commit marks the checkpoint for phase 1 context generation.
Use dx-fix IW-599 to return to this point.

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The session join attaches without checking for a terminal, and reports tmux's refusal as a command failure

Artifacts:
- phase-01-tasks.md

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Filed as #687; the push timeout went to #585 as a comment.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
docs(IW-599): add release notes
Some checks failed
CI / changes (pull_request) Successful in 5s
CI / contract (pull_request) Has been skipped
CI / format (pull_request) Successful in 10s
CI / lint (pull_request) Successful in 15s
CI / test (pull_request) Has been cancelled
CI / dashboard-build (pull_request) Has been cancelled
CI / compile (pull_request) Has been cancelled
d24d9a1eef
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
chore(IW-599): update review-state to all_complete
All checks were successful
CI / changes (pull_request) Successful in 5s
CI / contract (pull_request) Has been skipped
CI / format (pull_request) Successful in 9s
CI / lint (pull_request) Successful in 13s
CI / compile (pull_request) Successful in 1m36s
CI / dashboard-build (pull_request) Successful in 1m17s
CI / test (pull_request) Successful in 15m39s
2a1a92c441
mph merged commit 33042e126c into main 2026-10-06 21:15:12 +00:00
Sign in to join this conversation.
No description provided.