Skip to content

feat: auto-detect runtime mode on kild open#377

Merged
Wirasm merged 4 commits into
mainfrom
kild/297-daemon-flags-open
Feb 11, 2026
Merged

feat: auto-detect runtime mode on kild open#377
Wirasm merged 4 commits into
mainfrom
kild/297-daemon-flags-open

Conversation

@Wirasm

@Wirasm Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner

Summary

  • Daemon-created kilds now automatically reopen in daemon mode on kild open without requiring --daemon
  • Stores runtime_mode on Session struct, persists across stop/start
  • Resolution chain: --daemon/--no-daemon flag > session's stored mode > config > Terminal default
  • kild open --all respects per-session mode independently

Test plan

  • cargo fmt --check passes
  • cargo clippy --all -- -D warnings passes
  • cargo test --all passes
  • cargo build --all passes
  • Manual: kild create foo --daemonkild stop fookild open foo reopens in daemon
  • Manual: kild open foo --no-daemon overrides stored daemon mode

Closes #297

@Wirasm

Wirasm commented Feb 11, 2026

Copy link
Copy Markdown
Owner Author

PR Review Summary

Critical Issues (0 found)

None.

Important Issues (1 found — fixed)

Agent Issue Location Status
code-reviewer Logging source doesn't distinguish "config" from "default" fallback handler.rs:880 Fixed in 6e04e7e

Type Design (6.75/10)

Dimension Score
Encapsulation 7/10
Invariant Expression 5/10 → improved
Usefulness 9/10
Enforcement 6/10

Resolution: Extracted nested unwrap_or_else cascade into resolve_effective_runtime_mode() function that returns (RuntimeMode, &'static str). Self-documenting, centralized, and now distinguishes 4 sources: explicit, session, config, default.

Test Coverage Gaps (2 critical — fixed)

Gap Rating Status
Resolution chain untested (all 4 branches) 10/10 Added 4 unit tests in 6e04e7e
Runtime mode persistence across stop/reload 9/10 Added integration test in 6e04e7e

Documentation Updates

File Changes Status
CLAUDE.md Updated runtime mode resolution chain (5-step), added auto-detect docs Committed in df51cd3
README.md Updated kild open command comments for auto-detection Committed in df51cd3

Strengths

  • Clean Option<RuntimeMode> encoding for "no preference" vs "explicit choice"
  • Backward compatibility via #[serde(default)] for old sessions
  • Correct resolution priority chain
  • Good CLI boundary with resolve_explicit_runtime_mode()

Verdict

READY TO MERGE — all issues addressed, all tests pass.

When a daemon-created kild is stopped and reopened with `kild open`,
it now automatically reopens in daemon mode without requiring the
`--daemon` flag.

- Add `runtime_mode: Option<RuntimeMode>` to Session struct (persists
  across stop/start via `#[serde(default)]`)
- Set runtime_mode during `create_session` based on resolved mode
- Change `open_session` to accept `Option<RuntimeMode>` where `None`
  triggers auto-detection: explicit flag > session stored mode > config
  > Terminal default
- Add `resolve_explicit_runtime_mode` CLI helper that returns `None`
  when no flags passed (vs `resolve_runtime_mode` which always resolves)
- UI actions pass `None` for auto-detect instead of hardcoded Terminal

Closes #297
Document auto-detection behavior where kild open now uses the session's
stored runtime_mode by default, only using config or flags when explicit
overrides are provided.

Resolution chain: --daemon/--no-daemon flag > session's stored mode >
config > Terminal default
Extract the nested unwrap_or_else cascade into resolve_effective_runtime_mode()
which returns (RuntimeMode, source) for clearer logging. The source now
distinguishes "config" from "default" instead of lumping both as "default".

Add unit tests for all 4 resolution branches (explicit, session, config,
default) and a persistence test verifying runtime_mode survives stop + reload.
Clarify doc comment on Command::OpenKild.runtime_mode to distinguish
CLI-level semantics (no flag passed) from Session-level semantics
(legacy session). Add runtime_mode: None variants to store contract
test and both serialization round-trip tests.
@Wirasm Wirasm force-pushed the kild/297-daemon-flags-open branch from 48970fe to fc1efe4 Compare February 11, 2026 11:31
@Wirasm Wirasm merged commit 9205987 into main Feb 11, 2026
2 of 6 checks passed
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.

feat: add --daemon/--no-daemon flags to kild open

1 participant