Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Sources/CodexBar/Providers/Ollama/OllamaUIErrorMapper.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import CodexBarCore
import Foundation

struct OllamaUIErrorMapper {
static func userFacingMessage(
_ raw: String?,
localize: (String) -> String = L) -> String?
{
guard let raw else { return nil }
let trimmed = raw.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else { return nil }

if trimmed == OllamaUsageError.safariCookieAccessDenied.localizedDescription {
return localize("ollama_safari_cookie_access_hint")
}
if let browserName = self.browserName(
in: trimmed,
suffix: " cookie decryption was declined in Keychain; retry with a manual refresh.")
{
return String(format: localize("ollama_browser_cookie_decryption_denied"), browserName)
}
if let browserName = self.browserName(
in: trimmed,
suffix: " cookie decryption is disabled in CodexBar; enable Keychain access and refresh.")
{
return String(format: localize("ollama_browser_cookie_decryption_disabled"), browserName)
}
return trimmed
}

private static func browserName(in message: String, suffix: String) -> String? {
guard message.hasSuffix(suffix) else { return nil }
let name = String(message.dropLast(suffix.count)).trimmingCharacters(in: .whitespacesAndNewlines)
return name.isEmpty ? nil : name
}
}
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/ar.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Arabic localization for CodexBar */

"ollama_safari_cookie_access_hint" = "تحتاج ملفات تعريف ارتباط Safari إلى وصول كامل إلى القرص لتطبيق CodexBar (إعدادات النظام > الخصوصية والأمان).";
"ollama_browser_cookie_decryption_denied" = "تم رفض فك تشفير ملفات تعريف ارتباط %@ في سلسلة المفاتيح؛ أعد المحاولة بتحديث يدوي.";
"ollama_browser_cookie_decryption_disabled" = "فك تشفير ملفات تعريف ارتباط %@ معطل في CodexBar؛ فعّل الوصول إلى سلسلة المفاتيح ثم حدّث.";

" providers" = " providers";
"(System)" = "(النظام)";
"30d" = "30 يومًا";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/ca.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Catalan localization for CodexBar */

"ollama_safari_cookie_access_hint" = "Les galetes de Safari necessiten accés complet al disc per a CodexBar (Configuració del Sistema > Privadesa i seguretat).";
"ollama_browser_cookie_decryption_denied" = "S'ha denegat el desxifratge de les galetes de %@ al Clauer; torneu-ho a provar amb una actualització manual.";
"ollama_browser_cookie_decryption_disabled" = "El desxifratge de les galetes de %@ està desactivat a CodexBar; activeu l'accés al Clauer i actualitzeu.";

" providers" = " proveïdors";
"(System)" = "(Sistema)";
"30d" = "30 d";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/de.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* English localization for CodexBar (base/fallback) */

"ollama_safari_cookie_access_hint" = "Safari-Cookies benötigen vollen Festplattenzugriff für CodexBar (Systemeinstellungen > Datenschutz & Sicherheit).";
"ollama_browser_cookie_decryption_denied" = "Die Entschlüsselung der %@-Cookies wurde im Schlüsselbund abgelehnt; versuchen Sie es mit einer manuellen Aktualisierung erneut.";
"ollama_browser_cookie_decryption_disabled" = "Die Entschlüsselung der %@-Cookies ist in CodexBar deaktiviert; aktivieren Sie den Schlüsselbundzugriff und aktualisieren Sie.";

" providers" = "Anbieter";
"(System)" = "(System)";
"30d" = "30d";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/en.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* English localization for CodexBar (base/fallback) */

"ollama_safari_cookie_access_hint" = "Safari cookies need Full Disk Access for CodexBar (System Settings > Privacy & Security).";
"ollama_browser_cookie_decryption_denied" = "%@ cookie decryption was declined in Keychain; retry with a manual refresh.";
"ollama_browser_cookie_decryption_disabled" = "%@ cookie decryption is disabled in CodexBar; enable Keychain access and refresh.";

