Skip to content

fix(stats): filter out imported Claude Code sessions from mimo stats#312

Open
WqyJh wants to merge 2 commits into
mainfrom
mirror/pr-510
Open

fix(stats): filter out imported Claude Code sessions from mimo stats#312
WqyJh wants to merge 2 commits into
mainfrom
mirror/pr-510

Conversation

@WqyJh

@WqyJh WqyJh commented Jun 15, 2026

Copy link
Copy Markdown
Owner

Summary

Fixes XiaomiMiMo#494

This PR filters out imported Claude Code sessions from mimo stats command statistics.

Problem

When users install MiMo on a machine that already has Claude Code sessions in ~/.claude/projects, the mimo stats command includes imported Claude Code sessions in all metrics (sessions, days, tokens, cost, tool usage). This inflates the statistics for new MiMo users.

Solution

  • Import ClaudeImportTable to access the import tracking table
  • Query all imported session IDs from ClaudeImportTable
  • Filter out imported sessions when aggregating stats in getAllSessions()

Changes

  • packages/opencode/src/cli/cmd/stats.ts: Add filtering logic to exclude imported Claude Code sessions from stats calculation

Testing

Verified that the fix correctly filters out sessions that exist in the claude_import table while preserving native MiMo sessions.


Mirrored from XiaomiMiMo/MiMo-Code#510 — original author @gavanx.

gavanx added 2 commits June 13, 2026 15:27
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
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.

[bug]: mimo stats includes imported Claude Code sessions in all metrics

2 participants