Skip to content

fix: guard bare min on an empty daemon before creating a session - #1036

Merged
norrietaylor merged 1 commit into
mainfrom
inbox-patch/guard-empty-daemon-activate-c5e3517e196a1f47
Jul 29, 2026
Merged

fix: guard bare min on an empty daemon before creating a session#1036
norrietaylor merged 1 commit into
mainfrom
inbox-patch/guard-empty-daemon-activate-c5e3517e196a1f47

Conversation

@gominimal-aw-bot

@gominimal-aw-bot gominimal-aw-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Fixes #1031
Routing-Key: inbox-route/I_kwDOSUhdos8AAAABKmgdjQ

Bare min on 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's NoSessions branch called cmd_activate with attach: true and read no_input only to pick a prompt fallback, never to refuse. A new pure ensure_activate_on_empty_allowed guard now fires under --no-input or a non-TTY stdin before the create call, emitting the same refusal the explicit min session attach already gives, so nothing is created when the chained attach could not run. A scoped Distillery pass (project minimal) 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)

Generated by inbox-patch ·

Note

Guard bare min from creating a session on an empty daemon in non-interactive contexts

  • Adds ensure_activate_on_empty_allowed in lib.rs, a guard that returns an error when --no-input is set or stdin is not a TTY.
  • Calls the guard in the cmd_default handler when no sessions exist, before attempting activation.
  • Behavioral Change: bare min now 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

  • Bug Fixes
    • Prevented the bare min command from creating orphaned sessions when no sessions exist and input is non-interactive.
    • Added a clear refusal message when activation requires an interactive terminal.
    • Preserved activation for interactive terminal sessions.

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.
@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Bare min now refuses to activate on an empty daemon when --no-input is set or stdin is not a TTY, preventing orphaned sessions. A helper centralizes the check, with regression tests covering interactive and non-interactive cases.

Changes

Empty-daemon activation

Layer / File(s) Summary
Activation guard and regression coverage
crates/minimal/src/lib.rs
The empty-daemon path checks interactive prerequisites before activation, using a pure helper and tests for refusal and allowed TTY cases.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related PRs

Suggested reviewers: norrietaylor

Poem

I’m a bunny guarding the session gate,
No TTY? Empty? Please wait.
No orphan hops into the night,
Interactive paws make it right.
min now checks before delight.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The code matches #1031 by refusing empty-daemon activation before creating a session in non-interactive or non-TTY contexts.
Out of Scope Changes check ✅ Passed The changes stay focused on the empty-daemon guard and its regression test, with no unrelated scope added.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title is concise, specific, and accurately reflects the main change: guarding bare min on an empty daemon before session creation.
Description check ✅ Passed The description clearly explains the change and includes verification results, though it uses "Verification" instead of the template's exact "Testing" and omits the checklist.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between df22d71 and a4490f9.

📒 Files selected for processing (1)
  • crates/minimal/src/lib.rs

Comment thread crates/minimal/src/lib.rs
Comment on lines +1834 to +1839
/// 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).

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 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.

@norrietaylor
norrietaylor enabled auto-merge (squash) July 29, 2026 18:53
@norrietaylor
norrietaylor merged commit a64ee56 into main Jul 29, 2026
29 checks passed
@norrietaylor
norrietaylor deleted the inbox-patch/guard-empty-daemon-activate-c5e3517e196a1f47 branch July 29, 2026 18:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bare min under --no-input creates a session, then fails the TTY guard and leaves it orphaned

1 participant