Skip to content

refactor: remove legacy Gemini CLI code and related components - #5924

Closed
siddqamar wants to merge 2 commits into
stablyai:mainfrom
siddqamar:audit/legacy-gemini-cli
Closed

siddqamar wants to merge 2 commits into
stablyai:mainfrom
siddqamar:audit/legacy-gemini-cli

Conversation

@siddqamar

@siddqamar siddqamar commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Removed legacy Gemini CLI-related code and cleaned up associated files, folders, and references throughout the codebase following the deprecation of Gemini CLI. This change removes obsolete implementation details and reduces maintenance overhead.

Screenshots

No visual change.

Testing

  • pnpm lint
  • pnpm typecheck
  • pnpm test
  • pnpm build
  • Added or updated high-quality tests that would catch regressions, or explained why tests were not needed

Tests not run as part of this cleanup-only change.

AI Review Report

The changes were implemented with the assistance of an AI coding agent and primarily focused on removing deprecated Gemini CLI-related code, files, and references.

Review focus areas:

  • Removal of unused and obsolete code paths
  • Detection of stale imports and references
  • Cleanup of related files and directories
  • Verification that removed components were no longer required

No major issues were identified during the cleanup process. Manual verification of application behavior and platform-specific functionality is still recommended.

Cross-platform compatibility review was not independently verified and may require additional validation on macOS, Linux, and Windows.

Security Audit

This change primarily removes deprecated functionality and does not intentionally introduce new authentication, authorization, command execution, IPC, dependency, or secret-management logic.

No dedicated security audit was performed. Additional review is recommended before release if any removed components previously interacted with authentication flows, local file access, shell commands, or external services.

Notes

  • Removes legacy Gemini CLI support from the codebase.
  • Intended as a maintenance and cleanup change.
  • Additional validation may be required to ensure no remaining references to removed components exist.

Open in Stage

ELI5

Removes leftover Gemini CLI code after deprecation. Cleanup only; no intentional user-facing feature change.

@ghost

ghost commented Jun 20, 2026 •

Copy link
Copy Markdown

Ready to review this PR? Stage has broken it down into 7 individual chapters for you:

Title
1 Remove Gemini from shared types and telemetry
2 Delete Gemini rate limit fetching logic
3 Clean up RateLimitService and related tests
4 Delete Gemini agent hook service
5 Unwire Gemini hooks from main process and IPC
6 Remove Gemini session parsing logic
7 Remove Gemini from status bar UI
Open in Stage

Chapters generated by Stage for commit 0262622 on Jun 20, 2026 8:57pm UTC.

@coderabbitai

coderabbitai Bot commented Jun 20, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

This pull request removes all Gemini agent support from the codebase. Shared type unions (TuiAgent, StatusBarItem, ProviderRateLimits.provider, WellKnownAgentType, RateLimitState) drop the 'gemini' member; GlobalSettings removes geminiCliOAuthEnabled and adds opencodeWorkspaceId; telemetry schemas remove Gemini from AGENT_KIND_VALUES and SETTINGS_CHANGED_WHITELIST. The hook service removes gemini from MANAGED_AGENT_HOOK_INSTALLERS, LOCAL_MANAGED_HOOK_REMOVERS, and LOCAL_MANAGED_HOOK_STATUS_READERS registries and deletes all geminiHookService references from remote installers, IPC handlers, and the preload API bridge. AI Vault session scanning drops Gemini session discovery, directory constants, and parser function exports. The RateLimitService removes Gemini from its fetch cycle, state management, and settings resolver. Status bar UI components remove Gemini icon rendering, visibility checks, and provider detail blocks; corresponding test coverage for rate limit, agent gating, provider visibility, and tooltip functionality is updated to exclude or replace Gemini assertions.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Description check ⚠️ Warning The description matches the template overall, but the AI Review Report does not explicitly confirm macOS, Linux, and Windows cross-platform checks. Add a clear cross-platform review statement covering macOS, Linux, and Windows, including shortcuts, labels, paths, shell behavior, and Electron differences.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and accurately describes the main change: removal of legacy Gemini CLI code and related components throughout the codebase.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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.

@coderabbitai coderabbitai Bot left a comment

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/shared/rate-limit-types.ts (1)

69-70: ⚠️ Potential issue | 🔴 Critical

Remove the gemini: null field from RateLimitState initializations.

The RateLimitState type in src/shared/rate-limit-types.ts does not include a gemini field. However, at least two initialization sites still include it:

  • src/renderer/src/web/web-preload-api.ts:2304-2314 (line 2307)
  • src/renderer/src/store/slices/rate-limits.ts:18-28 (line 21)

Both need the gemini: null field removed to match the type definition.


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: ec7ab632-eaa4-4351-a185-956d59a71f05