" providers" = " providers";
"(System)" = "(System)";
"30d" = "30d";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/es.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Spanish localization for CodexBar */

"ollama_safari_cookie_access_hint" = "Las cookies de Safari necesitan acceso total al disco para CodexBar (Ajustes del Sistema > Privacidad y seguridad).";
"ollama_browser_cookie_decryption_denied" = "Se rechazó en el Llavero el descifrado de las cookies de %@; vuelve a intentarlo con una actualización manual.";
"ollama_browser_cookie_decryption_disabled" = "El descifrado de las cookies de %@ está desactivado en CodexBar; activa el acceso al Llavero y actualiza.";

" providers" = " proveedores";
"(System)" = "(Sistema)";
"30d" = "30 d";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/fa.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Persian localization for CodexBar */

"ollama_safari_cookie_access_hint" = "کوکی‌های Safari برای CodexBar به دسترسی کامل دیسک نیاز دارند (تنظیمات سیستم > حریم خصوصی و امنیت).";
"ollama_browser_cookie_decryption_denied" = "رمزگشایی کوکی‌های %@ در Keychain رد شد؛ با یک تازه‌سازی دستی دوباره تلاش کنید.";
"ollama_browser_cookie_decryption_disabled" = "رمزگشایی کوکی‌های %@ در CodexBar غیرفعال است؛ دسترسی Keychain را فعال و تازه‌سازی کنید.";

" providers" = " providers";
"(System)" = "(سیستم)";
"30d" = "30 روز";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/fr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* English localization for CodexBar (base/fallback) */

"ollama_safari_cookie_access_hint" = "Les cookies Safari nécessitent l’accès complet au disque pour CodexBar (Réglages Système > Confidentialité et sécurité).";
"ollama_browser_cookie_decryption_denied" = "Le déchiffrement des cookies %@ a été refusé dans le Trousseau ; réessayez avec une actualisation manuelle.";
"ollama_browser_cookie_decryption_disabled" = "Le déchiffrement des cookies %@ est désactivé dans CodexBar ; activez l’accès au Trousseau et actualisez.";

" providers" = " fournisseurs";
"(System)" = "(System)";
"30d" = "30d";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/gl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Galician localization for CodexBar */

"ollama_safari_cookie_access_hint" = "As cookies de Safari precisan acceso total ao disco para CodexBar (Axustes do Sistema > Privacidade e seguridade).";
"ollama_browser_cookie_decryption_denied" = "Rexeitouse no Chaveiro o descifrado das cookies de %@; téntao de novo cunha actualización manual.";
"ollama_browser_cookie_decryption_disabled" = "O descifrado das cookies de %@ está desactivado en CodexBar; activa o acceso ao Chaveiro e actualiza.";

" providers" = " provedores";
"(System)" = "(Sistema)";
"30d" = "30d";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/id.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Indonesian localization for CodexBar */

"ollama_safari_cookie_access_hint" = "Cookie Safari memerlukan Akses Disk Penuh untuk CodexBar (Pengaturan Sistem > Privasi & Keamanan).";
"ollama_browser_cookie_decryption_denied" = "Dekripsi cookie %@ ditolak di Rantai Kunci; coba lagi dengan penyegaran manual.";
"ollama_browser_cookie_decryption_disabled" = "Dekripsi cookie %@ dinonaktifkan di CodexBar; aktifkan akses Rantai Kunci lalu segarkan.";

" providers" = " penyedia";
"(System)" = "(Sistem)";
"30d" = "30 hari";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/it.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Italian localization for CodexBar */

"ollama_safari_cookie_access_hint" = "I cookie di Safari richiedono l’accesso completo al disco per CodexBar (Impostazioni di Sistema > Privacy e sicurezza).";
"ollama_browser_cookie_decryption_denied" = "La decrittografia dei cookie di %@ è stata rifiutata nel Portachiavi; riprova con un aggiornamento manuale.";
"ollama_browser_cookie_decryption_disabled" = "La decrittografia dei cookie di %@ è disabilitata in CodexBar; abilita l’accesso al Portachiavi e aggiorna.";

