From 2f6d56f69a071aa25590fa63d8174799254a1e9a Mon Sep 17 00:00:00 2001 From: Italian-seasoning <99997342+Italian-seasoning@users.noreply.github.com> Date: Sun, 15 Nov 2026 18:15:20 -0700 Subject: [PATCH 1/9] Add spacing and radius tokens; theme-aware glass panels Extends AppTypeScale with micro and display sizes and adds AppSpacing and AppRadius so views stop using one-off values. appGlassPanel now uses the active theme's panel tint and border instead of fixed white, which was nearly invisible in the light Runway Glass theme. Removes three leftover Codex Usage Monitor files that were no longer in the project. --- Runway/AppChrome.swift | 38 +++++++++++++++++---- Runway/CodexUsageMonitorApp.swift | 1 - RunwayWidget/CodexUsageWidget.swift | 1 - RunwayWidget/CodexUsageWidgetPreviews.swift | 1 - 4 files changed, 31 insertions(+), 10 deletions(-) delete mode 120000 Runway/CodexUsageMonitorApp.swift delete mode 120000 RunwayWidget/CodexUsageWidget.swift delete mode 120000 RunwayWidget/CodexUsageWidgetPreviews.swift diff --git a/Runway/AppChrome.swift b/Runway/AppChrome.swift index f84a59b..2d81c1b 100644 --- a/Runway/AppChrome.swift +++ b/Runway/AppChrome.swift @@ -1,13 +1,37 @@ import AppKit import SwiftUI +/// Runway's single source for type, spacing, radius and surfaces. +/// Views use these tokens instead of literals so every screen reads as one app. enum AppTypeScale { + static let micro: CGFloat = 10 static let caption: CGFloat = 11 static let label: CGFloat = 12 static let body: CGFloat = 13 static let sectionTitle: CGFloat = 14 static let pageTitle: CGFloat = 18 static let value: CGFloat = 22 + static let display: CGFloat = 30 +} + +enum AppSpacing { + static let xxs: CGFloat = 4 + static let xs: CGFloat = 8 + static let sm: CGFloat = 12 + static let md: CGFloat = 16 + static let lg: CGFloat = 24 + static let xl: CGFloat = 32 +} + +enum AppRadius { + /// Bars, chips and small marks. + static let small: CGFloat = 8 + /// Buttons, fields and rows. + static let control: CGFloat = 10 + /// Cards and grouped panels. + static let card: CGFloat = 14 + /// Window-level glass: navigation rail and workspace. + static let panel: CGFloat = 22 } enum AppSection: String, CaseIterable, Identifiable { @@ -765,29 +789,29 @@ extension View { @ViewBuilder func navigationGlass(namespace: Namespace.ID, opaque: Bool) -> some View { if opaque { - background(Color(nsColor: .windowBackgroundColor), in: RoundedRectangle(cornerRadius: 22)) + background(Color(nsColor: .windowBackgroundColor), in: RoundedRectangle(cornerRadius: AppRadius.panel)) } else if #available(macOS 26.0, *) { background { - RoundedRectangle(cornerRadius: 22) + RoundedRectangle(cornerRadius: AppRadius.panel) .fill(Color.clear) - .glassEffect(.regular.interactive(), in: RoundedRectangle(cornerRadius: 22)) + .glassEffect(.regular.interactive(), in: RoundedRectangle(cornerRadius: AppRadius.panel)) .glassEffectID("navigation", in: namespace) .glassEffectTransition(.identity) } } else { background { - RoundedRectangle(cornerRadius: 22) + RoundedRectangle(cornerRadius: AppRadius.panel) .fill(.regularMaterial) } } } @ViewBuilder - func appGlassPanel(cornerRadius: CGFloat) -> some View { - background(Color.white.opacity(0.035), in: RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)) + func appGlassPanel(cornerRadius: CGFloat = AppRadius.card) -> some View { + background(AppPalette.panelTint, in: RoundedRectangle(cornerRadius: cornerRadius, style: .continuous)) .overlay { RoundedRectangle(cornerRadius: cornerRadius, style: .continuous) - .stroke(Color.white.opacity(0.07), lineWidth: 1) + .stroke(AppPalette.panelBorder, lineWidth: 1) } } } diff --git a/Runway/CodexUsageMonitorApp.swift b/Runway/CodexUsageMonitorApp.swift deleted file mode 120000 index 07122e7..0000000 --- a/Runway/CodexUsageMonitorApp.swift +++ /dev/null @@ -1 +0,0 @@ -RunwayApp.swift \ No newline at end of file diff --git a/RunwayWidget/CodexUsageWidget.swift b/RunwayWidget/CodexUsageWidget.swift deleted file mode 120000 index 7594aff..0000000 --- a/RunwayWidget/CodexUsageWidget.swift +++ /dev/null @@ -1 +0,0 @@ -RunwayWidget.swift \ No newline at end of file diff --git a/RunwayWidget/CodexUsageWidgetPreviews.swift b/RunwayWidget/CodexUsageWidgetPreviews.swift deleted file mode 120000 index 422e627..0000000 --- a/RunwayWidget/CodexUsageWidgetPreviews.swift +++ /dev/null @@ -1 +0,0 @@ -RunwayWidgetPreviews.swift \ No newline at end of file From 5391b149ddb907a53e476ed855d72018a3aab2ba Mon Sep 17 00:00:00 2001 From: Italian-seasoning <99997342+Italian-seasoning@users.noreply.github.com> Date: Sun, 15 Nov 2026 18:18:07 -0700 Subject: [PATCH 2/9] Move app views onto shared type, spacing and radius tokens Replaces one-off font sizes, corner radii, padding and stack spacing with AppTypeScale, AppSpacing and AppRadius. Values are snapped to the nearest step; colours and layout structure are unchanged. --- Runway/AnalysisView.swift | 52 ++++++++--------- Runway/AppChrome.swift | 48 ++++++++-------- Runway/ContentView.swift | 108 ++++++++++++++++++------------------ Runway/DataHealthView.swift | 6 +- Runway/LimitViews.swift | 30 +++++----- Runway/MenuBarView.swift | 12 ++-- Runway/ModelsView.swift | 12 ++-- Runway/OnboardingView.swift | 64 ++++++++++----------- Runway/SessionsView.swift | 68 +++++++++++------------ Runway/SettingsView.swift | 14 ++--- Runway/WidgetsView.swift | 36 ++++++------ 11 files changed, 225 insertions(+), 225 deletions(-) diff --git a/Runway/AnalysisView.swift b/Runway/AnalysisView.swift index 0410f33..8b84b72 100644 --- a/Runway/AnalysisView.swift +++ b/Runway/AnalysisView.swift @@ -72,7 +72,7 @@ struct AnalysisView: View { var body: some View { VStack(spacing: 0) { AppSectionHeader(section: section) { - HStack(spacing: 8) { + HStack(spacing: AppSpacing.xs) { Picker("Period", selection: periodBinding) { ForEach(UsagePeriod.allCases) { period in Text(period.title).tag(Optional(period)) @@ -93,21 +93,21 @@ struct AnalysisView: View { } if selection.usesCustomDates { - HStack(spacing: 12) { + HStack(spacing: AppSpacing.sm) { DatePicker("From", selection: $selection.startDate, in: ...selection.endDate, displayedComponents: .date) DatePicker("To", selection: $selection.endDate, in: selection.startDate...max(selection.startDate, Date()), displayedComponents: .date) } .datePickerStyle(.field) - .font(.system(size: 11)) - .padding(.horizontal, 18) - .padding(.vertical, 8) + .font(.system(size: AppTypeScale.caption)) + .padding(.horizontal, AppSpacing.md) + .padding(.vertical, AppSpacing.xs) } MagneticScrollView { height in activityChart(height: max(80, height - 116)) } details: { - VStack(spacing: 10) { - LazyVGrid(columns: [GridItem(.adaptive(minimum: 155), spacing: 10)], spacing: 10) { + VStack(spacing: AppSpacing.xs) { + LazyVGrid(columns: [GridItem(.adaptive(minimum: 155), spacing: 10)], spacing: AppSpacing.xs) { modules } @@ -115,35 +115,35 @@ struct AnalysisView: View { InspectorSection(title: "More detail") { DisclosureGroup("Token breakdown") { - VStack(spacing: 8) { + VStack(spacing: AppSpacing.xs) { dataRow("Input", summary.usage.input.compactTokenString) dataRow("Cached input", summary.usage.cachedInput.compactTokenString) dataRow("Output", summary.usage.output.compactTokenString) dataRow("Unpriced lifetime tokens", (snapshot.unpricedTokens ?? 0).compactTokenString) - }.padding(.top, 8) + }.padding(.top, AppSpacing.xs) } DisclosureGroup("Headroom savings") { if let headroom = snapshot.headroom, headroom.isAvailable { - VStack(spacing: 8) { + VStack(spacing: AppSpacing.xs) { dataRow("Today", headroom.todayTokensSaved.compactTokenString) dataRow("7 days", headroom.last7DaysTokensSaved.compactTokenString) dataRow(headroom.trackedPeriodLabel, headroom.lifetimeTokensSaved.compactTokenString) dataRow("Requests compressed", headroom.lifetimeRequests.formatted()) dataRow("\(headroom.trackedPeriodLabel) API estimate avoided", headroom.costSavedUSD.compactCurrencyString) - }.padding(.top, 8) + }.padding(.top, AppSpacing.xs) } else { Text("No Headroom data recorded").foregroundStyle(.secondary) } } DisclosureGroup("Statistics") { - VStack(spacing: 8) { + VStack(spacing: AppSpacing.xs) { dataRow("Current streak", "\(snapshot.currentStreak) days") dataRow("Longest streak", "\(snapshot.longestStreak) days") dataRow("Peak day", snapshot.peakDay?.usage.total.compactTokenString ?? "—") dataRow("Peak date", snapshot.peakDay?.date.formatted(date: .abbreviated, time: .omitted) ?? "—") - }.padding(.top, 8) + }.padding(.top, AppSpacing.xs) } DisclosureGroup("Limit history") { LimitHistoryChart(history: snapshot.rateLimits?.history ?? [], showsFiveHour: snapshot.rateLimits?.showsFiveHour == true) - .frame(height: 125).padding(.top, 8) + .frame(height: 125).padding(.top, AppSpacing.xs) } } } @@ -152,26 +152,26 @@ struct AnalysisView: View { } private func activityChart(height: CGFloat) -> some View { - VStack(alignment: .leading, spacing: 16) { - VStack(alignment: .leading, spacing: 4) { + VStack(alignment: .leading, spacing: AppSpacing.md) { + VStack(alignment: .leading, spacing: AppSpacing.xxs) { Text(hoveredPoint.map { chartPeriod == .lifetime ? "Week of \($0.date.formatted(date: .abbreviated, time: .omitted))" : $0.date.formatted(date: .abbreviated, time: .omitted) } ?? "\(selection.measure == .tokens && (accountDays != nil || accountLifetimeWithoutDays) ? "Account" : "Local") \(periodLabel.lowercased())") - .font(.system(size: 11, weight: .medium)) + .font(.system(size: AppTypeScale.caption, weight: .medium)) .foregroundStyle(AppPalette.muted) - HStack(alignment: .firstTextBaseline, spacing: 7) { + HStack(alignment: .firstTextBaseline, spacing: AppSpacing.xs) { Text(hoveredPoint.map { exactValue($0.value) } ?? formatted(displayedChartValue)) - .font(.system(size: 30, weight: .semibold)).tracking(-0.7) + .font(.system(size: AppTypeScale.display, weight: .semibold)).tracking(-0.7) .monospacedDigit().minimumScaleFactor(0.65).lineLimit(1) Text(selection.measure.title.lowercased()) - .font(.system(size: 12, weight: .medium)).foregroundStyle(AppPalette.muted) + .font(.system(size: AppTypeScale.label, weight: .medium)).foregroundStyle(AppPalette.muted) } if summary.hasPartialLegacyCoverage { Label("Partial local history · Saved daily totals differ from surviving logs", systemImage: "circle.lefthalf.filled") - .font(.system(size: 11)).foregroundStyle(AppPalette.muted) + .font(.system(size: AppTypeScale.caption)).foregroundStyle(AppPalette.muted) } if selection.measure == .tokens, accountPeriodPending { Label(accountDays == nil ? "Account reporting pending · Showing local logs" : "Account today is pending · Showing reported totals", systemImage: "clock") - .font(.system(size: 11)).foregroundStyle(AppPalette.muted) + .font(.system(size: AppTypeScale.caption)).foregroundStyle(AppPalette.muted) } } Chart(chartPoints) { point in @@ -206,7 +206,7 @@ struct AnalysisView: View { } } .chartPlotStyle { plot in - plot.padding(.horizontal, 8) + plot.padding(.horizontal, AppSpacing.xs) } .frame(height: height) .chartOverlay { proxy in @@ -240,8 +240,8 @@ struct AnalysisView: View { .frame(maxWidth: .infinity) } } - .padding(.horizontal, 8) - .padding(.top, 4) + .padding(.horizontal, AppSpacing.xs) + .padding(.top, AppSpacing.xxs) .onChange(of: selection.period) { hoveredDate = nil } .onChange(of: selection.measure) { hoveredDate = nil } } @@ -325,7 +325,7 @@ struct AnalysisView: View { Text(title).foregroundStyle(.secondary) Spacer(minLength: 8) Text(value).monospacedDigit() - }.font(.system(size: 11)) + }.font(.system(size: AppTypeScale.caption)) } private var comparisonText: String? { diff --git a/Runway/AppChrome.swift b/Runway/AppChrome.swift index 2d81c1b..f266d92 100644 --- a/Runway/AppChrome.swift +++ b/Runway/AppChrome.swift @@ -92,29 +92,29 @@ struct AppRail: View { var health: SnapshotHealth var body: some View { - VStack(spacing: 10) { + VStack(spacing: AppSpacing.xs) { Image(nsImage: NSApp.applicationIconImage) .resizable() .scaledToFit() .frame(width: 32, height: 32) - .clipShape(RoundedRectangle(cornerRadius: 9, style: .continuous)) + .clipShape(RoundedRectangle(cornerRadius: AppRadius.small, style: .continuous)) .overlay { - RoundedRectangle(cornerRadius: 9, style: .continuous) + RoundedRectangle(cornerRadius: AppRadius.small, style: .continuous) .stroke(AppPalette.panelBorder, lineWidth: 1) } .accessibilityLabel("Runway") - .padding(.bottom, 5) + .padding(.bottom, AppSpacing.xxs) ForEach(AppSection.allCases.filter { $0 != .analysis }) { section in Button { selection = section } label: { Image(systemName: section.symbol) - .font(.system(size: 14, weight: .semibold)) + .font(.system(size: AppTypeScale.sectionTitle, weight: .semibold)) .frame(width: 34, height: 30) .background( selection == section ? AppPalette.accent.opacity(0.9) : Color.clear, - in: RoundedRectangle(cornerRadius: 8, style: .continuous) + in: RoundedRectangle(cornerRadius: AppRadius.small, style: .continuous) ) .contentShape(Rectangle()) } @@ -132,10 +132,10 @@ struct AppRail: View { presentsDataHealth.toggle() } label: { Image(systemName: health.symbol) - .font(.system(size: 13, weight: .semibold)) + .font(.system(size: AppTypeScale.body, weight: .semibold)) .foregroundStyle(health.color) .frame(width: 34, height: 30) - .background(Color.white.opacity(0.06), in: RoundedRectangle(cornerRadius: 8, style: .continuous)) + .background(Color.white.opacity(0.06), in: RoundedRectangle(cornerRadius: AppRadius.small, style: .continuous)) .contentShape(Rectangle()) } .buttonStyle(.plain) @@ -143,7 +143,7 @@ struct AppRail: View { .help("Data health: \(health.title)") .accessibilityLabel("Data health, \(health.title)") } - .padding(.vertical, 13) + .padding(.vertical, AppSpacing.sm) .frame(width: 52) .background(.thinMaterial) .overlay(alignment: .trailing) { Divider().overlay(AppPalette.divider) } @@ -156,19 +156,19 @@ struct AppSectionHeader: View { var body: some View { ViewThatFits(in: .horizontal) { - HStack(alignment: .center, spacing: 16) { + HStack(alignment: .center, spacing: AppSpacing.md) { labels.fixedSize(horizontal: true, vertical: false) Spacer(minLength: 12) trailing } - VStack(alignment: .leading, spacing: 10) { + VStack(alignment: .leading, spacing: AppSpacing.xs) { labels trailing }.frame(maxWidth: .infinity, alignment: .leading) } .controlSize(.small) - .padding(.horizontal, 18) - .padding(.vertical, 12) + .padding(.horizontal, AppSpacing.md) + .padding(.vertical, AppSpacing.sm) .overlay(alignment: .bottom) { Divider().overlay(AppPalette.divider) } } @@ -193,7 +193,7 @@ struct InspectorSection: View { VStack(alignment: .leading, spacing: 11) { if subtitleInline { ViewThatFits(in: .horizontal) { - HStack(alignment: .firstTextBaseline, spacing: 8) { + HStack(alignment: .firstTextBaseline, spacing: AppSpacing.xs) { Text(title) .font(.system(size: AppTypeScale.sectionTitle, weight: .semibold)) if let subtitle { @@ -210,9 +210,9 @@ struct InspectorSection: View { } content } - .padding(15) + .padding(AppSpacing.md) .frame(maxWidth: .infinity, alignment: .leading) - .appGlassPanel(cornerRadius: 16) + .appGlassPanel(cornerRadius: AppRadius.card) } private var labels: some View { @@ -240,8 +240,8 @@ struct MagneticScrollView: View { let height = max(0, geometry.size.height - 28) ScrollViewReader { proxy in ScrollView { - VStack(alignment: .leading, spacing: 16) { - VStack(spacing: 8) { + VStack(alignment: .leading, spacing: AppSpacing.md) { + VStack(spacing: AppSpacing.xs) { overview(max(0, height - 32)) .frame(maxWidth: .infinity, alignment: .topLeading) Spacer(minLength: 0) @@ -252,8 +252,8 @@ struct MagneticScrollView: View { } label: { Label("Details", systemImage: "chevron.down") .font(.system(size: AppTypeScale.caption, weight: .medium)) - .padding(.horizontal, 12) - .padding(.vertical, 4) + .padding(.horizontal, AppSpacing.sm) + .padding(.vertical, AppSpacing.xxs) .contentShape(Rectangle()) } .buttonStyle(.plain) @@ -268,7 +268,7 @@ struct MagneticScrollView: View { .frame(minHeight: height, alignment: .top) .id("details") } - .padding(14) + .padding(AppSpacing.sm) } .scrollIndicators(.hidden) } @@ -285,7 +285,7 @@ struct MetricModule: View { var accent = false var body: some View { - VStack(alignment: .leading, spacing: 5) { + VStack(alignment: .leading, spacing: AppSpacing.xxs) { HStack { Label(eyebrow, systemImage: symbol) .font(.system(size: AppTypeScale.caption, weight: .semibold)) @@ -312,9 +312,9 @@ struct MetricModule: View { .foregroundStyle(state.color) } } - .padding(12) + .padding(AppSpacing.sm) .frame(maxWidth: .infinity, minHeight: 108, maxHeight: 108, alignment: .topLeading) - .appGlassPanel(cornerRadius: 15) + .appGlassPanel(cornerRadius: AppRadius.card) .accessibilityElement(children: .combine) .accessibilityHint(state.title) } diff --git a/Runway/ContentView.swift b/Runway/ContentView.swift index 4add21b..8389757 100644 --- a/Runway/ContentView.swift +++ b/Runway/ContentView.swift @@ -64,14 +64,14 @@ struct DetailedContentView: View { record: $refreshRecord, isRefreshing: $isRefreshing ) - .background(.regularMaterial, in: RoundedRectangle(cornerRadius: 16, style: .continuous)) + .background(.regularMaterial, in: RoundedRectangle(cornerRadius: AppRadius.card, style: .continuous)) .overlay { - RoundedRectangle(cornerRadius: 16, style: .continuous) + RoundedRectangle(cornerRadius: AppRadius.card, style: .continuous) .stroke(Color.white.opacity(0.12), lineWidth: 1) } .shadow(color: .black.opacity(0.28), radius: 18, y: 8) .padding(.leading, 64) - .padding(.bottom, 16) + .padding(.bottom, AppSpacing.md) } } } @@ -176,8 +176,8 @@ struct ContentView: View { .frame(maxWidth: .infinity, maxHeight: .infinity) } .padding(.leading, 76) - .padding(.trailing, 12) - .padding(.vertical, 12) + .padding(.trailing, AppSpacing.sm) + .padding(.vertical, AppSpacing.sm) .workspaceGlass(shape: shape, namespace: glassNamespace, opaque: reduceTransparency) if !railOpen { @@ -213,7 +213,7 @@ struct ContentView: View { } private var windowControls: some View { - HStack(spacing: 7) { + HStack(spacing: AppSpacing.xs) { Button { NSApp.keyWindow?.close() } label: { Circle().fill(Color.red.opacity(0.8)).frame(width: 11, height: 11) .frame(width: 20, height: 20).contentShape(Rectangle()) @@ -244,12 +244,12 @@ struct ContentView: View { } if section == .analysis { Text(section.title) - .font(.system(size: 11, weight: .medium)) + .font(.system(size: AppTypeScale.caption, weight: .medium)) .foregroundStyle(.secondary) } } .buttonStyle(.plain) - .padding(.horizontal, 22).padding(.top, 15).padding(.bottom, 3) + .padding(.horizontal, AppSpacing.lg).padding(.top, AppSpacing.md).padding(.bottom, AppSpacing.xxs) } private func mouseTracking(height: CGFloat) -> some View { @@ -289,13 +289,13 @@ struct ContentView: View { ForEach(AppSection.allCases) { item in Button { select(item); dismissRail() } label: { Image(systemName: item.symbol) - .font(.system(size: 17, weight: .medium)) + .font(.system(size: AppTypeScale.pageTitle, weight: .medium)) .frame(width: 40, height: 42) .foregroundStyle(section == item ? settingsModel.settings.appTheme.accent : .primary) .background( section == item ? settingsModel.settings.appTheme.accent.opacity(0.18) : hoveredSection == item ? Color.white.opacity(0.08) : .clear, - in: RoundedRectangle(cornerRadius: 12) + in: RoundedRectangle(cornerRadius: AppRadius.control) ) .frame(width: WorkspaceNavigationGeometry.width, height: WorkspaceNavigationGeometry.rowHeight) .contentShape(Rectangle()) @@ -306,15 +306,15 @@ struct ContentView: View { .accessibilityAddTraits(section == item ? .isSelected : []) } } - .padding(.vertical, 7) + .padding(.vertical, AppSpacing.xs) .frame(width: WorkspaceNavigationGeometry.width, height: WorkspaceNavigationGeometry.height) .navigationGlass(namespace: glassNamespace, opaque: reduceTransparency) } private var activityPage: some View { MagneticScrollView { height in - VStack(alignment: .leading, spacing: 12) { - VStack(alignment: .leading, spacing: 5) { + VStack(alignment: .leading, spacing: AppSpacing.sm) { + VStack(alignment: .leading, spacing: AppSpacing.xxs) { HStack { Menu { Button("Follow latest activity") { selectedSessionID = nil } @@ -332,10 +332,10 @@ struct ContentView: View { Text(activity?.status() ?? "Awaiting data") .foregroundStyle(activity?.status() == "Working" ? AppPalette.positive : .secondary) } - .font(.system(size: 11, weight: .medium)) + .font(.system(size: AppTypeScale.caption, weight: .medium)) if let title = activity?.displayTitle { Text(title) - .font(.system(size: 15, weight: .medium)) + .font(.system(size: AppTypeScale.sectionTitle, weight: .medium)) .lineLimit(2) .help(title) } @@ -349,20 +349,20 @@ struct ContentView: View { .help("\(tokens.compactTokenString) / \(window.compactTokenString) context tokens") } } - .font(.system(size: 12)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.label)).foregroundStyle(.secondary) } let usage = activity?.usage ?? snapshot.currentSession - VStack(alignment: .leading, spacing: 10) { + VStack(alignment: .leading, spacing: AppSpacing.xs) { Text("Session usage") - .font(.system(size: 11, weight: .medium)) + .font(.system(size: AppTypeScale.caption, weight: .medium)) .foregroundStyle(.secondary) - HStack(alignment: .firstTextBaseline, spacing: 6) { + HStack(alignment: .firstTextBaseline, spacing: AppSpacing.xs) { Text(usage.total.compactTokenString) - .font(.system(size: 36, weight: .semibold)).tracking(-1.2).monospacedDigit() - Text("tokens").font(.system(size: 12)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.display, weight: .semibold)).tracking(-1.2).monospacedDigit() + Text("tokens").font(.system(size: AppTypeScale.label)).foregroundStyle(.secondary) Spacer(minLength: 8) Text("\((activity?.requests ?? snapshot.currentSessionTurns ?? 0).formatted()) requests") - .font(.system(size: 12)).monospacedDigit().foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.label)).monospacedDigit().foregroundStyle(.secondary) } if let points = activity?.usageHistory, !points.isEmpty { WidgetSparkline(chart: WidgetChartContent( @@ -375,16 +375,16 @@ struct ContentView: View { Spacer() Text("Latest") } - .font(.system(size: 10)) + .font(.system(size: AppTypeScale.micro)) .foregroundStyle(.secondary) } } - .padding(.top, 4) - VStack(alignment: .leading, spacing: 10) { + .padding(.top, AppSpacing.xxs) + VStack(alignment: .leading, spacing: AppSpacing.xs) { Text("Remaining allowance") - .font(.system(size: 11, weight: .medium)) + .font(.system(size: AppTypeScale.caption, weight: .medium)) .foregroundStyle(.secondary) - HStack(alignment: .top, spacing: 20) { + HStack(alignment: .top, spacing: AppSpacing.lg) { if snapshot.rateLimits?.showsFiveHour == true { WidgetAllowanceMeter(title: "5-hour", window: snapshot.rateLimits?.fiveHour, palette: activityPalette, showsConsumption: true, consumptionRate: snapshot.rateLimits?.consumptionPer15Minutes(for: snapshot.rateLimits?.fiveHour)) @@ -393,20 +393,20 @@ struct ContentView: View { showsConsumption: true, consumptionRate: snapshot.rateLimits?.consumptionPer15Minutes(for: snapshot.rateLimits?.weekly)) } } - .padding(12) - .background(.white.opacity(0.035), in: RoundedRectangle(cornerRadius: 14)) + .padding(AppSpacing.sm) + .background(.white.opacity(0.035), in: RoundedRectangle(cornerRadius: AppRadius.card)) Spacer(minLength: 0) HStack { Button { presentsDataHealth = true } label: { - HStack(spacing: 5) { + HStack(spacing: AppSpacing.xxs) { Circle().fill(health.color).frame(width: 5, height: 5) - Text(health.title).font(.system(size: 11)) + Text(health.title).font(.system(size: AppTypeScale.caption)) } } .buttonStyle(.plain).help(health.detail) .popover(isPresented: $presentsDataHealth) { DataHealthView(snapshot: $snapshot, record: $refreshRecord, isRefreshing: $isRefreshing) - .frame(width: 320).padding(14) + .frame(width: 320).padding(AppSpacing.sm) } Spacer() Button { @@ -427,12 +427,12 @@ struct ContentView: View { } .foregroundStyle(.secondary) } - .padding(.horizontal, 8) + .padding(.horizontal, AppSpacing.xs) .frame(minHeight: height, alignment: .top) } details: { InspectorSection(title: "Session details") { let usage = activity?.usage ?? snapshot.currentSession - VStack(spacing: 8) { + VStack(spacing: AppSpacing.xs) { detail("Reasoning", activity?.reasoningEffort?.capitalized) detail("Recorded events", (activity?.usageHistory).map { $0.count.formatted() }) detail("Tools", activity?.toolCalls.map(String.init)) @@ -451,7 +451,7 @@ struct ContentView: View { detail("CLI version", activity?.cliVersion) detail("Approvals", activity?.approvalPolicy) detail("Sandbox", activity?.sandboxMode) - }.font(.system(size: 11)) + }.font(.system(size: AppTypeScale.caption)) } } } @@ -478,22 +478,22 @@ struct ContentView: View { private var activeSessionsPage: some View { ScrollView { - LazyVStack(alignment: .leading, spacing: 10) { + LazyVStack(alignment: .leading, spacing: AppSpacing.xs) { HStack { Text("Recent chats").font(.system(size: AppTypeScale.sectionTitle, weight: .semibold)) Spacer() Text("\(snapshot.sessionActivity.filter { $0.status() == "Working" }.count) working") - .font(.system(size: 10)).foregroundStyle(.secondary) - }.padding(.bottom, 4) + .font(.system(size: AppTypeScale.micro)).foregroundStyle(.secondary) + }.padding(.bottom, AppSpacing.xxs) if snapshot.sessionActivity.isEmpty { ContentUnavailableView("No recent activity", systemImage: "rectangle.stack", description: Text("Chats appear after the next local refresh.")) } ForEach(snapshot.sessionActivity) { session in sessionButton(session) } Button("Browse chat history", systemImage: "clock.arrow.circlepath") { showsSessionHistory = true } - .buttonStyle(.plain).font(.system(size: 11)).foregroundStyle(.secondary) - .padding(.top, 8) - }.padding(18) + .buttonStyle(.plain).font(.system(size: AppTypeScale.caption)).foregroundStyle(.secondary) + .padding(.top, AppSpacing.xs) + }.padding(AppSpacing.md) } } @@ -503,24 +503,24 @@ struct ContentView: View { select(.analysis) } label: { HStack { - VStack(alignment: .leading, spacing: 4) { + VStack(alignment: .leading, spacing: AppSpacing.xxs) { Text(session.displayTitle).fontWeight(.medium).lineLimit(2).help(session.displayTitle) Text(ModelPricingCatalog.displayName(for: session.model)) - .font(.system(size: 11)).foregroundStyle(.secondary).lineLimit(1) + .font(.system(size: AppTypeScale.caption)).foregroundStyle(.secondary).lineLimit(1) } Spacer(minLength: 8) - VStack(alignment: .trailing, spacing: 4) { + VStack(alignment: .trailing, spacing: AppSpacing.xxs) { Text(session.usage.total.compactTokenString) .font(.system(size: AppTypeScale.sectionTitle, weight: .semibold, design: .rounded)) .monospacedDigit() - Text(session.status()).font(.system(size: 10)).foregroundStyle(.secondary) + Text(session.status()).font(.system(size: AppTypeScale.micro)).foregroundStyle(.secondary) } Image(systemName: "chevron.right") - .font(.system(size: 9, weight: .semibold)) + .font(.system(size: AppTypeScale.micro, weight: .semibold)) .foregroundStyle(.tertiary) } - .padding(12) - .appGlassPanel(cornerRadius: 12) + .padding(AppSpacing.sm) + .appGlassPanel(cornerRadius: AppRadius.control) }.buttonStyle(.plain) .help("View activity for \(session.displayTitle)") } @@ -573,7 +573,7 @@ struct SessionUsageChart: View { } var body: some View { - VStack(alignment: .leading, spacing: 6) { + VStack(alignment: .leading, spacing: AppSpacing.xs) { if showsCaption { HStack { Text("SESSION ACTIVITY").tracking(1.2) @@ -584,11 +584,11 @@ struct SessionUsageChart: View { Text("\(points.count) recorded events") } } - .font(.system(size: 10, weight: .medium)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.micro, weight: .medium)).foregroundStyle(.secondary) } if points.isEmpty { Text("Waiting for recorded token events") - .font(.system(size: 11)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.caption)).foregroundStyle(.secondary) .frame(maxWidth: .infinity, maxHeight: .infinity) } else { Chart { @@ -611,7 +611,7 @@ struct SessionUsageChart: View { .chartYAxis(.hidden) .chartXAxis { AxisMarks(values: .automatic(desiredCount: 3)) { _ in - AxisValueLabel(format: .dateTime.hour().minute()).font(.system(size: 10)) + AxisValueLabel(format: .dateTime.hour().minute()).font(.system(size: AppTypeScale.micro)) } } .accessibilityLabel("Recorded cumulative session tokens") @@ -627,7 +627,7 @@ struct CompactLimitRow: View { var accent: Color var body: some View { - VStack(spacing: 5) { + VStack(spacing: AppSpacing.xxs) { HStack { Text(title).fontWeight(.medium) Spacer() @@ -638,7 +638,7 @@ struct CompactLimitRow: View { Text("Awaiting data").foregroundStyle(.secondary) } } - .font(.system(size: 11)) + .font(.system(size: AppTypeScale.caption)) ProgressView(value: window?.isCurrent() == true ? (window?.remainingPercent ?? 0) / 100 : 0) .tint(accent) } diff --git a/Runway/DataHealthView.swift b/Runway/DataHealthView.swift index 80f02f3..3e25445 100644 --- a/Runway/DataHealthView.swift +++ b/Runway/DataHealthView.swift @@ -113,8 +113,8 @@ struct DataHealthView: View { } var body: some View { - VStack(alignment: .leading, spacing: 14) { - HStack(spacing: 9) { + VStack(alignment: .leading, spacing: AppSpacing.sm) { + HStack(spacing: AppSpacing.xs) { Image(systemName: health.symbol) .foregroundStyle(health.color) VStack(alignment: .leading, spacing: 1) { @@ -164,7 +164,7 @@ struct DataHealthView: View { .disabled(isRefreshing) .accessibilityHint("Waits for Codex usage sources and WidgetKit to finish refreshing") } - .padding(16) + .padding(AppSpacing.md) .frame(width: 320) } diff --git a/Runway/LimitViews.swift b/Runway/LimitViews.swift index da06350..7b2a525 100644 --- a/Runway/LimitViews.swift +++ b/Runway/LimitViews.swift @@ -30,7 +30,7 @@ struct LimitSummaryStrip: View { detail: "Local Codex record" ) } - .appGlassPanel(cornerRadius: 16) + .appGlassPanel(cornerRadius: AppRadius.card) } private func percent(_ window: RateLimitWindow?) -> String { @@ -50,21 +50,21 @@ private struct LimitSummaryCell: View { var body: some View { VStack(alignment: .leading, spacing: 2) { Text(value) - .font(.system(size: 15, weight: .bold, design: .rounded)) + .font(.system(size: AppTypeScale.sectionTitle, weight: .bold, design: .rounded)) .monospacedDigit() .lineLimit(1) .minimumScaleFactor(0.7) Text(label) - .font(.system(size: 10, weight: .semibold)) + .font(.system(size: AppTypeScale.micro, weight: .semibold)) .foregroundStyle(.secondary) Text(detail) - .font(.system(size: 9)) + .font(.system(size: AppTypeScale.micro)) .foregroundStyle(.tertiary) .lineLimit(1) } .frame(maxWidth: .infinity, alignment: .leading) - .padding(.horizontal, 12) - .padding(.vertical, 9) + .padding(.horizontal, AppSpacing.sm) + .padding(.vertical, AppSpacing.xs) .background(Color.clear) } } @@ -76,7 +76,7 @@ struct LimitHistoryChart: View { var body: some View { if history.isEmpty { Text("Rate-limit history will appear after Codex reports a limit window.") - .font(.system(size: 11)) + .font(.system(size: AppTypeScale.caption)) .foregroundStyle(.secondary) } else { Chart(history) { point in @@ -105,10 +105,10 @@ struct LimitPreferencesView: View { @State private var phoneTestStatus: String? var body: some View { - VStack(alignment: .leading, spacing: 10) { + VStack(alignment: .leading, spacing: AppSpacing.xs) { if showsMonitoring { Text("Updates follow local changes while Runway and ChatGPT or Codex are running. Widgets keep their last snapshot after either app quits. You can refresh manually at any time.") - .font(.system(size: 10)) + .font(.system(size: AppTypeScale.micro)) .foregroundStyle(.secondary) LabeledContent("Menu bar") { @@ -122,7 +122,7 @@ struct LimitPreferencesView: View { } if settingsModel.settings.menuBarDisplayMode == .hidden { Text("Reopen Runway to show the menu bar item again.") - .font(.system(size: 10)) + .font(.system(size: AppTypeScale.micro)) .foregroundStyle(.secondary) } @@ -142,7 +142,7 @@ struct LimitPreferencesView: View { } if showsNotifications { DisclosureGroup("Notifications") { - VStack(alignment: .leading, spacing: 10) { + VStack(alignment: .leading, spacing: AppSpacing.xs) { Toggle("Desktop reset and limit alerts", isOn: $settingsModel.settings.notificationsEnabled) .onChange(of: settingsModel.settings.notificationsEnabled) { _, enabled in guard enabled else { @@ -186,11 +186,11 @@ struct LimitPreferencesView: View { if settingsModel.settings.phoneNotificationsEnabled { Text("Automatic reset alerts require Runway and ChatGPT or Codex to be running. Install ntfy on your iPhone, then subscribe to this private topic. The topic is stored in Keychain.") - .font(.system(size: 10)) + .font(.system(size: AppTypeScale.micro)) .foregroundStyle(.secondary) if let phoneTopicURL { Text(phoneTopicURL) - .font(.system(size: 10, design: .monospaced)) + .font(.system(size: AppTypeScale.micro, design: .monospaced)) .textSelection(.enabled) HStack { Button("Copy topic URL") { @@ -207,7 +207,7 @@ struct LimitPreferencesView: View { } if let phoneTestStatus { Text(phoneTestStatus) - .font(.system(size: 10)) + .font(.system(size: AppTypeScale.micro)) .foregroundStyle(.secondary) } } @@ -223,7 +223,7 @@ struct LimitPreferencesView: View { } } } - }.padding(.top, 8) + }.padding(.top, AppSpacing.xs) } } } diff --git a/Runway/MenuBarView.swift b/Runway/MenuBarView.swift index aef8cb8..6e2e7bc 100644 --- a/Runway/MenuBarView.swift +++ b/Runway/MenuBarView.swift @@ -138,13 +138,13 @@ struct CodexMenuBarView: View { if settingsModel.settings.appTheme == .runway { settingsModel.settings.appTheme.windowTint } - VStack(alignment: .leading, spacing: 10) { + VStack(alignment: .leading, spacing: AppSpacing.xs) { HStack { Label("Runway", systemImage: "terminal") - .font(.system(size: 12, weight: .semibold)) + .font(.system(size: AppTypeScale.label, weight: .semibold)) Spacer() Text(activity?.status() ?? "Last recorded") - .font(.system(size: 10)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.micro)).foregroundStyle(.secondary) } if model.snapshot.rateLimits?.showsFiveHour == true { CompactLimitRow(title: "5-hour", window: model.snapshot.rateLimits?.fiveHour, accent: accent) @@ -158,11 +158,11 @@ struct CodexMenuBarView: View { Text(ModelPricingCatalog.displayName(for: activity?.model ?? model.snapshot.currentModel)) .foregroundStyle(.secondary).lineLimit(1).truncationMode(.middle) } - .font(.system(size: 11)).monospacedDigit() + .font(.system(size: AppTypeScale.caption)).monospacedDigit() HStack { Circle().fill(model.health.color).frame(width: 5, height: 5) Text(model.health.title) - .font(.system(size: 10)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.micro)).foregroundStyle(.secondary) .help(model.health.detail) Spacer() Button { model.refresh() } label: { @@ -185,7 +185,7 @@ struct CodexMenuBarView: View { } label: { Image(systemName: "ellipsis") } .menuStyle(.borderlessButton).fixedSize() }.buttonStyle(.plain) - }.padding(14) + }.padding(AppSpacing.sm) } .frame(width: 280) .preferredColorScheme(settingsModel.settings.appTheme.colorScheme) diff --git a/Runway/ModelsView.swift b/Runway/ModelsView.swift index cff312f..db08333 100644 --- a/Runway/ModelsView.swift +++ b/Runway/ModelsView.swift @@ -87,10 +87,10 @@ struct ModelsView: View { ) .frame(height: max(80, height - 100)) } else { - VStack(spacing: 10) { + VStack(spacing: AppSpacing.xs) { ForEach(Array(comparedModels.prefix(height < 350 ? 4 : 6))) { model in - VStack(spacing: 5) { - HStack(spacing: 8) { + VStack(spacing: AppSpacing.xxs) { + HStack(spacing: AppSpacing.xs) { Text(ModelPricingCatalog.displayName(for: model.model)) .lineLimit(1) .help(ModelPricingCatalog.displayName(for: model.model)) @@ -116,7 +116,7 @@ struct ModelsView: View { } } } details: { - VStack(spacing: 10) { + VStack(spacing: AppSpacing.xs) { InspectorSection( title: "Attributed models", subtitle: "Tokens, share, requests, and recorded API-equivalent estimate" @@ -126,7 +126,7 @@ struct ModelsView: View { .font(.system(size: AppTypeScale.caption)).foregroundStyle(.secondary) } ForEach(Array(comparedModels.enumerated()), id: \.element.id) { index, model in - VStack(spacing: 8) { + VStack(spacing: AppSpacing.xs) { HStack { Text("\(index + 1). \(ModelPricingCatalog.displayName(for: model.model))") .font(.system(size: AppTypeScale.body, weight: .semibold)).lineLimit(1) @@ -141,7 +141,7 @@ struct ModelsView: View { modelValue(model.availableCostEstimateUSD?.compactCurrencyString ?? "Unpriced", label: "API est.") } } - .padding(.vertical, 7) + .padding(.vertical, AppSpacing.xs) if model.id != comparedModels.last?.id { Divider().overlay(AppPalette.divider) diff --git a/Runway/OnboardingView.swift b/Runway/OnboardingView.swift index 8e0f8b9..40cb668 100644 --- a/Runway/OnboardingView.swift +++ b/Runway/OnboardingView.swift @@ -149,15 +149,15 @@ private struct SetupSheet: View { var body: some View { VStack(spacing: 0) { - HStack(spacing: 14) { + HStack(spacing: AppSpacing.sm) { Image(nsImage: NSApp.applicationIconImage) .resizable() .scaledToFit() .frame(width: 32, height: 32) - .clipShape(RoundedRectangle(cornerRadius: 9, style: .continuous)) + .clipShape(RoundedRectangle(cornerRadius: AppRadius.small, style: .continuous)) VStack(alignment: .leading, spacing: 1) { Text("Set up Runway") - .font(.system(size: 15, weight: .semibold)) + .font(.system(size: AppTypeScale.sectionTitle, weight: .semibold)) Text("Private, local, and ready for widgets") .font(.caption) .foregroundStyle(AppPalette.muted) @@ -165,7 +165,7 @@ private struct SetupSheet: View { Spacer() stepProgress } - .padding(20) + .padding(AppSpacing.lg) Divider() @@ -177,12 +177,12 @@ private struct SetupSheet: View { } } .frame(maxWidth: .infinity, maxHeight: .infinity) - .padding(.horizontal, 34) - .padding(.vertical, 26) + .padding(.horizontal, AppSpacing.xl) + .padding(.vertical, AppSpacing.lg) Divider() footer - .padding(20) + .padding(AppSpacing.lg) } .frame(width: 660, height: 520) .background(AppPalette.windowTint) @@ -195,7 +195,7 @@ private struct SetupSheet: View { } private var stepProgress: some View { - HStack(spacing: 7) { + HStack(spacing: AppSpacing.xs) { ForEach(0..<3) { step in Capsule() .fill(step <= model.page ? AppPalette.accent : Color.white.opacity(0.14)) @@ -211,7 +211,7 @@ private struct SetupSheet: View { } private var privacyPage: some View { - VStack(alignment: .leading, spacing: 16) { + VStack(alignment: .leading, spacing: AppSpacing.md) { pageHeading( symbol: "lock.shield.fill", title: "Your usage stays on this Mac", @@ -224,13 +224,13 @@ private struct SetupSheet: View { } private var accessPage: some View { - VStack(alignment: .leading, spacing: 16) { + VStack(alignment: .leading, spacing: AppSpacing.md) { pageHeading( symbol: "folder.badge.questionmark", title: "Connect your local Codex data", detail: "macOS may ask once for permission to read the Codex sessions folder. Nothing leaves your Mac." ) - HStack(spacing: 14) { + HStack(spacing: AppSpacing.sm) { accessStatus Spacer() if model.dataAccessState != .approved { @@ -239,10 +239,10 @@ private struct SetupSheet: View { .disabled(model.dataAccessState == .requesting) } } - .padding(16) - .background(Color.white.opacity(0.045), in: RoundedRectangle(cornerRadius: 15, style: .continuous)) + .padding(AppSpacing.md) + .background(Color.white.opacity(0.045), in: RoundedRectangle(cornerRadius: AppRadius.card, style: .continuous)) .overlay { - RoundedRectangle(cornerRadius: 15, style: .continuous) + RoundedRectangle(cornerRadius: AppRadius.card, style: .continuous) .stroke(Color.white.opacity(0.09), lineWidth: 1) } Spacer() @@ -250,7 +250,7 @@ private struct SetupSheet: View { } private var servicesPage: some View { - VStack(alignment: .leading, spacing: 16) { + VStack(alignment: .leading, spacing: AppSpacing.md) { pageHeading( symbol: model.unmetRequirements.isEmpty ? "checkmark.seal.fill" : "slider.horizontal.3", title: model.unmetRequirements.isEmpty ? "You’re ready to go" : "Keep widgets up to date", @@ -313,7 +313,7 @@ private struct SetupSheet: View { case .notRequested: statusLabel("Ready to check", symbol: "circle.dashed", color: AppPalette.muted) case .requesting: - HStack(spacing: 10) { + HStack(spacing: AppSpacing.xs) { ProgressView().controlSize(.small) Text("Checking access…") } @@ -342,15 +342,15 @@ private struct SetupSheet: View { } private func pageHeading(symbol: String, title: String, detail: String) -> some View { - HStack(alignment: .top, spacing: 16) { + HStack(alignment: .top, spacing: AppSpacing.md) { Image(systemName: symbol) - .font(.system(size: 22, weight: .semibold)) + .font(.system(size: AppTypeScale.value, weight: .semibold)) .foregroundStyle(AppPalette.accent) .frame(width: 48, height: 48) - .background(AppPalette.accent.opacity(0.14), in: RoundedRectangle(cornerRadius: 14, style: .continuous)) + .background(AppPalette.accent.opacity(0.14), in: RoundedRectangle(cornerRadius: AppRadius.card, style: .continuous)) VStack(alignment: .leading, spacing: 2) { Text(title) - .font(.system(size: 24, weight: .semibold)) + .font(.system(size: AppTypeScale.value, weight: .semibold)) Text(detail) .font(.system(size: AppTypeScale.body)) .foregroundStyle(AppPalette.muted) @@ -360,12 +360,12 @@ private struct SetupSheet: View { } private func setupRow(_ requirement: SetupRequirement, symbol: String, detail: String) -> some View { - HStack(spacing: 13) { + HStack(spacing: AppSpacing.sm) { Image(systemName: symbol) - .font(.system(size: 14, weight: .semibold)) + .font(.system(size: AppTypeScale.sectionTitle, weight: .semibold)) .foregroundStyle(AppPalette.accent) .frame(width: 34, height: 34) - .background(AppPalette.accent.opacity(0.12), in: RoundedRectangle(cornerRadius: 9, style: .continuous)) + .background(AppPalette.accent.opacity(0.12), in: RoundedRectangle(cornerRadius: AppRadius.small, style: .continuous)) VStack(alignment: .leading, spacing: 2) { Text(requirement.title).font(.system(size: AppTypeScale.sectionTitle, weight: .semibold)) Text(detail).font(.caption).foregroundStyle(AppPalette.muted) @@ -374,10 +374,10 @@ private struct SetupSheet: View { Image(systemName: model.state.completedRequirements.contains(requirement) ? "checkmark.circle.fill" : "circle") .foregroundStyle(model.state.completedRequirements.contains(requirement) ? .green : AppPalette.muted) } - .padding(13) - .background(Color.white.opacity(0.045), in: RoundedRectangle(cornerRadius: 14, style: .continuous)) + .padding(AppSpacing.sm) + .background(Color.white.opacity(0.045), in: RoundedRectangle(cornerRadius: AppRadius.card, style: .continuous)) .overlay { - RoundedRectangle(cornerRadius: 14, style: .continuous) + RoundedRectangle(cornerRadius: AppRadius.card, style: .continuous) .stroke(Color.white.opacity(0.09), lineWidth: 1) } } @@ -389,14 +389,14 @@ private struct SetupSheet: View { complete: Bool, @ViewBuilder controls: () -> Controls ) -> some View { - HStack(spacing: 13) { + HStack(spacing: AppSpacing.sm) { Image(systemName: symbol) - .font(.system(size: 14, weight: .semibold)) + .font(.system(size: AppTypeScale.sectionTitle, weight: .semibold)) .foregroundStyle(complete ? Color.green : AppPalette.accent) .frame(width: 34, height: 34) .background( (complete ? Color.green : AppPalette.accent).opacity(0.12), - in: RoundedRectangle(cornerRadius: 9, style: .continuous) + in: RoundedRectangle(cornerRadius: AppRadius.small, style: .continuous) ) VStack(alignment: .leading, spacing: 2) { Text(title).font(.system(size: AppTypeScale.sectionTitle, weight: .semibold)) @@ -405,10 +405,10 @@ private struct SetupSheet: View { Spacer() controls() } - .padding(13) - .background(Color.white.opacity(0.045), in: RoundedRectangle(cornerRadius: 14, style: .continuous)) + .padding(AppSpacing.sm) + .background(Color.white.opacity(0.045), in: RoundedRectangle(cornerRadius: AppRadius.card, style: .continuous)) .overlay { - RoundedRectangle(cornerRadius: 14, style: .continuous) + RoundedRectangle(cornerRadius: AppRadius.card, style: .continuous) .stroke(Color.white.opacity(0.09), lineWidth: 1) } } diff --git a/Runway/SessionsView.swift b/Runway/SessionsView.swift index c21761e..4ff5614 100644 --- a/Runway/SessionsView.swift +++ b/Runway/SessionsView.swift @@ -25,7 +25,7 @@ struct SessionsView: View { Picker("Range", selection: $range) { ForEach(SessionRange.allCases) { Text($0.title).tag($0) } }.pickerStyle(.segmented).labelsHidden() - .padding(.horizontal, 18).padding(.top, 8) + .padding(.horizontal, AppSpacing.md).padding(.top, AppSpacing.xs) } else { AppSectionHeader(section: .sessions) { Picker("Range", selection: $range) { @@ -33,8 +33,8 @@ struct SessionsView: View { }.pickerStyle(.segmented).frame(width: 176) } } - VStack(spacing: 10) { - HStack(spacing: 8) { + VStack(spacing: AppSpacing.xs) { + HStack(spacing: AppSpacing.xs) { Image(systemName: "magnifyingglass").foregroundStyle(.secondary) TextField("Find a chat or model", text: $search) .textFieldStyle(.plain).accessibilityLabel("Search chats") @@ -50,13 +50,13 @@ struct SessionsView: View { .menuStyle(.borderlessButton).fixedSize() .help("Order within each day: \(sort.rawValue)").accessibilityLabel("Sort chats") } - .font(.system(size: 12)).padding(10).appGlassPanel(cornerRadius: 10) + .font(.system(size: AppTypeScale.label)).padding(AppSpacing.xs).appGlassPanel(cornerRadius: AppRadius.control) HStack { Text("\(Set(sessions.map(\.sessionID)).count) chats") Spacer() Text("\(sessions.reduce(0) { $0 + $1.usage.total }.compactTokenString) tokens").monospacedDigit() - }.font(.system(size: 11, weight: .medium)).foregroundStyle(.secondary) - }.padding(.horizontal, 18).padding(.vertical, 12) + }.font(.system(size: AppTypeScale.caption, weight: .medium)).foregroundStyle(.secondary) + }.padding(.horizontal, AppSpacing.md).padding(.vertical, AppSpacing.sm) if sessions.isEmpty { ContentUnavailableView( @@ -67,14 +67,14 @@ struct SessionsView: View { ).frame(maxWidth: .infinity, maxHeight: .infinity) } else { ScrollView { - LazyVStack(alignment: .leading, spacing: 18) { + LazyVStack(alignment: .leading, spacing: AppSpacing.md) { ForEach(days) { day in - VStack(alignment: .leading, spacing: 8) { + VStack(alignment: .leading, spacing: AppSpacing.xs) { HStack { Text(day.title) Spacer() Text(day.sessions.reduce(0) { $0 + $1.usage.total }.compactTokenString).monospacedDigit() - }.font(.system(size: 10, weight: .semibold)).foregroundStyle(.secondary) + }.font(.system(size: AppTypeScale.micro, weight: .semibold)).foregroundStyle(.secondary) ForEach(day.sessions) { session in Button { selectedSession = session } label: { SessionRow(session: session) } .buttonStyle(.plain).help("Inspect \(session.displayTitle)") @@ -82,9 +82,9 @@ struct SessionsView: View { } } Text("Each row shows a chat’s usage for that day. API estimates are not subscription spending.") - .font(.system(size: 10)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.micro)).foregroundStyle(.secondary) .fixedSize(horizontal: false, vertical: true) - }.padding(.horizontal, 18).padding(.bottom, 18) + }.padding(.horizontal, AppSpacing.md).padding(.bottom, AppSpacing.md) } } } @@ -110,25 +110,25 @@ private struct SessionDay: Identifiable { private struct SessionRow: View { var session: CodexSessionSummary var body: some View { - HStack(alignment: .top, spacing: 12) { - VStack(alignment: .leading, spacing: 5) { - Text(session.displayTitle).font(.system(size: 12, weight: .semibold)).lineLimit(2) + HStack(alignment: .top, spacing: AppSpacing.sm) { + VStack(alignment: .leading, spacing: AppSpacing.xxs) { + Text(session.displayTitle).font(.system(size: AppTypeScale.label, weight: .semibold)).lineLimit(2) Text(ModelPricingCatalog.displayName(for: session.model)) - .font(.system(size: 10)).foregroundStyle(.secondary).lineLimit(1) + .font(.system(size: AppTypeScale.micro)).foregroundStyle(.secondary).lineLimit(1) Text("\(session.startedAt.formatted(date: .omitted, time: .shortened)) · \(session.turns.formatted()) \(session.turns == 1 ? "request" : "requests")") - .font(.system(size: 10)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.micro)).foregroundStyle(.secondary) } Spacer(minLength: 4) - VStack(alignment: .trailing, spacing: 5) { - Text(session.usage.total.compactTokenString).font(.system(size: 14, weight: .semibold, design: .rounded)) - Text("tokens").font(.system(size: 9)).foregroundStyle(.secondary) + VStack(alignment: .trailing, spacing: AppSpacing.xxs) { + Text(session.usage.total.compactTokenString).font(.system(size: AppTypeScale.sectionTitle, weight: .semibold, design: .rounded)) + Text("tokens").font(.system(size: AppTypeScale.micro)).foregroundStyle(.secondary) Text(session.estimatedCostUSD?.compactCurrencyString ?? "Unpriced") - .font(.system(size: 10)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.micro)).foregroundStyle(.secondary) }.monospacedDigit() - Image(systemName: "chevron.right").font(.system(size: 9, weight: .semibold)) - .foregroundStyle(.tertiary).padding(.top, 4) - }.padding(12).frame(maxWidth: .infinity, alignment: .leading) - .appGlassPanel(cornerRadius: 12).contentShape(Rectangle()) + Image(systemName: "chevron.right").font(.system(size: AppTypeScale.micro, weight: .semibold)) + .foregroundStyle(.tertiary).padding(.top, AppSpacing.xxs) + }.padding(AppSpacing.sm).frame(maxWidth: .infinity, alignment: .leading) + .appGlassPanel(cornerRadius: AppRadius.control).contentShape(Rectangle()) .accessibilityElement(children: .combine) } } @@ -139,18 +139,18 @@ private struct SessionDetailView: View { var onSelectActivity: ((String) -> Void)? @Environment(\.dismiss) private var dismiss var body: some View { - VStack(alignment: .leading, spacing: 16) { + VStack(alignment: .leading, spacing: AppSpacing.md) { HStack(alignment: .top) { - VStack(alignment: .leading, spacing: 5) { - Text(session.displayTitle).font(.system(size: 20, weight: .semibold)).lineLimit(3) + VStack(alignment: .leading, spacing: AppSpacing.xxs) { + Text(session.displayTitle).font(.system(size: AppTypeScale.pageTitle, weight: .semibold)).lineLimit(3) Text(session.updatedAt.formatted(.dateTime.month(.wide).day().year())) - .font(.system(size: 11)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.caption)).foregroundStyle(.secondary) } Spacer() Button("Done") { dismiss() }.keyboardShortcut(.cancelAction) } ScrollView { - VStack(alignment: .leading, spacing: 16) { + VStack(alignment: .leading, spacing: AppSpacing.md) { InspectorSection(title: "Recorded usage", subtitle: "For this day") { row("Model", ModelPricingCatalog.displayName(for: session.model)) row("Tokens", session.usage.total.formatted()) @@ -165,7 +165,7 @@ private struct SessionDetailView: View { row("Output", session.usage.output.formatted()) row("Reasoning output", session.usage.reasoningOutput.formatted()) Text("Cached input is part of input. Reasoning is part of output.") - .font(.system(size: 10)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.micro)).foregroundStyle(.secondary) } if let activity { InspectorSection(title: "Latest chat activity") { @@ -181,19 +181,19 @@ private struct SessionDetailView: View { } } Text("Session ID: \(session.sessionID)") - .font(.system(size: 10, design: .monospaced)).foregroundStyle(.secondary).textSelection(.enabled) + .font(.system(size: AppTypeScale.micro, design: .monospaced)).foregroundStyle(.secondary).textSelection(.enabled) Text("API estimates use recorded model rates and do not represent subscription spending.") - .font(.system(size: 10)).foregroundStyle(.secondary) + .font(.system(size: AppTypeScale.micro)).foregroundStyle(.secondary) } } - }.padding(20).frame(minWidth: 360, idealWidth: 420, maxWidth: 520, minHeight: 440, idealHeight: 540) + }.padding(AppSpacing.lg).frame(minWidth: 360, idealWidth: 420, maxWidth: 520, minHeight: 440, idealHeight: 540) } private func row(_ label: String, _ value: String) -> some View { HStack(alignment: .firstTextBaseline) { Text(label).foregroundStyle(.secondary) Spacer(minLength: 12) Text(value).multilineTextAlignment(.trailing).textSelection(.enabled) - }.font(.system(size: 12)).accessibilityElement(children: .ignore) + }.font(.system(size: AppTypeScale.label)).accessibilityElement(children: .ignore) .accessibilityLabel("\(label), \(value)") } } diff --git a/Runway/SettingsView.swift b/Runway/SettingsView.swift index 16545a9..f035e4e 100644 --- a/Runway/SettingsView.swift +++ b/Runway/SettingsView.swift @@ -11,7 +11,7 @@ struct SettingsView: View { } ScrollView { - VStack(spacing: 12) { + VStack(spacing: AppSpacing.sm) { InspectorSection(title: "Appearance") { LabeledContent("App theme") { Picker("App theme", selection: $settingsModel.settings.appTheme) { @@ -31,10 +31,10 @@ struct SettingsView: View { Spacer() Link("GitHub", destination: URL(string: "https://github.com/Italian-seasoning/CodexUsageMonitor")!) } - .font(.system(size: 11, weight: .medium)) - .padding(.horizontal, 4) + .font(.system(size: AppTypeScale.caption, weight: .medium)) + .padding(.horizontal, AppSpacing.xxs) DisclosureGroup("Setup and updates") { - VStack(spacing: 12) { + VStack(spacing: AppSpacing.sm) { HStack { VStack(alignment: .leading, spacing: 2) { Text("Codex data access").font(.system(size: AppTypeScale.body, weight: .semibold)) @@ -63,15 +63,15 @@ struct SettingsView: View { } LabeledContent("Version", value: Bundle.main.object(forInfoDictionaryKey: "CFBundleShortVersionString") as? String ?? "—") LabeledContent("Built", value: buildDate) - }.padding(.top, 10) + }.padding(.top, AppSpacing.xs) } } .frame(maxWidth: 720) .frame(maxWidth: .infinity) - .padding(14) + .padding(AppSpacing.sm) } } - .font(.system(size: 12)) + .font(.system(size: AppTypeScale.label)) .controlSize(.small) } diff --git a/Runway/WidgetsView.swift b/Runway/WidgetsView.swift index 1056204..f013bfc 100644 --- a/Runway/WidgetsView.swift +++ b/Runway/WidgetsView.swift @@ -53,21 +53,21 @@ struct WidgetsView: View { GeometryReader { geometry in if geometry.size.width < 650 { ScrollView { - VStack(spacing: 12) { + VStack(spacing: AppSpacing.sm) { sizeControls compactPreview(height: min(selectedSize.previewFrame.height, geometry.size.width - 28)) contentControls appearanceControls } - .padding(14) + .padding(AppSpacing.sm) } } else { ScrollView { - HStack(alignment: .top, spacing: 12) { + HStack(alignment: .top, spacing: AppSpacing.sm) { controls.frame(width: 310) preview.frame(maxWidth: .infinity, minHeight: 448) } - .padding(16) + .padding(AppSpacing.md) } .task { await loadWallpaper() } } @@ -89,7 +89,7 @@ struct WidgetsView: View { size: selectedSize.cardSize, monochrome: currentConfiguration.theme == .monochrome) } .frame(width: frame.width, height: frame.height) - .clipShape(RoundedRectangle(cornerRadius: 22)) + .clipShape(RoundedRectangle(cornerRadius: AppRadius.panel)) .scaleEffect(scale) .position(x: geometry.size.width / 2, y: height / 2) } @@ -109,7 +109,7 @@ struct WidgetsView: View { } private var controls: some View { - VStack(spacing: 12) { + VStack(spacing: AppSpacing.sm) { sizeControls contentControls appearanceControls @@ -117,9 +117,9 @@ struct WidgetsView: View { } private var sizeControls: some View { - VStack(alignment: .leading, spacing: 8) { - HStack(spacing: 6) { - Text("Size").font(.system(size: 12, weight: .semibold)) + VStack(alignment: .leading, spacing: AppSpacing.xs) { + HStack(spacing: AppSpacing.xs) { + Text("Size").font(.system(size: AppTypeScale.label, weight: .semibold)) Spacer() Circle() .fill(configuredSizes.contains(selectedSize) ? AppPalette.positive : AppPalette.muted) @@ -226,7 +226,7 @@ struct WidgetsView: View { } LabeledContent("Background") { - HStack(spacing: 8) { + HStack(spacing: AppSpacing.xs) { Button(currentConfiguration.backgroundMode == .customImage ? "Replace…" : "Choose Image…") { chooseBackgroundImage() } @@ -246,7 +246,7 @@ struct WidgetsView: View { Divider().overlay(AppPalette.divider) LabeledContent("Save mix") { - HStack(spacing: 6) { + HStack(spacing: AppSpacing.xs) { TextField("Name", text: $presetName) Button("Save") { savePreset() } .disabled(presetName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty) @@ -467,7 +467,7 @@ private struct DesktopWidgetPreview: View { .fill(.ultraThinMaterial) .frame(height: 25) - HStack(spacing: 6) { + HStack(spacing: AppSpacing.xs) { Circle().fill(.white.opacity(0.82)).frame(width: 4, height: 4) Text("Desktop · top-left preview") .font(.system(size: AppTypeScale.caption, weight: .semibold)) @@ -477,16 +477,16 @@ private struct DesktopWidgetPreview: View { .font(.system(size: AppTypeScale.caption, weight: .semibold)) .foregroundStyle(.white.opacity(0.88)) } - .padding(.horizontal, 12) + .padding(.horizontal, AppSpacing.sm) .frame(height: 25) widget - .padding(.leading, 28) + .padding(.leading, AppSpacing.lg) .padding(.top, 48) } - .clipShape(RoundedRectangle(cornerRadius: 18, style: .continuous)) + .clipShape(RoundedRectangle(cornerRadius: AppRadius.panel, style: .continuous)) .overlay { - RoundedRectangle(cornerRadius: 18, style: .continuous) + RoundedRectangle(cornerRadius: AppRadius.panel, style: .continuous) .stroke(AppPalette.panelBorder, lineWidth: 1) } .shadow(color: .black.opacity(0.24), radius: 16, y: 8) @@ -526,9 +526,9 @@ private struct DesktopWidgetPreview: View { ) } .frame(width: size.previewFrame.width, height: size.previewFrame.height) - .clipShape(RoundedRectangle(cornerRadius: 22, style: .continuous)) + .clipShape(RoundedRectangle(cornerRadius: AppRadius.panel, style: .continuous)) .overlay { - RoundedRectangle(cornerRadius: 22, style: .continuous) + RoundedRectangle(cornerRadius: AppRadius.panel, style: .continuous) .stroke(Color.white.opacity(0.12), lineWidth: 1) } .shadow(color: .black.opacity(0.3), radius: 14, y: 8) From 2005b7a5669867bf84bda9aeb0ff5476598c77b3 Mon Sep 17 00:00:00 2001 From: Italian-seasoning <99997342+Italian-seasoning@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:27:50 -0700 Subject: [PATCH 3/9] Activity page: permanent rail, one card style, fewer footnotes - The navigation rail now always sits in the left strip instead of hiding behind an edge-pull gesture; pages change on click, not on hover. - Session usage and remaining allowance share the glass card style, and the chart grows to fill the space that was left empty. - One read time replaces the per-meter read/reset/rate notes; reset times move to tooltips. The lone Activity label is gone. - The unused cursor glow border is now on the activity cards, and the rail's glass carries the theme tint so the desktop does not show through as a dark band. --- Runway/AppChrome.swift | 4 +- Runway/ContentView.swift | 76 +++++++++++++++++------------------ Shared/WidgetComponents.swift | 10 ++++- 3 files changed, 48 insertions(+), 42 deletions(-) diff --git a/Runway/AppChrome.swift b/Runway/AppChrome.swift index f266d92..dce74d3 100644 --- a/Runway/AppChrome.swift +++ b/Runway/AppChrome.swift @@ -793,8 +793,8 @@ extension View { } else if #available(macOS 26.0, *) { background { RoundedRectangle(cornerRadius: AppRadius.panel) - .fill(Color.clear) - .glassEffect(.regular.interactive(), in: RoundedRectangle(cornerRadius: AppRadius.panel)) + .fill(AppPalette.windowTint) + .glassEffect(.regular.tint(AppPalette.panelTint).interactive(), in: RoundedRectangle(cornerRadius: AppRadius.panel)) .glassEffectID("navigation", in: namespace) .glassEffectTransition(.identity) } diff --git a/Runway/ContentView.swift b/Runway/ContentView.swift index 8389757..1c97db5 100644 --- a/Runway/ContentView.swift +++ b/Runway/ContentView.swift @@ -152,7 +152,7 @@ struct ContentView: View { private var workspace: some View { GeometryReader { geometry in - let shape = WorkspaceGlassShape(pull: reduceMotion ? 0 : stretch, anchor: edgeAnchor) + let shape = WorkspaceGlassShape(pull: 0, anchor: edgeAnchor) ZStack(alignment: .topLeading) { workspaceSurface(shape) .allowsHitTesting(false) @@ -180,21 +180,10 @@ struct ContentView: View { .padding(.vertical, AppSpacing.sm) .workspaceGlass(shape: shape, namespace: glassNamespace, opaque: reduceTransparency) - if !railOpen { - Capsule() - .fill(Color.primary.opacity(0.38)) - .frame(width: 3, height: 32) - .position(x: 82 - stretch * 32, y: geometry.size.height / 2) - .allowsHitTesting(false) - .accessibilityHidden(true) - } - if railOpen { - navigationRail - .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading) - .padding(.leading, 41 - WorkspaceNavigationGeometry.width / 2) - .transition(reduceMotion ? .opacity : .offset(x: 18).combined(with: .opacity)) - } - mouseTracking(height: geometry.size.height) + // The rail is always present so the left edge reads as navigation, not empty space. + navigationRail + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .leading) + .padding(.leading, 41 - WorkspaceNavigationGeometry.width / 2) } .coordinateSpace(name: "workspace") .animation(motion, value: section) @@ -242,11 +231,6 @@ struct ContentView: View { } else { Spacer() } - if section == .analysis { - Text(section.title) - .font(.system(size: AppTypeScale.caption, weight: .medium)) - .foregroundStyle(.secondary) - } } .buttonStyle(.plain) .padding(.horizontal, AppSpacing.lg).padding(.top, AppSpacing.md).padding(.bottom, AppSpacing.xxs) @@ -287,7 +271,7 @@ struct ContentView: View { private var navigationRail: some View { VStack(spacing: 0) { ForEach(AppSection.allCases) { item in - Button { select(item); dismissRail() } label: { + Button { select(item) } label: { Image(systemName: item.symbol) .font(.system(size: AppTypeScale.pageTitle, weight: .medium)) .frame(width: 40, height: 42) @@ -369,33 +353,42 @@ struct ContentView: View { points: points.map { WidgetChartPoint(date: $0.date, value: Double($0.totalTokens)) }, accessibilitySummary: "Session token history, latest \(usage.total.compactTokenString) tokens" ), palette: activityPalette) - .frame(height: max(24, height - 362)) - HStack { - Text("Recent history") - Spacer() - Text("Latest") - } - .font(.system(size: AppTypeScale.micro)) - .foregroundStyle(.secondary) + .frame(minHeight: 40, maxHeight: .infinity) + } else { + Spacer(minLength: 0) } } - .padding(.top, AppSpacing.xxs) + .padding(AppSpacing.sm) + .frame(maxHeight: .infinity, alignment: .top) + .appGlassPanel() + .cursorGlowBorder(radius: AppRadius.card, accent: settingsModel.settings.appTheme.accent, isEnabled: !reduceMotion) VStack(alignment: .leading, spacing: AppSpacing.xs) { - Text("Remaining allowance") - .font(.system(size: AppTypeScale.caption, weight: .medium)) - .foregroundStyle(.secondary) + HStack(alignment: .firstTextBaseline) { + Text("Remaining allowance") + Spacer(minLength: AppSpacing.xs) + if let observed = snapshot.rateLimits?.weekly?.observedAt ?? snapshot.rateLimits?.fiveHour?.observedAt { + Text(observed.formatted(date: .omitted, time: .shortened)).monospacedDigit() + .help("Last read \(observed.formatted(date: .abbreviated, time: .shortened))") + } + } + .font(.system(size: AppTypeScale.caption, weight: .medium)) + .foregroundStyle(.secondary) HStack(alignment: .top, spacing: AppSpacing.lg) { if snapshot.rateLimits?.showsFiveHour == true { WidgetAllowanceMeter(title: "5-hour", window: snapshot.rateLimits?.fiveHour, palette: activityPalette, - showsConsumption: true, consumptionRate: snapshot.rateLimits?.consumptionPer15Minutes(for: snapshot.rateLimits?.fiveHour)) + showsConsumption: true, consumptionRate: snapshot.rateLimits?.consumptionPer15Minutes(for: snapshot.rateLimits?.fiveHour), + showsFootnotes: false) + .help(resetHelp(snapshot.rateLimits?.fiveHour)) } WidgetAllowanceMeter(title: "Weekly", window: snapshot.rateLimits?.weekly, palette: activityPalette, - showsConsumption: true, consumptionRate: snapshot.rateLimits?.consumptionPer15Minutes(for: snapshot.rateLimits?.weekly)) + showsConsumption: true, consumptionRate: snapshot.rateLimits?.consumptionPer15Minutes(for: snapshot.rateLimits?.weekly), + showsFootnotes: false) + .help(resetHelp(snapshot.rateLimits?.weekly)) } } .padding(AppSpacing.sm) - .background(.white.opacity(0.035), in: RoundedRectangle(cornerRadius: AppRadius.card)) - Spacer(minLength: 0) + .appGlassPanel() + .cursorGlowBorder(radius: AppRadius.card, accent: settingsModel.settings.appTheme.accent, isEnabled: !reduceMotion) HStack { Button { presentsDataHealth = true } label: { HStack(spacing: AppSpacing.xxs) { @@ -428,7 +421,7 @@ struct ContentView: View { .foregroundStyle(.secondary) } .padding(.horizontal, AppSpacing.xs) - .frame(minHeight: height, alignment: .top) + .frame(height: height, alignment: .top) } details: { InspectorSection(title: "Session details") { let usage = activity?.usage ?? snapshot.currentSession @@ -525,6 +518,11 @@ struct ContentView: View { .help("View activity for \(session.displayTitle)") } + private func resetHelp(_ window: RateLimitWindow?) -> String { + guard let window else { return "Not reported" } + return "Resets \(window.resetsAt.formatted(date: .abbreviated, time: .shortened))" + } + private var health: SnapshotHealth { SnapshotHealth(snapshot: snapshot, record: refreshRecord, isRefreshing: isRefreshing) } private var activityPalette: WidgetStylePalette { diff --git a/Shared/WidgetComponents.swift b/Shared/WidgetComponents.swift index 96fb018..da7bdfa 100644 --- a/Shared/WidgetComponents.swift +++ b/Shared/WidgetComponents.swift @@ -255,6 +255,8 @@ struct WidgetAllowanceMeter: View { var now: Date = .now var showsConsumption = false var consumptionRate: Double? = nil + /// Per-meter read/reset line. Hosts that show one shared timestamp turn this off. + var showsFootnotes = true private var current: RateLimitWindow? { window.flatMap { $0.isCurrent(at: now) ? $0 : nil } @@ -279,7 +281,13 @@ struct WidgetAllowanceMeter: View { .frame(width: geometry.size.width * CGFloat(min(1, max(0, (current?.remainingPercent ?? 0) / 100)))) } }.frame(height: 4) - if !compact { + if !compact, showsConsumption, !showsFootnotes, let consumptionRate { + Text("≈\(consumptionRate.formatted(.number.precision(.fractionLength(1))))% / 15 min") + .font(.system(size: 10, weight: .medium)) + .foregroundStyle(palette.secondary) + .lineLimit(1) + } + if !compact && showsFootnotes { Text(current.map { now.timeIntervalSince($0.observedAt) > 180 ? "Read \($0.observedAt.formatted(date: .abbreviated, time: .shortened))" : "Resets \($0.resetsAt.formatted(date: .abbreviated, time: .shortened))" } ?? "Not reported") From ccf1b3ee6b4d51884bda38858ab2664c789ebc9e Mon Sep 17 00:00:00 2001 From: Italian-seasoning <99997342+Italian-seasoning@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:29:27 -0700 Subject: [PATCH 4/9] Open at login so widgets stay current Widgets and the Droppy droplet read what the app last wrote; with the app closed they silently went stale (the installed copy last wrote on Nov 4). An installed copy now registers as a login item once on first launch, and Settings > Monitoring has an Open at login switch. --- Runway/RunwayApp.swift | 1 + Runway/SettingsView.swift | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) diff --git a/Runway/RunwayApp.swift b/Runway/RunwayApp.swift index bafd2bb..92eb152 100644 --- a/Runway/RunwayApp.swift +++ b/Runway/RunwayApp.swift @@ -37,6 +37,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } _ = AppUpdater.shared if BackgroundRefreshAgent.isStableInstall { + LoginItem.enableOnFirstLaunch() AppRegistration.refresh() } DispatchQueue.global(qos: .utility).async { diff --git a/Runway/SettingsView.swift b/Runway/SettingsView.swift index f035e4e..c5e2e73 100644 --- a/Runway/SettingsView.swift +++ b/Runway/SettingsView.swift @@ -1,8 +1,33 @@ +import ServiceManagement import SwiftUI +/// Widgets and the Droppy droplet only show what the app last wrote, so Runway +/// opens at login by default. The first launch of an installed copy turns it on once; +/// after that the user's choice in Settings wins. +enum LoginItem { + private static let configuredKey = "Runway.loginItemConfigured" + + static var isEnabled: Bool { SMAppService.mainApp.status == .enabled } + + static func set(_ enabled: Bool) { + UserDefaults.standard.set(true, forKey: configuredKey) + do { + if enabled { try SMAppService.mainApp.register() } else { try SMAppService.mainApp.unregister() } + } catch { + NSLog("Runway login item change failed: \(error.localizedDescription)") + } + } + + static func enableOnFirstLaunch() { + guard !UserDefaults.standard.bool(forKey: configuredKey) else { return } + set(true) + } +} + struct SettingsView: View { @EnvironmentObject private var settingsModel: CodexUsageSettingsModel @ObservedObject private var updater = AppUpdater.shared + @State private var openAtLogin = LoginItem.isEnabled var body: some View { VStack(spacing: 0) { @@ -23,6 +48,11 @@ struct SettingsView: View { } InspectorSection(title: "Monitoring") { + Toggle("Open at login", isOn: Binding(get: { openAtLogin }, set: { value in + LoginItem.set(value) + openAtLogin = LoginItem.isEnabled + })) + .help("Keeps widgets and the Droppy droplet current. Runway does no work while Codex is closed.") LimitPreferencesView() } HStack { From 3af27b9fe0580d460010692e8f7815c27fcbd52b Mon Sep 17 00:00:00 2001 From: Italian-seasoning <99997342+Italian-seasoning@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:30:47 -0700 Subject: [PATCH 5/9] Menu bar item: real height, fixed width, drawn meters The status item was drawn at a fixed 22 pt with 9 pt two-line text and a width that changed with the values. It now uses the system menu bar thickness (taller on notched displays), scales its text with it, reserves the widest value so neighbouring items stay put, and draws Meter mode as bars instead of dot characters. --- Runway/MenuBarView.swift | 67 +++++++++++++++++++++++++++++++++------- 1 file changed, 55 insertions(+), 12 deletions(-) diff --git a/Runway/MenuBarView.swift b/Runway/MenuBarView.swift index 6e2e7bc..8588719 100644 --- a/Runway/MenuBarView.swift +++ b/Runway/MenuBarView.swift @@ -69,7 +69,7 @@ struct CodexMenuBarLabel: View { var body: some View { let stale = model.health.kind != .freshComplete && model.health.kind != .freshPartial let lines = labelLines - let image = Self.labelImage(lines: lines) + let image = Self.labelImage(lines: lines, fractions: labelFractions, mode: settingsModel.settings.menuBarDisplayMode) Image(nsImage: image) .resizable() .frame(width: image.size.width, height: image.size.height) @@ -79,19 +79,55 @@ struct CodexMenuBarLabel: View { .accessibilityValue(lines.joined(separator: ", ")) } - private static func labelImage(lines: [String]) -> NSImage { + /// Draws the status item at the real menu bar height (taller on notched displays) + /// and at a fixed width per mode, so neighbouring items do not shift as values change. + private static func labelImage(lines: [String], fractions: [Double?], mode: MenuBarDisplayMode) -> NSImage { + let barHeight = max(22, NSStatusBar.system.thickness) let singleLine = lines.count == 1 - let font = NSFont.monospacedDigitSystemFont(ofSize: singleLine ? 13 : 9, weight: .medium) - let attributes: [NSAttributedString.Key: Any] = [ - .font: font, - .foregroundColor: NSColor.white, - ] - let sizes = lines.map { ($0 as NSString).size(withAttributes: attributes) } - let size = NSSize(width: ceil(sizes.map(\.width).max() ?? 1), height: 22) - let image = NSImage(size: size, flipped: true) { _ in + let fontSize = singleLine ? (barHeight * 0.56).rounded() : (barHeight * 0.42).rounded() + let font = NSFont.monospacedDigitSystemFont(ofSize: fontSize, weight: .semibold) + let attributes: [NSAttributedString.Key: Any] = [.font: font, .foregroundColor: NSColor.white] + let lineHeight = singleLine ? barHeight : barHeight / 2 + let prefixes = lines.map { String($0.split(separator: " ").first ?? "") } + + if mode == .meter { + let prefixWidth = ceil(("5H" as NSString).size(withAttributes: attributes).width) + let meterWidth: CGFloat = singleLine ? 34 : 28 + let size = NSSize(width: prefixWidth + 4 + meterWidth, height: barHeight) + let image = NSImage(size: size, flipped: true) { _ in + for index in lines.indices { + let top = CGFloat(index) * lineHeight + let textHeight = (prefixes[index] as NSString).size(withAttributes: attributes).height + (prefixes[index] as NSString).draw(at: NSPoint(x: 0, y: top + (lineHeight - textHeight) / 2), withAttributes: attributes) + let thickness: CGFloat = singleLine ? 5 : 4 + let track = NSRect(x: prefixWidth + 4, y: top + (lineHeight - thickness) / 2, width: meterWidth, height: thickness) + NSColor.white.withAlphaComponent(0.35).setFill() + NSBezierPath(roundedRect: track, xRadius: thickness / 2, yRadius: thickness / 2).fill() + if let fraction = fractions[index] { + var fill = track + fill.size.width = max(thickness, track.width * CGFloat(min(1, max(0, fraction)))) + NSColor.white.setFill() + NSBezierPath(roundedRect: fill, xRadius: thickness / 2, yRadius: thickness / 2).fill() + } + } + return true + } + image.isTemplate = true + return image + } + + // Reserve the widest value this mode can show so the item never changes width. + let widest: String = switch mode { + case .reset: "5H 12:59 PM" + default: "5H 100%" + } + let width = ceil(max((widest as NSString).size(withAttributes: attributes).width, + lines.map { ($0 as NSString).size(withAttributes: attributes).width }.max() ?? 1)) + let image = NSImage(size: NSSize(width: width, height: barHeight), flipped: true) { _ in for (index, line) in lines.enumerated() { - let y = singleLine ? (22 - sizes[index].height) / 2 : CGFloat(index * 11) - (line as NSString).draw(at: NSPoint(x: 0, y: y), withAttributes: attributes) + let textSize = (line as NSString).size(withAttributes: attributes) + let top = CGFloat(index) * lineHeight + (lineHeight - textSize.height) / 2 + (line as NSString).draw(at: NSPoint(x: width - textSize.width, y: top), withAttributes: attributes) } return true } @@ -99,6 +135,13 @@ struct CodexMenuBarLabel: View { return image } + private var labelFractions: [Double?] { + let limits = model.snapshot.rateLimits + var values = [limits?.weekly.map { $0.remainingPercent / 100 }] + if limits?.showsFiveHour == true { values.insert(limits?.fiveHour.map { $0.remainingPercent / 100 }, at: 0) } + return values + } + private var labelLines: [String] { let limits = model.snapshot.rateLimits let mode = settingsModel.settings.menuBarDisplayMode From f7726d8cfd880a089f178070e74bb00dabfd4673 Mon Sep 17 00:00:00 2001 From: Italian-seasoning <99997342+Italian-seasoning@users.noreply.github.com> Date: Sun, 15 Nov 2026 19:39:18 -0700 Subject: [PATCH 6/9] Bring the Droppy droplet into the repo as Runway 1.1.0 The droplet source only existed as untracked files. It now lives in Droplet/, is renamed to Runway, shows remaining 5-hour and weekly allowance, matches all six Runway themes, and dims stale data with the time it was last updated instead of silently showing old numbers. --- Droplet/.gitignore | 3 + Droplet/AGENTS.md | 205 ++++++++++++++++ Droplet/Assets/Creator.png | Bin 0 -> 2620 bytes Droplet/CHANGELOG.md | 17 ++ Droplet/Codexusage.icon/Assets/mark.png | Bin 0 -> 2012 bytes Droplet/Codexusage.icon/icon.json | 42 ++++ Droplet/Package.resolved | 15 ++ Droplet/Package.swift | 30 +++ Droplet/README.md | 32 +++ .../Codexusage/CodexusageDroplet.swift | 224 ++++++++++++++++++ .../Sources/Codexusage/MonitorSnapshot.swift | 77 ++++++ .../CodexusageHarness/CodexusageHarness.swift | 17 ++ Droplet/droplet.json | 37 +++ 13 files changed, 699 insertions(+) create mode 100644 Droplet/.gitignore create mode 100644 Droplet/AGENTS.md create mode 100644 Droplet/Assets/Creator.png create mode 100644 Droplet/CHANGELOG.md create mode 100644 Droplet/Codexusage.icon/Assets/mark.png create mode 100644 Droplet/Codexusage.icon/icon.json create mode 100644 Droplet/Package.resolved create mode 100644 Droplet/Package.swift create mode 100644 Droplet/README.md create mode 100644 Droplet/Sources/Codexusage/CodexusageDroplet.swift create mode 100644 Droplet/Sources/Codexusage/MonitorSnapshot.swift create mode 100644 Droplet/Sources/CodexusageHarness/CodexusageHarness.swift create mode 100644 Droplet/droplet.json diff --git a/Droplet/.gitignore b/Droplet/.gitignore new file mode 100644 index 0000000..29a1e94 --- /dev/null +++ b/Droplet/.gitignore @@ -0,0 +1,3 @@ +.build/ +.swiftpm/ +.DS_Store diff --git a/Droplet/AGENTS.md b/Droplet/AGENTS.md new file mode 100644 index 0000000..24c87f7 --- /dev/null +++ b/Droplet/AGENTS.md @@ -0,0 +1,205 @@ +# Codex Usage, a Droplet for Droppy + + + +This package is a **Droplet**: an extension that runs inside Droppy, the +Dynamic Island and shelf for Mac, written in SwiftUI against **DroppyKit**. +Droppy loads the built `.droplet` bundle into its own process and draws it on +the notch, the shelf, the lock screen and the menu bar. + +- Droplet id: `codexusage`. It is also `CodexusageDroplet.id` in Swift and `id` in `droplet.json`; the three must agree or the loader refuses the bundle. +- Swift product: `Codexusage`, a dynamic library. The harness target is `CodexusageHarness`. +- SDK checkout: `` (DroppyKit 1.20.1). Docs online: https://getdroppy.app/docs/droppykit +- Host: Droppy 15.3 or later, which runs an unsigned bundle once its user approves that build under Settings, Store, Local droplets and asks again each time it opens, or the free Droppy Playground (https://getdroppy.app/download/playground), which loads unsigned bundles without asking. + +## The loop + +Every change goes through all of this, in order. A droplet can compile, +validate and then draw nothing, so a green build is not the end. + +1. Edit `Sources/Codexusage/`. The manifest is `droplet.json`. +2. `droppykit build` writes `.build/Codexusage.droplet`, universal, linked against the + framework Droppy ships. Never a bare `swift build` for the bundle: it folds a second + copy of DroppyKit into the droplet, and that bundle loads in the harness and dies + inside Droppy at dyld with "Symbol not found". +3. `droppykit validate` runs the exact checks the Store's intake runs. +4. `droppykit run -- --shots ./shots --report ./shots/report.json` renders every surface + to a PNG without opening a window and writes a JSON verdict. Look at the pictures. + Read `report.json`: `problems` must be empty and every surface you declared must be + `provided`. +5. Put the bundle into Droppy Playground and confirm it loaded. Copy + `.build/Codexusage.droplet` to + `~/Library/Application Support/Droppy Playground/Droplets/codexusage/Codexusage.droplet`, + relaunch the Playground, and read its Store row: the subtitle is the loader's verdict. + +With the DroppyKit MCP server connected, the same steps are the tools `droppykit_build`, +`droppykit_validate`, `droppykit_shots` and `droppykit_install`, and `droppykit_shots` +returns the images inline. This package carries the server in `.mcp.json` (Claude Code) +and `.cursor/mcp.json` (Cursor). Codex: `codex mcp add droppykit -- /Scripts/droppykit mcp`. +The other tools are `droppykit_manifest` (a static check, no build), `droppykit_docs` +(the guides and a search over the SDK sources), `droppykit_doctor`, `droppykit_new`, +`droppykit_open_harness` and `droppykit_submit`. + +`droppykit run` with no arguments opens the harness window for a person: Droppy's own +Settings panel with a page per surface. You cannot see that window. The shots are your +eyes; take them after every visual change. + +`droppykit version` says which SDK checkout the scripts come from and which tag this +package pins; `droppykit update` moves both to the newest release. A build that stops with +"no compiled objects" or "DroppyKit.o not found" is an SDK older than 1.2.1: update it. + +## Rules + +- **Surfaces and conformances agree.** `surfaces` in `droplet.json` lists what the droplet + provides; the droplet conforms to the matching protocol for each of them and to nothing it + does not list. Disagreement is the most common reason a droplet validates and then does + nothing. +- **Every shelf widget declares both widths.** `preferredSoloWidth` and + `preferredPairedWidth` are required; Droppy refuses a descriptor that leaves either to a + host fallback. Solo and paired are different compositions, not one view at two widths: + branch on `context.isPaired`. +- **Layout traits describe the widget's rectangle.** Every number in + `ShelfWidgetLayoutTraits` is the area the widget draws in, in points at the Regular shelf + size, exactly what the harness renders; Droppy adds its own chrome around it. `.fixed(150)` + is a 150-point rectangle, alone and in a row, clamped to 48 through 480. A widget that needs + more height declares more; it never pads its way out of a clip. A solo widget is never + narrower than 352 on a notch or 370 on an island, so lay out to `context.availableSize`. +- **No card, no border around the widget.** Droppy paints nothing behind a widget and almost + every one of its own widgets lays its content directly on the shelf's black. Put no + background, fill, outline or rounded box on the widget's root view. `notchSurfaceCardFill` + is for a tile or a chip inside the widget that has to read as raised, never a frame. +- **Lay the widget out like Droppy's.** The root view fills the rectangle + (`.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading)`) with ONE + padding, `.padding(context.contentInsets)`, and nothing on top of it. It clears the host's + rounded clip: 8 on every edge under the 18pt card corner (a notch, and any row on either + shape), 0 alone on the island, where the island shell clips the card and keeps one even gap. + The shelf's chrome already inset the rectangle, so never add your own padding or corner + inset on top: it doubles the gap. + Leading text, trailing `.monospacedDigit()` numbers, rows that span the + full width, a header row of a 12pt symbol and a 12pt semibold title with the widget's control + at its trailing end, `DroppySpacing` steps between rows. Declare the height the content + needs; never leave unused space or fill it with padding. +- **The physical notch is cleared for you, except on a HUD strip.** The shelf, a takeover, + a HUD card and a live activity are inset past the camera housing by the host; never pad for + it. A HUD strip is handed the whole width across the housing: put its content at the two + outer edges and nothing in the middle (`host.environment.notchGeometry.closedWidth` is the + housing), the way the World Clock example's strip does. Never centre a strip. +- **Droppy owns every motion around your surfaces; you animate only what you swap.** A live + activity row and a HUD are mounted exactly like Droppy's own, so never put an entrance + transition on the view a factory returns (it plays twice). A live activity is compact only: + hovering or clicking it opens the shelf, `makeExpanded` is not mounted, and Stop / Start + belong in the shelf widget. A glyph, label or control you swap while a surface is up takes + `DroppyTransition.compactContent` in a wing or strip and `DroppyTransition.element` in a + card, never a transition or spring of your own (`minAPI` 1.8.0). +- **Buttons are Liquid Glass, Droppy's own.** `DroppyCircleButtonStyle` (20pt on an item, + 24pt in a row) for an icon action, `DroppyQuietButtonStyle` and `DroppyAccentButtonStyle` + (`.small`) for labelled ones, `DroppyGlassButtonStyle` for a label with its own sizing. + Never a flat wash, a bordered chip or a white button of your own. A list with a control per + row wraps in `droppyFlatGlassControls()`. Only a live activity row's controls keep + `DroppyLiveActivityControlStyle`. +- **Everything `activate(host:)` starts, `deactivate()` stops.** Timers, observers, tasks, + connections. Swift cannot unload code, so anything left running runs until Droppy + relaunches. +- **A widget the user watches holds the shelf open while it runs.** The shelf closes when the + pointer leaves it; a teleprompter, countdown or live transcript calls + `host.shelf.setHoldsOpen(true)` when its work starts and `false` the moment it ends + (`shelf-write`, `minAPI` 1.5.0). A widget with nothing to show until it is configured sends + the user to its settings pane with `host.workspace.openSettings()`, and asks for permissions + there through `host.permissions`, never from the shelf. +- **Host calls are gated by `capabilities`.** A service call without its capability in + `droplet.json` is refused: it returns `false` or `nil` and logs one line. Declare what you + use and only that; the user sees the list. +- **The principal class does nothing.** `CodexusagePrincipal` is `@objc`, is named in the + bundle's `NSPrincipalClass`, and only creates the droplet. It runs before the host is ready. +- **No `main.swift`.** The harness entry is `@main` in + `Sources/CodexusageHarness/CodexusageHarness.swift`, and a file named `main.swift` cannot + coexist with `@main`. +- **Look like Droppy, not like a guest.** Surfaces are dark. Foreground colours come from + `AdaptiveColors`, spacing from `DroppySpacing`, radii from `DroppyRadius` with + `style: .continuous`. No borders or outlines, no gradients, no ALL-CAPS labels, sentence + case everywhere, and never paint your own background on a widget. Never repeat the page + header in a settings pane: Droppy already shows the droplet's icon, name, summary and maker + above it, so the pane starts with its first setting (the Store refuses a pane that shows the + droplet's own icon or its name as a title). Settings panes are rooted + in `DropletSettingsPane` (`minAPI` 1.9.0) and built from `DropletSettingsCard`, + `DropletSettingsSection`, `DropletControlRow`, `DropletToggleRow`, `DropletStackedRow` and + `DropletSliderRow`; the host mounts the pane in its native grouped form, so the pane's + content is a list of sections, never a `VStack`, and it places no dividers. +- **`droplet.json` is the truth for the build.** `Info.plist` is generated from it. + `version` is numeric `major.minor.patch`; `summary` is at most 60 characters; + `minAppVersion` stays `15.3.0` unless the droplet needs something newer; `kit.minAPI` is + the oldest DroppyKit API the droplet actually calls. `droppykit build` fails when it is + older than that and names the calls and the version to set; set that version, never + lower it to get a droplet loaded. +- **Do not edit anything under ``.** That is the SDK checkout; fixes there go + upstream. This package is where the work is. + +## Where the truth is + +Read these before guessing at an API. They are on disk, in the SDK checkout. + +- Guides, as Markdown: `/Sources/DroppyKit/Documentation.docc/` + `CreateYourFirstDroplet.md`, `DropletSetup.md`, `DesignGuidelines.md`, `ShelfWidgets.md`, + `LiveActivities.md`, `ExpandedSurfaces.md`, `SettingsPanes.md`, `Icons.md`, `Harness.md`, + `HostSupport.md`, `Playground.md`, `Submitting.md`, and `BuildWithCodingAgents.md` for this + workflow in full. +- The surface protocols, one file each: `/Sources/DroppyKit/Capabilities/` +- The host services a droplet calls: `/Sources/DroppyKit/Services/DropletServices.swift` + and `/Sources/DroppyKit/Core/DropletHost.swift` +- The manifest type, with every field documented: `/Sources/DroppyKit/Bundle/DropletManifest.swift` +- Design tokens and the settings components: `/Sources/DroppyKit/DesignSystem/` +- A complete droplet that uses every surface: `/Examples/WorldClock/` +- The compatibility promise and the version ledger: `/COMPATIBILITY.md` + +## Surfaces + +| `surfaces` value in droplet.json | Conform to | Shot | +| --- | --- | --- | +| `shelf-widget` | `ShelfWidgetProviding` | `shelf-widget.png` | +| `live-activity` | `LiveActivityProviding` | `live-activity.png` | +| `expanded-surface` | `ExpandedSurfaceProviding` | `expanded-surface.png` | +| `settings-pane` | `SettingsPaneProviding` | `settings-pane.png` | +| `hud` | `HUDPresenting` | `hud.png` | +| `lock-screen-status` | `LockScreenStatusProviding` | `lock-screen.png` | +| `menu-bar-extra` | `MenuBarExtraProviding` | `menu-bar.png` | + +`overview.png` shows the identity card with a verdict pill per surface, `capabilities.png` +the capability switches, `preferences.png` every stored value, and `activity.png` every host +call in order, refused ones marked. + +## Done means + +- `droppykit build` and `droppykit validate` both pass. +- The report's `problems` is empty and `activation.error` is null. +- You have looked at the shot of every surface you touched. +- The bundle loaded in Droppy Playground: `droppykit_install` says loaded, or the Store row + shows it switched on. +- `droplet.json` still describes what the code does: surfaces, capabilities, summary. + +## Package layout + +``` +Package.swift product Codexusage (dynamic) and CodexusageHarness +droplet.json the manifest; Info.plist is generated from it +Sources/Codexusage/ the droplet +Sources/CodexusageHarness/ the @main harness entry; never main.swift +Codexusage.icon/ Icon Composer document, required +Assets/Creator.png square creator avatar, at least 256px, required +.build/Codexusage.droplet what droppykit build writes +AGENTS.md, CLAUDE.md, .cursor/ this brief and the agent wiring +.mcp.json, .cursor/mcp.json the DroppyKit MCP server; absolute paths for this Mac +``` + +## Submitting + +Your own build runs in Droppy only after you approve it under Settings, Store, Local +droplets, and Droppy asks again each time it opens; everyone else gets the droplet from +the Store, signed by Droppy after review. +When the droplet is done: replace the placeholder icon and creator avatar, fill in +`creator` and `source` in `droplet.json`, write `CHANGELOG.md`, and run `droppykit submit`. +The Store is a repository (gitlab.com/droppyformac1/droplets, one folder per droplet): +`submit` forks it, copies this package into `droplets//`, pushes a branch and opens +the merge request; when a maintainer merges it, the pipeline builds, signs and publishes +it. `droppykit submit --print` shows the plan without doing it (needs `glab`, signed in). +Opening the merge request means accepting the Droplet developer terms at +https://getdroppy.app/droplet-developer-terms. diff --git a/Droplet/Assets/Creator.png b/Droplet/Assets/Creator.png new file mode 100644 index 0000000000000000000000000000000000000000..51444b5a8286e30f86e0629c6ba690c1fc3bc936 GIT binary patch literal 2620 zcmb7FUuYY39RJ>*HkYn#F4Solp}DTCz6{KE)21%AX^nP+IyT+A!QtWCD)pfcv%R&` zwFv2h2n~C)FFuLlgUZ0Bv>1>ZQZ{89YOe;$U=vfQ5M~U1zQ0R$N!Pjgl;b{szu(_4 z$^7Y4qaAGr+K8y*)~$c4f8O2iI8Nu_jjy+V!o&C3t0&^7IpMa<1 zR!L#aRr-8j4Kw6E>xojrbyNF{%1~suC>#Y)Lgbr!D7=r6|fWih* ziV{^aWIv;eX?~+!LE{xErD{YvVURhJaAAd$TUKmM=TdOerDm`mN*L>e?`P0kk-JENAz(T(iCsI*Ru zLsg6brJABH6J2S;-e9M&bf#5dl<3h!I^NlF-zVqLPZs$t2cCnU^T}BB{Ok zS*0dBC%|KM@F;^y9W2VMJj`GU`4f_RhU<4fMHu^wZtCvhpdN`qnP_nzEoii&m294g z55Z}%#gvl?oQ&wRCFhqUc8%0sA^c{Dl23E;%VJKLLvR1BtQtP{yTHGf9e&nJ?3q(~+{0P2{ef$Rmp>M_` zzAYIt8IzTkU4ZXneN|nm{_|}sT@ZMqO-obq*Jz2#@nv&h$_X6&zwnnzQ{Y>LR zGtW{Q>V;*r_gphC{O>nsAL?l-jm=Ysnk<{?PYT-a;0sJz_cUr^;LrSN^bQIWtrVa0 z?(ir6@SplSPCu$qqwo6Tq;stgcG!?=9H4_lGle%%;24jZot~Uh@$<$90|7B&v$yM= zCD_qvbk2&k;~wO_Q-L&56(A3Z6}sgs8o+)D@_3l+;(1s~8BhuvoU`0){t?l*ccFy2 z09B~48J+rMfUoW4>D!5ahIww+C85eL32u%?djb8Tns2kG1D_7QMVKbcbAeOX7~?Hj zBb49lhi`T{r=jDuG!KgG=(H)QH4$DmML@1mqGBCn&xhnHMW;Num$aLz(|8$4Xo65A zb;v$O+ zS!C47h|B4mF{W{gzSjJDKiJ5FAFQ1DEnQV-fk~3eSGJdGuH0jxsuC8 zSZW^O_tp#rHXLY~AC#jPOtVW(lr5`IE8TtGG|#vaJk+ c>aAY}Be&OP-Uv-~;$>4}uIC109#@5Rb(*B=k{^zv= zC_mh-rH}#q&3AJO?m}YFkv_vv&>EHh`sT>&#k#BzOq?$TbHt9^#EdvY`8${6FKBWYn|fT|?ckn%w;oq9pG zoJMWgB4O0zlvJopQcECL_SH+d^2z~L#}umH4jPD0=2$J;tVR{a8&*3c$|0o9G;6j@ zpG1~DMVmeulh%Y*6FH_ST5V91CCWP_NWgA{-+Nqe{!m%V1T2HYR_g;<5`2rI^lyXq z(imKjHnU|LI-tme%C$t96s~Upj1dIvUQNa z%)2*vpnZCxW?Ci+={;+RZyTA@;;s2|`Yq)yJ+8vrbYE60Ahm)G+J?U!>!qB8v((qD zN$4UIg`xqY${q?0qZx_WY=f2jHXTESJ%RF{p_UAi+>I+6)XE-*;{5yri%e*(14fk< z3Hp?EkCy2LN#>B%W=3n>6D0&t3C`_izyJzmEPpFz8;t950vu=MD*D(ad%8d++)E?L z%&t|alf|keJ~eCvxP5)d(^p!LMpzZ@UK7T XVplI+FUCLmk0fb+YT8@L74H55Z*oz< literal 0 HcmV?d00001 diff --git a/Droplet/Codexusage.icon/icon.json b/Droplet/Codexusage.icon/icon.json new file mode 100644 index 0000000..23a86c1 --- /dev/null +++ b/Droplet/Codexusage.icon/icon.json @@ -0,0 +1,42 @@ +{ + "fill-specializations" : [ + { + "value" : { + "linear-gradient" : [ + "display-p3:0.56863,0.76863,1.00000,1.00000", + "srgb:0.14510,0.50196,1.00000,1.00000" + ] + } + }, + { + "appearance" : "dark", + "value" : { + "linear-gradient" : [ + "display-p3:0.20870,0.20870,0.20870,1.00000", + "display-p3:0.08561,0.08561,0.08561,1.00000" + ] + } + } + ], + "groups" : [ + { + "layers" : [ + { + "hidden" : false, + "image-name" : "mark.png", + "name" : "mark", + "position" : { + "scale" : 0.8, + "translation-in-points" : [ 0, 0 ] + } + } + ], + "shadow" : { "kind" : "neutral", "opacity" : 0.5 }, + "translucency" : { "enabled" : true, "value" : 0.5 } + } + ], + "supported-platforms" : { + "circles" : [ "watchOS" ], + "squares" : "shared" + } +} diff --git a/Droplet/Package.resolved b/Droplet/Package.resolved new file mode 100644 index 0000000..b9e2dd1 --- /dev/null +++ b/Droplet/Package.resolved @@ -0,0 +1,15 @@ +{ + "originHash" : "820a89feb0cad31edadb0b254219315437d9869b0d1e0516b99f3cab571903b3", + "pins" : [ + { + "identity" : "droppykit", + "kind" : "remoteSourceControl", + "location" : "https://gitlab.com/droppyformac1/droppykit.git", + "state" : { + "revision" : "3d728a7981975714057650f80639c1e27d512fdb", + "version" : "1.20.1" + } + } + ], + "version" : 3 +} diff --git a/Droplet/Package.swift b/Droplet/Package.swift new file mode 100644 index 0000000..e1f3f76 --- /dev/null +++ b/Droplet/Package.swift @@ -0,0 +1,30 @@ +// swift-tools-version: 6.2 +import PackageDescription + +let package = Package( + name: "Codexusage", + platforms: [.macOS(.v14)], + products: [ + // A droplet is a loadable bundle, so its product is a dynamic library. + // Do not make it static: the app already carries DroppyKit, and a + // second copy inside the droplet gives the same type two metadata + // records, which fails every cast between them. + .library(name: "Codexusage", type: .dynamic, targets: ["Codexusage"]) + ], + dependencies: [ + .package(url: "https://gitlab.com/droppyformac1/droppykit.git", from: "1.6.0") + ], + targets: [ + .target( + name: "Codexusage", + dependencies: [.product(name: "DroppyKit", package: "droppykit")] + ), + .executableTarget( + name: "CodexusageHarness", + dependencies: [ + "Codexusage", + .product(name: "DroppyKitHarness", package: "droppykit") + ] + ) + ] +) diff --git a/Droplet/README.md b/Droplet/README.md new file mode 100644 index 0000000..5b52c35 --- /dev/null +++ b/Droplet/README.md @@ -0,0 +1,32 @@ +# Codex Usage + +A Droplet for [Droppy](https://getdroppy.app), built with +[DroppyKit](https://getdroppy.app/docs/droppykit). + +## Developing + +```bash +droppykit run # open it in Droppy's Settings panel +droppykit build # produce Codexusage.droplet +droppykit validate # the checks the Store repository runs +droppykit submit # open the merge request that puts it in the Store +``` + +## With a coding agent + +Open this folder in Claude Code, Codex or Cursor. `AGENTS.md` is the brief +they read first, and `.mcp.json` / `.cursor/mcp.json` connect the DroppyKit +MCP server, which gives them the build, the checks, pictures of every surface +and an install into Droppy Playground as tools. Codex registers the server +once per Mac: `codex mcp add droppykit -- path/to/droppykit/Scripts/droppykit mcp`. +Run `droppykit agent` again after moving this folder or the SDK checkout. + +## Before submitting + +- Replace `Codexusage.icon` with real artwork, in Icon Composer. +- Replace `Assets/Creator.png` with your own square, unrounded mark. +- Fill in `summary`, `description` and `creator` in `droplet.json`, and + write `CHANGELOG.md`. +- `droppykit submit`: the Store is a repository, one folder per droplet, and + this opens the merge request that adds yours. See + [Submitting](https://getdroppy.app/docs/droppykit/submitting). diff --git a/Droplet/Sources/Codexusage/CodexusageDroplet.swift b/Droplet/Sources/Codexusage/CodexusageDroplet.swift new file mode 100644 index 0000000..b9b1286 --- /dev/null +++ b/Droplet/Sources/Codexusage/CodexusageDroplet.swift @@ -0,0 +1,224 @@ +import AppKit +import Charts +import Combine +import Darwin +import DroppyKit +import SwiftUI + +@objc(CodexusagePrincipal) +public final class CodexusagePrincipal: NSObject, DropletPrincipal { + public override init() { super.init() } + @MainActor public func makeDroplet() -> AnyObject { CodexusageDroplet() } +} + +@MainActor +public final class CodexusageDroplet: NSObject, ObservableObject, Droplet { + public nonisolated static let id: DropletID = "codexusage" + @Published private(set) var snapshot: MonitorSnapshot? + @Published private(set) var message: String? + private var host: DropletHost? + private var refreshTask: Task? + + private static var snapshotURL: URL { + let home = getpwuid(getuid()).map { String(cString: $0.pointee.pw_dir) } + ?? FileManager.default.homeDirectoryForCurrentUser.path + return URL(fileURLWithPath: home) + .appendingPathComponent("Library/Application Support/CodexUsageMonitor/snapshot.json") + } + + public func activate(host: DropletHost) throws { + self.host = host + refreshTask = Task { [weak self] in + while !Task.isCancelled { + await self?.reload() + do { try await Task.sleep(for: .seconds(5)) } catch { return } + } + } + } + + public func deactivate() { + refreshTask?.cancel() + refreshTask = nil + host = nil + } + + private func reload() async { + let url = Self.snapshotURL + let result = await Task.detached(priority: .utility) { + Result { () throws -> MonitorSnapshot in + let attributes = try FileManager.default.attributesOfItem(atPath: url.path) + guard let size = attributes[.size] as? Int, size <= 8_000_000 else { + throw CocoaError(.fileReadTooLarge) + } + return try JSONDecoder().decode(MonitorSnapshot.self, from: Data(contentsOf: url)) + } + }.value + guard !Task.isCancelled, host != nil else { return } + switch result { + case .success(let value): + snapshot = value + message = value.isFresh(at: .now) ? nil : "Open Runway to refresh." + case .failure: + message = "Open Runway to prepare local data." + } + } + + func openMonitor() { + let workspace = NSWorkspace.shared + guard let url = workspace.urlForApplication(withBundleIdentifier: "com.codexusage.CodexUsageMonitor") + ?? workspace.urlForApplication(withBundleIdentifier: "com.codexusage.CodexUsageMonitor.debug") else { + message = "Install or open Runway first." + return + } + _ = host?.workspace.open(url) + } +} + +extension CodexusageDroplet: ShelfWidgetProviding { + public var widgetDescriptors: [ShelfWidgetDescriptor] { + [ShelfWidgetDescriptor( + id: "activity", title: "Codex Usage", systemImage: "terminal", + layoutTraits: ShelfWidgetLayoutTraits( + preferredSoloWidth: 380, preferredPairedWidth: 210, contentHeight: .fixed(148) + ) + )] + } + + public func makeWidgetView(_ id: ShelfWidgetID, context: ShelfWidgetContext) -> AnyView { + AnyView(CodexActivityWidget(droplet: self, context: context)) + } + + public func makeWidgetSettingsPopover(_ id: ShelfWidgetID) -> AnyView? { nil } +} + +private struct CodexActivityWidget: View { + @ObservedObject var droplet: CodexusageDroplet + let context: ShelfWidgetContext + + private var accent: Color { + // Mirrors Runway's AppTheme accents so the shelf matches the app. + switch droplet.snapshot?.appearanceTheme { + case "crimson": Color(red: 0.12, green: 0.78, blue: 0.76) + case "classicRed": Color(red: 0.98, green: 0.16, blue: 0.21) + case "graphite": Color(red: 0.42, green: 0.67, blue: 1) + case "rain": Color(red: 0.48, green: 0.76, blue: 0.91) + case "autumn": Color(red: 0.96, green: 0.64, blue: 0.35) + case "runway": Color(red: 0.86, green: 0.42, blue: 0.16) + default: Color(red: 0.45, green: 0.68, blue: 1) + } + } + + private var stale: Bool { droplet.snapshot.map { !$0.isFresh(at: .now) } ?? false } + + private var updatedText: String { + guard let date = droplet.snapshot?.generatedAt else { return "not updated" } + return date.formatted(.relative(presentation: .numeric, unitsStyle: .abbreviated)) + } + + var body: some View { + Group { + let snapshot = droplet.snapshot + let activity = snapshot?.latest + VStack(alignment: .leading, spacing: 7) { + HStack(spacing: 5) { + Label(stale ? "Runway · \(updatedText)" : "Runway", systemImage: "chart.xyaxis.line") + .font(.system(size: 11, weight: .semibold)).lineLimit(1) + Spacer(minLength: 0) + Button { droplet.openMonitor() } label: { Image(systemName: "arrow.up.forward.app") } + .buttonStyle(DroppyCircleButtonStyle(size: 20)) + .help(droplet.message ?? "Open Runway").accessibilityLabel("Open Runway") + }.foregroundStyle(AdaptiveColors.notchSurfaceSecondaryText) + if let snapshot { + Text(activity?.model ?? snapshot.currentModel ?? "Model unavailable") + .font(.system(size: context.isPaired ? 13 : 15, weight: .semibold)) + .lineLimit(1).minimumScaleFactor(0.7) + let usage = activity?.usage ?? snapshot.currentSession + HStack(alignment: .firstTextBaseline, spacing: 5) { + Text(usage.compact) + .font(.system(size: context.isPaired ? 22 : 25, weight: .semibold, design: .rounded)) + .monospacedDigit() + Text("tokens").font(.system(size: 10)) + .foregroundStyle(AdaptiveColors.notchSurfaceSecondaryText) + Spacer(minLength: 0) + if !context.isPaired { + Text("\(activity?.requests ?? snapshot.currentSessionTurns ?? 0) requests") + .font(.system(size: 10)).foregroundStyle(AdaptiveColors.notchSurfaceSecondaryText) + } + } + TokenSparkline(points: activity?.usageHistory ?? [], accent: accent).frame(height: context.isPaired ? 30 : 34) + if let limits = snapshot.rateLimits { + HStack(spacing: 10) { + if let five = limits.fiveHour { AllowanceBar(title: "5H", window: five, accent: accent) } + if let weekly = limits.weekly { AllowanceBar(title: "W", window: weekly, accent: accent) } + } + } + } else { + Text("Connect the monitor").font(.system(size: 14, weight: .semibold)) + Text(droplet.message ?? "Reading the local snapshot…") + .font(.system(size: 11)).foregroundStyle(AdaptiveColors.notchSurfaceSecondaryText) + } + Spacer(minLength: 0) + } + .foregroundStyle(AdaptiveColors.notchSurfacePrimaryText) + .opacity(stale ? 0.62 : 1) + .padding(context.contentInsets) + .frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .topLeading) + } + } +} + +private struct TokenSparkline: View { + var points: [MonitorSnapshot.Point] + var accent: Color + + var body: some View { + Group { + if points.count > 1, let first = points.first, let last = points.last { + Chart(points, id: \.date) { point in + LineMark(x: .value("Time", point.date), y: .value("Tokens", point.totalTokens)) + .interpolationMethod(.monotone) + .lineStyle(StrokeStyle(lineWidth: 1.6, lineCap: .round, lineJoin: .round)) + .foregroundStyle(accent) + } + .chartXScale(domain: first.date...last.date) + .chartYScale(domain: 0...max(last.totalTokens, 1)) + .chartXAxis(.hidden) + .chartYAxis(.hidden) + } else { + Text(points.isEmpty ? "Awaiting token events" : "1 recorded token event") + .font(.system(size: 9)).foregroundStyle(AdaptiveColors.notchSurfaceSecondaryText) + } + } + .accessibilityElement() + .accessibilityLabel("Recorded session token history") + .accessibilityValue(points.last.map { "\($0.totalTokens) tokens" } ?? "No recorded events") + } +} + +private struct AllowanceBar: View { + var title: String + var window: MonitorSnapshot.Window + var accent: Color + + private var fraction: Double { + guard window.resetsAt > .now, window.usedPercent.isFinite else { return 0 } + return max(0, min(1, (100 - window.usedPercent) / 100)) + } + + var body: some View { + HStack(spacing: 5) { + Text(title).font(.system(size: 10, weight: .semibold)).foregroundStyle(AdaptiveColors.notchSurfaceSecondaryText) + GeometryReader { proxy in + Capsule().fill(AdaptiveColors.notchSurfaceSecondaryText.opacity(0.25)) + .overlay(alignment: .leading) { + Capsule().fill(accent).frame(width: fraction > 0 ? max(4, proxy.size.width * fraction) : 0) + } + } + .frame(height: 4) + Text(window.remaining(at: .now)).font(.system(size: 10, weight: .semibold)).monospacedDigit() + } + .accessibilityElement(children: .ignore) + .accessibilityLabel("\(title == "W" ? "Weekly" : "Five-hour") allowance") + .accessibilityValue(window.remaining(at: .now)) + } +} diff --git a/Droplet/Sources/Codexusage/MonitorSnapshot.swift b/Droplet/Sources/Codexusage/MonitorSnapshot.swift new file mode 100644 index 0000000..8e2a81b --- /dev/null +++ b/Droplet/Sources/Codexusage/MonitorSnapshot.swift @@ -0,0 +1,77 @@ +import Foundation + +// Decode only the monitor's public snapshot. This process never reads Codex logs. +struct MonitorSnapshot: Decodable, Sendable { + var generatedAt: Date? + var currentModel: String? + var currentSession: Usage + var currentSessionTurns: Int? + var rateLimits: Limits? + var sessionActivity: [Activity]? + var appearanceTheme: String? + + struct Point: Decodable, Sendable { + var date: Date + var totalTokens: Int + } + + struct Usage: Decodable, Sendable { + var input: Int + var cachedInput: Int + var output: Int + var total: Int + var compact: String { + total.formatted(.number.notation(.compactName).precision(.fractionLength(0...1))) + } + } + + struct Activity: Decodable, Sendable { + var id: String + var project: String? + var model: String? + var state: String + var observedAt: Date? + var toolCalls: Int? + var toolFailures: Int? + var usage: Usage + var requests: Int + var usageHistory: [Point]? + + func isWorking(at now: Date) -> Bool { + state == "running" && observedAt.map { now.timeIntervalSince($0) <= 120 } == true + } + + func status(at now: Date) -> String { + switch state { + case "running": isWorking(at: now) ? "Working" : "Last seen working" + case "completed": "Finished" + case "interrupted": "Interrupted" + default: "Last recorded" + } + } + } + + struct Limits: Decodable, Sendable { + var fiveHour: Window? + var weekly: Window? + } + + struct Window: Decodable, Sendable { + var usedPercent: Double + var resetsAt: Date + + func remaining(at now: Date) -> String { + guard resetsAt > now, usedPercent.isFinite else { return "—" } + return "\(Int(max(0, min(100, 100 - usedPercent)).rounded()))%" + } + } + + var latest: Activity? { + sessionActivity?.first { $0.isWorking(at: .now) } ?? sessionActivity?.first + } + + func isFresh(at now: Date) -> Bool { + // Runway refreshes only while Codex is open, so allow ten quiet minutes. + generatedAt.map { now.timeIntervalSince($0) <= 600 } == true + } +} diff --git a/Droplet/Sources/CodexusageHarness/CodexusageHarness.swift b/Droplet/Sources/CodexusageHarness/CodexusageHarness.swift new file mode 100644 index 0000000..96ead96 --- /dev/null +++ b/Droplet/Sources/CodexusageHarness/CodexusageHarness.swift @@ -0,0 +1,17 @@ +// +// CodexusageHarness.swift +// +// Run with: droppykit run +// +// Not named main.swift on purpose: Swift treats that name as top-level code, +// which cannot coexist with @main. +// + +import DroppyKit +import DroppyKitHarness +import Codexusage + +@main +struct CodexusageHarness: DropletHarnessApp { + static func makeDroplet() -> any Droplet { CodexusageDroplet() } +} diff --git a/Droplet/droplet.json b/Droplet/droplet.json new file mode 100644 index 0000000..cea68a8 --- /dev/null +++ b/Droplet/droplet.json @@ -0,0 +1,37 @@ +{ + "id": "codexusage", + "name": "Runway", + "version": "1.1.0", + "summary": "Codex session graph, tokens and allowance from Runway", + "description": "Session graph, token usage and remaining 5-hour and weekly allowance from Runway. Reads Runway's local snapshot; no model calls, no Codex logs.", + "category": "Productivity", + "kit": { + "abi": 1, + "minAPI": "1.8.0" + }, + "minAppVersion": "15.3.0", + "capabilities": [], + "surfaces": [ + "shelf-widget" + ], + "icon": "Codexusage.icon", + "creator": { + "name": "Italian-seasoning", + "kind": "community", + "url": "https://github.com/Italian-seasoning", + "avatar": "Creator.png" + }, + "source": { + "repository": "https://github.com/Italian-seasoning/CodexUsageMonitor", + "license": "All rights reserved" + }, + "screenshots": [], + "keywords": [ + "Codex", + "Runway", + "tokens", + "usage", + "limits", + "local" + ] +} From 48574c71646f94e2090ad670fdee48cc26cb59ef Mon Sep 17 00:00:00 2001 From: Italian-seasoning <99997342+Italian-seasoning@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:04:04 -0700 Subject: [PATCH 7/9] Session chart: activity bars with a running total and hover readout The cumulative line sat flat for most of a session. The activity card now buckets token growth into bars so bursts are visible, keeps the running total as a faint line, and shows the bucket's tokens, time and total on hover instead of permanent axis labels. --- Runway/ContentView.swift | 113 ++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 48 deletions(-) diff --git a/Runway/ContentView.swift b/Runway/ContentView.swift index 1c97db5..9986a16 100644 --- a/Runway/ContentView.swift +++ b/Runway/ContentView.swift @@ -349,10 +349,8 @@ struct ContentView: View { .font(.system(size: AppTypeScale.label)).monospacedDigit().foregroundStyle(.secondary) } if let points = activity?.usageHistory, !points.isEmpty { - WidgetSparkline(chart: WidgetChartContent( - points: points.map { WidgetChartPoint(date: $0.date, value: Double($0.totalTokens)) }, - accessibilitySummary: "Session token history, latest \(usage.total.compactTokenString) tokens" - ), palette: activityPalette) + SessionUsageChart(points: points, accent: settingsModel.settings.appTheme.accent, + highlight: activityPalette.highlight) .frame(minHeight: 40, maxHeight: .infinity) } else { Spacer(minLength: 0) @@ -559,63 +557,82 @@ struct ContentView: View { } } +/// Session activity: bars show when tokens were spent, a faint line shows the running total. +/// Hover reads out one bucket; nothing else is labelled, so the card stays quiet. struct SessionUsageChart: View { var points: [CodexTokenPoint] var accent: Color - var showsCaption = true + var highlight: Color @State private var selectedDate: Date? - private var selectedPoint: CodexTokenPoint? { - guard let selectedDate else { return nil } - return points.min { abs($0.date.timeIntervalSince(selectedDate)) < abs($1.date.timeIntervalSince(selectedDate)) } + private struct Bucket: Identifiable { + var start: Date + var end: Date + var tokens: Int + var cumulative: Int + var id: Date { start } + var mid: Date { start.addingTimeInterval(end.timeIntervalSince(start) / 2) } + } + + private var buckets: [Bucket] { + let sorted = points.sorted { $0.date < $1.date } + guard let first = sorted.first, let last = sorted.last else { return [] } + let span = max(last.date.timeIntervalSince(first.date), 60) + let count = min(32, max(8, sorted.count)) + let width = span / Double(count) + var result = (0.. Date: Sun, 15 Nov 2026 23:21:41 -0700 Subject: [PATCH 8/9] Refresh once at launch so login launches update widgets A login launch never becomes the active app, so the foreground refresh did not run and widgets kept old data until Codex was opened. --- Runway/RunwayApp.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Runway/RunwayApp.swift b/Runway/RunwayApp.swift index 92eb152..28b3ca8 100644 --- a/Runway/RunwayApp.swift +++ b/Runway/RunwayApp.swift @@ -65,6 +65,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { ) { _ in Task { _ = await RefreshCoordinator.shared.refresh(trigger: .wake) } } + // One refresh at launch, so a login launch updates widgets and the droplet + // even when the window never comes to the front. + Task { _ = await RefreshCoordinator.shared.refresh(trigger: .wake) } showMainWindowSoon() } From 8d5f5b4bf497972ad29e950c0b60727715b0ada6 Mon Sep 17 00:00:00 2001 From: Italian-seasoning <99997342+Italian-seasoning@users.noreply.github.com> Date: Sun, 15 Nov 2026 23:37:35 -0700 Subject: [PATCH 9/9] Let the launch refresh run while Codex is closed The idle-power gate skipped every non-manual trigger, so the launch refresh never ran and widgets stayed stale after an install or login. Co-Authored-By: Claude Opus 5.5 --- Runway/RefreshCoordinator.swift | 3 ++- Runway/RunwayApp.swift | 2 +- RunwayTests/RefreshCoordinatorTests.swift | 5 +++-- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Runway/RefreshCoordinator.swift b/Runway/RefreshCoordinator.swift index 7551a55..5d1448d 100644 --- a/Runway/RefreshCoordinator.swift +++ b/Runway/RefreshCoordinator.swift @@ -50,7 +50,8 @@ actor RefreshCoordinator { return result }) { self.engine = { trigger, force in - if trigger != .manual { + // Manual and launch refreshes always run; launch happens once per app start. + if trigger != .manual && trigger != .launch { guard await isSourceAppRunning() else { return RefreshResult(outcome: .unchanged, snapshot: nil, message: "Automatic refresh is paused while ChatGPT and Codex are closed.") diff --git a/Runway/RunwayApp.swift b/Runway/RunwayApp.swift index 28b3ca8..5247e8c 100644 --- a/Runway/RunwayApp.swift +++ b/Runway/RunwayApp.swift @@ -67,7 +67,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate, NSWindowDelegate { } // One refresh at launch, so a login launch updates widgets and the droplet // even when the window never comes to the front. - Task { _ = await RefreshCoordinator.shared.refresh(trigger: .wake) } + requestRefresh(.launch) showMainWindowSoon() } diff --git a/RunwayTests/RefreshCoordinatorTests.swift b/RunwayTests/RefreshCoordinatorTests.swift index c9a5181..dc5c682 100644 --- a/RunwayTests/RefreshCoordinatorTests.swift +++ b/RunwayTests/RefreshCoordinatorTests.swift @@ -85,13 +85,14 @@ struct RefreshCoordinatorTests { await calls.record(trigger: trigger, force: force) return RefreshResult(outcome: .updated, snapshot: nil, message: "updated") } - for trigger: RefreshTrigger in [.launch, .foreground, .sourceChange, .fallbackTimer, .backgroundAgent, .wake] { + for trigger: RefreshTrigger in [.foreground, .sourceChange, .fallbackTimer, .backgroundAgent, .wake] { let result = await coordinator.refresh(trigger: trigger) #expect(result.outcome == .unchanged) } #expect(await calls.count == 0) + _ = await coordinator.refresh(trigger: .launch) _ = await coordinator.refresh(trigger: .manual) - #expect(await calls.values == [RecordedCall(trigger: .manual, force: true)]) + #expect(await calls.values.map(\.trigger) == [.launch, .manual]) } @Test("Queued source events recheck desktop presence before collecting data")