Skip to content

Fix duplicate context window suffix in model display#29

Merged
himattm merged 2 commits intomainfrom
fix/trim-model-display-name
Mar 15, 2026
Merged

Fix duplicate context window suffix in model display#29
himattm merged 2 commits intomainfrom
fix/trim-model-display-name

Conversation

@himattm
Copy link
Owner

@himattm himattm commented Mar 15, 2026

Summary

  • Claude Code includes "(1M context)" in the model display_name field (e.g. "Opus 4.6 (1M context)")
  • renderModel() was appending its own "(1M)" suffix, producing "Opus 4.6 (1M context) (1M)"
  • Added trimContextSuffix() to strip the trailing " (Xk/M context)" before appending our own indicator

Test plan

  • TestTrimContextSuffix — covers various display name formats including names with existing parens
  • TestRenderModel_TrimsContextSuffixFromDisplayName — end-to-end check that duplication is gone
  • Full test suite passes

🤖 Generated with Claude Code

Claude Code includes "(1M context)" in display_name, causing
renderModel to produce "Opus 4.6 (1M context) (1M)". Strip the
trailing context suffix before appending our own indicator.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request addresses a display bug where model names in the status line showed a duplicated context window suffix. By introducing a new utility function to strip pre-existing context information from the model's display name, the system now correctly formats and presents model names with a single, consistent context window indicator, improving user interface clarity.

Highlights

  • Duplicate context window suffix fixed: The renderModel function was incorrectly appending a context window suffix (e.g., "(1M)") to model display names that already contained a similar suffix (e.g., "(1M context)"), leading to redundant output like "Opus 4.6 (1M context) (1M)".
  • New trimContextSuffix function introduced: A new helper function, trimContextSuffix, was introduced to remove the existing context window suffix from model display names before renderModel adds its own, ensuring a clean and correct display.
  • Comprehensive testing added: Dedicated unit tests (TestTrimContextSuffix) were added to validate the new trimming logic, along with an end-to-end test (TestRenderModel_TrimsContextSuffixFromDisplayName) to confirm the fix for the duplicate suffix issue in the renderModel function.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • internal/statusline/statusline.go
    • Introduced trimContextSuffix function to remove redundant context window information from model display names.
    • Updated renderModel to utilize trimContextSuffix before appending its own context window indicator.
  • internal/statusline/statusline_test.go
    • Added TestTrimContextSuffix with various test cases to verify the new context trimming logic.
    • Included TestRenderModel_TrimsContextSuffixFromDisplayName to confirm the end-to-end fix for duplicate context suffixes in model rendering.
Activity
  • The author identified a bug where Claude Code's model display names caused duplicate context window suffixes.
  • A new function, trimContextSuffix, was implemented to resolve the duplication.
  • Unit tests (TestTrimContextSuffix) and an end-to-end test (TestRenderModel_TrimsContextSuffixFromDisplayName) were added and passed.
  • The full test suite was run and passed.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly addresses the issue of duplicate context window suffixes in the model display name by introducing a trimContextSuffix function. The overall approach is sound, and the addition of unit tests is appreciated. However, I've identified a potential issue in the implementation of trimContextSuffix where it might be too aggressive and incorrectly trim model names that don't actually have the context window suffix. I've provided a suggestion to make the logic more robust.

Comment on lines +342 to +350
func trimContextSuffix(name string) string {
// Match patterns like " (1M context)", " (200k context)"
if idx := strings.LastIndex(name, " ("); idx >= 0 {
tail := name[idx:]
if strings.HasSuffix(tail, " context)") {
return name[:idx]
}
}
return name

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The current logic for trimming the suffix is a bit too broad and could incorrectly trim valid model names like "My Model (for some context)". By also checking that the suffix contains a digit, we can make this more robust and prevent most false positives.

For even greater robustness, you could consider using a regular expression to precisely match the expected format like (1M context). You could also enhance the test suite with a case like {"My Model (for some context)", "My Model (for some context)"} to cover this scenario.

Suggested change
func trimContextSuffix(name string) string {
// Match patterns like " (1M context)", " (200k context)"
if idx := strings.LastIndex(name, " ("); idx >= 0 {
tail := name[idx:]
if strings.HasSuffix(tail, " context)") {
return name[:idx]
}
}
return name
func trimContextSuffix(name string) string {
// Match patterns like " (1M context)", " (200k context)"
if idx := strings.LastIndex(name, " ("); idx >= 0 {
tail := name[idx:]
// To avoid false positives, also check that the suffix contains a digit.
if strings.HasSuffix(tail, " context)") && strings.ContainsAny(tail, "0123456789") {
return name[:idx]
}
}
return name
}

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 47aaa86. Added digit check to trimContextSuffix and a test case for the false-positive scenario.

Add digit check to trimContextSuffix to avoid false positives on
names like "My Model (for some context)". Add test case for it.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@himattm himattm merged commit b492f54 into main Mar 15, 2026
1 check passed
@himattm himattm deleted the fix/trim-model-display-name branch March 15, 2026 23:30
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.

1 participant