" providers" = " provider";
"(System)" = "(Sistema)";
"30d" = "30 g";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/ja.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Japanese localization for CodexBar */

"ollama_safari_cookie_access_hint" = "Safari Cookie を読み込むには、CodexBar にフルディスクアクセスが必要です(システム設定 > プライバシーとセキュリティ)。";
"ollama_browser_cookie_decryption_denied" = "%@ Cookie の復号がキーチェーンで拒否されました。手動で更新して再試行してください。";
"ollama_browser_cookie_decryption_disabled" = "%@ Cookie の復号が CodexBar で無効です。キーチェーンへのアクセスを有効にして更新してください。";

" providers" = " 件のプロバイダ";
"(System)" = "(システム)";
"30d" = "30日";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/ko.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Korean (한국어) localization for CodexBar */

"ollama_safari_cookie_access_hint" = "Safari 쿠키를 읽으려면 CodexBar에 전체 디스크 접근 권한이 필요합니다(시스템 설정 > 개인정보 보호 및 보안).";
"ollama_browser_cookie_decryption_denied" = "%@ 쿠키 복호화가 키체인에서 거부되었습니다. 수동 새로 고침으로 다시 시도하세요.";
"ollama_browser_cookie_decryption_disabled" = "%@ 쿠키 복호화가 CodexBar에서 비활성화되어 있습니다. 키체인 접근을 활성화하고 새로 고침하세요.";

" providers" = " 공급자";
"(System)" = "(시스템)";
"30d" = "30일";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/nl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Dutch localization for CodexBar */

"ollama_safari_cookie_access_hint" = "Safari-cookies vereisen volledige schijftoegang voor CodexBar (Systeeminstellingen > Privacy en beveiliging).";
"ollama_browser_cookie_decryption_denied" = "Het ontsleutelen van %@-cookies is geweigerd in Sleutelhanger; probeer opnieuw met handmatig vernieuwen.";
"ollama_browser_cookie_decryption_disabled" = "Het ontsleutelen van %@-cookies is uitgeschakeld in CodexBar; schakel Sleutelhangertoegang in en vernieuw.";

" providers" = " providers";
"(System)" = "(Systeem)";
"30d" = "30d";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/pl.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* English localization for CodexBar (base/fallback) */

"ollama_safari_cookie_access_hint" = "Pliki cookie Safari wymagają pełnego dostępu do dysku dla CodexBar (Ustawienia systemowe > Prywatność i ochrona).";
"ollama_browser_cookie_decryption_denied" = "Odszyfrowanie plików cookie %@ zostało odrzucone w Pęku kluczy; spróbuj ponownie przez ręczne odświeżenie.";
"ollama_browser_cookie_decryption_disabled" = "Odszyfrowanie plików cookie %@ jest wyłączone w CodexBar; włącz dostęp do Pęku kluczy i odśwież.";

" providers" = " providers";
"(System)" = "(System)";
"30d" = "30d";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/pt-BR.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Brazilian Portuguese localization for CodexBar */

"ollama_safari_cookie_access_hint" = "Os cookies do Safari precisam de Acesso Total ao Disco para o CodexBar (Ajustes do Sistema > Privacidade e Segurança).";
"ollama_browser_cookie_decryption_denied" = "A descriptografia dos cookies do %@ foi recusada nas Chaves; tente novamente com uma atualização manual.";
"ollama_browser_cookie_decryption_disabled" = "A descriptografia dos cookies do %@ está desativada no CodexBar; ative o acesso às Chaves e atualize.";

" providers" = " provedores";
"(System)" = "(Sistema)";
"30d" = "30d";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/ru.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Russian localization for CodexBar */

