fix: guard bare min on an empty daemon before creating a session - #1036
Conversation
Bare `min` on a daemon with zero sessions created a session, printed its id, then failed the interactive-attach TTY guard and exited 1, leaving the session orphaned. cmd_default answered NoSessions by calling cmd_activate with attach: true, and read no_input only to pick a prompt fallback, never to refuse. Refuse before creating: a new ensure_activate_on_empty_allowed guard fires under --no-input or a non-TTY stdin and emits the same message the explicit `min session attach` already gives, so nothing is created when the chained attach could not run.
📝 WalkthroughWalkthroughBare ChangesEmpty-daemon activation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@crates/minimal/src/lib.rs`:
- Around line 1834-1839: Align the guard comment near the bare min empty-daemon
handling with the actual message emitted by ensure_interactive_attach_tty.
Either update the comment to describe the helper’s distinct non-TTY refusal
message, or centralize and reuse one shared message so both attach paths emit
identical text.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: e86a0115-da0c-4c95-8949-43834f5a4a0a
📒 Files selected for processing (1)
crates/minimal/src/lib.rs
| /// Guard for bare `min` on an empty daemon: activating there chains straight | ||
| /// into an interactive attach, which needs a TTY on stdin. Under `--no-input`, | ||
| /// or when stdin is not a terminal, that attach can never succeed — so refuse | ||
| /// before creating anything, emitting the same message the explicit | ||
| /// `min session attach` produces, instead of creating a session and then | ||
| /// failing the attach guard, which leaves the session orphaned (#1031). |
There was a problem hiding this comment.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Align the comment with the actual attach error.
ensure_interactive_attach_tty emits a different non-TTY message at lines 1865-1868, so this helper does not emit “the same message” as explicit min session attach. Update the comment or centralize the shared refusal message if exact reuse is intended.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@crates/minimal/src/lib.rs` around lines 1834 - 1839, Align the guard comment
near the bare min empty-daemon handling with the actual message emitted by
ensure_interactive_attach_tty. Either update the comment to describe the
helper’s distinct non-TTY refusal message, or centralize and reuse one shared
message so both attach paths emit identical text.
Fixes #1031
Routing-Key: inbox-route/I_kwDOSUhdos8AAAABKmgdjQ
Bare
minon a daemon with zero sessions activated a new session and printed its id, then failed the interactive-attach TTY guard and exited 1 — leaving the session orphaned.cmd_default'sNoSessionsbranch calledcmd_activatewithattach: trueand readno_inputonly to pick a prompt fallback, never to refuse. A new pureensure_activate_on_empty_allowedguard now fires under--no-inputor a non-TTY stdin before the create call, emitting the same refusal the explicitmin session attachalready gives, so nothing is created when the chained attach could not run. A scoped Distillery pass (projectminimal) surfaced no prior fix for this create-before-guard path.Verification
cargo fmt --all --check --manifest-path target/Cargo.toml — clean, no drift
cargo clippy --workspace --locked -- -D warnings — 0 warnings
cargo build --workspace --locked — Finished, exit 0
cargo test --workspace --locked — ok, 40 suites passed, 0 failed (incl. new bare_min_refuses_to_activate_on_empty_daemon_non_interactively)
Note
Guard bare
minfrom creating a session on an empty daemon in non-interactive contextsensure_activate_on_empty_allowedin lib.rs, a guard that returns an error when--no-inputis set or stdin is not a TTY.cmd_defaulthandler when no sessions exist, before attempting activation.minnow exits with "no sessions exist; use 'min session activate' to create one" instead of creating a session that immediately fails to attach in non-interactive or non-TTY contexts.Macroscope summarized a4490f9.
Summary by CodeRabbit
mincommand from creating orphaned sessions when no sessions exist and input is non-interactive.