Skip to content

armgit / orca

Public Imported from GitHub
0

Orca is the place for working with a fleet of agents (e.g. Grok Bot, Claude Code). Run any coding agent with your own subscription. Available on desktop, mobile and remote runtime.

1.4 KB
Raw Blame
import type { ExecutionHostId } from '../../../src/shared/execution-host'
import {
  getExecutionHostHealthLabel,
  getSshConnectionHealth,
  type ExecutionHostHealth
} from '../../../src/shared/execution-host-health'
import { sshTargetSummaryHostId } from '../../../src/shared/worktree/host-context-labels'
import { isSshConnectionStatus } from '../transport/ssh-connection-status-arms'

// Mirror desktop SSH health; older hosts without lifecycle and unknown statuses provide no verdict.
export function buildSshHostHealthById(
  sshTargets: readonly { id: string; connected?: boolean; connectionStatus?: string }[]
): Map<ExecutionHostId, ExecutionHostHealth> {
  const health = new Map<ExecutionHostId, ExecutionHostHealth>()
  for (const target of sshTargets) {
    const status = target.connectionStatus
    if (
      target.connected === undefined ||
      (status !== undefined && !isSshConnectionStatus(status))
    ) {
      continue
    }
    health.set(sshTargetSummaryHostId(target.id), getSshConnectionHealth(status))
  }
  return health
}

/** The word a row's host badge adds; a healthy or local host keeps the bare name. */
export function getHostHealthBadgeLabel(
  health: ExecutionHostHealth | undefined
): string | undefined {
  if (health === undefined || health === 'local' || health === 'available') {
    return undefined
  }
  return getExecutionHostHealthLabel(health)
}