"ollama_safari_cookie_access_hint" = "Для файлов cookie Safari приложению CodexBar нужен полный доступ к диску (Системные настройки > Конфиденциальность и безопасность).";
"ollama_browser_cookie_decryption_denied" = "Расшифровка файлов cookie %@ была отклонена в Связке ключей; повторите попытку с помощью ручного обновления.";
"ollama_browser_cookie_decryption_disabled" = "Расшифровка файлов cookie %@ отключена в CodexBar; включите доступ к Связке ключей и обновите.";

" providers" = " провайдеров";
"(System)" = "(Система)";
"30d" = "30 дн.";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/sv.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Swedish localization for CodexBar */

"ollama_safari_cookie_access_hint" = "Safari-cookies kräver full skivåtkomst för CodexBar (Systeminställningar > Integritet och säkerhet).";
"ollama_browser_cookie_decryption_denied" = "Dekryptering av %@-cookies nekades i Nyckelhanteraren; försök igen med en manuell uppdatering.";
"ollama_browser_cookie_decryption_disabled" = "Dekryptering av %@-cookies är inaktiverad i CodexBar; aktivera åtkomst till Nyckelhanteraren och uppdatera.";

" providers" = " leverantörer";
"(System)" = "(System)";
"30d" = "30 d";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/th.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Thai localization for CodexBar */

"ollama_safari_cookie_access_hint" = "คุกกี้ Safari ต้องใช้สิทธิ์เข้าถึงดิสก์แบบเต็มสำหรับ CodexBar (การตั้งค่าระบบ > ความเป็นส่วนตัวและความปลอดภัย)";
"ollama_browser_cookie_decryption_denied" = "การถอดรหัสคุกกี้ %@ ถูกปฏิเสธในพวงกุญแจ โปรดลองอีกครั้งด้วยการรีเฟรชด้วยตนเอง";
"ollama_browser_cookie_decryption_disabled" = "การถอดรหัสคุกกี้ %@ ถูกปิดใช้งานใน CodexBar ให้เปิดการเข้าถึงพวงกุญแจแล้วรีเฟรช";

" providers" = "ผู้ให้บริการ ";
"(System)" = "(ระบบ)";
"30d" = "30 วัน";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/tr.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Turkish localization for CodexBar */

"ollama_safari_cookie_access_hint" = "Safari çerezleri için CodexBar’a Tam Disk Erişimi gerekir (Sistem Ayarları > Gizlilik ve Güvenlik).";
"ollama_browser_cookie_decryption_denied" = "%@ çerezlerinin şifresini çözme Anahtar Zinciri’nde reddedildi; manuel yenilemeyle tekrar deneyin.";
"ollama_browser_cookie_decryption_disabled" = "%@ çerezlerinin şifresini çözme CodexBar’da devre dışı; Anahtar Zinciri erişimini etkinleştirip yenileyin.";

" providers" = " sağlayıcı";
"(System)" = "(Sistem)";
"30d" = "30 gün";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/uk.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Ukrainian localization for CodexBar */

"ollama_safari_cookie_access_hint" = "Для файлів cookie Safari програмі CodexBar потрібен повний доступ до диска (Системні параметри > Конфіденційність і безпека).";
"ollama_browser_cookie_decryption_denied" = "Розшифрування файлів cookie %@ було відхилено у В’язці ключів; повторіть спробу за допомогою ручного оновлення.";
"ollama_browser_cookie_decryption_disabled" = "Розшифрування файлів cookie %@ вимкнено в CodexBar; увімкніть доступ до В’язки ключів і оновіть.";

" providers" = "провайдерів";
"(System)" = "(Система)";
"30d" = "30д";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/vi.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* English localization for CodexBar (base/fallback) */

