feat(minimald): streamline context creation flow for minimald - #810
Conversation
📝 WalkthroughWalkthroughThe session actor no longer caches workspace contexts. Contexts are rebuilt on demand, with callers explicitly selecting whether missing ChangesSession context handling
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.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
crates/minimald/src/session.rs (1)
891-896: 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick winStale doc comment: "Called at most once per actor lifetime" is no longer accurate.
build_contextis now called on everycontext()request since caching was removed. Update the doc to reflect the on-demand construction pattern.📝 Proposed fix for the doc comment
- /// Do the actual context construction: run [`mctx::Context::new`] against - /// a session-rooted [`Config`]. Called at most once per actor lifetime by - /// [`Self::context`]. - /// - /// The workspace mfile it parses is either the client's uploaded one or - /// a default scaffolded here on the way past. - /// - /// [`Config`]: mctx::Config + /// Do the actual context construction: run [`mctx::Context::new`] against + /// a session-rooted [`Config`]. Called on demand by [`Self::context`], + /// re-reading the workspace mfile each time so changes to + /// `minimal.toml` are reflected without restarting the session. + /// + /// The workspace mfile it parses is either the client's uploaded one or + /// a default scaffolded here on the way past (when `scaffold_if_missing` + /// is set). + /// + /// [`Config`]: mctx::Config🤖 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/minimald/src/session.rs` around lines 891 - 896, Update the documentation for build_context to remove the claim that it is called at most once per actor lifetime and describe that context construction occurs on demand for each context() request. Preserve the existing explanation of session-rooted Config and workspace mfile handling.
🧹 Nitpick comments (1)
crates/minimald/src/session.rs (1)
837-848: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value
contexttakes&mut selfbut no longer mutatesself.Since the cached field was removed,
contextonly readsself.innerand delegates tobuild_context(&self). It could take&self, which would also letsession_launcherpotentially relax its own&mut selfbound.♻️ Proposed refactor
-async fn context(&mut self, scaffold_if_missing: bool) -> Result<mctx::Context, String> { +async fn context(&self, scaffold_if_missing: bool) -> Result<mctx::Context, String> {🤖 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/minimald/src/session.rs` around lines 837 - 848, Change Session::context to take &self instead of &mut self, since it only reads self.inner and calls build_context. Update callers and any enclosing methods such as session_launcher to use shared borrows where this signature permits, while preserving the existing draft-session error and context-building behavior.
🤖 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.
Outside diff comments:
In `@crates/minimald/src/session.rs`:
- Around line 891-896: Update the documentation for build_context to remove the
claim that it is called at most once per actor lifetime and describe that
context construction occurs on demand for each context() request. Preserve the
existing explanation of session-rooted Config and workspace mfile handling.
---
Nitpick comments:
In `@crates/minimald/src/session.rs`:
- Around line 837-848: Change Session::context to take &self instead of &mut
self, since it only reads self.inner and calls build_context. Update callers and
any enclosing methods such as session_launcher to use shared borrows where this
signature permits, while preserving the existing draft-session error and
context-building behavior.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: dd794628-5ec1-4920-bc22-882ef2f879a3
📒 Files selected for processing (1)
crates/minimald/src/session.rs
minimal.tomlexcept in the attach path - rely onmin activateto provide onemctx::Context: create it each time to enable it to change as the file on disk changes.Summary by CodeRabbit
Bug Fixes
Improvements