fix(mimocode): scan ~/.local/share/mimocode, not /micode - #784
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
1 issue found across 8 files
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
~/.local/share/mimocode, not /micode
The scanner hardcoded the MiMo Code data root (XDG_DATA_HOME + "mimocode"),
duplicating the path that lives in `ClientId::MiMoCode` metadata and risking
drift the next time the directory changes. Resolve it via
`ClientId::MiMoCode.data().resolve_path_with_env_strategy(...)` like OpenCode,
Kimi, and the other XDG clients already do.
Behavior-preserving: for an XdgData root the helper yields the identical
`{XDG_DATA_HOME|~/.local/share}/mimocode` path. Verified by the existing
test_micode_authoritative_cost_is_not_repriced_on_first_parse_or_cache_hit.
Constraint: scan path must match clients.rs metadata to avoid silent non-detection
Confidence: high
Scope-risk: narrow
junhoyeo
left a comment
There was a problem hiding this comment.
Thanks @Javis603 — excellent fix and an exemplary writeup. The root-cause evidence (the git log -S "micode" history check, before/after CLI output, and the honest scoped-out note about MiMo Code importing Claude Code sessions into mimocode.db) made this easy to verify. MiMo Code usage was silently undetected before this, so it is a real correctness fix.
I pushed one maintainer commit (26c5749b) addressing cubic's P2: the scanner now derives the data dir from ClientId::MiMoCode metadata instead of duplicating the path, so it stays in sync with clients.rs. fmt + clippy clean, mimocode detection test passing. 🚀
Summary
MiMo Code usage is never detected: the scanner looks in
~/.local/share/micode/, but MiMo Code stores its SQLite session db under~/.local/share/mimocode/. Pointing the scanner atmimocodefixes detection. The client id staysmicode— only the data directory changes.Root cause
MiMo Code (
XiaomiMiMo/MiMo-Code) resolves all of its XDG base dirs from a single app name:So sessions live at
~/.local/share/mimocode/mimocode.db(and config/state/cache under~/.config/mimocode,~/.local/state/mimocode). On Windows the same layout appears under%USERPROFILE%\.local\share\mimocode\.The MiMo Code scanner added in #710 assumed
~/.local/share/micode/mimocode.db. Note this is internally inconsistent: the directory ismicodebut the filename matcher ismimocode.db. The stringmicodenever appears anywhere in MiMo-Code's history (git log -S '"micode"' --allis empty) — it has beenmimocodesince the V0.1.0 open-source release on 2026-06-10. So no backward-compat fallback tomicodeis needed.Evidence
The shipped tokscale 4.0.4 scans
~/.local/share/micode/— which does not exist — so it finds nothing:Built from this branch, it scans the real
~/.local/share/mimocode/directory (no symlink, no env override) and finds the sessions. Filtered to the genuine native MiMo provider (mimo):Note: MiMo Code imports Claude Code sessions into its db
MiMo Code automatically imports Claude Code sessions (
~/.claude/projects) intomimocode.dbon first run — itsclaude-importservice (CLImimocode session import-claude; README: "Import from Claude Code"). The observed log showsservice=claude-import scanned=113 imported=113 ... resynced=4.So
mimocode.dbcan hold sessions whose tokens are already attributed to theclaudeclient, and scanning it will double-count them undermicode. This PR only corrects the scan path; whether to exclude or dedup imported sessions is a separate decision, out of scope here.Changes
clients.rs—MiMoCode.relative:"micode"→"mimocode"scanner.rs— scan dir{xdg_data}/micode→{xdg_data}/mimocode(+ comment)sessions/micode.rs— doc-comment pathlib.rs— the one test that seeds a fixture at.local/share/micodemoves to.local/share/mimocodeso it matches the scan pathREADME.md/README.ja.md/README.ko.md/README.zh-cn.md— the MiMo Code data-dir paths (clients table, platform-paths table, MiMo Code section)Unchanged: the client id
micode, themimocode.db/mimocode-<channel>.dbfilename matcher, the parser, and every CLI/TUI/frontend id.Verification
cargo fmt --all -- --check— cleancargo clippy --locked --workspace --all-features -- -D warnings— cleancargo test --workspace --all-features— 1950 passed, 0 failed (includes the updated micode path-fixture test)Follow-up (intentionally not in this PR)
MiMo Code also honors
MIMOCODE_HOMEto relocate all four base dirs ($MIMOCODE_HOME/data). Honoring it could be a separate enhancement; this PR keeps the change minimal and focused on the default XDG path.