Skip to content

Leeroybrun/tmp/merge upstream 2026 01 16#11

Merged
leeroybrun merged 10 commits intomainfrom
leeroybrun/tmp/merge-upstream-2026-01-16
Jan 16, 2026
Merged

Leeroybrun/tmp/merge upstream 2026 01 16#11
leeroybrun merged 10 commits intomainfrom
leeroybrun/tmp/merge-upstream-2026-01-16

Conversation

@leeroybrun
Copy link
Owner

@leeroybrun leeroybrun commented Jan 16, 2026

Summary by CodeRabbit

  • Documentation

    • Updated README with Claude usage examples, Gemini authentication details, and new command references.
  • New Features

    • Added happy connect status command to display connection status for all vendors with user email information.
    • Added happy gemini project commands to manage Google Cloud Project configuration and linking.
    • Gemini now preserves conversation history when switching models for better continuity.
  • Improvements

    • Enhanced Gemini error handling with retry logic for transient failures and improved user guidance.
    • Improved model change detection in UI for accurate display synchronization.

✏️ Tip: You can customize this high-level summary in your review settings.

Scoteezy and others added 10 commits January 12, 2026 16:11
- Move AgentBackend, AgentRegistry to core/
- Create transport/ with TransportHandler abstraction
- Move Gemini-specific logic to GeminiTransport
- Create adapters/ for message transformation
- Create factories/ for high-level agent creation
- Rename AcpSdkBackend → AcpBackend
- Remove acp/utils.ts (merged into transport handlers)
…proved UX

ACP Integration:
- Add sendAgentMessage() for unified Agent Communication Protocol format
- Migrate all Gemini messages from sendCodexMessage to sendAgentMessage(gemini, ...)
- Add ACP message types: task_started, task_complete, turn_aborted, permission-request

Model Selection:
- Support dynamic model selection from frontend via meta.model
- Save selected model to ~/.gemini/config.json for persistence

Permission Handling:
- Integrate GeminiPermissionHandler with permission modes (default, read-only, safe-yolo, yolo)
- Add permission ID to tool call ID mapping for proper UI tracking

Message Flow Improvements:
- Add waitForResponseComplete() to ensure all chunks received before task_complete
- Accumulate response chunks and send complete message once (fixes fragmentation)
- Fix status flickering by not resetting thinking on intermediate idle events

Error Handling:
- Add retry logic for empty response errors (up to 3 retries)
- Improve quota error handling: no retry, show reset time, suggest alternative model
- Better error messages for model not found, rate limits, quota exceeded

Tool Handling:
- Improve change_title detection from toolCallId pattern
- Add tool-result emission after permission approval
- Track hadToolCallInTurn for proper task_complete timing
- Add ConversationHistory class to track user/assistant messages
- Inject previous conversation context into new session on model change
- Allows seamless model switching without losing context
…ling

- Add `happy gemini project set/get` commands for Workspace accounts
- Store project ID per-account (linked to email)
- Show helpful error message for "Authentication required" with guide link
- Sync local ~/.gemini/oauth_creds.json on `happy connect gemini`
- Add `happy connect status` command to show vendor auth status
- Pass GOOGLE_CLOUD_PROJECT env var to Gemini SDK
codex: make abort graceful; force-close MCP on kill/exit
@leeroybrun leeroybrun merged commit f8dfd05 into main Jan 16, 2026
5 of 6 checks passed
@coderabbitai
Copy link

coderabbitai bot commented Jan 16, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This pull request refactors the ACP agent backend architecture by introducing a transport abstraction layer, standardizing agent message types, and integrating Google Cloud Project configuration for Gemini. It renames AcpSdkBackend to AcpBackend, adds comprehensive message adapters for mobile clients, updates CLI commands for vendor connection status and project management, and enhances Gemini integration with conversation history and improved error handling.

Changes

