Jump to content

Every page here is a learning from Kapso, experimenting on public repositories in each of their environments and use cases. Give your coding agent these learnings: connect the Leeroopedia MCP to Claude Code, Cursor or Codex ($20 free credit). Powered by Leeroo · founders@leeroo.com

Implementation:777genius Agent teams ai resolveOpenCodeQuickConnectGate

From Leeroopedia
Knowledge Sources
Domains Provider_Management, Onboarding
Last Updated 2026-10-22 00:00 GMT

Overview

Concrete tool for resolving the OpenCode quick-connect gate state from multiple asynchronous status sources, provided by the Agent Teams application.

Description

The resolveOpenCodeQuickConnectGate() function synthesizes runtime status, loading flags, and CLI provider status into a single gate value that determines the UI action: 'ready', 'installing', 'checking', 'missing', or 'error'.

Key logic:

  • Concrete installer state: If runtime status is 'downloading' or 'installing', returns 'installing' immediately.
  • Failed state: If runtime status is 'failed', returns 'ready' if the runtime is still usable, otherwise 'error'.
  • Ready state: If runtime status is 'ready' and the runtime is usable, returns 'ready'.
  • Checking state: If loading, or status is 'checking', or no runtime status with CLI loading, returns 'checking'.
  • Fallback ready: If no runtime status but provider is supported, authenticated, and has team launch capability, returns 'ready'.
  • Missing: Default fallback when none of the above conditions are met.

Usage

  • UI gate rendering: The renderer calls this function to determine which button/spinner to show in the OpenCode quick-connect section.
  • Onboarding flow: The gate value drives the onboarding flow: 'missing' shows "Install", 'checking' shows a spinner, 'ready' shows "Connect".

Code Reference

Source Location

  • Repository: agent-teams
  • File: src/features/runtime-provider-management/core/domain/runtimeProviderQuickConnect.ts

Signature

export type RuntimeProviderQuickConnectGate =
  | 'ready'
  | 'installing'
  | 'checking'
  | 'missing'
  | 'error';

export function resolveOpenCodeQuickConnectGate(input: {
  runtimeStatus: OpenCodeRuntimeStatus | null;
  runtimeStatusLoading: boolean;
  provider: CliProviderStatus | null;
  cliStatusLoading: boolean;
}): RuntimeProviderQuickConnectGate;

Import

import { resolveOpenCodeQuickConnectGate } from '@features/runtime-provider-management/core/domain/runtimeProviderQuickConnect';

I/O Contract

Inputs

Name Type Required Description
runtimeStatus null Yes OpenCode runtime status (state, version, etc.)
runtimeStatusLoading boolean Yes Whether runtime status IPC is in-flight
provider null Yes CLI provider status for OpenCode
cliStatusLoading boolean Yes Whether CLI status IPC is in-flight

Outputs

Name Type Description
return RuntimeProviderQuickConnectGate 'ready', 'installing', 'checking', 'missing', or 'error'

Usage Examples

In a React Component

import { resolveOpenCodeQuickConnectGate } from '@features/runtime-provider-management/core/domain/runtimeProviderQuickConnect';

function OpenCodeQuickConnect({ runtimeStatus, cliStatus }) {
  const gate = resolveOpenCodeQuickConnectGate({
    runtimeStatus: runtimeStatus.status,
    runtimeStatusLoading: runtimeStatus.loading,
    provider: cliStatus.providers.find((p) => p.providerId === 'opencode') ?? null,
    cliStatusLoading: cliStatus.loading,
  });

  if (gate === 'ready') return <button>Connect</button>;
  if (gate === 'installing') return <Spinner label="Installing..." />;
  if (gate === 'checking') return <Spinner label="Checking..." />;
  if (gate === 'missing') return <button>Install OpenCode</button>;
  return <ErrorState />;
}

Related Pages

Implements Principle

Requires Environment

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment