diff --git a/docs/llms-full.txt b/docs/llms-full.txt
index 93d664d8..56e119ba 100644
--- a/docs/llms-full.txt
+++ b/docs/llms-full.txt
@@ -62,7 +62,7 @@ Documentation
Using Flowlight
- Everything from the first launch to tuning the agent rules. Flowlight 0.14.5, macOS 15 or later.
+ Everything from the first launch to tuning the agent rules. Flowlight 0.15.0, macOS 15 or later.
On this page
@@ -887,7 +887,7 @@ Understand your AI agents.
brew install --cask xinbetween/tap/flowlightCopy
- v0.14.5macOS 15+UniversalGPL-3.0No telemetry
+ v0.15.0macOS 15+UniversalGPL-3.0No telemetry
connectionslive
@@ -1617,9 +1617,28 @@ Releases
Downloads, checksums and full notes for each version are on GitHub Releases.
- 0.14.5
+ 0.15.0
October 17, 2026Latest
+ Block known ad and tracker destinations across apps. Three official managed packs cover
+ advertising, cross-site tracking, and privacy/telemetry hosts. They ship disabled, require explicit review,
+ and can apply to every app or only selected apps.
+
+ Keep blocking explainable and reversible. Preview seven days of retained traffic before
+ enabling a pack, review its built-in destinations and provenance, inspect aggregated activity, add scoped
+ per-app exceptions, or use an ordinary allow rule as the universal escape hatch.
+
+ Fail open with atomic, version-bound enforcement. Flowlight validates and transfers one
+ complete pack generation to the Network Extension, binds consent to the exact reviewed content, preserves
+ ordinary-rule and essential-system precedence, and never treats a partial or stale update as active.
+
+ Set honest network-only expectations. Hostname blocking cannot remove first-party ads,
+ page gaps, browser overlays, scripted popups or native app windows; those need the later browser extension.
+ ECH, QUIC, encrypted DNS, direct IPs, shared CDNs and unavailable hostnames can also limit coverage.
+
+ 0.14.5
+October 17, 2026
+
Review plugin actions in Flowlight's existing editors. Plugin findings can now suggest guardrails,
network rules, mock responses, request rewrites and response transforms as typed, inert actions. Inspect opens the
matching editor with bounded defaults, and nothing changes until the user reviews and saves it.
diff --git a/docs/llms.txt b/docs/llms.txt
index 86ab145d..bc4480cd 100644
--- a/docs/llms.txt
+++ b/docs/llms.txt
@@ -1,6 +1,6 @@
# Flowlight
-> Free, open-source (GPL-3.0) application-aware network monitor for macOS, with focused visibility into AI agents. It attributes observed TCP and UDP activity to the application that made it and records the destination, protocol and byte counts, keeping local history from second to year. Recognized AI agents are listed by name along with the tools and MCP servers they start, under per-agent allowlists. It can also refuse, once asked: a rule blocks an application, a destination or a URL for as long as you specify, and a guardrail withholds a tool from an agent before its model is offered it. Runs on macOS 15 or later; capture is by a sampler or a Network Extension. Current version: 0.14.5.
+> Free, open-source (GPL-3.0) application-aware network monitor for macOS, with focused visibility into AI agents. It attributes observed TCP and UDP activity to the application that made it and records the destination, protocol and byte counts, keeping local history from second to year. Recognized AI agents are listed by name along with the tools and MCP servers they start, under per-agent allowlists. It can also refuse, once asked: a rule blocks an application, a destination or a URL for as long as you specify, and a guardrail withholds a tool from an agent before its model is offered it. Runs on macOS 15 or later; capture is by a sampler or a Network Extension. Current version: 0.15.0.
- [Download Flowlight.dmg](https://github.com/xinbetween/flowlight/releases/latest/download/Flowlight.dmg)
- [Source code](https://github.com/xinbetween/flowlight)
diff --git a/docs/plugins/index.html b/docs/plugins/index.html
index f79a6096..3267f5d1 100644
--- a/docs/plugins/index.html
+++ b/docs/plugins/index.html
@@ -211,7 +211,7 @@
Block known ad and tracker destinations across apps. Three official managed packs cover
+ advertising, cross-site tracking, and privacy/telemetry hosts. They ship disabled, require explicit review,
+ and can apply to every app or only selected apps.
+
Keep blocking explainable and reversible. Preview seven days of retained traffic before
+ enabling a pack, review its built-in destinations and provenance, inspect aggregated activity, add scoped
+ per-app exceptions, or use an ordinary allow rule as the universal escape hatch.
+
Fail open with atomic, version-bound enforcement. Flowlight validates and transfers one
+ complete pack generation to the Network Extension, binds consent to the exact reviewed content, preserves
+ ordinary-rule and essential-system precedence, and never treats a partial or stale update as active.
+
Set honest network-only expectations. Hostname blocking cannot remove first-party ads,
+ page gaps, browser overlays, scripted popups or native app windows; those need the later browser extension.
+ ECH, QUIC, encrypted DNS, direct IPs, shared CDNs and unavailable hostnames can also limit coverage.
+
+
+
+
+
0.14.5
Review plugin actions in Flowlight's existing editors. Plugin findings can now suggest guardrails,
network rules, mock responses, request rewrites and response transforms as typed, inert actions. Inspect opens the
@@ -1215,7 +1233,7 @@
Block known ad and tracker destinations across apps. Three official managed packs cover
+ advertising, cross-site tracking, and privacy/telemetry hosts. They ship disabled, require explicit review,
+ and can apply to every app or only selected apps.
+
Keep blocking explainable and reversible. Preview seven days of retained traffic before
+ enabling a pack, review its built-in destinations and provenance, inspect aggregated activity, add scoped
+ per-app exceptions, or use an ordinary allow rule as the universal escape hatch.
+
Fail open with atomic, version-bound enforcement. Flowlight validates and transfers one
+ complete pack generation to the Network Extension, binds consent to the exact reviewed content, preserves
+ ordinary-rule and essential-system precedence, and never treats a partial or stale update as active.
+
Set honest network-only expectations. Hostname blocking cannot remove first-party ads,
+ page gaps, browser overlays, scripted popups or native app windows; those need the later browser extension.
+ ECH, QUIC, encrypted DNS, direct IPs, shared CDNs and unavailable hostnames can also limit coverage.
diff --git a/docs/llms-full.txt b/docs/llms-full.txt
index 56e119ba..5cc393a3 100644
--- a/docs/llms-full.txt
+++ b/docs/llms-full.txt
@@ -62,7 +62,7 @@ Documentation
Using Flowlight
- Everything from the first launch to tuning the agent rules. Flowlight 0.15.0, macOS 15 or later.
+ Everything from the first launch to tuning the agent rules. Flowlight 0.15.1, macOS 15 or later.
On this page
@@ -887,7 +887,7 @@ Understand your AI agents.
brew install --cask xinbetween/tap/flowlightCopy
- v0.15.0macOS 15+UniversalGPL-3.0No telemetry
+ v0.15.1macOS 15+UniversalGPL-3.0No telemetry
connectionslive
@@ -1617,8 +1617,20 @@ Releases
Downloads, checksums and full notes for each version are on GitHub Releases.
+ 0.15.1
+October 18, 2026Latest
+
+ Keep managed-pack changes safely in review. Opening or cancelling an off pack no longer
+ activates it, and configuration changes persist only after an explicit Save succeeds.
+
+ Add selected apps without closing the editor. Pressing Return in the app field now adds
+ the typed app or process to the draft instead of triggering the sheet's Save action.
+
+ Show the configuration that actually committed. Pack cards now observe managed-pack state
+ directly, so scope, status, exceptions and activity refresh as soon as an asynchronous save completes.
+
0.15.0
-October 17, 2026Latest
+October 17, 2026
Block known ad and tracker destinations across apps. Three official managed packs cover
advertising, cross-site tracking, and privacy/telemetry hosts. They ship disabled, require explicit review,
diff --git a/docs/llms.txt b/docs/llms.txt
index bc4480cd..b6693510 100644
--- a/docs/llms.txt
+++ b/docs/llms.txt
@@ -1,6 +1,6 @@
# Flowlight
-> Free, open-source (GPL-3.0) application-aware network monitor for macOS, with focused visibility into AI agents. It attributes observed TCP and UDP activity to the application that made it and records the destination, protocol and byte counts, keeping local history from second to year. Recognized AI agents are listed by name along with the tools and MCP servers they start, under per-agent allowlists. It can also refuse, once asked: a rule blocks an application, a destination or a URL for as long as you specify, and a guardrail withholds a tool from an agent before its model is offered it. Runs on macOS 15 or later; capture is by a sampler or a Network Extension. Current version: 0.15.0.
+> Free, open-source (GPL-3.0) application-aware network monitor for macOS, with focused visibility into AI agents. It attributes observed TCP and UDP activity to the application that made it and records the destination, protocol and byte counts, keeping local history from second to year. Recognized AI agents are listed by name along with the tools and MCP servers they start, under per-agent allowlists. It can also refuse, once asked: a rule blocks an application, a destination or a URL for as long as you specify, and a guardrail withholds a tool from an agent before its model is offered it. Runs on macOS 15 or later; capture is by a sampler or a Network Extension. Current version: 0.15.1.
- [Download Flowlight.dmg](https://github.com/xinbetween/flowlight/releases/latest/download/Flowlight.dmg)
- [Source code](https://github.com/xinbetween/flowlight)
diff --git a/docs/plugins/index.html b/docs/plugins/index.html
index 3267f5d1..0ba7b180 100644
--- a/docs/plugins/index.html
+++ b/docs/plugins/index.html
@@ -211,7 +211,7 @@
Keep managed-pack changes safely in review. Opening or cancelling an off pack no longer
+ activates it, and configuration changes persist only after an explicit Save succeeds.
+
Add selected apps without closing the editor. Pressing Return in the app field now adds
+ the typed app or process to the draft instead of triggering the sheet's Save action.
+
Show the configuration that actually committed. Pack cards now observe managed-pack state
+ directly, so scope, status, exceptions and activity refresh as soon as an asynchronous save completes.
+
+
+
+
+
0.15.0
Block known ad and tracker destinations across apps. Three official managed packs cover
advertising, cross-site tracking, and privacy/telemetry hosts. They ship disabled, require explicit review,
@@ -1233,7 +1245,7 @@
Keep managed-pack changes safely in review. Opening or cancelling an off pack no longer
+ activates it, and configuration changes persist only after an explicit Save succeeds.
+
Add selected apps without closing the editor. Pressing Return in the app field now adds
+ the typed app or process to the draft instead of triggering the sheet's Save action.
+
Show the configuration that actually committed. Pack cards now observe managed-pack state
+ directly, so scope, status, exceptions and activity refresh as soon as an asynchronous save completes.
+
+
+
+
+
0.15.0
Block known ad and tracker destinations across apps. Three official managed packs cover
advertising, cross-site tracking, and privacy/telemetry hosts. They ship disabled, require explicit review,
From 876fe93e0557f2630d1ebf0d16cae1a72a7b7d0c Mon Sep 17 00:00:00 2001
From: blessdyb
Date: Sun, 18 Oct 2026 08:28:28 -0700
Subject: [PATCH 3/4] Harden managed pack editor saves
Co-Authored-By: Claude Code
---
Flowlight/Analysis/InstalledApps.swift | 29 ++++--
Flowlight/Analysis/RulePackStore.swift | 12 ++-
Flowlight/UI/RulePackEditorDraft.swift | 21 ++--
Flowlight/UI/RulePacksView.swift | 138 ++++++++++++++++++++-----
FlowlightTests/RulePackTests.swift | 38 ++++++-
5 files changed, 187 insertions(+), 51 deletions(-)
diff --git a/Flowlight/Analysis/InstalledApps.swift b/Flowlight/Analysis/InstalledApps.swift
index c4ed9c92..4fc96db3 100644
--- a/Flowlight/Analysis/InstalledApps.swift
+++ b/Flowlight/Analysis/InstalledApps.swift
@@ -17,8 +17,13 @@ enum InstalledApps {
var bluetoothPurpose: String?
}
+ struct ScanResult: Sendable {
+ var apps: [App]
+ var complete: Bool
+ }
+
private static let lock = NSLock()
- private static var cached: [App]?
+ private static var cached: ScanResult?
/// Where applications live. The system folder is included because Safari and Mail are perfectly reasonable
/// things to focus on, and they aren't in /Applications.
@@ -29,15 +34,22 @@ enum InstalledApps {
/// Scanned once and kept. A Mac doesn't gain applications while a popover is open, and re-reading several
/// hundred Info.plists on every keystroke would be felt.
- static func all() -> [App] {
+ static func all() -> [App] { scan().apps }
+
+ static func scan() -> ScanResult {
lock.lock()
if let cached { lock.unlock(); return cached }
lock.unlock()
var found: [String: App] = [:]
+ var complete = true
let manager = FileManager.default
for directory in searchPaths {
- guard let entries = try? manager.contentsOfDirectory(atPath: directory) else { continue }
+ guard manager.fileExists(atPath: directory) else { continue }
+ guard let entries = try? manager.contentsOfDirectory(atPath: directory) else {
+ complete = false
+ continue
+ }
for entry in entries where entry.hasSuffix(".app") {
let path = directory + "/" + entry
guard let bundle = Bundle(path: path), let id = bundle.bundleIdentifier, !id.isEmpty else { continue }
@@ -49,9 +61,14 @@ enum InstalledApps {
found[id] = App(name: name, bundleID: id, path: path, bluetoothPurpose: purpose)
}
}
- let sorted = found.values.sorted { $0.name.localizedCaseInsensitiveCompare($1.name) == .orderedAscending }
- lock.lock(); cached = sorted; lock.unlock()
- return sorted
+ let result = ScanResult(
+ apps: found.values.sorted { $0.name.localizedCaseInsensitiveCompare($1.name) == .orderedAscending },
+ complete: complete && !found.isEmpty
+ )
+ if result.complete {
+ lock.lock(); cached = result; lock.unlock()
+ }
+ return result
}
/// The applications built to use Bluetooth, as they say so themselves in their Info.plist.
diff --git a/Flowlight/Analysis/RulePackStore.swift b/Flowlight/Analysis/RulePackStore.swift
index 718a29c7..acede341 100644
--- a/Flowlight/Analysis/RulePackStore.swift
+++ b/Flowlight/Analysis/RulePackStore.swift
@@ -31,6 +31,10 @@ final class RulePackStore: ObservableObject {
var enabledCount: Int { configurations.filter(\.enabled).count }
var hasEnabledPacks: Bool { enabledCount > 0 }
+ var failureMessage: String? {
+ if case .failed(let message) = status { return message }
+ return nil
+ }
func configuration(for packID: String) -> RulePackConfiguration {
configurations.first { $0.packID == packID } ?? RulePackConfiguration(packID: packID)
@@ -185,7 +189,13 @@ final class RulePackStore: ObservableObject {
return
}
db.queue.async { [weak self, weak db] in
- guard let db else { return }
+ guard let db else {
+ Task { @MainActor in
+ self?.status = .failed("Rule pack storage is unavailable.")
+ onFailure?()
+ }
+ return
+ }
do {
try write(db)
Task { @MainActor in commit() }
diff --git a/Flowlight/UI/RulePackEditorDraft.swift b/Flowlight/UI/RulePackEditorDraft.swift
index 279ccca3..92873225 100644
--- a/Flowlight/UI/RulePackEditorDraft.swift
+++ b/Flowlight/UI/RulePackEditorDraft.swift
@@ -9,6 +9,7 @@ struct RulePackEditorDraft {
}
enum AppSubmission: Equatable {
+ case loading
case ignored
case added(String)
}
@@ -21,7 +22,6 @@ struct RulePackEditorDraft {
let originalConfiguration: RulePackConfiguration
var configuration: RulePackConfiguration
var typedApp = ""
- private(set) var saveAction: SaveAction?
init(saved: RulePackConfiguration, intent: Intent) {
originalConfiguration = saved
@@ -33,11 +33,12 @@ struct RulePackEditorDraft {
configuration.scope != .selectedApps || !configuration.apps.isEmpty
}
- mutating func submitApp(installed: [InstalledApps.App]) -> AppSubmission {
- addApp(typedApp, installed: installed)
+ mutating func submitApp(installed: [InstalledApps.App], appsLoaded: Bool = true) -> AppSubmission {
+ addApp(typedApp, installed: installed, appsLoaded: appsLoaded)
}
- mutating func addApp(_ value: String, installed: [InstalledApps.App]) -> AppSubmission {
+ mutating func addApp(_ value: String, installed: [InstalledApps.App], appsLoaded: Bool = true) -> AppSubmission {
+ guard appsLoaded else { return .loading }
guard let target = InstalledApps.target(forTyped: value, apps: installed) else { return .ignored }
if !configuration.apps.contains(where: { $0.caseInsensitiveCompare(target.value) == .orderedSame }) {
configuration.apps.append(target.value)
@@ -47,17 +48,13 @@ struct RulePackEditorDraft {
return .added(target.value)
}
- mutating func requestSave() -> SaveAction? {
- guard canSave else { saveAction = nil; return nil }
+ func requestSave() -> SaveAction? {
+ guard canSave else { return nil }
if originalConfiguration.enabled,
originalConfiguration.scope == .selectedApps,
configuration.scope == .allApps {
- saveAction = .confirmBroadening
- } else {
- saveAction = .commit(configuration)
+ return .confirmBroadening
}
- return saveAction
+ return .commit(configuration)
}
-
- mutating func clearSaveAction() { saveAction = nil }
}
diff --git a/Flowlight/UI/RulePacksView.swift b/Flowlight/UI/RulePacksView.swift
index 8a9d60ee..4d4a0cd9 100644
--- a/Flowlight/UI/RulePacksView.swift
+++ b/Flowlight/UI/RulePacksView.swift
@@ -10,15 +10,24 @@ struct RulePacksView: View {
private struct RulePackEditorRequest: Identifiable {
let pack: RulePackDefinition
- let saved: RulePackConfiguration
let intent: RulePackEditorDraft.Intent
var id: String { pack.id }
}
+struct RulePackSaveTracker {
+ private(set) var packIDs: Set = []
+
+ func contains(_ packID: String) -> Bool { packIDs.contains(packID) }
+ mutating func begin(_ packID: String) { packIDs.insert(packID) }
+ mutating func finish(_ packID: String) { packIDs.remove(packID) }
+}
+
private struct RulePacksContent: View {
@EnvironmentObject var monitor: TrafficMonitor
@ObservedObject var packs: RulePackStore
@State private var editor: RulePackEditorRequest?
+ @State private var saves = RulePackSaveTracker()
+ @State private var saveErrors: [String: String] = [:]
var body: some View {
ScrollView {
@@ -37,8 +46,10 @@ private struct RulePacksContent: View {
.padding(Measure.gutter)
}
.sheet(item: $editor) { request in
- RulePackEditor(pack: request.pack, saved: request.saved, intent: request.intent, packs: packs)
+ RulePackEditor(pack: request.pack, saved: packs.configuration(for: request.pack.id),
+ intent: request.intent, packs: packs, rules: monitor.rules)
}
+ .onChange(of: packs.version) { _, _ in saveErrors.removeAll() }
}
private var explanation: some View {
@@ -54,6 +65,8 @@ private struct RulePacksContent: View {
let configuration = packs.configuration(for: pack.id)
let events = packs.events(for: pack.id)
let blocks = events.reduce(0) { $0 + $1.count }
+ let exceptions = packs.overrides(for: pack.id)
+ let isSaving = saves.contains(pack.id)
return VStack(alignment: .leading, spacing: 10) {
HStack(alignment: .top, spacing: 12) {
Image(systemName: symbol(pack)).font(.title3).foregroundStyle(configuration.enabled ? FL.critical : .secondary)
@@ -66,26 +79,35 @@ private struct RulePacksContent: View {
Spacer(minLength: 8)
Toggle("", isOn: Binding(get: { configuration.enabled }, set: { enabled in
if enabled {
- editor = RulePackEditorRequest(pack: pack, saved: configuration, intent: .activate)
+ editor = RulePackEditorRequest(pack: pack, intent: .activate)
} else {
var changed = configuration
changed.enabled = false
- packs.save(changed)
+ saves.begin(pack.id)
+ saveErrors[pack.id] = nil
+ packs.save(changed) { success in
+ saves.finish(pack.id)
+ if !success { saveErrors[pack.id] = packs.failureMessage ?? L("Failed: %@", L("Save")) }
+ }
}
- })).toggleStyle(.switch).controlSize(.small).labelsHidden()
+ })).toggleStyle(.switch).controlSize(.small).labelsHidden().disabled(isSaving)
}
HStack(spacing: 8) {
pill(status(configuration), tint: statusTint(configuration))
pill(configuration.scope == .allApps ? L("Every app") : L("%lld selected apps", configuration.apps.count))
pill(L("%lld destinations", pack.entries.count))
if blocks > 0 { pill(L("%lld blocked", blocks), tint: FL.critical) }
- if !packs.overrides(for: pack.id).isEmpty {
- pill(L("%lld exceptions", packs.overrides(for: pack.id).count), tint: FL.good)
+ if !exceptions.isEmpty {
+ pill(L("%lld exceptions", exceptions.count), tint: FL.good)
}
Spacer()
Button(L("Review…")) {
- editor = RulePackEditorRequest(pack: pack, saved: configuration, intent: .review)
- }
+ editor = RulePackEditorRequest(pack: pack, intent: .review)
+ }.disabled(isSaving)
+ }
+ if let saveError = saveErrors[pack.id] {
+ Label(saveError, systemImage: "exclamationmark.triangle")
+ .font(.caption).foregroundStyle(FL.critical)
}
Text(L(pack.manifest.caveatKey)).font(.caption).foregroundStyle(.tertiary)
.fixedSize(horizontal: false, vertical: true)
@@ -144,17 +166,23 @@ private struct RulePackEditor: View {
@EnvironmentObject var monitor: TrafficMonitor
@Environment(\.dismiss) private var dismiss
@ObservedObject var packs: RulePackStore
+ @ObservedObject var rules: RuleStore
@State private var draft: RulePackEditorDraft
@State private var installed: [InstalledApps.App] = []
+ @State private var appsLoaded = false
+ @State private var appsScanned = false
@State private var preview: RuleSimulation.Result?
@State private var previewing = false
+ @State private var previewError: String?
+ @State private var saveError: String?
@State private var confirmBroadening = false
@State private var saving = false
init(pack: RulePackDefinition, saved: RulePackConfiguration,
- intent: RulePackEditorDraft.Intent, packs: RulePackStore) {
+ intent: RulePackEditorDraft.Intent, packs: RulePackStore, rules: RuleStore) {
self.pack = pack
self.packs = packs
+ self.rules = rules
_draft = State(initialValue: RulePackEditorDraft(saved: saved, intent: intent))
}
@@ -174,21 +202,30 @@ private struct RulePackEditor: View {
exceptions
}.padding(Measure.gutter)
}
+ .disabled(saving)
+ if let saveError {
+ Label(saveError, systemImage: "exclamationmark.triangle")
+ .font(.caption).foregroundStyle(FL.critical)
+ .padding(.horizontal, Measure.gutter).padding(.bottom, 8)
+ }
Divider()
HStack {
Button(L("Test against recent traffic")) { Task { await runPreview() } }
+ .disabled(previewing || saving)
if previewing { ProgressView().controlSize(.small) }
Spacer()
- Button(L("Cancel")) { dismiss() }
+ Button(L("Cancel")) { dismiss() }.disabled(saving)
Button(L("Save")) { save() }
.disabled(!draft.canSave || saving)
}.padding(Measure.gutter)
}
.frame(width: Measure.prose)
.frame(minHeight: 620)
- .onAppear {
- Task { installed = await Task.detached(priority: .userInitiated) { InstalledApps.all() }.value }
- }
+ .interactiveDismissDisabled(saving)
+ .onChange(of: draft.configuration) { _, _ in invalidatePreview() }
+ .onChange(of: packs.version) { _, _ in invalidatePreview() }
+ .onChange(of: rules.version) { _, _ in invalidatePreview() }
+ .onAppear { loadApps() }
.confirmationDialog(L("Apply this pack to every app?"), isPresented: $confirmBroadening) {
Button(L("Apply to every app"), role: .destructive) { commit(draft.configuration) }
Button(L("Cancel"), role: .cancel) {}
@@ -207,9 +244,14 @@ private struct RulePackEditor: View {
if draft.configuration.scope == .selectedApps {
HStack {
TextField(L("App name, bundle identifier, or process"), text: $draft.typedApp)
- .onSubmit { addApp() }
+ .onSubmit { if appsLoaded { addApp() } }
+ if !appsScanned {
+ ProgressView().controlSize(.small)
+ } else if !appsLoaded {
+ Button(L("Refresh")) { loadApps() }.controlSize(.small)
+ }
Button(L("Add")) { addApp() }
- .disabled(draft.typedApp.trimmingCharacters(in: .whitespaces).isEmpty)
+ .disabled(!appsLoaded || draft.typedApp.trimmingCharacters(in: .whitespaces).isEmpty)
}
if !draft.typedApp.isEmpty, !appSuggestions.isEmpty {
VStack(alignment: .leading, spacing: 0) {
@@ -249,7 +291,11 @@ private struct RulePackEditor: View {
}
@ViewBuilder private var previewSection: some View {
- if let preview {
+ if let previewError {
+ Label(previewError, systemImage: "exclamationmark.triangle")
+ .font(.caption).foregroundStyle(FL.critical)
+ .padding(10).background(FL.critical.opacity(0.1), in: RoundedRectangle(cornerRadius: 8))
+ } else if let preview {
VStack(alignment: .leading, spacing: 5) {
Text(L("Recent-traffic impact")).font(.headline)
if preview.connectionsConsidered == 0 {
@@ -302,12 +348,24 @@ private struct RulePackEditor: View {
}.prefix(5))
}
+ private func loadApps() {
+ appsScanned = false
+ appsLoaded = false
+ Task {
+ let result = await Task.detached(priority: .userInitiated) { InstalledApps.scan() }.value
+ installed = result.apps
+ appsLoaded = result.complete
+ appsScanned = true
+ }
+ }
+
private func addApp(_ value: String? = nil) {
- if let value { _ = draft.addApp(value, installed: installed) }
- else { _ = draft.submitApp(installed: installed) }
+ if let value { _ = draft.addApp(value, installed: installed, appsLoaded: appsLoaded) }
+ else { _ = draft.submitApp(installed: installed, appsLoaded: appsLoaded) }
}
private func save() {
+ saveError = nil
switch draft.requestSave() {
case .commit(let configuration): commit(configuration)
case .confirmBroadening: confirmBroadening = true
@@ -317,24 +375,50 @@ private struct RulePackEditor: View {
private func commit(_ configuration: RulePackConfiguration? = nil) {
saving = true
+ saveError = nil
let value = configuration ?? draft.configuration
packs.save(value) { success in
saving = false
- if success { dismiss() }
+ if success {
+ dismiss()
+ } else {
+ saveError = packs.failureMessage ?? L("Failed: %@", L("Save"))
+ }
}
}
+ private func invalidatePreview() {
+ preview = nil
+ previewError = nil
+ }
+
private func runPreview() async {
+ let candidate = draft.configuration
+ let packVersion = packs.version
+ let ruleVersion = rules.version
previewing = true
+ preview = nil
+ previewError = nil
defer { previewing = false }
- let input = try? await monitor.read {
- (try $0.flowsForSimulation(since: Date().addingTimeInterval(-7 * 86400)), try $0.loadPolicies())
+ do {
+ let input = try await monitor.read {
+ (try $0.flowsForSimulation(since: Date().addingTimeInterval(-7 * 86400)),
+ try $0.loadPolicies())
+ }
+ guard candidate == draft.configuration,
+ packVersion == packs.version,
+ ruleVersion == rules.version else { return }
+ preview = RulePackSimulation.run(candidate: candidate, definitions: packs.definitions,
+ configurations: packs.configurations,
+ overrides: packs.overrides, rules: rules.rules,
+ policies: input.1, paused: rules.isPaused,
+ flows: input.0, session: RuleStore.session)
+ } catch {
+ guard candidate == draft.configuration,
+ packVersion == packs.version,
+ ruleVersion == rules.version else { return }
+ previewError = L("Failed: %@", L("Test against recent traffic"))
}
- preview = RulePackSimulation.run(candidate: draft.configuration, definitions: packs.definitions,
- configurations: packs.configurations,
- overrides: packs.overrides, rules: monitor.rules.rules,
- policies: input?.1 ?? [:], paused: monitor.rules.isPaused,
- flows: input?.0 ?? [], session: RuleStore.session)
}
}
diff --git a/FlowlightTests/RulePackTests.swift b/FlowlightTests/RulePackTests.swift
index b7e133e5..cfaa4bee 100644
--- a/FlowlightTests/RulePackTests.swift
+++ b/FlowlightTests/RulePackTests.swift
@@ -363,7 +363,7 @@ final class RulePackTests: XCTestCase {
XCTAssertFalse(draft.configuration.enabled)
XCTAssertEqual(draft.configuration.scope, .allApps)
- XCTAssertNil(draft.saveAction)
+ XCTAssertEqual(draft.requestSave(), .commit(saved))
}
func testEditorActivationAndCancelNeverMutateSavedConfiguration() {
@@ -387,12 +387,40 @@ final class RulePackTests: XCTestCase {
XCTAssertEqual(draft.submitApp(installed: []), .added("com.apple.curl"))
XCTAssertEqual(draft.configuration.apps, ["com.apple.curl"])
XCTAssertEqual(draft.typedApp, "")
- XCTAssertNil(draft.saveAction, "Return in the app field must not save or dismiss the editor")
draft.typedApp = "com.example.second"
XCTAssertEqual(draft.submitApp(installed: []), .added("com.example.second"))
XCTAssertEqual(draft.configuration.apps, ["com.apple.curl", "com.example.second"])
- XCTAssertNil(draft.saveAction, "Return must remain Add even after Save becomes valid")
+ XCTAssertEqual(draft.requestSave(), .commit(draft.configuration),
+ "Return only edits the draft; explicit Save decides whether to commit")
+ }
+
+ func testConcurrentCardSavesStayTrackedIndependently() {
+ var saves = RulePackSaveTracker()
+ saves.begin("official.advertising")
+ saves.begin("official.tracking")
+
+ saves.finish("official.advertising")
+
+ XCTAssertFalse(saves.contains("official.advertising"))
+ XCTAssertTrue(saves.contains("official.tracking"))
+ }
+
+ func testEditorWaitsForInstalledAppsBeforeResolvingDisplayName() {
+ let safari = InstalledApps.App(name: "Safari", bundleID: "com.apple.Safari",
+ path: "/Applications/Safari.app")
+ var draft = RulePackEditorDraft(saved: RulePackConfiguration(packID: "official.advertising"),
+ intent: .activate)
+ draft.configuration.scope = .selectedApps
+ draft.typedApp = "Safari"
+
+ XCTAssertEqual(draft.submitApp(installed: [], appsLoaded: false), .loading)
+ XCTAssertEqual(draft.typedApp, "Safari")
+ XCTAssertTrue(draft.configuration.apps.isEmpty)
+
+ XCTAssertEqual(draft.submitApp(installed: [safari], appsLoaded: true), .added("com.apple.Safari"))
+ XCTAssertEqual(draft.configuration.apps, ["com.apple.Safari"])
+ XCTAssertEqual(draft.typedApp, "")
}
func testEditorExplicitSaveAndBroadeningDecision() {
@@ -405,8 +433,8 @@ final class RulePackTests: XCTestCase {
XCTAssertEqual(draft.requestSave(), .confirmBroadening)
selected.apps = []
- var invalid = RulePackEditorDraft(saved: selected, intent: .review)
- XCTAssertNil(invalid.saveAction)
+ let invalid = RulePackEditorDraft(saved: selected, intent: .review)
+ XCTAssertNil(invalid.requestSave())
XCTAssertFalse(invalid.canSave)
}
From 54bc6dc695f247cdf0ea401d576ea552593784fa Mon Sep 17 00:00:00 2001
From: blessdyb
Date: Sun, 18 Oct 2026 08:39:28 -0700
Subject: [PATCH 4/4] Keep pack save failures visible
Co-Authored-By: Claude Code
---
Flowlight/UI/RulePacksView.swift | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/Flowlight/UI/RulePacksView.swift b/Flowlight/UI/RulePacksView.swift
index 4d4a0cd9..26d92597 100644
--- a/Flowlight/UI/RulePacksView.swift
+++ b/Flowlight/UI/RulePacksView.swift
@@ -49,7 +49,6 @@ private struct RulePacksContent: View {
RulePackEditor(pack: request.pack, saved: packs.configuration(for: request.pack.id),
intent: request.intent, packs: packs, rules: monitor.rules)
}
- .onChange(of: packs.version) { _, _ in saveErrors.removeAll() }
}
private var explanation: some View {
@@ -79,6 +78,7 @@ private struct RulePacksContent: View {
Spacer(minLength: 8)
Toggle("", isOn: Binding(get: { configuration.enabled }, set: { enabled in
if enabled {
+ saveErrors[pack.id] = nil
editor = RulePackEditorRequest(pack: pack, intent: .activate)
} else {
var changed = configuration
@@ -102,6 +102,7 @@ private struct RulePacksContent: View {
}
Spacer()
Button(L("Review…")) {
+ saveErrors[pack.id] = nil
editor = RulePackEditorRequest(pack: pack, intent: .review)
}.disabled(isSaving)
}