feat!: coalesce default dir computation across crates - #619
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
💤 Files with no reviewable changes (1)
🚧 Files skipped from review as they are similar to previous changes (6)
📝 WalkthroughWalkthroughAdds shared helpers for minimal state and cache directories in ChangesMinimal directory defaults centralization
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: 3
🧹 Nitpick comments (1)
crates/mctx/src/config.rs (1)
156-167: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDuplicated path-conversion chain.
.as_utf8_path().as_std_path().to_path_buf()is repeated here and incrates/minimal/src/client.rs. Consider a small convenience method (e.g.DaemonAbsPath::into_path_buf()) in thepathscrate to remove the repetition.🤖 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/mctx/src/config.rs` around lines 156 - 167, The path conversion chain is duplicated in the `Config` fallback logic and in `minimal::client`, so extract it into a shared convenience on `DaemonAbsPath` in the `paths` crate (for example an `into_path_buf()` helper). Update the `minimal_state_dir` and `minimal_cache_dir` initializers in `Config` to call that helper, and similarly switch the `crates/minimal/src/client.rs` call site to use the shared method instead of repeating `.as_utf8_path().as_std_path().to_path_buf()`.
🤖 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/mctx/src/config.rs`:
- Around line 156-167: The `ConfigBuilder::build` fallback for
`minimal_state_dir` and `minimal_cache_dir` currently calls
`paths::minimal_state_dir()` / `paths::minimal_cache_dir()`, which can panic and
bypass the `Result<Config, ConfigError>` contract. Update `build()` to avoid any
panicking path by resolving these directories through a fallible flow and
propagating failures as `ConfigError` instead; use the existing `ConfigBuilder`
and `ConfigError` types so callers still get an error instead of a crash.
In `@crates/minimal/src/client.rs`:
- Around line 165-171: `resolve_socket_path` in `client.rs` should preserve its
`std::io::Result<PathBuf>` contract instead of panicking through
`paths::minimal_state_dir()`. Restore the previous error propagation by handling
the case where neither the state dir nor home dir can be resolved and returning
a `NotFound`-style `Err` from `resolve_socket_path`, so callers can handle the
failure instead of crashing; use the existing `resolve_socket_path` and
`paths::minimal_state_dir`/`default_dir` paths to locate the change.
In `@crates/paths/src/lib.rs`:
- Around line 147-161: default_dir() currently panics on home-dir lookup and
path validation, which breaks the Result-based flow used by minimal_cache_dir(),
minimal_state_dir(), resolve_socket_path(), and ConfigBuilder::build(). Update
default_dir() to return a Result using the crate’s Error type instead of calling
expect, and propagate failures from dirs::home_dir(),
Utf8PathBuf::from_path_buf(), and DaemonAbsPath::try_new(). Then adjust the
minimal_* helpers to bubble that Result up so callers like client.rs and
config.rs can handle the error, while any CLI boundary that wants to abort can
still unwrap/expect there.
---
Nitpick comments:
In `@crates/mctx/src/config.rs`:
- Around line 156-167: The path conversion chain is duplicated in the `Config`
fallback logic and in `minimal::client`, so extract it into a shared convenience
on `DaemonAbsPath` in the `paths` crate (for example an `into_path_buf()`
helper). Update the `minimal_state_dir` and `minimal_cache_dir` initializers in
`Config` to call that helper, and similarly switch the
`crates/minimal/src/client.rs` call site to use the shared method instead of
repeating `.as_utf8_path().as_std_path().to_path_buf()`.
🪄 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: 627f98f8-8e6d-4847-8328-bad4b69122ba
⛔ Files ignored due to path filters (1)
Cargo.lockis excluded by!**/*.lock
📒 Files selected for processing (7)
crates/mctx/Cargo.tomlcrates/mctx/src/config.rscrates/minimal/src/client.rscrates/minimald/Cargo.tomlcrates/minimald/src/main.rscrates/paths/Cargo.tomlcrates/paths/src/lib.rs
💤 Files with no reviewable changes (1)
- crates/minimald/Cargo.toml
XDG_CACHE_DIR/minimalfallback~/.cache/minimalXDG_STATE_DIR/minimalfallback~/.local/state/minimalThis is technically a behavior change for legacy mip, which would use
~/.cache/minimalunconditionally, but now respects XDG_CACHE_DIR if set. But given we are doing a pivot to Minimal One, now is the right time for that.Summary by CodeRabbit
New Features
Bug Fixes