Skip to content

feat(statusline): add total AI agent time to CC statusline display#198

Merged
AnnatarHe merged 1 commit intomainfrom
feat/cc-statusline-agent-time
Jan 4, 2026
Merged

feat(statusline): add total AI agent time to CC statusline display#198
AnnatarHe merged 1 commit intomainfrom
feat/cc-statusline-agent-time

Conversation

@AnnatarHe
Copy link
Copy Markdown
Contributor

Summary

  • Add totalSessionSeconds from backend GraphQL API to the CC statusline display
  • New display format: 🤖 model | 💰 $session | 📊 $daily | ⏱️ time | 📈 context%
  • Time formatted smartly: 45s, 2m5s, or 1h30m

Test plan

  • All CC statusline tests pass
  • All CC info timer tests pass
  • All cache tests pass
  • Manual testing with daemon running

🤖 Generated with Claude Code

Display totalSessionSeconds from backend GraphQL API in the statusline.
The new display format shows agent time in magenta between daily cost
and context percentage:

🤖 model | 💰 $session | 📊 $daily | ⏱️ time | 📈 context%

Time is formatted as:
- Under 1 minute: 45s
- Under 1 hour: 2m5s
- 1+ hours: 1h30m (drops seconds for readability)

Changes:
- Add TotalSessionSeconds to GraphQL query and response types
- Update daemon CCInfoCache and CCInfoResponse structs
- Add CCStatuslineDailyStats type for cache and service layer
- Add formatSessionDuration helper function
- Update all related tests

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

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Copy Markdown
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 enhances the AI agent statusline by integrating and displaying the total session time. It involves updating the data fetching logic to retrieve session duration from the backend, modifying internal data models to store this new metric, and adjusting the statusline rendering to present the time in a user-friendly, formatted manner. The changes ensure that users have a more comprehensive overview of their AI agent usage directly in the statusline.

Highlights

  • AI Agent Time Display: The CC statusline now includes the total AI agent time (totalSessionSeconds) fetched from the backend GraphQL API.
  • New Statusline Format: The display format has been updated to 🤖 model | 💰 $session | 📊 $daily | ⏱️ time | 📈 context% to accommodate the new time metric.
  • Smart Time Formatting: A new utility function formatSessionDuration has been introduced to format the session time smartly (e.g., 45s, 2m5s, 1h30m).
  • Backend Data Integration: The GraphQL query and data structures across the daemon and model layers have been extended to fetch and store totalSessionSeconds alongside totalCostUsd.
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.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jan 4, 2026

Codecov Report

❌ Patch coverage is 74.66667% with 19 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
model/cc_statusline_service.go 0.00% 15 Missing ⚠️
commands/cc_statusline.go 83.33% 4 Missing ⚠️
Flag Coverage Δ
unittests 37.32% <74.66%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
daemon/cc_info_timer.go 95.55% <100.00%> (+0.20%) ⬆️
daemon/socket.go 64.60% <100.00%> (+0.31%) ⬆️
model/cc_statusline_cache.go 100.00% <100.00%> (ø)
commands/cc_statusline.go 57.00% <83.33%> (+8.19%) ⬆️
model/cc_statusline_service.go 0.00% <0.00%> (ø)

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Copy Markdown
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 enhances the status line functionality by adding the display of AI agent session time alongside the existing cost and context percentage. This involved updating various data structures (e.g., CCInfoCache, CCInfoResponse, CCStatuslineDailyStats) to include session duration in seconds. The GraphQL API query was modified to fetch this new totalSessionSeconds field, and the daemon's caching and communication logic (cc_info_timer.go, socket.go) were adjusted to handle and transmit this data. A new formatSessionDuration helper function was introduced to convert seconds into a human-readable format for display. All related functions, including getDailyCostWithDaemonFallback (renamed to getDailyStatsWithDaemonFallback) and formatStatuslineOutput, were updated to incorporate the new session time. Corresponding test cases were also updated or added to cover these changes. A review comment suggested improving the CCStatuslineCacheSet function by calling time.Now() only once to ensure consistency for both Date and FetchedAt fields.

Comment on lines 88 to 94
statuslineCache.entry = &ccStatuslineCacheEntry{
Date: time.Now().Format("2006-01-02"),
CostUsd: costUsd,
FetchedAt: time.Now(),
TTL: statuslineCache.ttl,
Date: time.Now().Format("2006-01-02"),
CostUsd: stats.Cost,
SessionSeconds: stats.SessionSeconds,
FetchedAt: time.Now(),
TTL: statuslineCache.ttl,
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Calling time.Now() multiple times within the same function can lead to subtle bugs if the execution happens to cross a time boundary (like midnight). Here, Date and FetchedAt are derived from two separate calls.

To ensure consistency and atomicity for the timestamp, it's better to call time.Now() once and reuse the result.

Suggested change
statuslineCache.entry = &ccStatuslineCacheEntry{
Date: time.Now().Format("2006-01-02"),
CostUsd: costUsd,
FetchedAt: time.Now(),
TTL: statuslineCache.ttl,
Date: time.Now().Format("2006-01-02"),
CostUsd: stats.Cost,
SessionSeconds: stats.SessionSeconds,
FetchedAt: time.Now(),
TTL: statuslineCache.ttl,
}
now := time.Now()
statuslineCache.entry = &ccStatuslineCacheEntry{
Date: now.Format("2006-01-02"),
CostUsd: stats.Cost,
SessionSeconds: stats.SessionSeconds,
FetchedAt: now,
TTL: statuslineCache.ttl,
}

@AnnatarHe AnnatarHe merged commit 2e0901f into main Jan 4, 2026
5 checks passed
@AnnatarHe AnnatarHe deleted the feat/cc-statusline-agent-time branch January 4, 2026 17:38
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