fix(stats): filter out imported Claude Code sessions from mimo stats#312
Open
WqyJh wants to merge 2 commits into
Open
fix(stats): filter out imported Claude Code sessions from mimo stats#312WqyJh wants to merge 2 commits into
WqyJh wants to merge 2 commits into
Conversation
Fixes XiaomiMiMo#494 - Import ClaudeImportTable to access the import tracking table - Query all imported session IDs from ClaudeImportTable - Filter out imported sessions when aggregating stats This prevents inflated statistics for users who just installed MiMo and have existing Claude Code history in ~/.claude/projects.
- Test filtering out imported sessions from stats - Test counting all sessions when none are imported - Test handling case where all sessions are imported - Test returning zero stats when no sessions exist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes XiaomiMiMo#494
This PR filters out imported Claude Code sessions from
mimo statscommand statistics.Problem
When users install MiMo on a machine that already has Claude Code sessions in
~/.claude/projects, themimo statscommand includes imported Claude Code sessions in all metrics (sessions, days, tokens, cost, tool usage). This inflates the statistics for new MiMo users.Solution
ClaudeImportTableto access the import tracking tableClaudeImportTablegetAllSessions()Changes
packages/opencode/src/cli/cmd/stats.ts: Add filtering logic to exclude imported Claude Code sessions from stats calculationTesting
Verified that the fix correctly filters out sessions that exist in the
claude_importtable while preserving native MiMo sessions.Mirrored from XiaomiMiMo/MiMo-Code#510 — original author @gavanx.