Skip to content

fix: wire session branching, complete JSON output, token budget config#33

Merged
kienbui1995 merged 1 commit intomainfrom
fix/small-gaps
Apr 11, 2026
Merged

fix: wire session branching, complete JSON output, token budget config#33
kienbui1995 merged 1 commit intomainfrom
fix/small-gaps

Conversation

@kienbui1995
Copy link
Copy Markdown
Owner

@kienbui1995 kienbui1995 commented Apr 11, 2026

3 small gaps fixed:

  1. Session branching — /fork /branches /switch /branch delete now wired to BranchManager
  2. JSON output — added cost, cache tokens to --json output
  3. Token budget config — max_context_window + strategy in [compaction]

183 tests pass.

Summary by CodeRabbit

  • New Features
    • Enhanced branch management with fork, list, switch, and delete operations and status feedback
    • JSON output now includes cost estimation and cache token metrics
    • New configuration options for compaction strategy and maximum context window settings

Session branching:
- /fork, /branches, /switch, /branch delete now call BranchManager

JSON output:
- Added cost, cache_creation_tokens, cache_read_tokens

Token budget config:
- max_context_window override in [compaction]
- strategy: smart|naive in [compaction]
@kienbui1995 kienbui1995 merged commit 7aa171f into main Apr 11, 2026
4 of 5 checks passed
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 11, 2026

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: b9022f34-f3c4-4564-bb69-7c4a40970238

📥 Commits

Reviewing files that changed from the base of the PR and between 0925a92 and e897a4b.

📒 Files selected for processing (2)
  • mc/crates/mc-cli/src/main.rs
  • mc/crates/mc-config/src/types.rs

📝 Walkthrough

Walkthrough

Branch command handling now supports subcommands (fork, list, switch, delete) that execute against BranchManager and a locked runtime session. JSON output includes cache tokens and cost estimates. Configuration types extend with compaction context window and strategy options.

Changes

Cohort / File(s) Summary
Branch Command Processing
mc/crates/mc-cli/src/main.rs
Implemented branch subcommand parsing and execution (fork, list, switch, delete) with BranchManager integration. Added formatted output for each operation including branch listing with current marker, success/failure messages for switch and delete, and cost field in JSON output computed via ModelRegistry.
Configuration Type Extensions
mc/crates/mc-config/src/types.rs
Extended CompactionConfig with optional max_context_window and strategy fields. Added compaction_max_context and compaction_strategy fields to RuntimeConfig. Updated from_layers to populate new fields with "smart" as default strategy.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI Handler
    participant Parser as Command Parser
    participant BranchMgr as BranchManager
    participant Runtime as Runtime Session
    
    CLI->>Parser: receive PendingCommand::Branch(cmd)
    Parser->>Parser: parse subcommand (fork/list/switch/delete)
    Parser->>Runtime: try_lock()
    alt lock successful
        alt fork
            Parser->>BranchMgr: fork_branch()
            BranchMgr-->>Parser: success
        else list
            Parser->>Runtime: get session.branch_id
            Parser->>BranchMgr: list_branches()
            BranchMgr-->>Parser: branches with current marker
        else switch
            Parser->>BranchMgr: switch_branch(id)
            BranchMgr-->>Parser: success/failure
        else delete
            Parser->>BranchMgr: delete_branch(id)
            BranchMgr-->>Parser: success/failure
        end
        Parser-->>CLI: formatted output
    else lock failed
        Parser-->>CLI: Unknown branch command
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~22 minutes

Poem

🐰 Branches bloom beneath my paws,
Subcommands fork without a pause,
Cache tokens counted, costs weighed true,
Smart compaction through and through! ✨🌿

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/small-gaps

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

@kienbui1995 kienbui1995 deleted the fix/small-gaps branch April 11, 2026 20:50
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.

1 participant