feat(ui): implement Extension UI API for footer status badges#20485
feat(ui): implement Extension UI API for footer status badges#20485anpag wants to merge 4 commits intogoogle-gemini:mainfrom
Conversation
Summary of ChangesHello @anpag, 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 enhances the Gemini CLI's extensibility by introducing a new UI API for dynamic footer status badges. This architectural change empowers extensions to contribute real-time, context-specific information directly to the user interface, moving away from hardcoded checks in the core. It improves modularity and provides a clean, non-intrusive way for users to monitor relevant environmental or application states. Highlights
Changelog
Activity
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
|
|
Updated the PR with comprehensive documentation for the new Extension UI API in |
There was a problem hiding this comment.
Code Review
This pull request introduces a new Extension UI API for adding status badges to the footer, enhancing the CLI's extensibility. However, it introduces a significant security risk by allowing extensions to execute arbitrary shell commands in the background every 30 seconds without explicit user consent, which could be exploited by malicious extensions. Additionally, a critical race condition in the badge fetching logic could lead to non-deterministic UI behavior and issues with stable React keys.
| const { stdout } = await spawnAsync( | ||
| badgeConfig.command, | ||
| badgeConfig.args ?? [], | ||
| ); |
There was a problem hiding this comment.
This section introduces a high security risk by using spawnAsync to execute arbitrary commands from extension configurations every 30 seconds without explicit user consent. Malicious extensions could exploit this to run harmful commands. To remediate, update the extension installation logic to detect ui.badges and require explicit user consent, showing the exact commands. Also, consider restricting allowed commands or sandboxing scripts, and notify users about background command execution. Furthermore, there's a race condition in how newBadges is populated. The fetchBadges function mutates the newBadges array concurrently, leading to non-deterministic badge ordering and issues with stable React keys. A safer pattern involves each promise resolving with a complete badge object (including a stable key) before collection. This also requires updating the StatusBadge interface in packages/cli/src/ui/contexts/UIStateContext.tsx to include a key property, which should then be used in packages/cli/src/ui/components/Footer.tsx.
References
- Security checks, such as an extension allowlist, should be implemented in a 'fail-closed' manner. If an item's validity cannot be verified (e.g., due to missing metadata), it should be rejected by default.
- To resolve race conditions between tool synchronization and system instruction updates, prefer making the tool synchronization function (
syncPlanModeTools) synchronous instead of managing asynchronicity with promise chaining.
|
Thanks for the review! I've updated the PR to address the concerns:
|
Summary
This PR introduces a new Extension UI API that allows Gemini CLI extensions to contribute dynamic "status badges" to the application's footer.
Instead of hardcoding specific environment checks (like gcloud or venv) into the core, this architectural change empowers the extension ecosystem to surface relevant context visually to the user in a clean, non-intrusive way.
Details
1. Schema Extensions
uicontributions toGeminiCLIExtensionandExtensionConfig.badgesarray ingemini-extension.json:2. Implementation
useExtensionStatusBadges.ts: A generic hook that discovers active extensions, executes their status commands asynchronously, and caches the results.Footer.tsxto map over and render these extension-provided badges.3. Safety & Performance
spawnAsyncfor non-blocking command execution.Related Issues
Resolves #20476
Addresses the customization needs discussed in #8191
How to Validate
npm run build.ui.badgessection in its manifest.npm start.Pre-Merge Checklist