Skip to content

feat(minimald): streamline context creation flow for minimald - #810

Merged
twitchyliquid64 merged 1 commit into
mainfrom
tom/session-inner
Jul 17, 2026
Merged

feat(minimald): streamline context creation flow for minimald#810
twitchyliquid64 merged 1 commit into
mainfrom
tom/session-inner

Conversation

@twitchyliquid64

@twitchyliquid64 twitchyliquid64 commented Jul 17, 2026

Copy link
Copy Markdown
Member
  • No longer stamp a default minimal.toml except in the attach path - rely on min activate to provide one
  • Do not cache a mctx::Context: create it each time to enable it to change as the file on disk changes.

Summary by CodeRabbit

  • Bug Fixes

    • Improved workspace context handling by rebuilding context when needed, ensuring changes are reflected reliably.
    • Prevented unnecessary creation of missing workspace configuration during regular context requests.
  • Improvements

    • Workspace configuration is now created automatically when required during host setup.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The session actor no longer caches workspace contexts. Contexts are rebuilt on demand, with callers explicitly selecting whether missing minimal.toml files should be scaffolded.

Changes

Session context handling

Layer / File(s) Summary
Uncached context construction and scaffolding control
crates/minimald/src/session.rs
Active sessions no longer store cached contexts; Session::context and build_context rebuild contexts and conditionally scaffold minimal.toml.
Lifecycle and caller-specific context requests
crates/minimald/src/session.rs
Session activation paths remove cache initialization, while regular context requests disable scaffolding and production launching enables it.

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

Possibly related PRs

  • gominimal/minimal#754: Updates related session lifecycle transitions in crates/minimald/src/session.rs.

Suggested reviewers: norrietaylor

Poem

I’m a rabbit with a freshly built nest,
Contexts are made anew at each request.
No cached burrow beneath the floor,
Scaffolds appear when hosts ask for more.
Hop, hop—clean state is best!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly reflects the main change: simplifying context creation in minimald.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ 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.

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 win

Stale doc comment: "Called at most once per actor lifetime" is no longer accurate.

build_context is now called on every context() 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

context takes &mut self but no longer mutates self.

Since the cached field was removed, context only reads self.inner and delegates to build_context(&self). It could take &self, which would also let session_launcher potentially relax its own &mut self bound.

♻️ 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

📥 Commits

Reviewing files that changed from the base of the PR and between 11daebe and 59755a6.

📒 Files selected for processing (1)
  • crates/minimald/src/session.rs

@twitchyliquid64
twitchyliquid64 enabled auto-merge (squash) July 17, 2026 17:36
@twitchyliquid64
twitchyliquid64 merged commit dd20ee6 into main Jul 17, 2026
28 checks passed
@twitchyliquid64
twitchyliquid64 deleted the tom/session-inner branch July 17, 2026 17:41
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.

2 participants