📥 Commits

Reviewing files that changed from the base of the PR and between c3bff64 and 262287d8e777c66c7a8e91044491d6dcfa575377.

📒 Files selected for processing (29)
  • src/main/agent-hooks/managed-agent-hook-controls.ts
  • src/main/agent-hooks/remote-managed-hook-installers.ts
  • src/main/ai-vault/session-scanner-agent-parser.ts
  • src/main/ai-vault/session-scanner-primary-parsers.ts
  • src/main/ai-vault/session-scanner-types.ts
  • src/main/ai-vault/session-scanner.test.ts
  • src/main/ai-vault/session-scanner.ts
  • src/main/gemini/hook-service.test.ts
  • src/main/gemini/hook-service.ts
  • src/main/index.ts
  • src/main/ipc/agent-hooks.ts
  • src/main/rate-limits/gemini-bucket-formatting.test.ts
  • src/main/rate-limits/gemini-bucket-formatting.ts
  • src/main/rate-limits/gemini-cli-oauth-extractor.ts
  • src/main/rate-limits/gemini-oauth-sources.ts
  • src/main/rate-limits/gemini-usage-fetcher.fallback.test.ts
  • src/main/rate-limits/gemini-usage-fetcher.test-fixtures.ts
  • src/main/rate-limits/gemini-usage-fetcher.test.ts
  • src/main/rate-limits/gemini-usage-fetcher.ts
  • src/main/rate-limits/service.test.ts
  • src/main/rate-limits/service.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/shared/agent-hook-types.ts
  • src/shared/agent-status-types.ts
  • src/shared/rate-limit-types.ts
  • src/shared/status-bar-defaults.ts
  • src/shared/telemetry-events.ts
  • src/shared/types.ts
💤 Files with no reviewable changes (23)
  • src/main/rate-limits/gemini-bucket-formatting.test.ts
  • src/shared/status-bar-defaults.ts
  • src/main/gemini/hook-service.test.ts
  • src/shared/agent-hook-types.ts
  • src/main/rate-limits/gemini-cli-oauth-extractor.ts
  • src/main/rate-limits/gemini-oauth-sources.ts
  • src/preload/api-types.ts
  • src/main/rate-limits/gemini-usage-fetcher.test.ts
  • src/main/rate-limits/gemini-usage-fetcher.fallback.test.ts
  • src/main/ai-vault/session-scanner-types.ts
  • src/main/ai-vault/session-scanner-agent-parser.ts
  • src/preload/index.ts
  • src/main/rate-limits/gemini-usage-fetcher.ts
  • src/main/rate-limits/gemini-bucket-formatting.ts
  • src/main/rate-limits/gemini-usage-fetcher.test-fixtures.ts
  • src/shared/agent-status-types.ts
  • src/main/rate-limits/service.ts
  • src/main/ipc/agent-hooks.ts
  • src/shared/telemetry-events.ts
  • src/shared/types.ts
  • src/main/ai-vault/session-scanner.ts
  • src/main/gemini/hook-service.ts
  • src/main/ai-vault/session-scanner-primary-parsers.ts

@siddqamar

Copy link
Copy Markdown
Contributor Author

Code rabbit raised concerns about a few non gemini cli related code removal. I am currently reviewing those changes and will push a follow up commit if any unrelated deletions are identified

@siddqamar
siddqamar force-pushed the audit/legacy-gemini-cli branch from 262287d to 325f8a6 Compare June 20, 2026 20:24

@coderabbitai coderabbitai Bot left a comment

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.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
src/main/rate-limits/service.ts (2)

934-948: ⚠️ Potential issue | 🔴 Critical

Fix remaining Gemini references in status-bar components after service state removal.

The service no longer provides a gemini field, but multiple renderer components still reference it:

  • status-bar-provider-visibility.ts: Accesses providers.gemini (lines 128, 138), checks settings?.geminiCliOAuthEnabled (line 59), and handles providerId === 'gemini' (line 77)
  • StatusBar.tsx: Destructures gemini from rateLimits (line 1799), passes it to getVisibleUsageProvider (line 1808), and checks gemini?.status (line 1848)
  • tooltip.tsx: Handles provider === 'gemini' (lines 76, 95)
  • status-bar-agent-gating.ts: Includes 'gemini' in CLI_GATED_ITEMS (line 9)

These unresolved references will cause runtime errors. Remove all Gemini-related code from the status-bar components to complete the removal.


98-147: ⚠️ Potential issue | 🔴 Critical

Update setSettingsResolver caller in src/main/index.ts to return only the required properties.

The call at line 1331 passes store!.getSettings() which returns the full GlobalSettings object, but the narrowed signature expects only { opencodeSessionCookie: string; opencodeWorkspaceId: string }. Update the caller to extract and return only these two properties:

Suggested fix
rateLimits.setSettingsResolver(() => {
  const settings = store!.getSettings()
  return {
    opencodeSessionCookie: settings.opencodeSessionCookie,
    opencodeWorkspaceId: settings.opencodeWorkspaceId
  }
})

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 9381d793-fe6e-463d-b9db-205d75022712

📥 Commits

Reviewing files that changed from the base of the PR and between 262287d8e777c66c7a8e91044491d6dcfa575377 and 325f8a6.

📒 Files selected for processing (29)
  • src/main/agent-hooks/managed-agent-hook-controls.ts
  • src/main/agent-hooks/remote-managed-hook-installers.ts
  • src/main/ai-vault/session-scanner-agent-parser.ts
  • src/main/ai-vault/session-scanner-primary-parsers.ts
  • src/main/ai-vault/session-scanner-types.ts
  • src/main/ai-vault/session-scanner.test.ts
  • src/main/ai-vault/session-scanner.ts
  • src/main/gemini/hook-service.test.ts
  • src/main/gemini/hook-service.ts
  • src/main/index.ts
  • src/main/ipc/agent-hooks.ts
  • src/main/rate-limits/gemini-bucket-formatting.test.ts
  • src/main/rate-limits/gemini-bucket-formatting.ts
  • src/main/rate-limits/gemini-cli-oauth-extractor.ts
  • src/main/rate-limits/gemini-oauth-sources.ts
  • src/main/rate-limits/gemini-usage-fetcher.fallback.test.ts
  • src/main/rate-limits/gemini-usage-fetcher.test-fixtures.ts
  • src/main/rate-limits/gemini-usage-fetcher.test.ts
  • src/main/rate-limits/gemini-usage-fetcher.ts
  • src/main/rate-limits/service.test.ts
  • src/main/rate-limits/service.ts
  • src/preload/api-types.ts
  • src/preload/index.ts
  • src/shared/agent-hook-types.ts
  • src/shared/agent-status-types.ts
  • src/shared/rate-limit-types.ts
  • src/shared/status-bar-defaults.ts
  • src/shared/telemetry-events.ts
  • src/shared/types.ts
💤 Files with no reviewable changes (22)
  • src/main/ai-vault/session-scanner-types.ts
  • src/main/ai-vault/session-scanner-agent-parser.ts
  • src/main/rate-limits/gemini-bucket-formatting.ts
  • src/main/rate-limits/gemini-usage-fetcher.test-fixtures.ts
  • src/shared/status-bar-defaults.ts
  • src/main/gemini/hook-service.ts
  • src/main/rate-limits/gemini-usage-fetcher.fallback.test.ts
  • src/shared/agent-status-types.ts
  • src/main/rate-limits/gemini-usage-fetcher.ts
  • src/main/rate-limits/gemini-bucket-formatting.test.ts
  • src/shared/agent-hook-types.ts
  • src/preload/index.ts
  • src/preload/api-types.ts
  • src/main/ipc/agent-hooks.ts
  • src/main/rate-limits/gemini-oauth-sources.ts
  • src/main/rate-limits/gemini-usage-fetcher.test.ts
  • src/main/rate-limits/gemini-cli-oauth-extractor.ts
  • src/main/ai-vault/session-scanner-primary-parsers.ts
  • src/main/ai-vault/session-scanner.ts
  • src/main/gemini/hook-service.test.ts
  • src/shared/telemetry-events.ts
  • src/shared/types.ts
✅ Files skipped from review due to trivial changes (1)
  • src/main/index.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/main/agent-hooks/remote-managed-hook-installers.ts
  • src/main/ai-vault/session-scanner.test.ts
  • src/shared/rate-limit-types.ts
  • src/main/agent-hooks/managed-agent-hook-controls.ts

@siddqamar

Copy link
Copy Markdown
Contributor Author

I reviewed the code rabbit comment and pushed a follow-up fix. The branch has been updated accordingly.

- Remove Gemini CLI hook service and related Gemini-specific wiring.

- Delete rate-limit, automation, AI vault, preload, and agent-hook code paths.

- Remove shared enums, types, tests, and fixtures tied to discontinued CLI support.

- Restore non-Gemini shared rate-limit and agent-status code that was accidentally included in the cleanup.
- Remove the live Gemini usage bar and related status-bar gating.

- Remove Gemini from the empty-state CTA and provider visibility logic.

- Update the matching status-bar tests to reflect the cleanup.

- Leave the shared Gemini icon helper in place for settings UI usage.
@AmethystLiang

Copy link
Copy Markdown
Contributor

Thanks for the PR! Closing it for now as we'll have a new version based on the main, but will credit you as the commit author in that PR!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants