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
50 changes: 25 additions & 25 deletions apps/decodex-app/Sources/DecodexApp/AccountPanelView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,8 @@ private struct PanelInteractiveSurfaceModifier: ViewModifier {
let hoverShadowRadius: CGFloat

func body(content: Content) -> some View {
let responds = !isDisabled
let hoverActive = responds && isHovered && !isPressed
let responds = isDisabled == false
let hoverActive = responds && isHovered && isPressed == false
let pressActive = responds && isPressed

content
Expand Down Expand Up @@ -222,7 +222,7 @@ struct AccountPanelView: View {
isPresented: Binding(
get: { pendingLogout != nil },
set: { visible in
if !visible {
if visible == false {
pendingLogout = nil
disarmLogout()
}
Expand Down Expand Up @@ -334,7 +334,7 @@ struct AccountPanelView: View {
size: 25,
action: {
Task {
await store.setFastMode(!store.fastModeEnabled)
await store.setFastMode(store.fastModeEnabled == false)
}
},
help: store.fastModeEnabled ? "Turn fast mode off" : "Turn fast mode on"
Expand Down Expand Up @@ -515,7 +515,7 @@ struct AccountPanelView: View {
return "Not loaded"
}

if let selector = control.accountSelector, !selector.isEmpty {
if let selector = control.accountSelector, selector.isEmpty == false {
if emailsHidden {
let value = account(matching: selector)?.panelDisplayName(emailsHidden: true)
?? AccountDisplay.alias(forIdentity: selector)
Expand All @@ -541,7 +541,7 @@ struct AccountPanelView: View {
return false
}

return !selector.isEmpty
return selector.isEmpty == false
}

private var accountListHeight: CGFloat {
Expand Down Expand Up @@ -727,7 +727,7 @@ struct AccountRowView: View {
symbol: account.codexActive ? "person.crop.circle.fill" : "person.crop.circle",
tint: PanelPalette.codexAccent(colorScheme),
isActive: account.codexActive,
isDisabled: account.codexActive || !account.canUseInCodex,
isDisabled: account.codexActive || account.canUseInCodex == false,
isSubtle: true,
size: 21,
action: useInCodex,
Expand All @@ -741,7 +741,7 @@ struct AccountRowView: View {
? PanelPalette.routeAccent(colorScheme)
: PanelPalette.actionBlue(colorScheme),
isActive: account.selected,
isDisabled: !account.canRouteRuns && !account.selected,
isDisabled: account.canRouteRuns == false && account.selected == false,
isSubtle: true,
size: 21,
action: routeRunsHere,
Expand All @@ -753,7 +753,7 @@ struct AccountRowView: View {
tint: PanelPalette.destructive(colorScheme),
isActive: isLogoutArmed,
isDestructive: true,
isSubtle: !isLogoutArmed,
isSubtle: isLogoutArmed == false,
size: 21,
action: logout,
help: isLogoutArmed ? "Click again to confirm removal" : "Remove account"
Expand All @@ -762,7 +762,7 @@ struct AccountRowView: View {
}
}

if !runs.isEmpty {
if runs.isEmpty == false {
AccountRunSummaryView(runs: runs)
}

Expand Down Expand Up @@ -1096,7 +1096,7 @@ struct AccountPoolUsageEstimateView: View {
let measuredAccounts = accounts.filter { account in
account.sevenDayUsedPercent != nil
}
guard !measuredAccounts.isEmpty, estimate.totalCapacityPercent > 0 else {
guard measuredAccounts.isEmpty == false, estimate.totalCapacityPercent > 0 else {
return nil
}

Expand Down Expand Up @@ -1305,7 +1305,7 @@ struct AccountUsageMeterView: View {
.monospacedDigit()
.lineLimit(1)

if !resetDisplay.date.isEmpty {
if resetDisplay.date.isEmpty == false {
Text(resetDisplay.date)
.font(PanelFont.tertiary)
.foregroundStyle(PanelPalette.secondaryText(colorScheme).opacity(colorScheme == .dark ? 0.68 : 0.78))
Expand Down Expand Up @@ -1535,7 +1535,7 @@ struct OperatorStatusStripView: View {

var body: some View {
VStack(alignment: .leading, spacing: 5) {
if !metrics.isEmpty {
if metrics.isEmpty == false {
HStack(spacing: 0) {
ForEach(Array(metrics.enumerated()), id: \.element.id) { index, metric in
if index > 0 {
Expand All @@ -1548,7 +1548,7 @@ struct OperatorStatusStripView: View {
.frame(height: 32)
}

if !snapshot.activeRuns.isEmpty {
if snapshot.activeRuns.isEmpty == false {
OperatorLaneListView(runs: snapshot.activeRuns, showsAllLanes: $showsAllLanes)
.padding(.top, metrics.isEmpty ? 0 : 1)
}
Expand Down Expand Up @@ -1817,7 +1817,7 @@ struct OperatorLanePopoverView: View {
OperatorLaneReadoutRow(title: humanizedPanelToken(bucket.name), items: bucketReadoutItems(bucket))
}

if !contextReadoutItems.isEmpty {
if contextReadoutItems.isEmpty == false {
OperatorLaneReadoutDivider()
OperatorLaneReadoutRow(title: "Context", items: contextReadoutItems)
}
Expand Down Expand Up @@ -1872,7 +1872,7 @@ struct OperatorLanePopoverView: View {
private var detailBuckets: [OperatorChildAgentBucket] {
orderedBuckets.filter { bucket in
bucket.name.caseInsensitiveCompare("Model") != .orderedSame
&& !bucketReadoutItems(bucket).isEmpty
&& bucketReadoutItems(bucket).isEmpty == false
}
}

Expand Down Expand Up @@ -1955,7 +1955,7 @@ struct OperatorLanePopoverView: View {
if bucket.outputBytes > 0 {
items.append(OperatorLaneReadoutItem(label: "output bytes", value: formatCompactBytes(bucket.outputBytes)))
}
if !normalizedName.contains("tracker") {
if normalizedName.contains("tracker") == false {
if bucket.inputTokens > 0 {
items.append(OperatorLaneReadoutItem(label: "input", value: "\(formatCompactCount(bucket.inputTokens)) tok"))
}
Expand Down Expand Up @@ -2329,7 +2329,7 @@ struct PanelIconButtonView: View {
)
)
.disabled(isDisabled)
.opacity(isDisabled && !isActive ? 0.56 : 1)
.opacity(isDisabled && isActive == false ? 0.56 : 1)
.help(help)
}

Expand Down Expand Up @@ -2575,7 +2575,7 @@ private func compactUsageDate(_ value: String) -> String {

var components = DateComponents()
components.calendar = Calendar(identifier: .gregorian)
components.year = 2000
components.year = 2_000
components.month = month
components.day = day
guard let date = components.date else {
Expand Down Expand Up @@ -2726,11 +2726,11 @@ private func parsePanelTimestamp(_ value: String) -> Date? {
}

private func compactLanePath(_ value: String?) -> String? {
guard var text = panelTrimmed(value), !text.isEmpty else {
guard var text = panelTrimmed(value), text.isEmpty == false else {
return nil
}

if let home = ProcessInfo.processInfo.environment["HOME"], !home.isEmpty {
if let home = ProcessInfo.processInfo.environment["HOME"], home.isEmpty == false {
text = text.replacingOccurrences(of: home, with: "~")
}
if text.count <= 42 {
Expand Down Expand Up @@ -2834,13 +2834,13 @@ struct ModernGlassSurfaceModifier: ViewModifier {

private extension CodexAccount {
var randomNameSeed: String {
if !accountFingerprint.isEmpty {
if accountFingerprint.isEmpty == false {
return accountFingerprint
}
if let email, !email.isEmpty {
if let email, email.isEmpty == false {
return email
}
if let planType, !planType.isEmpty {
if let planType, planType.isEmpty == false {
return planType
}

Expand All @@ -2850,7 +2850,7 @@ private extension CodexAccount {
func panelDisplayName(emailsHidden: Bool) -> String {
if emailsHidden {
if let randomName = randomName?.trimmingCharacters(in: .whitespacesAndNewlines),
!randomName.isEmpty
randomName.isEmpty == false
{
return randomName
}
Expand Down
16 changes: 8 additions & 8 deletions apps/decodex-app/Sources/DecodexApp/AccountStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ final class AccountStore: ObservableObject {
}

let codexLabel = accountList?.codexAuth?.displayName ?? "no Codex auth"
if let selector = control.accountSelector, !selector.isEmpty {
if let selector = control.accountSelector, selector.isEmpty == false {
return "Codex: \(codexLabel) / Decodex: \(selector)"
}

Expand Down Expand Up @@ -71,7 +71,7 @@ final class AccountStore: ObservableObject {
}

func refresh(force: Bool = false) async {
guard !isRefreshing else {
guard isRefreshing == false else {
return
}

Expand Down Expand Up @@ -112,7 +112,7 @@ final class AccountStore: ObservableObject {
}

func resetLoginSession() {
guard !isLoggingIn else {
guard isLoggingIn == false else {
return
}

Expand All @@ -126,7 +126,7 @@ final class AccountStore: ObservableObject {
}

automaticRefreshTask = Task { [weak self] in
while !Task.isCancelled {
while Task.isCancelled == false {
do {
try await Task.sleep(nanoseconds: 60_000_000_000)
} catch {
Expand All @@ -151,7 +151,7 @@ final class AccountStore: ObservableObject {
}

private func runOperatorSnapshotStream() async {
while !Task.isCancelled {
while Task.isCancelled == false {
do {
try await connectOperatorSnapshotStream()
} catch {
Expand All @@ -176,7 +176,7 @@ final class AccountStore: ObservableObject {
socket.cancel(with: .normalClosure, reason: nil)
}

while !Task.isCancelled {
while Task.isCancelled == false {
let event = try await receiveOperatorDashboardEvent(from: socket)

applyOperatorDashboardEvent(event)
Expand Down Expand Up @@ -281,7 +281,7 @@ final class AccountStore: ObservableObject {
}

func setFastMode(_ enabled: Bool) async {
guard !isSettingFastMode else {
guard isSettingFastMode == false else {
return
}

Expand Down Expand Up @@ -434,7 +434,7 @@ struct DeviceLoginPrompt: Equatable {

private static func normalizedCode(from line: String) -> String? {
let trimmed = line.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else {
guard trimmed.isEmpty == false else {
return nil
}

Expand Down
8 changes: 4 additions & 4 deletions apps/decodex-app/Sources/DecodexApp/DecodexAppBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ private final class AppBridgeEventParser<Response: Decodable>: @unchecked Sendab
}

func append(_ data: Data) throws {
guard !data.isEmpty else {
guard data.isEmpty == false else {
return
}

Expand All @@ -134,7 +134,7 @@ private final class AppBridgeEventParser<Response: Decodable>: @unchecked Sendab
buffer = ""
lock.unlock()

if !remainder.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty {
if remainder.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty == false {
try handle(remainder)
}

Expand All @@ -161,7 +161,7 @@ private final class AppBridgeEventParser<Response: Decodable>: @unchecked Sendab

private func handle(_ line: String) throws {
let trimmed = line.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmed.isEmpty else {
guard trimmed.isEmpty == false else {
return
}
guard let data = trimmed.data(using: .utf8) else {
Expand Down Expand Up @@ -269,7 +269,7 @@ struct DecodexAppBridge: Sendable {
}

private func helperExecutableURL() throws -> URL {
if let override = ProcessInfo.processInfo.environment["DECODEX_APP_HELPER"], !override.isEmpty {
if let override = ProcessInfo.processInfo.environment["DECODEX_APP_HELPER"], override.isEmpty == false {
let overrideURL = URL(fileURLWithPath: override)
if FileManager.default.isExecutableFile(atPath: overrideURL.path) {
return overrideURL
Expand Down
26 changes: 20 additions & 6 deletions apps/decodex-app/Sources/DecodexApp/DecodexServerBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ private enum DecodexServerProbe: Equatable {
actor DecodexServerBridge {
static let shared = DecodexServerBridge()

private let defaultBaseURL = URL(string: "http://127.0.0.1:8912")!
private let defaultBaseURL = DecodexServerBridge.makeDefaultBaseURL()
private let defaultListenAddress = "127.0.0.1:8912"
private let liveCheckFreshness: TimeInterval = 5
private var serverBaseURL: URL?
Expand Down Expand Up @@ -70,7 +70,7 @@ actor DecodexServerBridge {
baseURL: URL,
as type: T.Type
) async throws -> T {
let url = routeURL(baseURL: baseURL, route: route)
let url = try routeURL(baseURL: baseURL, route: route)
var urlRequest = URLRequest(url: url)

urlRequest.httpMethod = route.method
Expand Down Expand Up @@ -239,7 +239,7 @@ actor DecodexServerBridge {
}

private func decodexExecutableURL() throws -> URL {
if let override = ProcessInfo.processInfo.environment["DECODEX_APP_DECODEX"], !override.isEmpty {
if let override = ProcessInfo.processInfo.environment["DECODEX_APP_DECODEX"], override.isEmpty == false {
let overrideURL = URL(fileURLWithPath: override)
if FileManager.default.isExecutableFile(atPath: overrideURL.path) {
return overrideURL
Expand All @@ -259,16 +259,30 @@ actor DecodexServerBridge {
)
}

private func routeURL(baseURL: URL, route: ServerRoute) -> URL {
private func routeURL(baseURL: URL, route: ServerRoute) throws -> URL {
let parts = route.path.split(separator: "?", maxSplits: 1).map(String.init)
var components = URLComponents(url: baseURL, resolvingAgainstBaseURL: false)!
guard var components = URLComponents(url: baseURL, resolvingAgainstBaseURL: false) else {
throw DecodexAppBridgeError.invalidResponse("Decodex server URL is invalid")
}

components.path = "/" + parts[0]
if parts.count == 2 {
components.query = parts[1]
}

return components.url!
guard let url = components.url else {
throw DecodexAppBridgeError.invalidResponse("Decodex server route URL is invalid")
}

return url
}

private static func makeDefaultBaseURL() -> URL {
guard let url = URL(string: "http://127.0.0.1:8912") else {
preconditionFailure("default Decodex server URL must be valid")
}

return url
}
}

Expand Down
4 changes: 2 additions & 2 deletions apps/decodex-app/Sources/DecodexApp/LoginPanelPresenter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ struct LoginPanelPresenter: NSViewRepresentable {
private func origin(for panelSize: NSSize) -> NSPoint {
let parentWindow = hostView?.window
let screen = parentWindow?.screen ?? NSScreen.main
let visibleFrame = screen?.visibleFrame ?? NSRect(x: 0, y: 0, width: 1280, height: 800)
let visibleFrame = screen?.visibleFrame ?? NSRect(x: 0, y: 0, width: 1_280, height: 800)
let margin: CGFloat = 8

var x: CGFloat
Expand All @@ -158,7 +158,7 @@ struct LoginPanelPresenter: NSViewRepresentable {
}
panel = nil
hostingView = nil
guard !isClosingProgrammatically else {
guard isClosingProgrammatically == false else {
return
}

Expand Down
Loading