Skip to content

Comments

refactor(commands): replace positional params with statuslineParams struct#234

Merged
AnnatarHe merged 1 commit intomainfrom
refactor/cc-statusline-params-struct
Feb 15, 2026
Merged

refactor(commands): replace positional params with statuslineParams struct#234
AnnatarHe merged 1 commit intomainfrom
refactor/cc-statusline-params-struct

Conversation

@AnnatarHe
Copy link
Contributor

@AnnatarHe AnnatarHe commented Feb 15, 2026

Summary

  • Introduce statuslineParams struct to replace 12 positional parameters in formatStatuslineOutput
  • Update call site in commandCCStatusline and all ~13 test call sites to use named struct fields
  • Zero-value fields (empty strings, false, nil, 0) can now be omitted at call sites, improving readability

Test plan

  • go test ./commands/ -run TestCCStatuslineTestSuite -count=1 passes
  • go vet ./commands/ clean

🤖 Generated with Claude Code


Open with Devin

…s struct

formatStatuslineOutput had 12 positional parameters making call sites
hard to read and error-prone. Introduce a statuslineParams struct with
named fields for clarity and easier future extension.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@chatgpt-codex-connector
Copy link

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @AnnatarHe, 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 significantly refactors the formatStatuslineOutput function by replacing a large number of positional parameters with a single, well-defined struct. This change enhances the clarity and maintainability of the code by grouping related parameters, making function calls easier to understand and reducing the likelihood of parameter order errors. It streamlines the interface for generating statusline output across the application.

Highlights

  • Refactored formatStatuslineOutput function signature: The formatStatuslineOutput function now accepts a single statuslineParams struct instead of 12 positional parameters, significantly improving readability and maintainability.
  • Introduced statuslineParams struct: A new statuslineParams struct was defined to encapsulate all parameters required by the statusline formatting logic.
  • Updated call sites: The primary call site in commandCCStatusline and all associated test cases were updated to utilize the new statuslineParams struct, passing named fields for clarity.
  • Improved readability at call sites: Zero-value fields (e.g., empty strings, false, nil, 0) can now be omitted when calling formatStatuslineOutput, further enhancing code readability.
Changelog
  • commands/cc_statusline.go
    • Introduced the statuslineParams struct to consolidate multiple function parameters.
    • Modified the formatStatuslineOutput function to accept the new statuslineParams struct.
    • Updated the commandCCStatusline function to pass data to formatStatuslineOutput using the statuslineParams struct.
    • Adjusted all internal references within formatStatuslineOutput to access fields from the statuslineParams struct.
  • commands/cc_statusline_test.go
    • Updated all test cases for formatStatuslineOutput to use the new statuslineParams struct for parameter passing.
    • Modified test calls to leverage named fields and omit zero-value fields where appropriate, reflecting the improved readability.
Activity
  • The pull request was generated using Claude Code.
  • The author confirmed that go test ./commands/ -run TestCCStatuslineTestSuite -count=1 passes.
  • The author confirmed that go vet ./commands/ is clean.
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
Contributor

@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 is a great refactoring that significantly improves the readability and maintainability of the formatStatuslineOutput function by replacing a long list of positional parameters with a statuslineParams struct. The changes are well-executed and the updated test files clearly demonstrate the benefits of this new approach.

I have one suggestion to make the URL construction more robust, which is a minor improvement on the existing logic.

url := fmt.Sprintf("%s/users/%s/coding-agent/session/%s", webEndpoint, userLogin, sessionID)
sessionStr := color.Cyan.Sprintf("💰 $%.2f", p.SessionCost)
if p.UserLogin != "" && p.WebEndpoint != "" && p.SessionID != "" {
url := fmt.Sprintf("%s/users/%s/coding-agent/session/%s", p.WebEndpoint, p.UserLogin, p.SessionID)
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

Using fmt.Sprintf for URL concatenation can be brittle. If p.WebEndpoint has a trailing slash, this will result in a double slash in the URL (e.g., https://example.com//users/...). For more robust URL construction, it's better to handle this case.

A simple way to fix this is to use strings.TrimRight to remove any trailing slash from the base URL.

This same issue exists on lines 206 and 223.

Suggested change
url := fmt.Sprintf("%s/users/%s/coding-agent/session/%s", p.WebEndpoint, p.UserLogin, p.SessionID)
url := fmt.Sprintf("%s/users/%s/coding-agent/session/%s", strings.TrimRight(p.WebEndpoint, "/"), p.UserLogin, p.SessionID)

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@AnnatarHe AnnatarHe merged commit 566d5fd into main Feb 15, 2026
4 of 5 checks passed
@AnnatarHe AnnatarHe deleted the refactor/cc-statusline-params-struct branch February 15, 2026 14:19
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