Skip to content

fix: Claude usage parsing for CLI v2.x and trust prompt handling#486

Merged
Shironex merged 2 commits intov0.11.0rcfrom
fix/claude-usage-parsing
Jan 14, 2026
Merged

fix: Claude usage parsing for CLI v2.x and trust prompt handling#486
Shironex merged 2 commits intov0.11.0rcfrom
fix/claude-usage-parsing

Conversation

@Shironex
Copy link
Copy Markdown
Collaborator

Summary

  • Fix Claude usage popover showing 0% by using node-pty on all platforms (including macOS) for more reliable PTY handling
  • Use process.cwd() as working directory since project directory is likely already trusted by Claude CLI
  • Add detection for new trust prompt text variants in CLI v2.x ("Ready to code here", "permission to work")
  • Add specific error handling and UI message when trust prompt needs manual approval

Test plan

  • Verify Claude usage popover shows correct percentages on macOS
  • Verify trust prompt error message appears when folder permission is needed
  • Test on Windows/Linux (existing code path, should still work)

🤖 Generated with Claude Code

- Use node-pty on all platforms instead of expect on macOS for more reliable PTY handling
- Use process.cwd() as working directory (project dir is likely already trusted)
- Add detection for new trust prompt text variants ("Ready to code here", "permission to work")
- Add specific error handling for trust prompt pending state
- Show helpful UI message when trust prompt needs manual approval

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 14, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown
Contributor

Summary of Changes

Hello @Shironex, 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 integration with the Claude CLI by addressing inconsistencies in usage data reporting, particularly on macOS, and improving the robustness of handling trust prompts. The changes aim to provide a more stable and informative experience for users interacting with the Claude CLI through the application, ensuring correct usage display and clear guidance for necessary permissions.

Highlights

  • Reliable Claude Usage Parsing: Standardized the Claude usage command execution to use node-pty across all platforms, including macOS, to resolve issues where the Claude usage popover might display 0% due to unreliable PTY handling.
  • Improved Trust Prompt Handling: Updated the Claude CLI interaction to use process.cwd() as the working directory, assuming it's already trusted, and added detection for new trust prompt text variants introduced in CLI v2.x (e.g., 'Ready to code here', 'permission to work').
  • Specific Error Feedback for Trust Prompts: Implemented dedicated error handling and UI messages to inform users when a Claude CLI trust prompt requires manual approval, guiding them to run 'claude' in their terminal to grant access.

🧠 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.

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
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 significantly improves the Claude CLI integration by standardizing PTY handling across platforms and enhancing trust prompt detection and user feedback. The changes address issues with usage parsing and provide clearer guidance to users when manual intervention is required for folder permissions. The refactoring to use node-pty consistently is a positive step towards more reliable operation.

Comment on lines +174 to +176
const workingDirectory = this.isWindows
? process.env.USERPROFILE || os.homedir() || 'C:\\'
: os.tmpdir();
: process.cwd();
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

The pull request description mentions, "Use process.cwd() as working directory since project directory is likely already trusted by Claude CLI." While the expectScript (used for macOS) was updated to process.cwd(), the executeClaudeUsageCommandPty function still uses process.env.USERPROFILE || os.homedir() || 'C:\' for Windows. This creates an inconsistency in the working directory logic across platforms. If the intention is to use the current working directory for all platforms to leverage existing trust, the Windows logic should also be updated to process.cwd() for consistency and to ensure the intended behavior.

      const workingDirectory = process.cwd();

Address PR review comment - use process.cwd() for Windows too instead of
USERPROFILE/homedir fallback for consistency.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@Shironex Shironex merged commit 3f8a8db into v0.11.0rc Jan 14, 2026
5 of 6 checks passed
@Shironex Shironex deleted the fix/claude-usage-parsing branch January 14, 2026 16:56
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