"ollama_safari_cookie_access_hint" = "Cookie Safari cần Quyền truy cập toàn bộ ổ đĩa cho CodexBar (Cài đặt hệ thống > Quyền riêng tư & Bảo mật).";
"ollama_browser_cookie_decryption_denied" = "Việc giải mã cookie %@ đã bị từ chối trong Chuỗi khóa; hãy thử lại bằng cách làm mới thủ công.";
"ollama_browser_cookie_decryption_disabled" = "Việc giải mã cookie %@ bị tắt trong CodexBar; hãy bật quyền truy cập Chuỗi khóa rồi làm mới.";

" providers" = "nhà cung cấp";
"(System)" = "(Hệ thống)";
"30d" = "30d";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/zh-Hans.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Chinese (Simplified) localization for CodexBar */

"ollama_safari_cookie_access_hint" = "CodexBar 需要“完全磁盘访问权限”才能读取 Safari Cookie(系统设置 > 隐私与安全性)。";
"ollama_browser_cookie_decryption_denied" = "钥匙串拒绝解密 %@ Cookie;请通过手动刷新重试。";
"ollama_browser_cookie_decryption_disabled" = "CodexBar 中已停用 %@ Cookie 解密;请启用钥匙串访问权限并刷新。";

" providers" = " 提供商";
"(System)" = "(System)";
"30d" = "30 天";
Expand Down
4 changes: 4 additions & 0 deletions Sources/CodexBar/Resources/zh-Hant.lproj/Localizable.strings
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
/* Chinese (Traditional) localization for CodexBar */

"ollama_safari_cookie_access_hint" = "CodexBar 需要「完整磁碟存取權」才能讀取 Safari Cookie(系統設定 > 隱私權與安全性)。";
"ollama_browser_cookie_decryption_denied" = "鑰匙圈拒絕解密 %@ Cookie;請透過手動重新整理再試一次。";
"ollama_browser_cookie_decryption_disabled" = "CodexBar 中已停用 %@ Cookie 解密;請啟用鑰匙圈存取權並重新整理。";

" providers" = " 提供者";
"(System)" = "(系統)";
"30d" = "30 天";
Expand Down
10 changes: 8 additions & 2 deletions Sources/CodexBar/UsageStore+Accessors.swift
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,14 @@ extension UsageStore {

func userFacingError(for provider: UsageProvider) -> String? {
if let raw = self.errors[provider] {
guard provider == .codex else { return raw }
return CodexUIErrorMapper.userFacingMessage(raw)
switch provider {
case .codex:
return CodexUIErrorMapper.userFacingMessage(raw)
case .ollama:
return OllamaUIErrorMapper.userFacingMessage(raw)
default:
return raw
}
}
if let diagnostic = self.diagnostics[provider] {
return diagnostic
Expand Down
17 changes: 17 additions & 0 deletions Sources/CodexBarCore/BrowserCookieAccessGate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ public enum BrowserCookieAccessGate {
])
}

static func hasActiveDenial(for browser: Browser, now: Date = Date()) -> Bool {
guard browser.usesKeychainForCookieDecryption else { return false }
return self.lock.withLock { state in
self.loadIfNeeded(&state)
guard let blockedUntil = state.deniedUntilByBrowser[browser.rawValue] else { return false }
guard blockedUntil <= now else { return true }
state.deniedUntilByBrowser.removeValue(forKey: browser.rawValue)
state.chromiumFamilyDeniedUntil = state.deniedUntilByBrowser.values.max()
self.persist(state)
return false
}
}

static func recordAllowed(for browser: Browser) {
guard browser.usesKeychainForCookieDecryption,
ProviderInteractionContext.current == .userInitiated,
Expand Down Expand Up @@ -356,6 +369,10 @@ public enum BrowserCookieAccessGate {

public static func recordIfNeeded(_ error: Error, now: Date = Date()) {}
public static func recordDenied(for browser: Browser, now: Date = Date()) {}
static func hasActiveDenial(for browser: Browser, now: Date = Date()) -> Bool {
false
}

public static func resetForTesting() {}
}
#endif
Loading