Skip to content

feat(config): add Xiaomi MiMo token plan mode#2800

Merged
Hmbown merged 1 commit into
codex/v0.9.0-stewardshipfrom
codex/harvest-2627-xiaomi-token-plan-mode
Jun 5, 2026
Merged

feat(config): add Xiaomi MiMo token plan mode#2800
Hmbown merged 1 commit into
codex/v0.9.0-stewardshipfrom
codex/harvest-2627-xiaomi-token-plan-mode

Conversation

@Hmbown
Copy link
Copy Markdown
Owner

@Hmbown Hmbown commented Jun 5, 2026

Harvests the narrow Xiaomi MiMo Token Plan mode/env-selection/docs slice from #2627 by @xyuai for the v0.9.0 stewardship branch.

Credits #2621 reported by @springeye. This does not close #2621; remaining scope there includes model-list behavior, credit/cost display, and rate-limit awareness.

What landed:

  • Adds providers.xiaomi_mimo.mode plus XIAOMI_MIMO_MODE / MIMO_MODE.
  • Supports token-plan-sgp, token-plan-cn, token-plan-ams, and pay-as-you-go endpoint selection.
  • Prefers XIAOMI_MIMO_TOKEN_PLAN_API_KEY / MIMO_TOKEN_PLAN_API_KEY for Token Plan mode while preserving standard MiMo key env vars for pay-as-you-go.
  • Keeps the v0.9 branch's existing Token Plan api-key header behavior.
  • Updates README/config/provider docs and changelog credit.

Verification:

  • cargo test -p codewhale-config --locked xiaomi -- --nocapture
  • cargo test -p codewhale-tui --locked --bin codewhale-tui xiaomi_mimo -- --nocapture
  • cargo fmt --all -- --check
  • cargo clippy -p codewhale-config -p codewhale-tui --locked --all-targets --all-features -- -D warnings
  • git diff --check
  • git diff --cached --check
  • ./scripts/release/check-versions.sh
  • python3 scripts/check-coauthor-trailers.py --range origin/codex/v0.9.0-stewardship..HEAD --check-authors

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmbown has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@Hmbown Hmbown merged commit 1256125 into codex/v0.9.0-stewardship Jun 5, 2026
2 checks passed
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces Xiaomi MiMo mode selection (XIAOMI_MIMO_MODE / MIMO_MODE) to support Token Plan region endpoints (China, Singapore, Amsterdam) and pay-as-you-go routing, along with dedicated Token Plan environment keys. Feedback on the implementation points out that when both mode and base_url are provided, base_url inference can incorrectly override an explicitly configured mode during API key resolution. The reviewer suggests prioritizing explicit mode configuration over base_url inference in both crates/config/src/lib.rs and crates/tui/src/config.rs.

Important

The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.

Comment thread crates/config/src/lib.rs
Comment on lines +2156 to +2171
let standard_selected = normalized_mode
.as_deref()
.is_some_and(xiaomi_mimo_mode_uses_standard_endpoint)
|| base_url.is_some_and(xiaomi_mimo_base_url_is_pay_as_you_go);
if standard_selected {
return xiaomi_mimo_env_var(STANDARD_ENV_VARS);
}

let token_plan_selected = normalized_mode
.as_deref()
.and_then(xiaomi_mimo_base_url_for_mode)
.is_some()
|| base_url.is_some_and(xiaomi_mimo_base_url_uses_token_plan);
if token_plan_selected {
return xiaomi_mimo_env_var(TOKEN_PLAN_ENV_VARS);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In the current implementation, if both mode and base_url are provided, the base_url inference can override an explicitly configured mode. For example, if mode is set to "token-plan-cn" but base_url is configured to a pay-as-you-go endpoint, standard_selected will evaluate to true, selecting the standard API key instead of the token plan API key. Explicit configuration of mode should take precedence over base_url inference. We can resolve this by matching on normalized_mode first, and only falling back to base_url inference if normalized_mode is None.

    let (standard_selected, token_plan_selected) = match normalized_mode.as_deref() {
        Some(m) => (
            xiaomi_mimo_mode_uses_standard_endpoint(m),
            xiaomi_mimo_base_url_for_mode(m).is_some(),
        ),
        None => (
            base_url.is_some_and(xiaomi_mimo_base_url_is_pay_as_you_go),
            base_url.is_some_and(xiaomi_mimo_base_url_uses_token_plan),
        ),
    };
    if standard_selected {
        return xiaomi_mimo_env_var(STANDARD_ENV_VARS);
    }
    if token_plan_selected {
        return xiaomi_mimo_env_var(TOKEN_PLAN_ENV_VARS);
    }

Comment thread crates/tui/src/config.rs
Comment on lines +4214 to +4229
let standard_selected = normalized_mode
.as_deref()
.is_some_and(xiaomi_mimo_mode_uses_standard_endpoint)
|| base_url.is_some_and(xiaomi_mimo_base_url_is_pay_as_you_go);
if standard_selected {
return xiaomi_mimo_env_var(STANDARD_ENV_VARS);
}

let token_plan_selected = normalized_mode
.as_deref()
.and_then(xiaomi_mimo_base_url_for_mode)
.is_some()
|| base_url.is_some_and(xiaomi_mimo_base_url_uses_token_plan);
if token_plan_selected {
return xiaomi_mimo_env_var(TOKEN_PLAN_ENV_VARS);
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

In the current implementation, if both mode and base_url are provided, the base_url inference can override an explicitly configured mode. For example, if mode is set to "token-plan-cn" but base_url is configured to a pay-as-you-go endpoint, standard_selected will evaluate to true, selecting the standard API key instead of the token plan API key. Explicit configuration of mode should take precedence over base_url inference. We can resolve this by matching on normalized_mode first, and only falling back to base_url inference if normalized_mode is None.

    let (standard_selected, token_plan_selected) = match normalized_mode.as_deref() {
        Some(m) => (
            xiaomi_mimo_mode_uses_standard_endpoint(m),
            xiaomi_mimo_base_url_for_mode(m).is_some(),
        ),
        None => (
            base_url.is_some_and(xiaomi_mimo_base_url_is_pay_as_you_go),
            base_url.is_some_and(xiaomi_mimo_base_url_uses_token_plan),
        ),
    };
    if standard_selected {
        return xiaomi_mimo_env_var(STANDARD_ENV_VARS);
    }
    if token_plan_selected {
        return xiaomi_mimo_env_var(TOKEN_PLAN_ENV_VARS);
    }

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