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
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
package sh.sandboxed.dashboard.orb

/**
* Special cyber access of a subscription account as Core reports it in `cyber_access` on
* `GET /api/ai/providers`: Daybreak on a Codex/ChatGPT login, CVP on a Claude login.
* Mirrors `accountCyberAccessView` in `orb/src/accountCyberAccess.ts` and iOS
* `OrbAccountCyberAccess`, checked against `shared/orb-spec/fixtures/account-cyber-access.json`.
* See `docs/specs/subscription-cyber-access.md`.
*/
object OrbAccountCyberAccess {
const val RULE =
"Kept for missions that ask for it; other missions use this account only when no other account is available."
const val RESERVED_RULE =
"Only missions that ask for it use this account; other missions never fall back to it."

data class View(
/** False when the account's provider has no special access to mark. */
val offered: Boolean,
/** Text of the account badge, "" for none. */
val badge: String,
val title: String,
val on: Boolean,
val detail: String,
/** The account is kept only for missions that ask for the access. */
val reserved: Boolean,
/** Title of the reserve switch, "" when the account is not marked. */
val reserveTitle: String,
)

private val labels = mapOf("daybreak" to "Daybreak", "cvp" to "CVP")
private val none = View(false, "", "", false, "", false, "")
private val day = Regex("^\\d{4}-\\d{2}-\\d{2}")

fun accountCyberAccessView(value: Any?): View {
val v = OrbJSON.dict(value) ?: return none
val available = v["available"] as? String
val name = labels[available] ?: return none
val title = "$name access"
if (v["access"] != available) {
return View(true, "", title, false,
"Turn on if this account has $name. Orb then keeps it for missions that ask for $name and uses your other accounts first.",
false, "")
}
val date = day.find((v["updated_at"] as? String).orEmpty())?.value
val learned = (if (v["source"] == "detected") "Detected" else "Set manually") + (date?.let { " on $it" } ?: "") + "."
val reserved = v["reserved"] == true
return View(true, name, title, true, "$learned ${if (reserved) RESERVED_RULE else RULE}",
reserved, "Keep for $name missions")
}

/** Words added to the account subtitle in Inference: the badge, and that it is kept. */
fun subtitleBadge(value: Any?): String {
val view = accountCyberAccessView(value)
if (view.badge.isEmpty()) return ""
return if (view.reserved) "${view.badge} only" else view.badge
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ internal fun providerStatusSubtitle(provider: OrbRow, detail: OrbDict?, health:
} else ""
val rpmBadge = provider.int("rpm_limit")?.let { "$it RPM" }.orEmpty()
val concBadge = provider.int("max_concurrency")?.let { "$it concurrent" }.orEmpty()
return listOf(providerType, state, rpmBadge, concBadge, resetSuffix)
val cyberBadge = OrbAccountCyberAccess.subtitleBadge(provider.raw["cyber_access"])
return listOf(providerType, cyberBadge, state, rpmBadge, concBadge, resetSuffix)
.filter { it.isNotEmpty() }
.joinToString(" · ")
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package sh.sandboxed.dashboard.orb

import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import org.junit.Test

class OrbAccountCyberAccessTest {
private val spec = OrbSpec.dict("fixtures/account-cyber-access.json")

@Test fun matchesSharedFixture() {
assertEquals(spec["rule"], OrbAccountCyberAccess.RULE)
assertEquals(spec["reserved_rule"], OrbAccountCyberAccess.RESERVED_RULE)
val views = OrbJSON.dictList(spec["views"])
assertTrue(views.isNotEmpty())
for (case in views) {
val name = case["name"] as String
val e = OrbJSON.dict(case["view"])!!
assertEquals(name, OrbAccountCyberAccess.View(
offered = e["offered"] as Boolean,
badge = e["badge"] as String,
title = e["title"] as String,
on = e["on"] as Boolean,
detail = e["detail"] as String,
reserved = e["reserved"] as Boolean,
reserveTitle = e["reserveTitle"] as String,
), OrbAccountCyberAccess.accountCyberAccessView(case["payload"]))
}
}

@Test fun subtitleShowsTheMarkAndTheReserve() {
val marked = mapOf("access" to "daybreak", "available" to "daybreak", "source" to "operator")
assertEquals("Daybreak", OrbAccountCyberAccess.subtitleBadge(marked))
assertEquals("Daybreak only", OrbAccountCyberAccess.subtitleBadge(marked + ("reserved" to true)))
assertEquals("", OrbAccountCyberAccess.subtitleBadge(mapOf("access" to "none", "available" to "cvp")))
assertEquals("", OrbAccountCyberAccess.subtitleBadge(null))
val row = OrbRow(mapOf("id" to "a", "provider_type" to "openai", "enabled" to true,
"cyber_access" to marked + ("reserved" to true)))
assertTrue(providerStatusSubtitle(row, null).startsWith("openai · Daybreak only · "))
}
}
4 changes: 2 additions & 2 deletions android_dashboard/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ android.nonTransitiveRClass=true
kotlin.code.style=official

# App version (single source; versionCode can be overridden from CI with -PorbVersionCode=N)
orbVersionName=1.90.0
orbVersionCode=2026113002
orbVersionName=1.91.0
orbVersionCode=2026113003
8 changes: 4 additions & 4 deletions ios_dashboard/SandboxedDashboard.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2026113002;
CURRENT_PROJECT_VERSION = 2026113003;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_PREVIEWS = YES;
ENABLE_STRICT_OBJC_MSGSEND = YES;
Expand All @@ -936,7 +936,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
MARKETING_VERSION = 1.90.0;
MARKETING_VERSION = 1.91.0;
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
Expand Down Expand Up @@ -1067,7 +1067,7 @@
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
CODE_SIGN_STYLE = Automatic;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 2026113002;
CURRENT_PROJECT_VERSION = 2026113003;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_PREVIEWS = YES;
Expand All @@ -1081,7 +1081,7 @@
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.0;
MARKETING_VERSION = 1.90.0;
MARKETING_VERSION = 1.91.0;
MTL_ENABLE_DEBUG_INFO = NO;
MTL_FAST_MATH = YES;
PRODUCT_NAME = "$(TARGET_NAME)";
Expand Down
55 changes: 54 additions & 1 deletion ios_dashboard/SandboxedDashboard/Orb/OrbProvidersSettings.swift
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,8 @@ struct OrbProvidersSettings: View {
let resetBadge = showResetBadge ? (OrbSubscriptionResetSummary.from(detail)?.badge ?? "") : ""
let rpmBadge = p["rpm_limit"].number.map { "\(Int($0)) RPM" } ?? ""
let concBadge = p["max_concurrency"].number.map { "\(Int($0)) concurrent" } ?? ""
return [lead, state, rpmBadge, concBadge, resetBadge].filter { !$0.isEmpty }.joined(separator: " · ")
let cyberBadge = OrbAccountCyberAccess.subtitleBadge(p["cyber_access"])
return [lead, cyberBadge, state, rpmBadge, concBadge, resetBadge].filter { !$0.isEmpty }.joined(separator: " · ")
}
/// Quota severity of the row (nil while below 80% or when another state wins).
private func quotaStatus(_ p: OrbJSON) -> OrbQuotaStatus? {
Expand Down Expand Up @@ -1178,6 +1179,58 @@ struct OrbCloudAccountsSettings: View {

/// Account connection and alternative-router settings as Core reports them
/// (Orb: accountVpn.ts), checked against `shared/orb-spec/fixtures/account-vpn.json`.
/// Special cyber access of a subscription account as Core reports it in `cyber_access` on
/// `GET /api/ai/providers`: Daybreak on a Codex/ChatGPT login, CVP on a Claude login.
/// Mirrors `accountCyberAccessView` in `orb/src/accountCyberAccess.ts` and Android
/// `OrbAccountCyberAccess`, checked against `shared/orb-spec/fixtures/account-cyber-access.json`.
/// See `docs/specs/subscription-cyber-access.md`.
enum OrbAccountCyberAccess {
static let rule =
"Kept for missions that ask for it; other missions use this account only when no other account is available."
static let reservedRule =
"Only missions that ask for it use this account; other missions never fall back to it."

struct View: Equatable {
/// False when the account's provider has no special access to mark.
var offered = false
/// Text of the account badge, "" for none.
var badge = ""
var title = ""
var on = false
var detail = ""
/// The account is kept only for missions that ask for the access.
var reserved = false
/// Title of the reserve switch, "" when the account is not marked.
var reserveTitle = ""
}

private static let labels = ["daybreak": "Daybreak", "cvp": "CVP"]

static func accountCyberAccessView(_ value: OrbJSON) -> View {
let available = value["available"].text
guard let name = labels[available] else { return View() }
let title = "\(name) access"
guard value["access"].text == available else {
return View(offered: true, title: title,
detail: "Turn on if this account has \(name). Orb then keeps it for missions that ask for \(name) and uses your other accounts first.")
}
let stamp = value["updated_at"].text
let day = stamp.range(of: #"^\d{4}-\d{2}-\d{2}"#, options: .regularExpression).map { String(stamp[$0]) }
let learned = (value["source"].text == "detected" ? "Detected" : "Set manually") + (day.map { " on \($0)" } ?? "") + "."
let reserved = value["reserved"] == .bool(true)
return View(offered: true, badge: name, title: title, on: true,
detail: "\(learned) \(reserved ? reservedRule : rule)",
reserved: reserved, reserveTitle: "Keep for \(name) missions")
}

/// Words added to the account subtitle in Inference: the badge, and that it is kept.
static func subtitleBadge(_ value: OrbJSON) -> String {
let view = accountCyberAccessView(value)
if view.badge.isEmpty { return "" }
return view.reserved ? "\(view.badge) only" : view.badge
}
}

enum OrbAccountVpn {
struct View: Equatable {
/// Saved country, or "" for Direct.
Expand Down
24 changes: 24 additions & 0 deletions ios_dashboard/SandboxedDashboardTests/OrbSettingsTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,30 @@ final class OrbSettingsTests: XCTestCase {
let data = try JSONSerialization.data(withJSONObject: [value ?? NSNull()])
return try XCTUnwrap(JSONDecoder().decode([OrbJSON].self, from: data).first)
}
func testAccountCyberAccessMatchesSharedFixture() throws {
let spec = try OrbSpec.json("fixtures/account-cyber-access.json")
XCTAssertEqual(spec["rule"] as? String, OrbAccountCyberAccess.rule)
XCTAssertEqual(spec["reserved_rule"] as? String, OrbAccountCyberAccess.reservedRule)
let views = try XCTUnwrap(spec["views"] as? [[String: Any]])
XCTAssertFalse(views.isEmpty)
for c in views {
let name = try XCTUnwrap(c["name"] as? String)
let e = try XCTUnwrap(c["view"] as? [String: Any])
let expected = OrbAccountCyberAccess.View(
offered: try XCTUnwrap(e["offered"] as? Bool),
badge: try XCTUnwrap(e["badge"] as? String),
title: try XCTUnwrap(e["title"] as? String),
on: try XCTUnwrap(e["on"] as? Bool),
detail: try XCTUnwrap(e["detail"] as? String),
reserved: try XCTUnwrap(e["reserved"] as? Bool),
reserveTitle: try XCTUnwrap(e["reserveTitle"] as? String))
XCTAssertEqual(OrbAccountCyberAccess.accountCyberAccessView(try orbJSON(c["payload"])), expected, name)
}
let kept = try orbJSON(["access": "daybreak", "available": "daybreak", "source": "operator", "reserved": true])
XCTAssertEqual(OrbAccountCyberAccess.subtitleBadge(kept), "Daybreak only")
XCTAssertEqual(OrbAccountCyberAccess.subtitleBadge(try orbJSON(["access": "cvp", "available": "cvp"])), "CVP")
XCTAssertEqual(OrbAccountCyberAccess.subtitleBadge(.null), "")
}
func testAccountConnectionMatchesSharedFixture() throws {
let spec = try OrbSpec.json("fixtures/account-vpn.json")
let routes = try XCTUnwrap(spec["routes"] as? [[String: Any]])
Expand Down
4 changes: 2 additions & 2 deletions ios_dashboard/project.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ settings:
# Single source of the app version for the app and the Live Activity extension
# (both Info.plists read these). Bump CURRENT_PROJECT_VERSION (YYYYMMDDNN) for a
# release; Xcode Cloud appends its run number (ci_scripts/ci_pre_xcodebuild.sh).
MARKETING_VERSION: "1.90.0"
CURRENT_PROJECT_VERSION: "2026113002"
MARKETING_VERSION: "1.91.0"
CURRENT_PROJECT_VERSION: "2026113003"
SWIFT_VERSION: "6.0"
CODE_SIGN_STYLE: "Automatic"
ENABLE_PREVIEWS: "YES"
Expand Down
Loading