fix: Claude usage parsing for CLI v2.x and trust prompt handling#486
fix: Claude usage parsing for CLI v2.x and trust prompt handling#486
Conversation
- 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>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the Note Other AI code review bot(s) detectedCodeRabbit 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. Comment |
Summary of ChangesHello @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
🧠 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 AssistThe 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
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 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
|
There was a problem hiding this comment.
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.
| const workingDirectory = this.isWindows | ||
| ? process.env.USERPROFILE || os.homedir() || 'C:\\' | ||
| : os.tmpdir(); | ||
| : process.cwd(); |
There was a problem hiding this comment.
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>
Summary
process.cwd()as working directory since project directory is likely already trusted by Claude CLITest plan
🤖 Generated with Claude Code