Skip to content
19 changes: 8 additions & 11 deletions Sources/CodeCaps/ConsoleViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ enum ConsolePage: Hashable {
case runawayAlerts
case plugin(String)
case settingsMenuBar
case settingsPlatforms
case settingsLogoStyle
case settingsSourcesFleet
case settingsNotifications
Expand All @@ -32,7 +31,6 @@ enum ConsolePage: Hashable {
case .runawayAlerts: return "runawayAlerts"
case .plugin(let pluginId): return "plugin:" + pluginId
case .settingsMenuBar: return "settingsMenuBar"
case .settingsPlatforms: return "settingsPlatforms"
case .settingsLogoStyle: return "settingsLogoStyle"
case .settingsSourcesFleet: return "settingsSourcesFleet"
case .settingsNotifications: return "settingsNotifications"
Expand All @@ -47,7 +45,10 @@ enum ConsolePage: Hashable {
case "allPlatforms": return .allPlatforms
case "runawayAlerts": return .runawayAlerts
case "settingsMenuBar": return .settingsMenuBar
case "settingsPlatforms": return .settingsPlatforms
// The old Platforms page merged into Platforms & Sources (owner,
// 2026-11-27): a saved selection under the old key lands on the
// merged page forever.
case "settingsPlatforms": return .settingsSourcesFleet
case "settingsLogoStyle": return .settingsLogoStyle
case "settingsSourcesFleet": return .settingsSourcesFleet
case "settingsNotifications": return .settingsNotifications
Expand All @@ -70,9 +71,8 @@ enum ConsolePage: Hashable {
case .runawayAlerts: return "Runaway Alerts"
case .plugin(let pluginId): return CodeCapsPlugin.named(pluginId)?.title ?? "Plugin"
case .settingsMenuBar: return "Menu Bar & PiP"
case .settingsPlatforms: return "Platforms"
case .settingsLogoStyle: return "Logo Style"
case .settingsSourcesFleet: return "Sources & Fleet"
case .settingsSourcesFleet: return "Platforms & Sources"
case .settingsNotifications: return "Alerts & Alarms"
case .settingsAppearance: return "Appearance"
case .settingsInfisical: return "Infisical Sync"
Expand All @@ -87,7 +87,6 @@ enum ConsolePage: Hashable {
case .runawayAlerts: return "flame.fill"
case .plugin(let pluginId): return CodeCapsPlugin.named(pluginId)?.symbol ?? "puzzlepiece.extension"
case .settingsMenuBar: return "menubar.rectangle"
case .settingsPlatforms: return "square.grid.2x2"
case .settingsLogoStyle: return "photo.on.rectangle.angled"
case .settingsSourcesFleet: return "arrow.up.arrow.down.circle"
case .settingsNotifications: return "bell.badge"
Expand All @@ -99,7 +98,7 @@ enum ConsolePage: Hashable {
}

static let settingsPages: [ConsolePage] = [
.settingsMenuBar, .settingsPlatforms, .settingsLogoStyle, .settingsSourcesFleet, .settingsNotifications, .settingsAppearance, .settingsInfisical, .settingsAbout,
.settingsMenuBar, .settingsLogoStyle, .settingsSourcesFleet, .settingsNotifications, .settingsAppearance, .settingsInfisical, .settingsAbout,
]

static let pluginPages: [ConsolePage] = CodeCapsPlugin.allCases.map { .plugin($0.id) }
Expand Down Expand Up @@ -337,7 +336,7 @@ struct ConsoleView: View {
.accessibilityHidden(true)
}
if let unavailable = state.unavailableAlert {
Text("Alert source unavailable: \(unavailable.providerKey)\(unavailable.windowId.map { " · \($0)" } ?? "").\(sentenceGap)Check Sources & Fleet for this provider.")
Text("Alert source unavailable: \(unavailable.providerKey)\(unavailable.windowId.map { " · \($0)" } ?? "").\(sentenceGap)Check Platforms & Sources for this provider.")
.font(.callout)
.foregroundStyle(Theme.warning)
.padding(.horizontal, Metrics.pagePadding)
Expand All @@ -359,12 +358,10 @@ struct ConsoleView: View {
.padding(Metrics.pagePadding)
case .settingsMenuBar:
SettingsMenuBarPage(model: model)
case .settingsPlatforms:
SettingsPlatformsPage(model: model)
case .settingsLogoStyle:
SettingsLogoStylePage(model: model)
case .settingsSourcesFleet:
SettingsSourcesFleetPage(model: model)
SettingsPlatformsAndSourcesPage(model: model)
case .settingsNotifications:
SettingsNotificationsPage(model: model, state: state)
case .settingsAppearance:
Expand Down
2 changes: 1 addition & 1 deletion Sources/CodeCaps/GlanceViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -2516,7 +2516,7 @@ struct GlanceRow: View {

/// Shown below the platform list when a reader's saved login is present on
/// this Mac but unreadable until the owner allows this build once. The button
/// deep-links to Sources & Fleet, where the one-time step lives.
/// deep-links to Platforms & Sources, where the one-time step lives.
struct ConsentRow: View {
let message: String
var action: () -> Void
Expand Down
13 changes: 13 additions & 0 deletions Sources/CodeCaps/MonitorModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -855,6 +855,7 @@ final class MonitorModel: ObservableObject {
localEnabled = defaults.object(forKey: "localEnabled") as? Bool ?? true
glanceLogosFollowAccent = defaults.bool(forKey: "glanceLogosFollowAccent")
pipBackground = PipBackground(rawValue: defaults.string(forKey: "pipBackground") ?? "") ?? .black
pipLogoStyle = PipLogoStyle(rawValue: defaults.string(forKey: "pipLogoStyle") ?? "") ?? .automatic
pipShowProviderNames = defaults.bool(forKey: "pipShowProviderNames")
providerChecksEnabled = SourceRefreshPreference.enabled(SourceRefreshPreference.providerEnabled, defaults: defaults)
sessionFileChecksEnabled = SourceRefreshPreference.enabled(SourceRefreshPreference.sessionEnabled, defaults: defaults)
Expand Down Expand Up @@ -2039,6 +2040,18 @@ final class MonitorModel: ObservableObject {
}
}

/// Which artwork the PiP HUD draws beside each provider. Automatic — the
/// shipped default — keeps silhouettes on a dark HUD and brand-colour
/// marks on a white one; the explicit choices override that because the
/// owner asked to choose which logo the PiP uses (2026-11-27). A per-user
/// display preference, like the PiP background.
@Published var pipLogoStyle: PipLogoStyle {
didSet {
defaults.set(pipLogoStyle.rawValue, forKey: "pipLogoStyle")
if presentsPipWindows { PipWidgetController.shared.update(model: self) }
}
}

/// Whether the Glance popover's provider logos wear the chosen accent.
///
/// Off by default, and deliberately so. A logo in the accent stops looking
Expand Down
87 changes: 63 additions & 24 deletions Sources/CodeCaps/PipWidget.swift
Original file line number Diff line number Diff line change
Expand Up @@ -730,21 +730,56 @@ final class PipWidgetController: NSObject, NSWindowDelegate {
disabledSources: Set<String> = [],
peerRows: [DisplaySection] = []) -> [QuotaWindowSnapshot] {
let windows = currentWindows(for: row, now: now, issue: issue, disabledSources: disabledSources, peerRows: peerRows)
let minPercent = windows.compactMap(\.remainingPercent).min()
let current = DisplaySection(id: row.id, providerKey: row.providerKey, title: row.title,
platformTitle: row.platformTitle,
section: QuotaPlatformSection(providerKey: row.providerKey, providerLabel: row.section.providerLabel,
via: row.section.via, expected: row.section.expected, windows: windows, iconHint: row.section.iconHint),
poolKey: row.poolKey, remainingPercent: minPercent,
resetAt: nil, maskedWindowIds: row.maskedWindowIds,
drivingWindowId: minPercent.flatMap({ mp in windows.first(where: { $0.remainingPercent == mp })?.window.id }))
let meters = glanceMeterPair(for: current, now: now)
var out: [QuotaWindowSnapshot] = []
if let short = meters.short { out.append(short) }
if let long = meters.long, long.window.id != meters.short?.window.id {
out.append(long)
} else if meters.short == nil, let primary = windows.first {
out.append(primary)
// One pairing helper for both window sets, so the narrow and wide
// answers can never disagree about how a pair is picked.
func pair(for ws: [QuotaWindowSnapshot]) -> [QuotaWindowSnapshot] {
let minPercent = ws.compactMap(\.remainingPercent).min()
let current = DisplaySection(id: row.id, providerKey: row.providerKey, title: row.title,
platformTitle: row.platformTitle,
section: QuotaPlatformSection(providerKey: row.providerKey, providerLabel: row.section.providerLabel,
via: row.section.via, expected: row.section.expected, windows: ws, iconHint: row.section.iconHint),
poolKey: row.poolKey, remainingPercent: minPercent,
resetAt: nil, maskedWindowIds: row.maskedWindowIds,
drivingWindowId: minPercent.flatMap({ mp in ws.first(where: { $0.remainingPercent == mp })?.window.id }))
let meters = glanceMeterPair(for: current, now: now)
var out: [QuotaWindowSnapshot] = []
if let short = meters.short { out.append(short) }
if let long = meters.long, long.window.id != meters.short?.window.id {
out.append(long)
} else if meters.short == nil, let primary = ws.first {
out.append(primary)
}
return out
}
var out = pair(for: windows)
// The dropdown pairs its meters over every drawable window, including
// one whose period has ended — it draws as a full bar with a "due"
// countdown. `currentWindows` drops that awaiting-refresh window
// before the pairing sees it, so a pool with a due 5h and a live 7d
// showed only the 7d in the HUD while the dropdown showed both
// (owner, 2026-11-27, Antigravity Third-Party). When a drawable row
// comes up short, re-pair over the same drawable set the dropdown
// uses (supplementary, masked, and disabled sources still excluded,
// so the HUD never draws a window its surfaces turned off). Three
// gates keep the rescue from disagreeing with the surfaces:
// a failed row keeps its status words instead of meters; a row
// with no current windows at all — every period ended, or sources
// off — keeps its empty meter set so the status carries the story
// (CI, 2026-11-27, PipInteractionTests); and a unified-pool row
// never rescues, because `currentWindows` suppresses its own stale
// windows in favour of a peer's fresher reading, and re-pairing the
// row's own windows would put a suppressed meter back in the HUD
// (Kody finding, 2026-11-27).
if !windows.isEmpty, out.count < 2, issue == nil,
!UnifiedSubscriptionPool.participantKeys.contains(row.providerKey) {
let drawable = row.section.windows
.filter {
!$0.window.isSupplementaryVideoQuota && !row.isMasked($0)
&& !disabledSources.contains($0.window.source ?? "")
}
.map { QuotaWindowSnapshot(window: $0.window, now: now) }
let wide = pair(for: drawable)
if wide.count > out.count { out = wide }
}
return out
}
Expand Down Expand Up @@ -875,11 +910,13 @@ struct PipWidgetView: View {
/// site is how a light HUD ends up with white text or a dark mark on white.
private var background: PipBackground { model.pipBackground }

/// The mark style a provider's logo takes on this background. Same logos as
/// the popover (the owner asked for that on 2026-10-10), then adapted to the
/// fill so they read on it.
private func markStyle(for row: DisplaySection) -> MarkStyle {
background.markStyle(for: model.glanceMarkStyle(for: row.id))
/// The mark presentation the owner's PiP logo choice asks for on this
/// background. The old rule — always the background-adapted silhouette,
/// always monochrome-forced — is the Automatic default; Brand Color and
/// Light/Dark override it (owner, 2026-11-27: "it should be an option in
/// settings to use which logo for PiP").
private func logoPresentation(for row: DisplaySection) -> (style: MarkStyle, forceMonochrome: Bool) {
model.pipLogoStyle.presentation(on: background, ownerStyle: model.glanceMarkStyle(for: row.id))
}

/// The one row the detail view is showing, or nil.
Expand Down Expand Up @@ -1147,11 +1184,12 @@ struct PipWidgetView: View {

return HStack(spacing: PipMetrics.rowSpacing) {
if detail.showsProviderLogo {
let logo = logoPresentation(for: row)
PlatformLogo(providerKey: row.id,
size: PipMetrics.providerLogoSize,
style: markStyle(for: row),
style: logo.style,
iconHint: row.poolKey == nil ? row.section.iconHint : nil,
forceMonochrome: true)
forceMonochrome: logo.forceMonochrome)
// Owner 2026-10-10: "after the platform name (or logo if no
// name shown) there should be a little flame for usage spike".
// Beside the LOGO rather than after the name, because the name
Expand Down Expand Up @@ -1270,11 +1308,12 @@ struct PipWidgetView: View {
return ScrollView(.vertical, showsIndicators: false) {
VStack(alignment: .leading, spacing: 0) {
HStack(spacing: 6) {
let logo = logoPresentation(for: row)
PlatformLogo(providerKey: row.id,
size: 16,
style: markStyle(for: row),
style: logo.style,
iconHint: row.poolKey == nil ? row.section.iconHint : nil,
forceMonochrome: true)
forceMonochrome: logo.forceMonochrome)
Text(row.title)
.font(.system(size: 12, weight: .bold))
.foregroundStyle(background.ink)
Expand Down
Loading
Loading