Skip to content

refactor(api): route geminiCli explicitly to the Anthropic handler - #1441

Open
easonLiangWorldedtech wants to merge 2 commits into
Zoo-Code-Org:mainfrom
easonLiangWorldedtech:fix/issue-1029-geminicli-explicit-routing
Open

refactor(api): route geminiCli explicitly to the Anthropic handler#1441
easonLiangWorldedtech wants to merge 2 commits into
Zoo-Code-Org:mainfrom
easonLiangWorldedtech:fix/issue-1029-geminicli-explicit-routing

Conversation

@easonLiangWorldedtech

Copy link
Copy Markdown
Contributor

Related GitHub Issue

Closes: #1029

Description

geminiCli was the only provider without an explicit case in buildApiHandler (src/api/index.ts), so it silently fell through to the default AnthropicHandler. Per the issue (and its proposed approach), this PR makes the routing explicit without changing runtime behavior and without introducing a dedicated handler:

  • src/api/index.ts — adds case providerIdentifiers.geminiCli: return new AnthropicHandler(options) immediately before the default branch, with a comment documenting that the Anthropic handler is intentional until a dedicated Gemini CLI handler exists.
  • src/api/__tests__/index.spec.ts — the existing factory tests already pin geminiCli → AnthropicHandler (via the expectedHandlers map exercised with it.each); the inline comment is updated to reflect that the routing is now explicit.

Test Procedure

  • pnpm --filter zoo-code test api/__tests__/index.spec.ts → 40/40 pass (the parameterized returns the expected handler for %s case includes gemini-cli).
  • pnpm --dir src exec tsc --noEmit → clean.
  • pnpm --dir src exec eslint --max-warnings=0 api/index.ts api/__tests__/index.spec.ts → clean.
  • Behavior check: the new case returns the exact same constructor as the previous fall-through, so routing output is unchanged.

Pre-Submission Checklist

  • Issue Linked: This PR is linked to an approved GitHub Issue (see "Related GitHub Issue" above).
  • Scope: My changes are focused on the linked issue (one major feature/fix per PR).
  • Self-Review: I have performed a thorough self-review of my code.
  • Testing: New and/or updated tests have been added to cover my changes (if applicable).
  • Visual Snapshot (UI changes only): N/A — no UI change.
  • Documentation Impact: No user-facing documentation changes required.
  • Contribution Guidelines: I have read and agree to the Contributor Guidelines.

Visual Snapshots

N/A — no rendered UI surface.

Videos (interaction / animation only)

N/A.

Documentation Updates

  • No documentation updates are required.

Additional Notes

None — intentionally minimal per the issue's acceptance criteria (explicit case + documentation comment, runtime routing unchanged).

Get in Touch

easonLiangWorldedtech

…oo-Code-Org#1029)

buildApiHandler had no case for geminiCli, so the provider silently fell
through to the default Anthropic handler. Add an explicit case with a
comment documenting the intentional fallback until a dedicated Gemini CLI
handler exists. Runtime behavior is unchanged; the existing factory tests
already pin geminiCli to AnthropicHandler, and the spec comment now
reflects that the routing is explicit.
@coderabbitai

coderabbitai Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Team

Run ID: 644405b4-ec5f-4370-97e8-cb847129331a

📥 Commits

Reviewing files that changed from the base of the PR and between a5f4192 and a5f263b.

📒 Files selected for processing (2)
  • src/api/__tests__/index.spec.ts
  • src/api/index.ts

Included review availability: Your plan provides up to 4 included reviews per hour; 3 remain after this review.

📜 Recent review details
🧰 Additional context used
📓 Path-based instructions (8)
Treat model, provider, MCP, path, command, and tool data as untrusted. Check approval and allowlist bypasses, injection and traversal risks, secrets/PII exposure in logs, abort and stream behavior, retries, provider compatibility, and enfor...

⚙️ CodeRabbit configuration file

Files:

  • src/api/__tests__/index.spec.ts
  • src/api/index.ts
Require regression coverage at the lowest valid harness with behavior-focused assertions, including relevant negative, error, false/unset, and boundary cases. Check cleanup and deterministic async behavior and prefer shared typed test helpe...

⚙️ CodeRabbit configuration file

Files:

  • src/api/__tests__/index.spec.ts
Check strict typing and exhaustive behavior across normal, boundary, error, cancellation, retry, and compatibility paths. Verify promises and errors are handled, existing helpers are reused, and new code introduces no `any`, unjustified dou...

⚙️ CodeRabbit configuration file

Files:

  • src/api/__tests__/index.spec.ts
  • src/api/index.ts
Verify extension/webview contracts, cancellation and error propagation, VS Code lifecycle correctness, and behavior under retries and partial failure. Check listeners, resources, and providers are disposed without stale state or duplicate w...

⚙️ CodeRabbit configuration file

Files:

  • src/api/__tests__/index.spec.ts
  • src/api/index.ts
Act as an adversarial second-opinion reviewer. Verify PR claims against implementation, contracts, and tests. Trace changed inputs through normal, boundary, error, cancellation, retry, and default paths and their consumers. Seek plausible c...

⚙️ CodeRabbit configuration file

Files:

  • src/api/__tests__/index.spec.ts
  • src/api/index.ts
Add focused tests for UI binding and save behavior, persistence or normalization, and the value returned by `getStateToPostToWebview()`, including true and false/unset cases when defaults could hide omissions.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/api/__tests__/index.spec.ts
Fix lint violations in new TypeScript code instead of suppressing them.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/api/__tests__/index.spec.ts
  • src/api/index.ts
After editing a file, run ESLint with pruning and zero warnings for that relative file, and confirm its suppression count did not increase.

📄 CodeRabbit inference engine (AGENTS.md)

Files:

  • src/api/__tests__/index.spec.ts
  • src/api/index.ts
🔇 Additional comments (2)
src/api/index.ts (1)

238-242: LGTM!

src/api/__tests__/index.spec.ts (1)

80-80: LGTM!


📝 Walkthrough

Summary by CodeRabbit

  • Refactor
    • Clarified provider routing so Gemini CLI requests are explicitly handled through the Anthropic integration.
  • Tests
    • Updated test documentation to reflect the explicit Gemini CLI routing behavior.

Walkthrough

buildApiHandler now explicitly maps geminiCli to AnthropicHandler. The test comment reflects this routing. Runtime behavior remains unchanged.

Changes

Gemini CLI routing

Layer / File(s) Summary
Explicit handler routing
src/api/index.ts, src/api/__tests__/index.spec.ts
buildApiHandler adds an explicit geminiCli case that returns AnthropicHandler. The test comment documents the mapping.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Merge Risk: ⚪ Minimal · up to a5f26

Gemini CLI requests continue using the same Anthropic handler, with only the routing declaration made explicit and documented. No actionable merge-blocking risk remains after the reported tests and checks.

Suggested reviewers: edelauna

🚥 Pre-merge checks | ✅ 6 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (6 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: explicit routing of the Gemini CLI provider to the Anthropic handler.
Description check ✅ Passed The description includes the linked issue, implementation details, testing results, checklist, documentation impact, and relevant reviewer context.
Linked Issues check ✅ Passed The changes satisfy issue #1029 by adding an explicit geminiCli case, documenting the intentional AnthropicHandler fallback, preserving runtime behavior, and avoiding a dedicated handler.
Out of Scope Changes check ✅ Passed The changes are limited to the requested routing branch and its test comment. No unrelated or out-of-scope changes are present.
Regression Evidence ✅ Passed PASS: The PR adds an explicit providerIdentifiers.geminiCli branch that returns new AnthropicHandler(options). The parent revision routed the same provider through default, which returned the sa…
Trust And Persistence Invariants ✅ Passed PASS — The changed runtime path in src/api/index.ts only adds an explicit providerIdentifiers.geminiCli case that returns new AnthropicHandler(options), which matches the prior default branch. T…
Full details: Regression Evidence

Explanation

PASS: The PR adds an explicit providerIdentifiers.geminiCli branch that returns new AnthropicHandler(options). The parent revision routed the same provider through default, which returned the same constructor, so no runtime behavior changed. The focused buildApiHandler parameterized test includes providerIdentifiers.geminiCli with AnthropicHandler and invokes the factory. No affected error, negative, unset, or UI branch was introduced.

Full details: Trust And Persistence Invariants

Explanation

PASS — The changed runtime path in src/api/index.ts only adds an explicit providerIdentifiers.geminiCli case that returns new AnthropicHandler(options), which matches the prior default branch. The test change in src/api/__tests__/index.spec.ts changes only a comment. No changed path handles secrets or PII, executes unvalidated input, bypasses controls, writes persisted state, or allocates lifecycle resources.

  • Fix all pre-merge checks with AI
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

Some tools did not complete. Review the errors below.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

src/api/__tests__/index.spec.ts

ESLint skipped: missing config or dependency (missing-dependency). The ESLint configuration references a package that is not available in the sandbox.

src/api/index.ts

ESLint skipped: the matched ESLint configuration already failed (missing-dependency).


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.

@codecov

codecov Bot commented Aug 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@easonLiangWorldedtech

Copy link
Copy Markdown
Contributor Author

/coderabbit review

2 similar comments
@easonLiangWorldedtech

Copy link
Copy Markdown
Contributor Author

/coderabbit review

@easonLiangWorldedtech

Copy link
Copy Markdown
Contributor Author

/coderabbit review

@github-actions github-actions Bot added the awaiting-review PR changes are ready and waiting for maintainer re-review label Aug 29, 2026
@github-actions

github-actions Bot commented Aug 29, 2026

Copy link
Copy Markdown
Contributor

Review process

Thanks for contributing. This comment tracks the review sequence and the next action.

  1. Required CI checks pass.
  2. The workflow starts CodeRabbit automatically.
  3. For eligible human-authored PRs, CodeRabbit reviews and approves the latest commit.
  4. A human maintainer reviews and approves after CodeRabbit.

Current step: Required CI passed. Wait for CodeRabbit to approve the latest commit.

@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit awaiting-review PR changes are ready and waiting for maintainer re-review and removed awaiting-review PR changes are ready and waiting for maintainer re-review labels Aug 29, 2026
@github-actions github-actions Bot added coderabbit-review-active Required CI passed; CodeRabbit review is active and removed coderabbit-review-active Required CI passed; CodeRabbit review is active labels Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-coderabbit Waiting for CodeRabbit to approve the latest commit coderabbit-review-active Required CI passed; CodeRabbit review is active

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[ENHANCEMENT] Make Gemini CLI handler routing explicit

2 participants