Skip to content

feat: Add Xiaomi MiMo prepaid balance provider#1309

Open
AdrianSimionov wants to merge 7 commits into
steipete:mainfrom
AdrianSimionov:feat/mimo-balance
Open

feat: Add Xiaomi MiMo prepaid balance provider#1309
AdrianSimionov wants to merge 7 commits into
steipete:mainfrom
AdrianSimionov:feat/mimo-balance

Conversation

@AdrianSimionov
Copy link
Copy Markdown

Adds a new .mimobalance provider (Alibaba-style separate provider pattern) that shows MiMo prepaid API balance with Paid/Granted breakdown.

  • Fetches /api/v1/balance endpoint for cashBalance and giftBalance
  • Shows total balance in menubar (e.g. $9.60)
  • Menu card displays Paid/Granted breakdown like DeepSeek
  • Uses cookie-based auth, reusing MiMo cookie importer
  • Separate provider so users can enable balance independently from token plan

New provider (.mimobalance) shows cashBalance (Paid) and giftBalance
(Granted) from MiMo API alongside the existing token plan provider.
Displays in menubar and menu card following DeepSeek balance pattern.
@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented Jun 5, 2026

Codex review: needs changes before merge. Reviewed June 5, 2026, 1:25 AM ET / 05:25 UTC.

Summary
Adds a disabled-by-default Xiaomi MiMo Balance provider that fetches prepaid balance with shared MiMo cookie auth, displays paid/granted balance in the app, and wires CLI, widget exclusions, docs, and parser tests.

Reproducibility: yes. for the review finding: source inspection shows the docs use mimobalance, while CLI provider selection resolves only descriptor names and aliases, where this PR registers mimo-balance and xiaomi-mimo-balance. I did not run the CLI because this pass is read-only.

Review metrics: 2 noteworthy metrics.

  • Provider surface: 1 provider added across 22 files. The change touches app registration, core descriptors/fetching, CLI, widget exclusions, docs, and tests, so maintainer review should treat it as a provider addition rather than a parser-only patch.
  • Diff size: +635/-16. The patch is moderate in size and spans auth, display, and documentation surfaces that green parser tests alone do not fully settle.

Merge readiness
Overall: 🦐 gold shrimp
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🦐 gold shrimp
Result: needs maintainer review before merge.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Fix the documented CLI provider argument or add mimobalance as a tested alias.
  • [P2] Have maintainers explicitly accept the shared MiMo cookie-auth behavior before merge.

Risk before merge

  • [P1] The PR adds a new provider that reads MiMo browser-cookie auth and shares the existing .mimo settings/cache, so mistakes here show up as auth failures or setup confusion rather than isolated UI polish.
  • [P1] This read-only review did not run Swift tests or make check; final merge should rely on CI or maintainer-run checks.

Maintainer options:

  1. Fix the CLI name mismatch first (recommended)
    Update the CLI example to mimo-balance or add and test mimobalance as an accepted alias so the documented path works before maintainer review finishes.
  2. Accept the shared-cookie provider surface
    After the CLI mismatch is fixed, maintainers can intentionally accept that the new balance provider reads and caches MiMo browser-cookie auth through the existing .mimo settings/cache.
  3. Pause if the provider split is not wanted
    If maintainers do not want a separate balance provider sharing MiMo auth state, pause or close this branch and keep balance/token-plan behavior in the existing provider.
Copy recommended automerge instruction
@clawsweeper automerge

Special instructions:
Fix the MiMo Balance CLI documentation/alias mismatch: either change docs/mimo.md to show `codexbar usage --provider mimo-balance`, or add `mimobalance` as an accepted alias in the provider descriptor with focused CLI parsing coverage; do not change the shared MiMo cookie behavior.

Next step before merge

  • [P2] A narrow automated repair can fix the CLI docs/alias mismatch; the auth-provider surface still needs maintainer acceptance before merge.

Security
Cleared: No new dependency, workflow, or broad permission change was found; the intended cookie-auth expansion is tracked as auth-provider merge risk.

Review findings

  • [P2] Use an executable MiMo Balance CLI name — docs/mimo.md:50
Review details

Best possible solution:

Fix the CLI docs or alias mismatch, then have maintainers explicitly accept the new disabled-by-default provider and shared MiMo cookie-auth behavior.

Do we have a high-confidence way to reproduce the issue?

Yes for the review finding: source inspection shows the docs use mimobalance, while CLI provider selection resolves only descriptor names and aliases, where this PR registers mimo-balance and xiaomi-mimo-balance. I did not run the CLI because this pass is read-only.

Is this the best way to solve the issue?

Not quite yet: the provider implementation follows existing MiMo and balance-provider patterns, but the documented CLI path must match the registered CLI name or alias before merge. The shared-cookie provider behavior also needs maintainer sign-off because it changes auth-provider surface.

Full review comments:

  • [P2] Use an executable MiMo Balance CLI name — docs/mimo.md:50
    The new docs tell users to run codexbar usage --provider mimobalance, but CLI parsing only accepts descriptor CLI names and aliases. This descriptor registers mimo-balance and xiaomi-mimo-balance, so the documented command is rejected unless the docs use mimo-balance or the descriptor adds mimobalance as an alias.
    Confidence: 0.9

Overall correctness: patch is incorrect
Overall confidence: 0.86

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against 65e39f4dcb3a.

Label changes

Label changes:

  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): The contributor provided a screenshot showing the after-change MiMo Balance menu bar value and menu card paid/granted breakdown; no contributor action is needed for proof.
  • remove status: 👀 ready for maintainer look: Current PR status label is status: ⏳ waiting on author.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦐 gold shrimp, so this older rating label is no longer current.

Label justifications:

  • P2: This is a normal-priority provider addition with a concrete docs/CLI mismatch and limited blast radius because the new provider is disabled by default.
  • merge-risk: 🚨 auth-provider: Merging adds a new provider that reads MiMo browser-cookie auth and shares the existing MiMo cookie settings/cache.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦞 diamond lobster and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action. Sufficient (screenshot): The contributor provided a screenshot showing the after-change MiMo Balance menu bar value and menu card paid/granted breakdown; no contributor action is needed for proof.
  • proof: sufficient: Contributor real behavior proof is sufficient. The contributor provided a screenshot showing the after-change MiMo Balance menu bar value and menu card paid/granted breakdown; no contributor action is needed for proof.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The contributor provided a screenshot showing the after-change MiMo Balance menu bar value and menu card paid/granted breakdown; no contributor action is needed for proof.
Evidence reviewed

Acceptance criteria:

  • [P1] swift test --filter CLIEntryTests.
  • [P1] swift test --filter MiMoProviderTests.
  • [P1] make check.
  • [P1] rg -n "mimo-balance|mimobalance|Xiaomi MiMo Balance" README.md docs/mimo.md docs/providers.md docs/configuration.md.

What I checked:

Likely related people:

  • Peter Steinberger: Current-main blame and path history for the existing MiMo provider, settings, docs, and tests all point to the v0.32.4 import commit authored by Peter Steinberger in this checkout. (role: feature-history owner; confidence: medium; commits: 723734ef3422; files: Sources/CodexBarCore/Providers/MiMo/MiMoProviderDescriptor.swift, Sources/CodexBarCore/Providers/MiMo/MiMoUsageFetcher.swift, Sources/CodexBar/Providers/MiMo/MiMoProviderImplementation.swift)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. labels Jun 5, 2026
frozenBalance, overdraftLimit, and remainingOverdraftLimit can be
null in the API response.  Make them optional so JSONDecoder does
not reject valid payloads.  Add focused parser tests with null and
full-field fixtures.
@AdrianSimionov
Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented Jun 5, 2026

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@AdrianSimionov
Copy link
Copy Markdown
Author

Behavior proof: MiMo Balance provider successfully fetching and displaying prepaid balance with paid/granted breakdown. Balance shows $9.60 total (Paid: $9.60 / Granted: $0.00).

mimo-balance-paid-granted

@clawsweeper re-review

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented Jun 5, 2026

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient Contributor real behavior proof is sufficient. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 5, 2026
MiMo Balance now reuses the existing MiMo token-plan cookie
settings instead of maintaining its own separate auth surface.
The MiMoBalanceWebFetchStrategy reads from the .mimo cookie
cache and settings, eliminating the duplicate credential path.

Currency formatting uses UsageFormatter.currencyString with the
API's currency code instead of hardcoding $/¥ symbols.
@AdrianSimionov
Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented Jun 5, 2026

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. labels Jun 5, 2026
CLI snapshot for .mimobalance now populates .mimo settings so the
fetch strategy reads the shared MiMo auth state.  Menubar balance
extractor no longer requires $ or ¥ prefix — splits on space to
work with any currency.
@AdrianSimionov
Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented Jun 5, 2026

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

Replace empty options array with functional picker bound to shared
MiMo cookie settings.  Users who enable only the balance provider
can now configure cookie source (Auto/Manual) directly.
@AdrianSimionov
Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented Jun 5, 2026

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot removed the rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. label Jun 5, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 5, 2026
@AdrianSimionov
Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper
Copy link
Copy Markdown

clawsweeper Bot commented Jun 5, 2026

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Jun 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 auth-provider 🚨 Merging this PR could break OAuth, tokens, provider routing, model choice, or credentials. P2 Normal priority bug or improvement with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient Contributor real behavior proof is sufficient. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant