diff --git a/App/BridgeModel.swift b/App/BridgeModel.swift index e79c055..1902db9 100644 --- a/App/BridgeModel.swift +++ b/App/BridgeModel.swift @@ -22,6 +22,10 @@ final class BridgeStatus { var devices: [DeviceStatus] = [] /// Whether Syndicate's feedback is arriving (#21): the listener can be up while Syndicate is quiet or gone. var syndicateFeedback: FeedbackState = .waiting + /// Syndicate answers with no deck info: its OSC FEEDBACK subscriptions are off (#150). + var noDeckData = false + /// LED subscriptions a loaded deck's answer lacked (#150). + var missingSubscriptions: [Subscription] = [] /// The last time Syndicate's feedback stopped, for the menu. var lastDropout: String? /// When feedback last dropped, as the time to show ("21:14"), stamped as it happens (#66). diff --git a/App/Runtime.swift b/App/Runtime.swift index d07787c..ea311de 100644 --- a/App/Runtime.swift +++ b/App/Runtime.swift @@ -44,6 +44,8 @@ enum BridgeHost { status.lastDropoutTime = Date.now.formatted(date: .omitted, time: .shortened) } status.syndicateFeedback = coordinatorStatus.feedback + status.noDeckData = coordinatorStatus.noDeckData + status.missingSubscriptions = coordinatorStatus.missingSubscriptions status.lastDropout = coordinatorStatus.lastDropout status.sweeping = coordinatorStatus.sweeping status.demo = coordinatorStatus.demo diff --git a/App/Snapshots.swift b/App/Snapshots.swift index ec0f611..1dbf484 100644 --- a/App/Snapshots.swift +++ b/App/Snapshots.swift @@ -32,6 +32,20 @@ enum Snapshots { $0.feedback = .listening(port: 9096) $0.syndicateFeedback = .live }), + // Syndicate's OSC FEEDBACK subscriptions off (#150): NO DECK DATA, and help naming them. + ("feedback-no-deck-data", { + $0.bridges = [ControllerStatus(deck: 1, connected: true, profile: "Denon LC6000 PRIME")] + $0.feedback = .listening(port: 9096) + $0.syndicateFeedback = .live + $0.noDeckData = true + }), + // A loaded deck answered without Cues (#150): LIVE, and help about the pad colors. + ("feedback-cues-missing", { + $0.bridges = [ControllerStatus(deck: 1, connected: true, profile: "Denon LC6000 PRIME")] + $0.feedback = .listening(port: 9096) + $0.syndicateFeedback = .live + $0.missingSubscriptions = [.cues] + }), // Syndicate stopped answering (#21): DROPPED, and the last dropout under the lights. ("feedback-dropped", { $0.bridges = [ControllerStatus(deck: 1, connected: true, profile: "Denon LC6000 PRIME")] diff --git a/App/StatusPanel.swift b/App/StatusPanel.swift index d4bc2e3..a9236d5 100644 --- a/App/StatusPanel.swift +++ b/App/StatusPanel.swift @@ -39,7 +39,7 @@ extension BridgeStatus { case .listening(let port): switch syndicateFeedback { case .waiting: .waiting(port: port) - case .live: .live(port: port) + case .live: noDeckData ? .noDeckData(port: port) : .live(port: port) case .stale: .stopped(port: port) } case .portInUse(let port): .portInUse(port: port) @@ -56,7 +56,7 @@ extension BridgeStatus { controller: first?.controller ?? .notConnected, feedback: feedback, deck: first?.deck ?? deck, stopped: problem != nil, lastDropout: lastDropoutTime, master: self.controller?.master == true, demo: demo, lastEvent: first?.lastEvent, others: Array(entries.dropFirst()), stopReason: stopReason, - followsLayers: first?.followsLayers ?? false + followsLayers: first?.followsLayers ?? false, missingSubscriptions: missingSubscriptions.map(\.rawValue) ) } diff --git a/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Coordinator.swift b/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Coordinator.swift index cadd6c0..1fd6b64 100644 --- a/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Coordinator.swift +++ b/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Coordinator.swift @@ -53,6 +53,8 @@ public final class Coordinator { private var lastFeedbackAt: Double? /// When the last Resend went out, while it waits for an answer. Any feedback is the answer. private var resendSentAt: Double? + /// The answer to the last Resend (#150): when it went out, and the addresses that arrived within its window. + private var answer: (sentAt: Double, messages: [OSCMessage])? /// Set while the Diagnostics window is open (#26); nil otherwise, so nothing is built for it during a set. /// The LED sweep in progress: when it started, its steps and the next one to send. @@ -302,6 +304,7 @@ public final class Coordinator { runSweep() for bridge in bridges { bridge.tick() } checkLiveness() + checkSubscriptions() disconnectFailedOutputs() } @@ -408,6 +411,8 @@ public final class Coordinator { } } diagnostics?(.oscIn(message)) + answer?.messages.append(message) + if SubscriptionCheck.provesSubscriptions(message.address) { status.noDeckData = false } feedbackArrived() for bridge in bridges { bridge.handle(message) } for index in controllers.indices { status.controllers[index].master = controllers[index].bridge.isMaster } @@ -458,6 +463,15 @@ public final class Coordinator { } } + /// Once a Resend's answer window closes, what the answer held shows which subscriptions are on (#150). + private func checkSubscriptions() { + guard let answer, clock.now - answer.sentAt >= Double(oscSettings.feedbackAnswerMs) / 1000 else { return } + self.answer = nil + guard let check = SubscriptionCheck(answer: answer.messages) else { return } + status.noDeckData = check.noDeckData + status.missingSubscriptions = check.missing + } + /// Syndicate didn't answer: show idle for its state until it's back. private func feedbackStopped() { let event = "Syndicate feedback stopped" @@ -665,6 +679,7 @@ public final class Coordinator { private func requestResend() { guard resendSentAt == nil else { return } resendSentAt = clock.now + answer = (clock.now, []) controllers[0].bridge.send("Feedback/Resend", .int(1)) } diff --git a/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Status.swift b/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Status.swift index 60242b1..3ec7c06 100644 --- a/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Status.swift +++ b/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/Status.swift @@ -7,6 +7,10 @@ public struct CoordinatorStatus: Equatable, Sendable { public var feedback: FeedbackState /// The last time feedback stopped, for the menu. public var lastDropout: String? + /// Syndicate answered a Resend with no deck or header values: its OSC FEEDBACK subscriptions are off (#150). + public var noDeckData = false + /// LED subscriptions a loaded deck's answer lacked (#150), in `Subscription` order. Empty when none are missing. + public var missingSubscriptions: [Subscription] = [] /// An LED sweep (#26) is running. public var sweeping = false /// The built-in demo controller (#64) is running instead of the real one. diff --git a/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/SubscriptionCheck.swift b/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/SubscriptionCheck.swift new file mode 100644 index 0000000..4f07bab --- /dev/null +++ b/Packages/ControllerBridgeKit/Sources/ControllerBridgeCore/SubscriptionCheck.swift @@ -0,0 +1,41 @@ +// Which of Syndicate's OSC FEEDBACK subscriptions are on, judged from its answer to a Resend (#150). + +/// A Syndicate OSC FEEDBACK subscription that the controller's LEDs need. +public enum Subscription: String, CaseIterable, Equatable, Sendable { + /// Each is named for the deck value it sends, the last part of its address. + case playing, cues, sync, loop +} + +/// Syndicate answers a Resend with every subscribed value, and always ColorPalette. Values for an empty deck aren't +/// sent, so only what arrived counts: missing values are judged only on a deck that reported Loaded 1. +struct SubscriptionCheck: Equatable { + /// The answer had no deck and no header values (BPM, Metronome, MasterVolume…): subscriptions are off. + var noDeckData: Bool + /// The LED subscriptions a loaded deck lacked. + var missing: [Subscription] + + /// Nil for no answer at all: silence says nothing about subscriptions. + init?(answer messages: [OSCMessage]) { + guard !messages.isEmpty else { return nil } + noDeckData = !messages.contains { Self.provesSubscriptions($0.address) } + // Each deck's values, by deck number: the last two parts of /Syndicate/Deck//. + var values: [String: Set] = [:] + var loaded: Set = [] + for message in messages { + let parts = message.address.lowercased().split(separator: "/") + guard parts.count >= 3, parts[parts.count - 3] == "deck" else { continue } + let deck = String(parts[parts.count - 2]), value = String(parts[parts.count - 1]) + values[deck, default: []].insert(value) + if value == "loaded", message.arguments.first?.wholeNumber == 1 { loaded.insert(deck) } + } + missing = Subscription.allCases.filter { subscription in + loaded.contains { !(values[$0] ?? []).contains(subscription.rawValue) } + } + } + + /// A deck or header value: some deck subscriptions are on. + static func provesSubscriptions(_ address: String) -> Bool { + let path = address.lowercased() + return path.contains("/deck/") || path.contains("/header/") + } +} diff --git a/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/HelpMessage.swift b/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/HelpMessage.swift index a84439c..516c149 100644 --- a/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/HelpMessage.swift +++ b/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/HelpMessage.swift @@ -35,10 +35,14 @@ public struct HelpMessage: Equatable, Sendable { self.init(text: "No feedback from Syndicate yet. Set OSC FEEDBACK to 127.0.0.1 : \(port).", showsGuide: true) case .stopped: self.init(text: "Syndicate stopped answering. Is it still running? The LEDs catch up when it's back.", showsGuide: true) - case .starting, .live, .failed: + case .starting, .live, .noDeckData, .failed: // Every controller counts (#89): the first that needs a hand, named by its number when there are several. let all = [state.controller] + state.others.map(\.controller) - guard let index = all.firstIndex(where: { if case .connected = $0 { false } else { true } }) else { return nil } + guard let index = all.firstIndex(where: { if case .connected = $0 { false } else { true } }) else { + guard let subscriptions = Self.subscriptions(state) else { return nil } + self = subscriptions + return + } let name = all.count > 1 ? "Controller \(index + 1)" : nil switch all[index] { case .notConnected: @@ -57,4 +61,37 @@ public struct HelpMessage: Equatable, Sendable { } } } + + /// Syndicate's subscriptions off, or some LED ones missing on a loaded deck (#150). + private static func subscriptions(_ state: BridgeState) -> HelpMessage? { + let place = "Syndicate › Settings › OSC FEEDBACK" + if case .noDeckData = state.feedback { + return HelpMessage(text: "Syndicate isn't sending deck info. In \(place), turn on the subscriptions: \(list(SetupGuide.subscriptions)).", + showsGuide: true) + } + let missing = state.missingSubscriptions.compactMap { value in + SetupGuide.subscriptionName(for: value).map { (led: ledName(value), name: $0) } + } + guard !missing.isEmpty else { return nil } + let leds = list(missing.map(\.led)), names = list(missing.map(\.name)) + let text = missing.count == 1 + ? "\(leds.prefix(1).uppercased() + leds.dropFirst()) need the \(names) subscription. Turn it on in \(place)." + : "\(leds.prefix(1).uppercased() + leds.dropFirst()) need the \(names) subscriptions. Turn them on in \(place)." + return HelpMessage(text: text, showsGuide: true) + } + + /// What a subscription lights on the controller. + private static func ledName(_ value: String) -> String { + switch value { + case "playing": "the Play LED" + case "cues": "hot cue pad colors" + case "sync": "the Sync LED" + default: "the loop LEDs" + } + } + + /// "A, B and C". + private static func list(_ items: [String]) -> String { + items.count < 2 ? items.joined() : items.dropLast().joined(separator: ", ") + " and " + items.last! + } } diff --git a/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/SetupGuide.swift b/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/SetupGuide.swift index ce8ab4e..9d3b1be 100644 --- a/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/SetupGuide.swift +++ b/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/SetupGuide.swift @@ -22,6 +22,18 @@ public struct SetupGuide: Equatable, Sendable { "BPM/Sync", "Loop", ] + /// The subscription that sends a deck value (#150), by the value's name: "cues" is "Cues". Nil for one the guide + /// doesn't list. + public static func subscriptionName(for value: String) -> String? { + switch value { + case "playing": "Playing" + case "cues": "Cues" + case "sync": "BPM/Sync" + case "loop": "Loop" + default: nil + } + } + /// Bump when the steps change in a way a returning user should see. public static let version = 1 diff --git a/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/StatusPresentation.swift b/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/StatusPresentation.swift index fb82fcb..182bb67 100644 --- a/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/StatusPresentation.swift +++ b/Packages/ControllerBridgeKit/Sources/ControllerBridgePresentation/StatusPresentation.swift @@ -61,6 +61,8 @@ public struct BridgeState: Equatable, Sendable { case live(port: Int) /// Listening, but Syndicate hasn't answered since launch (#21). case waiting(port: Int) + /// Syndicate answers, but with no deck info: its OSC FEEDBACK subscriptions are off (#150). + case noDeckData(port: Int) /// Listening, but Syndicate stopped answering (#21). case stopped(port: Int) /// Another app holds the port, so no feedback arrives. @@ -105,10 +107,13 @@ public struct BridgeState: Equatable, Sendable { /// The first controller follows its own deck layers (#79). public var followsLayers = false + /// The LED subscriptions a loaded deck's feedback lacked (#150), by deck value name: "playing", "cues"… + public var missingSubscriptions: [String] = [] public init(controller: Controller, feedback: Feedback, deck: Int, stopped: Bool = false, lastDropout: String? = nil, master: Bool = false, demo: Bool = false, lastEvent: String? = nil, others: [ControllerEntry] = [], - stopReason: StopReason = .midi, followsLayers: Bool = false) { + stopReason: StopReason = .midi, followsLayers: Bool = false, missingSubscriptions: [String] = []) { + self.missingSubscriptions = missingSubscriptions self.stopReason = stopReason self.followsLayers = followsLayers self.demo = demo @@ -274,6 +279,7 @@ public struct StatusPresentation: Equatable, Sendable { let feedback: StatusLight = switch state.feedback { case .starting: StatusLight(label: "FEEDBACK", word: "STARTING", tone: .idle) case .live: StatusLight(label: "FEEDBACK", word: "LIVE", tone: .live) + case .noDeckData: StatusLight(label: "FEEDBACK", word: "NO DECK DATA", tone: .attention) case .waiting: StatusLight(label: "FEEDBACK", word: "WAITING", tone: .idle) case .stopped: StatusLight(label: "FEEDBACK", word: "DROPPED", tone: .attention) case .portInUse(let port): StatusLight(label: "FEEDBACK", word: "PORT \(port) IN USE", tone: .error) @@ -307,7 +313,10 @@ public struct StatusPresentation: Equatable, Sendable { else { .attention } lastDropout = state.lastDropout.map { CaptionedValue(caption: "Last dropout", value: $0) } // Quitting stops a working set only while feedback is live, so that's when Quit asks first (#66). - if case .live = state.feedback { quitAsks = true } else { quitAsks = false } + switch state.feedback { + case .live, .noDeckData: quitAsks = true + default: quitAsks = false + } // In demo mode a click would be held for the real controller and jump its deck later, unasked (#90). deckPicker = state.stopped ? .hidden : state.demo ? .disabled(reason: "Demo controller is on, so the deck stays put.") : .enabled diff --git a/Packages/ControllerBridgeKit/Tests/ControllerBridgeCoreTests/SubscriptionsTests.swift b/Packages/ControllerBridgeKit/Tests/ControllerBridgeCoreTests/SubscriptionsTests.swift new file mode 100644 index 0000000..1226ed2 --- /dev/null +++ b/Packages/ControllerBridgeKit/Tests/ControllerBridgeCoreTests/SubscriptionsTests.swift @@ -0,0 +1,121 @@ +import ControllerBridgeCore +import Testing + +/// Syndicate answers a Resend with every subscribed value, and always ColorPalette (user guide §14.10). An answer with +/// ColorPalette but no deck values means its OSC FEEDBACK subscriptions are off: LIVE, but every LED stays dark (#150). +@Suite("Feedback subscriptions") +struct SubscriptionsTests { + static let palette = OSCMessage("/Syndicate/ColorPalette", [.int(1), .int(255), .int(0), .int(0)]) + + static func tick(_ rig: Rig, at time: Double) { + rig.clock.now = time + rig.coordinator.tick() + } + + @Test("The launch Resend answered with only ColorPalette, no deck or header values: no deck data, once its 2 s window closes") + func onlyPalette() throws { + let rig = try Rig() + rig.coordinator.start() // sends a Resend at t = 0 + rig.clock.now = 0.3 + rig.coordinator.feedback(Self.palette) + Self.tick(rig, at: 1.9) + #expect(rig.coordinator.status.noDeckData == false) + Self.tick(rig, at: 2.0) + #expect(rig.coordinator.status.feedback == .live) + #expect(rig.coordinator.status.noDeckData == true) + } + + /// No deck data flagged at t = 2. + static func noDeckDataRig() throws -> Rig { + let rig = try Rig() + rig.coordinator.start() + rig.clock.now = 0.3 + rig.coordinator.feedback(Self.palette) + Self.tick(rig, at: 2.0) + return rig + } + + @Test("A deck or header value arriving later, any time, clears it: the subscriptions are on now", arguments: [ + "/Syndicate/Deck/2/Playing", "/Syndicate/Header/BPM", + ]) + func deckValueClears(address: String) throws { + let rig = try Self.noDeckDataRig() + rig.clock.now = 30 + rig.coordinator.feedback(Self.palette) + #expect(rig.coordinator.status.noDeckData == true) + rig.coordinator.feedback(OSCMessage(address, [.int(1)])) + #expect(rig.coordinator.status.noDeckData == false) + } + + @Test("Empty decks with header values in the answer are plain LIVE: Syndicate sends nothing for an empty deck") + func emptyDecksWithHeader() throws { + let rig = try Rig() + rig.coordinator.start() + rig.clock.now = 0.3 + rig.coordinator.feedback(Self.palette) + rig.coordinator.feedback(OSCMessage("/Syndicate/Header/BPM", [.float(120)])) + Self.tick(rig, at: 2.0) + #expect(rig.coordinator.status.noDeckData == false) + } + + /// The launch Resend answered with `messages` at t = 0.3, and its window closed at t = 2. + static func answered(_ messages: [OSCMessage]) throws -> Rig { + let rig = try Rig() + rig.coordinator.start() + rig.clock.now = 0.3 + for message in [Self.palette, OSCMessage("/Syndicate/Header/BPM", [.float(120)])] + messages { + rig.coordinator.feedback(message) + } + Self.tick(rig, at: 2.0) + return rig + } + + @Test("A loaded deck without Cues in the answer: the Cues subscription is missing. Empty deck 2 counts for nothing") + func loadedDeckWithoutCues() throws { + let rig = try Self.answered([ + OSCMessage("/Syndicate/Deck/1/Loaded", [.int(1)]), + OSCMessage("/Syndicate/Deck/1/Playing", [.int(0)]), + OSCMessage("/Syndicate/Deck/1/Sync", [.int(0)]), + OSCMessage("/Syndicate/Deck/1/Loop", [.int(0)]), + OSCMessage("/Syndicate/Deck/2/Loaded", [.int(0)]), + ]) + #expect(rig.coordinator.status.noDeckData == false) + #expect(rig.coordinator.status.missingSubscriptions == [.cues]) + } + + @Test("A loaded deck with only Loaded: Playing, Cues, Sync and Loop are all missing") + func loadedDeckOnly() throws { + let rig = try Self.answered([OSCMessage("/Syndicate/Deck/3/Loaded", [.int(1)])]) + #expect(rig.coordinator.status.missingSubscriptions == [.playing, .cues, .sync, .loop]) + } + + @Test("A loaded deck with every LED value: nothing is missing") + func loadedDeckComplete() throws { + let rig = try Self.answered(["Loaded", "Playing", "Cues", "Sync", "Loop"].map { + OSCMessage("/Syndicate/Deck/1/\($0)", [.int(1)]) + }) + #expect(rig.coordinator.status.missingSubscriptions == []) + } + + @Test("Silence is never missing subscriptions: an unanswered Resend goes stale, with no deck data warning") + func silenceFlagsNothing() throws { + let rig = try Rig() + rig.coordinator.start() + Self.tick(rig, at: 2.0) + #expect(rig.coordinator.status.noDeckData == false) + #expect(rig.coordinator.status.missingSubscriptions == []) + } + + @Test("A later complete answer clears an earlier gap: during a paused set, the quiet Resend gets every value again") + func laterAnswerClearsGap() throws { + let rig = try Self.answered([OSCMessage("/Syndicate/Deck/1/Loaded", [.int(1)])]) + #expect(rig.coordinator.status.missingSubscriptions == [.playing, .cues, .sync, .loop]) + Self.tick(rig, at: 10.3) // 10 s quiet: the next Resend + rig.clock.now = 10.5 + for value in ["Loaded", "Playing", "Cues", "Sync", "Loop"] { + rig.coordinator.feedback(OSCMessage("/Syndicate/Deck/1/\(value)", [.int(1)])) + } + Self.tick(rig, at: 12.3) + #expect(rig.coordinator.status.missingSubscriptions == []) + } +} diff --git a/Packages/ControllerBridgeKit/Tests/ControllerBridgePresentationTests/SubscriptionsPresentationTests.swift b/Packages/ControllerBridgeKit/Tests/ControllerBridgePresentationTests/SubscriptionsPresentationTests.swift new file mode 100644 index 0000000..02c8071 --- /dev/null +++ b/Packages/ControllerBridgeKit/Tests/ControllerBridgePresentationTests/SubscriptionsPresentationTests.swift @@ -0,0 +1,55 @@ +import ControllerBridgeCore +import ControllerBridgePresentation +import Testing + +/// Syndicate's OSC FEEDBACK subscriptions off (#150): feedback is live, but no deck info comes, so the LEDs stay dark. +@Suite("Subscriptions presentation") +struct SubscriptionsPresentationTests { + static let connected = BridgeState.Controller.connected(profile: "Denon LC6000 PRIME") + + @Test("No deck data: an orange FEEDBACK ● NO DECK DATA light") + func noDeckDataLight() { + let status = StatusPresentation(BridgeState(controller: Self.connected, feedback: .noDeckData(port: 9096), deck: 1)) + #expect(status.lights.contains(StatusLight(label: "FEEDBACK", word: "NO DECK DATA", tone: .attention))) + } + + @Test("No deck data: help names the subscriptions to turn on, and links the guide") + func noDeckDataHelp() { + #expect(HelpMessage(BridgeState(controller: Self.connected, feedback: .noDeckData(port: 9096), deck: 1)) == HelpMessage( + text: "Syndicate isn't sending deck info. In Syndicate › Settings › OSC FEEDBACK, turn on the subscriptions: Playing, PlayPending, Loaded and TrackInfo, Position/Progress, TempoSlider/TempoSliderEnabled, Cues, BPM/Sync and Loop.", + showsGuide: true + )) + } + + @Test("Cues missing on a loaded deck: the light stays LIVE, and help says the pad colors need the Cues subscription") + func cuesMissing() { + let state = BridgeState(controller: Self.connected, feedback: .live(port: 9096), deck: 1, missingSubscriptions: ["cues"]) + #expect(StatusPresentation(state).lights.contains(StatusLight(label: "FEEDBACK", word: "LIVE", tone: .live))) + #expect(HelpMessage(state) == HelpMessage( + text: "Hot cue pad colors need the Cues subscription. Turn it on in Syndicate › Settings › OSC FEEDBACK.", + showsGuide: true + )) + } + + @Test("Several missing: one sentence names each LED and each subscription, in order") + func severalMissing() { + let state = BridgeState(controller: Self.connected, feedback: .live(port: 9096), deck: 1, + missingSubscriptions: ["playing", "sync", "loop"]) + #expect(HelpMessage(state) == HelpMessage( + text: "The Play LED, the Sync LED and the loop LEDs need the Playing, BPM/Sync and Loop subscriptions. Turn them on in Syndicate › Settings › OSC FEEDBACK.", + showsGuide: true + )) + } + + @Test("A controller that needs a hand comes first: its LEDs can't show anything until it's connected") + func controllerFirst() { + let state = BridgeState(controller: .notConnected, feedback: .noDeckData(port: 9096), deck: 1) + #expect(HelpMessage(state)?.text == "No controller connected. Plug it in over USB; the bridge finds it.") + } + + @Test("Every LED subscription the bridge checks is named as the setup guide and README name it", arguments: Subscription.allCases) + func namesMatchGuide(subscription: Subscription) { + let name = SetupGuide.subscriptionName(for: subscription.rawValue) + #expect(name.map(SetupGuide.subscriptions.contains) == true, "\(subscription): \(String(describing: name))") + } +}