Skip to content

Fix statusline to show actual current model instead of hardcoded Opus 4.5#1071

Closed
thewoolleyman wants to merge 5219 commits intoruvnet:mainfrom
thewoolleyman:fix/statusline-model-detection
Closed

Fix statusline to show actual current model instead of hardcoded Opus 4.5#1071
thewoolleyman wants to merge 5219 commits intoruvnet:mainfrom
thewoolleyman:fix/statusline-model-detection

Conversation

@thewoolleyman
Copy link

Problem

The claude-flow hooks statusline command was showing a hardcoded "Opus 4.5" model name regardless of which model the user was actually using in Claude Code. This caused confusion when users switched models (e.g., to Sonnet or Haiku) but the statusline continued to display "Opus 4.5".

Root Cause

In v3/@claude-flow/cli/src/commands/hooks.ts, the getUserInfo() function had:

const modelName = 'Opus 4.5';

There was no detection of the actual model from Claude Code's session state.

Solution

Updated the getUserInfo() function to:

  1. Read ~/.claude.json to find the current project's lastModelUsage
  2. Prefer the most specific path: When multiple project paths match, choose the longest (most specific) one
  3. Calculate total token usage: Include cache tokens (cacheReadInputTokens + cacheCreationInputTokens) to accurately determine the most-used model
  4. Parse model ID: Convert model IDs like claude-sonnet-4-5-20250929 to human-readable names like "Sonnet 4.5"
  5. Fallback gracefully: Show "Unknown" if detection fails

Changes

  • Added os import for accessing home directory
  • Replaced hardcoded const modelName = 'Opus 4.5' with let modelName = 'Unknown'
  • Added model detection logic that:
    • Finds the most specific matching project path
    • Calculates total token usage including cache tokens
    • Maps model IDs to display names (Opus 4.5, Sonnet 4.5, Sonnet 4, Haiku 4.5)

Testing

Tested with:

  • User switching from Opus to Sonnet → statusline correctly shows "Sonnet 4.5"
  • Nested project directories → correctly prefers specific project path over parent
  • Multiple models used in session → shows the most-used model by token count

Impact

  • Users will now see their actual current model in the statusline
  • Works correctly across all Claude models (Opus, Sonnet, Haiku)
  • Handles edge cases like nested project directories

Screenshot

Before:

▊ Claude Flow V3 ● user  │  ⎇ main  │  Opus 4.5

After (when using Sonnet):

▊ Claude Flow V3 ● user  │  ⎇ main  │  Sonnet 4.5

🤖 Generated with assistance from Claude Code

ruvnet and others added 30 commits January 15, 2026 21:00
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:00:10Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:01:01Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:01:59Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:02:57Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:03:34Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:06:09Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:08:43Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:11:44Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:14:22Z
- Changes: 6 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:14:30Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:14:49Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:15:03Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:15:16Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:15:28Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:15:34Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:15:42Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:16:11Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:16:21Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:16:29Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:16:34Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:16:56Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:17:34Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:19:36Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:19:42Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:20:50Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:21:54Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:22:01Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:23:43Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:24:04Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-15T21:25:26Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
ruvnet and others added 28 commits January 27, 2026 15:44
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-27T15:44:54Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-27T15:52:09Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: main
- Timestamp: 2026-01-27T15:55:59Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: review/memory-vector-system
- Timestamp: 2026-01-27T16:15:46Z
- Changes: 6 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: review/memory-vector-system
- Timestamp: 2026-01-27T16:17:09Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Rewrite memory-tools.ts to use advanced sql.js + HNSW backend
- Add backward compatibility with auto-migration from legacy JSON store
- Update CLI README with enhanced documentation
- Bump version to 3.0.0-alpha.185
- Regenerate agent configs with updated capabilities

Performance improvements:
- 150x-12,500x faster semantic search via HNSW indexing
- Vector embeddings with cosine similarity
- Persistent SQLite storage (WASM)

Breaking changes: None (backward compatible with migration)

Co-Authored-By: claude-flow <ruv@ruv.net>
fix(mcp): Integrate memory tools with sql.js/HNSW backend
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-27T18:15:53Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-27T18:16:54Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-27T18:16:55Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-27T18:18:00Z
- Changes: 6 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-27T18:18:11Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-27T18:20:17Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-27T18:21:34Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:30:35Z
- Changes: 11 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:30:36Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:30:38Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:30:39Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:30:44Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:30:55Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:30:57Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:31:14Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:31:24Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:31:52Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:39:16Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Automatic checkpoint created by Claude Code
- Branch: feature/pretrain-self-learning-benchmarks
- Timestamp: 2026-01-28T19:39:48Z
- Changes: 1 file(s)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…s 4.5"

The statusline command was showing a hardcoded "Opus 4.5" model name
regardless of which model the user was actually using in Claude Code.

Root cause:
- getUserInfo() function had `const modelName = 'Opus 4.5'` hardcoded
- No detection of actual model from Claude Code's session state

Fix:
- Read ~/.claude.json to find the current project's lastModelUsage
- Prefer the most specific (longest) matching project path
- Calculate total token usage including cache tokens to find most-used model
- Parse model ID to human-readable name (Opus 4.5, Sonnet 4.5, Haiku 4.5)
- Fallback to "Unknown" if detection fails

Result:
- Statusline now correctly shows the actual model being used
- Works across all Claude models (Opus, Sonnet, Haiku)
- Handles nested project directories correctly

Fixes: User switching to Sonnet but statusline still showing Opus
Change 'Unknown' to 'Model unknown (no usage yet)' to better communicate
why the model isn't detected and that it will be once usage data is recorded.
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.

3 participants