Skip to content

armgit / avibe

Public Imported from GitHub
0

Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.

927 B
Raw Blame
import type { TunnelQualitySnapshot } from '../context/ApiContext';

export const getTunnelQualityDisplayState = (
  quality: Pick<TunnelQualitySnapshot, 'state' | 'grade'> | undefined,
  fresh: boolean,
): TunnelQualitySnapshot['grade'] | 'degraded' | 'recovering' => {
  if (!fresh || !quality) return 'unknown';
  if (quality.state === 'recovering') return 'recovering';
  if (quality.state === 'degraded') return 'degraded';
  return quality.grade;
};

export const getTunnelRequestPathDisplayState = (
  requestPath: TunnelQualitySnapshot['request_path'],
): 'absent' | 'measuring' | 'latency' | 'unavailable' => {
  if (!requestPath) return 'absent';
  if (
    requestPath.confidence !== 'low'
    && (requestPath.status === 'unavailable' || requestPath.success_count === 0)
  ) {
    return 'unavailable';
  }
  if (requestPath.confidence !== 'low' && requestPath.latency_ms) return 'latency';
  return 'measuring';
};