Cohort / File(s) Summary
ACP Backend Core Architecture
src/agent/acp/AcpBackend.ts, src/agent/acp/createAcpBackend.ts, src/agent/acp/index.ts, src/agent/acp/utils.ts
Refactors ACP backend from AcpSdkBackend to AcpBackend, introducing TransportHandler abstraction. Removes legacy utility functions (isInvestigationTool, determineToolName, getRealToolName, getToolCallTimeout) and shifts responsibility to transport handlers. Adds factory function createAcpBackend for backend instantiation. Updates public API surface with backward-compatibility aliases.
Transport Layer
src/agent/transport/TransportHandler.ts, src/agent/transport/DefaultTransport.ts, src/agent/transport/handlers/GeminiTransport.ts, src/agent/transport/handlers/index.ts, src/agent/transport/index.ts
Introduces comprehensive transport abstraction: TransportHandler interface defining initialization timeout, stdout/stderr handling, tool pattern recognition, and per-tool timeouts. Provides DefaultTransport with sensible baseline behaviors and GeminiTransport with Gemini-specific logic. Consolidates transport exports through index modules.
Agent Messaging System
src/agent/core/AgentMessage.ts, src/agent/core/AgentBackend.ts, src/agent/core/index.ts, src/agent/adapters/MobileMessageFormat.ts, src/agent/adapters/MessageAdapter.ts, src/agent/adapters/index.ts
Establishes standardized agent message types (ModelOutputMessage, ToolCallMessage, PermissionRequestMessage, etc.) with type guards and helpers. Adds MessageAdapter for converting internal messages to mobile-friendly payloads. Extends AgentBackend interface with optional waitForResponseComplete method. Centralizes message type exports through index modules.
Gemini Factory & Transport
src/agent/factories/gemini.ts, src/agent/factories/index.ts, src/agent/index.ts
Replaces AcpSdkBackend with AcpBackend in Gemini factory. Adds currentUserEmail option to GeminiBackendOptions and integrates Google Cloud Project configuration. Introduces Gemini-specific transport handler. Restructures factories barrel export and updates agent initialization to use factory registry.
Gemini Integration & State
src/gemini/runGemini.ts, src/gemini/utils/config.ts, src/gemini/utils/conversationHistory.ts
Refactors Gemini session management to use ACP-style agent messages instead of Codex-specific messages. Adds ConversationHistory utility to preserve context across model switches. Extends config to track Google Cloud Project (googleCloudProject, googleCloudProjectEmail) with save function. Adds retry logic with backoff, improves error handling, and defers message sending until turn completion.
API Session
src/api/apiSession.ts, src/utils/offlineSessionStub.ts
Introduces ACPMessageData union type and ACPProvider type. Updates sendAgentMessage signature to use provider and ACP payload structure (type: 'acp', provider, data). Removes internal canSend helper in favor of direct socket checks. Adds sendAgentMessage to offline session stub.
CLI Command Enhancements
src/commands/connect.ts, src/commands/connect/utils.ts, src/index.ts
Adds status subcommand to show connection status across vendors (Gemini, Codex, Claude) with expiration tracking. Introduces updateLocalGeminiCredentials to persist OAuth tokens locally. Adds JWT payload decoder for extracting user email from id_token. Implements happy gemini project subcommands (set, get) for Google Cloud Project configuration and persistence.
Documentation
README.md
Expands with comprehensive Gemini CLI section including authentication flow for Personal Google Accounts and Google Workspace, new subcommand documentation (main, utility, connect, gemini), environment variable references, and usage examples.
UI Updates
src/ui/ink/GeminiDisplay.tsx
Adjusts model message detection to use the latest (most recent) system message from reversed list instead of the first occurrence.

Sequence Diagram(s)

sequenceDiagram
    participant CLI as CLI User
    participant Agent as Gemini Agent
    participant Transport as Transport Handler
    participant Backend as ACP Backend
    participant LLM as Gemini LLM

    CLI->>Agent: Send prompt via runGemini
    Agent->>Backend: Initialize with transportHandler
    Backend->>Transport: getInitTimeout()
    Transport-->>Backend: timeout value
    
    Agent->>Backend: sendPrompt(prompt)
    Backend->>Agent: Emits status 'starting'
    
    Backend->>LLM: Execute with stdout/stderr
    LLM-->>Backend: tool-call response (JSON)
    
    Backend->>Transport: filterStdoutLine(line)
    Transport-->>Backend: filtered JSON or null
    Backend->>Agent: Emits tool-call message
    
    Agent->>Backend: handleToolResult(result)
    Backend->>Agent: Emits tool-result message
    
    Backend->>Transport: handleStderr(text, context)
    Transport-->>Backend: possible error message
    
    Backend->>Agent: Emits status 'idle'
    Agent->>Backend: waitForResponseComplete()
    Backend-->>Agent: Promise resolves when complete
    Agent->>CLI: Display final response
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~50 minutes

The changes introduce a well-structured transport abstraction layer and comprehensive agent messaging system across multiple files. While individual new type definitions are straightforward, the refactoring involves significant logic migration in AcpBackend.ts, runGemini.ts, and apiSession.ts. The integration spans multiple interconnected components (factories, transports, message adapters) requiring careful verification of data flow and backward compatibility. The Gemini-specific enhancements add conversation history management and enhanced error handling with retry logic, increasing cognitive load during review.

Possibly related PRs

  • Sync upstream main 12-01-2016 #1: Overlaps on shared agent session infrastructure including src/utils/offlineSessionStub.ts modifications and offline reconnection utilities, suggesting coordinated changes to the session management layer.

Poem

🐰 The transport hops along with style,
Messages now dance the ACP way,
Gemini learns to keep its chat awhile,
As backends refactor—hip-hip-hooray!
From SDK to Backend's grace we go,

✨ Finishing touches
  • 📝 Generate docstrings


📜 Recent review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e2ef9d8 and e5ba068.

📒 Files selected for processing (29)
  • README.md
  • src/agent/acp/AcpBackend.ts
  • src/agent/acp/createAcpBackend.ts
  • src/agent/acp/index.ts
  • src/agent/acp/utils.ts
  • src/agent/adapters/MessageAdapter.ts
  • src/agent/adapters/MobileMessageFormat.ts
  • src/agent/adapters/index.ts
  • src/agent/core/AgentBackend.ts
  • src/agent/core/AgentMessage.ts
  • src/agent/core/AgentRegistry.ts
  • src/agent/core/index.ts
  • src/agent/factories/gemini.ts
  • src/agent/factories/index.ts
  • src/agent/index.ts
  • src/agent/transport/DefaultTransport.ts
  • src/agent/transport/TransportHandler.ts
  • src/agent/transport/handlers/GeminiTransport.ts
  • src/agent/transport/handlers/index.ts
  • src/agent/transport/index.ts
  • src/api/apiSession.ts
  • src/commands/connect.ts
  • src/commands/connect/utils.ts
  • src/gemini/runGemini.ts
  • src/gemini/utils/config.ts
  • src/gemini/utils/conversationHistory.ts
  • src/index.ts
  • src/ui/ink/GeminiDisplay.tsx
  • src/utils/offlineSessionStub.ts

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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

Summary of Changes

Hello @leeroybrun, 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 introduces significant architectural improvements to the agent backend, primarily by refactoring the ACP implementation to be more modular and extensible through the use of TransportHandlers. This change enables more robust and agent-specific handling of communication protocols, leading to a more stable and feature-rich experience, especially for the Gemini integration. Additionally, new mechanisms for standardizing messages for the mobile application and managing Gemini-specific configurations have been implemented, alongside updated documentation to guide users through these enhancements.

Highlights

  • ACP Backend Refactoring: The core Agent Client Protocol (ACP) backend (AcpSdkBackend renamed to AcpBackend) has been significantly refactored to introduce a TransportHandler interface. This allows for agent-specific logic (like stdout filtering, stderr handling, and tool name detection) to be modularized and injected, improving extensibility and maintainability.
  • Enhanced Gemini Integration: The Gemini agent now features improved error handling with retry logic for transient API issues, better detection of quota and authentication errors, and the introduction of conversation history to maintain context across model changes. New commands (happy gemini project set/get) have been added for managing Google Cloud Projects, crucial for Workspace accounts.
  • Mobile Message Adapters: New MessageAdapter and MobileMessageFormat modules have been introduced to standardize the transformation of internal AgentMessage types into a consistent format expected by the Happy mobile application, ensuring seamless communication and UI updates.
  • Documentation Updates: The README.md has been updated to reflect the new Gemini commands, usage instructions, and authentication requirements, providing clearer guidance for users.
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

@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 is an impressive and substantial pull request that significantly refactors the agent backend architecture. The introduction of the TransportHandler abstraction is an excellent design choice that greatly improves modularity and maintainability by separating generic ACP logic from agent-specific implementations. The accompanying reorganization of the src/agent directory into core, factories, transport, and adapters brings a much clearer structure to the codebase.

Beyond the refactoring, this PR introduces several valuable features for the Gemini integration, including robust retry logic for API calls, context preservation across model changes, and support for Google Workspace accounts via project ID configuration. The CLI enhancements, such as happy connect status and happy gemini project, are also great additions for user experience.

I have one main piece of feedback regarding a type mismatch in the newly introduced ACPMessageData type, which could affect message payloads. Overall, this is a high-quality contribution that moves the project forward in a very positive direction.

*/
export type ACPMessageData =
// Core message types
| { type: 'message'; message: string }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The message type in ACPMessageData appears to be missing the id and options properties. In src/gemini/runGemini.ts, a payload is constructed with these properties and passed to sendAgentMessage, which expects a body of type ACPMessageData. This creates a type mismatch.

Given that most other types within ACPMessageData include an id, its absence here seems like a potential oversight. The options property is also important for the mobile UI.

To ensure type safety and correct data transmission, please consider updating this type definition.

Suggested change
| { type: 'message'; message: string }
| { type: 'message'; message: string; id: string; options?: unknown }

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.

3 participants