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.

1.2 KB
Raw Blame
export type VaultSandboxLocale = 'en' | 'zh';
export type VaultSandboxTheme = 'light' | 'dark';
export type VaultSandboxAppearance = {
  locale: VaultSandboxLocale;
  theme: VaultSandboxTheme;
};

const DEFAULT_APPEARANCE: VaultSandboxAppearance = { locale: 'en', theme: 'dark' };

let currentAppearance = DEFAULT_APPEARANCE;
const listeners = new Set<(appearance: VaultSandboxAppearance) => void>();

export function normalizeVaultSandboxLocale(language: string | undefined | null): VaultSandboxLocale {
  return language?.toLowerCase().startsWith('zh') ? 'zh' : 'en';
}

export function getVaultSandboxAppearance(): VaultSandboxAppearance {
  return currentAppearance;
}

export function setVaultSandboxAppearance(appearance: VaultSandboxAppearance): boolean {
  if (appearance.locale === currentAppearance.locale && appearance.theme === currentAppearance.theme) {
    return false;
  }
  currentAppearance = appearance;
  listeners.forEach((listener) => listener(currentAppearance));
  return true;
}

export function subscribeVaultSandboxAppearance(listener: (appearance: VaultSandboxAppearance) => void): () => void {
  listeners.add(listener);
  return () => listeners.delete(listener);
}