Your home as a live 3D model in the Mac menu bar and on iPhone — lights and ACs via Smart Life, Home Assistant, Philips Hue and Apple Home.
Mac: a Settings window, opened with ⌘, (#6)
0xProbability32a3240fd871
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 7dd8113..83c5c80 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -14,6 +14,10 @@ What changed in each release of House Control. The Mac app is on### Mac+- **Settings window** (⌘,): General (Open at Login, the island), Home (floor plans, the editor, plan files),+ Connections (Smart Life, Home Assistant, Hue and Apple Home, each a click away from its setup), iPhone (pairing+ and who is connected), AI Access and About. It is in the menu bar icon's right-click menu and the panel's gear+ menu too ([#6](https://github.com/0xProbabillity/house-control/issues/6)).- **Open at Login**, in the menu bar icon's right-click menu and in the panel's gear menu: House Control starts withyour Mac. It is the app's entry under System Settings → General → Login Items, so it can be switched off there too.Run from the disk image, the app asks to be moved to Applications first; moved there later, the login item follows it.diff --git a/README.md b/README.mdindex 058a41f..32ef95b 100644--- a/README.md+++ b/README.md@@ -118,17 +118,21 @@ macOS does not ask for the Local Network permission after every build:`CODESIGN_IDENTITY="Apple Development: [email protected] (ABCDE12345)" ./scripts/build-app.sh`.To keep it, drag `build/HouseControl.app` into `/Applications`. To start it with your Mac, turn on **Open at-Login** in the menu bar icon's right-click menu (or in the panel's gear menu); it shows up under+Login** in **Settings** (⌘, or the menu bar icon's right-click menu → **Settings…**); it shows up under**System Settings → General → Login Items**, where it can be switched off too.-There is no Dock icon and no main window: look for the house in the menu bar.+There is no Dock icon and no main window: look for the house in the menu bar. Its **Settings** window (⌘, from any+House Control window, or **Settings…** in the right-click menu and the panel's gear menu) has everything in one place:+Open at Login and the island, your floor plans, Smart Life, Home Assistant, Hue and Apple Home, iPhone pairing,+AI Access and About.## Using it| Do this | To get this || --- | --- || Click the menu bar icon | Open or close the panel |-| Right-click the menu bar icon | Edit Home, Load Floor Plan, Reveal Plan File, Reveal Device Log, Show Island, Open at Login, Pair iPhone, AI Access, Reload, Quit |+| Right-click the menu bar icon | Settings, Edit Home, Load Floor Plan, Reveal Plan File, Reveal Device Log, Show Island, Open at Login, Pair iPhone, AI Access, Reload, Quit |+| `⌘,` | Settings || Click a lamp in the 3D view, or its tile | Toggle it || Drag sideways across a light tile | Dim it || Click the sliders icon on a light tile | Brightness, white temperature, colour |diff --git a/macos/Sources/HouseControl/AppDelegate.swift b/macos/Sources/HouseControl/AppDelegate.swiftindex ee4387c..15c98ea 100644--- a/macos/Sources/HouseControl/AppDelegate.swift+++ b/macos/Sources/HouseControl/AppDelegate.swift@@ -19,6 +19,9 @@ final class AppDelegate: NSObject, NSApplicationDelegate {private var statusItem: NSStatusItem!private var panel: PanelController!private var editor: EditorController?+ /// Where a new editor window opens ("service:hue", …), when Settings asked for a connection.+ private var editorSection: String?+ private var settings: SettingsWindowController?private var pollTimer: Timer?/// AI Access: the private link an AI assistant uses to run the home.private lazy var agent: AgentController = {@@ -30,6 +33,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {guard let self else { return }self.panel.host.call("agentLive", live)self.refreshStatusIcon()+ self.refreshSettings()}return agent}()@@ -69,7 +73,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {if islandEnabled { showIsland() }LoginItem.followMove()- // HOUSE_SNAPSHOT_DIR=<folder> writes panel.png and island.png there a few seconds+ // HOUSE_SNAPSHOT_DIR=<folder> writes panel.png and island.png (and settings.png) there a few seconds// after launch: a look at the UI without a screen (see HOUSE_RENDER_HIDDEN).if let folder = ProcessInfo.processInfo.environment["HOUSE_SNAPSHOT_DIR"] {let directory = URL(fileURLWithPath: folder, isDirectory: true)@@ -77,11 +81,15 @@ final class AppDelegate: NSObject, NSApplicationDelegate {DispatchQueue.main.asyncAfter(deadline: .now() + delay) { [weak self] inself?.panel.host.snapshot(to: directory.appendingPathComponent("panel.png"))self?.island?.host.snapshot(to: directory.appendingPathComponent("island.png"))+ self?.settings?.snapshot(to: directory.appendingPathComponent("settings.png"))}}if ProcessInfo.processInfo.environment["HOUSE_OPEN_PAIRING"] != nil {DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) { [weak self] in self?.pairPhone() }}+ if let pane = ProcessInfo.processInfo.environment["HOUSE_OPEN_SETTINGS"] {+ DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) { [weak self] in self?.showSettings(pane: pane.isEmpty || pane == "1" ? nil : pane) }+ }if ProcessInfo.processInfo.environment["HOUSE_OPEN_EDITOR"] != nil {DispatchQueue.main.asyncAfter(deadline: .now() + 0.8) { [weak self] in self?.openEditor() }}@@ -175,6 +183,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {if NSApp.currentEvent?.type == .rightMouseUp {panel.hide()let menu = NSMenu()+ let settingsItem = menu.addItem(withTitle: "Settings…", action: #selector(openSettings), keyEquivalent: ",")+ settingsItem.target = self+ settingsItem.image = NSImage(systemSymbolName: "gearshape", accessibilityDescription: nil)+ menu.addItem(.separator())menu.addItem(withTitle: "Edit Home…", action: #selector(openEditor), keyEquivalent: "").target = selfmenu.addItem(withTitle: "Load Floor Plan…", action: #selector(loadPlan), keyEquivalent: "").target = selfmenu.addItem(withTitle: "Reveal Plan File", action: #selector(revealPlan), keyEquivalent: "").target = self@@ -228,6 +240,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {if !smartLife.isSmartLifeConnected, !phoneUserCode.isEmpty { account["userCode"] = phoneUserCode }boot["smartLife"] = accountboot["services"] = hub.servicesInfo+ if let section = editorSection { boot["section"] = section }switch ProcessInfo.processInfo.environment["HOUSE_OPEN_EDITOR"] {case "smartlife": boot["section"] = "service:smartlife"case "homeassistant", "hue", "homekit", "connections":@@ -251,6 +264,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {reloadLinks()setPolling(false) // reads at once while the panel or the island is opensync.broadcast()+ refreshSettings()}@objc private func reloadAll() {@@ -259,6 +273,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {panel.host.load()if island?.isShown == true { island?.host.load() }sync.broadcast()+ refreshSettings()}@objc private func loadPlan() {@@ -318,8 +333,13 @@ final class AppDelegate: NSObject, NSApplicationDelegate {NSWorkspace.shared.activateFileViewerSelecting([hub.log.fileURL])}- @objc private func openEditor() {+ @objc private func openEditor() { showEditor(section: nil) }++ /// `section` ("connections", "service:hue", …) opens the editor on that screen.+ private func showEditor(section: String?) {panel.hide()+ if let section, let editor { editor.host.call("openSection", section) }+ editorSection = sectionif editor == nil {let host = WebHost(mode: "editor", transparent: false) { [unowned self] in self.bootPayload() }host.onMessage = { [weak self, unowned host] message in self?.handle(message, from: host) }@@ -331,6 +351,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {editor = controllerhost.load()}+ editorSection = nileditor?.show()}@@ -375,6 +396,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {case "openAgent": openAgent()case "revealPlan": revealPlan()case "openEditor": openEditor()+ case "openSettings": showSettings()case "quit": NSApp.terminate(nil)case "setOpenAtLogin": setOpenAtLogin(message["on"] as? Bool ?? false)@@ -557,6 +579,7 @@ final class AppDelegate: NSObject, NSApplicationDelegate {let show = island?.isShown != trueUserDefaults.standard.set(show, forKey: "island")if show { showIsland() } else { island?.hide() }+ refreshSettings()}// MARK: - Open at Login@@ -579,8 +602,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {}panel.host.call("openAtLogin", LoginItem.state.rawValue)// The very first registration can take a moment to show in the status.+ refreshSettings()DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] inself?.panel.host.call("openAtLogin", LoginItem.state.rawValue)+ self?.refreshSettings()}}@@ -615,7 +640,10 @@ final class AppDelegate: NSObject, NSApplicationDelegate {self.editor?.host.call("servicesChanged", self.hub.servicesInfo)}}- sync.onPeersChanged = { [weak self] in self?.refreshPairingWindow() }+ sync.onPeersChanged = { [weak self] in+ self?.refreshPairingWindow()+ self?.refreshSettings()+ }sync.onShowQR = { [weak self] content, device in self?.showLoginCode(content, for: device) }sync.start() // only listens once a phone has been paired}@@ -719,12 +747,83 @@ final class AppDelegate: NSObject, NSApplicationDelegate {loginWindow?.setStatus("Requested by \(device)", active: true)}+ // MARK: - Settings++ @objc private func openSettings() { showSettings() }+ @objc private func openAbout() { showSettings(pane: "About") }++ private func showSettings(pane: String? = nil) {+ panel.hide()+ if settings == nil {+ let controller = SettingsWindowController()+ let model = controller.model+ model.setOpenAtLogin = { [weak self] on in self?.setOpenAtLogin(on) }+ model.setIsland = { [weak self] on in+ guard let self, on != (self.island?.isShown == true) else { return }+ self.toggleIsland()+ }+ model.selectPlan = { [weak self] plan in+ guard let self, plan != self.plans.activePlan else { return }+ self.plans.select(plan)+ self.reloadAll()+ self.editor?.host.load()+ }+ model.editHome = { [weak self] in self?.openEditor() }+ model.loadPlan = { [weak self] in self?.loadPlan() }+ model.revealPlan = { [weak self] in self?.revealPlan() }+ model.openConnection = { [weak self] id in self?.showEditor(section: "service:\(id)") }+ model.pairPhone = { [weak self] in self?.pairPhone() }+ model.openAgent = { [weak self] in self?.openAgent() }+ model.stopAgent = { [weak self] in self?.agent.stop() }+ model.revealLog = { [weak self] in self?.revealLog() }+ controller.onShow = { [weak self] in self?.refreshSettings() }+ settings = controller+ }+ settings?.show(pane: pane)+ }++ /// Puts what is true now into an open Settings window.+ private func refreshSettings() {+ guard let model = settings?.model else { return }+ model.openAtLogin = LoginItem.state+ model.islandShown = island?.isShown == true+ var choices = PlanStore.bundled.map { id in+ SettingsModel.Plan(id: id, name: "Demo · \(id == "home" ? "Apartment" : id.capitalized)")+ }+ if plans.hasCustomPlan { choices.insert(.init(id: "custom", name: plans.customPlanName ?? "My home"), at: 0) }+ model.plans = choices+ model.activePlan = plans.activePlan+ let info = hub.servicesInfo+ func entry(_ id: String) -> [String: Any] { info[id] as? [String: Any] ?? [:] }+ func connected(_ id: String) -> Bool { entry(id)["connected"] as? Bool ?? false }+ let homeKit = entry("homekit")+ model.connections = [+ .init(id: "smartlife", name: "Smart Life", symbol: "bolt.horizontal.fill", tint: .orange,+ detail: connected("smartlife") ? "Signed in" : "Not signed in", connected: connected("smartlife")),+ .init(id: "homeassistant", name: "Home Assistant", symbol: "house.and.flag.fill", tint: .blue,+ detail: connected("homeassistant") ? entry("homeassistant")["name"] as? String ?? "Connected" : "Not connected",+ connected: connected("homeassistant")),+ .init(id: "hue", name: "Philips Hue", symbol: "lightbulb.2.fill", tint: .indigo,+ detail: connected("hue") ? entry("hue")["name"] as? String ?? "Connected" : "Not paired", connected: connected("hue")),+ .init(id: "homekit", name: "Apple Home", symbol: "homekit", tint: .yellow,+ detail: connected("homekit")+ ? "\(homeKit["count"] as? Int ?? 0) devices, from \(homeKit["from"] as? String ?? "your iPhone")"+ : "Comes from a paired iPhone", connected: connected("homekit")),+ ]+ model.phones = sync.connectedDevices+ model.aiLive = agent.isLive+ }+// MARK: - Menu (gives the editor window the usual shortcuts)private func buildMainMenu() {let main = NSMenu()let appItem = NSMenuItem()let appMenu = NSMenu()+ appMenu.addItem(withTitle: "About House Control", action: #selector(openAbout), keyEquivalent: "").target = self+ appMenu.addItem(.separator())+ appMenu.addItem(withTitle: "Settings…", action: #selector(openSettings), keyEquivalent: ",").target = self+ appMenu.addItem(.separator())appMenu.addItem(withTitle: "Quit House Control", action: #selector(NSApplication.terminate(_:)), keyEquivalent: "q")appItem.submenu = appMenumain.addItem(appItem)diff --git a/macos/Sources/HouseControl/SettingsWindow.swift b/macos/Sources/HouseControl/SettingsWindow.swiftnew file mode 100644index 0000000..b79800c--- /dev/null+++ b/macos/Sources/HouseControl/SettingsWindow.swift@@ -0,0 +1,355 @@+import AppKit+import SwiftUI+import HouseCore++/// What the Settings window shows. The app delegate fills it in whenever the window comes up+/// or something it shows changes, and carries out what it asks for.+@MainActor+final class SettingsModel: ObservableObject {+ struct Plan: Identifiable, Hashable {+ let id: String+ let name: String+ }++ struct Connection: Identifiable {+ let id: String+ let name: String+ let symbol: String+ let tint: Color+ let detail: String+ let connected: Bool+ }++ @Published var openAtLogin: LoginItem.State = .off+ @Published var islandShown = false+ @Published var plans: [Plan] = []+ @Published var activePlan = "home"+ @Published var connections: [Connection] = []+ @Published var phones: [String] = []+ @Published var aiLive = false++ var setOpenAtLogin: (Bool) -> Void = { _ in }+ var setIsland: (Bool) -> Void = { _ in }+ var selectPlan: (String) -> Void = { _ in }+ var editHome: () -> Void = {}+ var loadPlan: () -> Void = {}+ var revealPlan: () -> Void = {}+ var openConnection: (String) -> Void = { _ in }+ var pairPhone: () -> Void = {}+ var openAgent: () -> Void = {}+ var stopAgent: () -> Void = {}+ var revealLog: () -> Void = {}+}++/// House Control → Settings… (⌘,): the app's options in one window, the way every Mac app has+/// them. The panel's gear menu and the menu bar icon's right-click menu lead here too.+@MainActor+final class SettingsWindowController: NSWindowController {+ let model = SettingsModel()+ var onShow: (() -> Void)?++ init() {+ let tabs = NSTabViewController()+ tabs.tabStyle = .toolbar+ let panes: [(String, String, AnyView)] = [+ ("General", "gearshape", AnyView(GeneralPane())),+ ("Home", "house", AnyView(HomePane())),+ ("Connections", "point.3.connected.trianglepath.dotted", AnyView(ConnectionsPane())),+ ("iPhone", "iphone", AnyView(PhonePane())),+ ("AI Access", "sparkles", AnyView(AgentPane())),+ ("About", "info.circle", AnyView(AboutPane())),+ ]+ for (title, symbol, view) in panes {+ let host = NSHostingController(rootView: view.environmentObject(model))+ host.sizingOptions = .preferredContentSize+ host.title = title // the tab controller names the window after the pane on show+ let item = NSTabViewItem(viewController: host)+ item.label = title+ item.image = NSImage(systemSymbolName: symbol, accessibilityDescription: title)+ tabs.addTabViewItem(item)+ }+ let window = NSWindow(contentViewController: tabs)+ window.styleMask = [.titled, .closable]+ window.isReleasedWhenClosed = false+ window.setFrameAutosaveName("HouseControlSettings")+ super.init(window: window)+ }++ /// The window as a PNG, drawn without the screen (HOUSE_SNAPSHOT_DIR).+ func snapshot(to url: URL) {+ guard let view = window?.contentView?.superview ?? window?.contentView,+ let rep = view.bitmapImageRepForCachingDisplay(in: view.bounds) else { return }+ view.cacheDisplay(in: view.bounds, to: rep)+ try? rep.representation(using: .png, properties: [:])?.write(to: url)+ }++ @available(*, unavailable)+ required init?(coder: NSCoder) { fatalError() }++ func show(pane: String? = nil) {+ onShow?()+ if let pane, let tabs = window?.contentViewController as? NSTabViewController,+ let index = tabs.tabViewItems.firstIndex(where: { $0.label == pane }) {+ tabs.selectedTabViewItemIndex = index+ }+ NSApp.activate(ignoringOtherApps: true)+ if window?.isVisible != true { window?.center() }+ showWindow(nil)+ window?.makeKeyAndOrderFront(nil)+ }+}++// MARK: - Panes++/// One pane: a grouped form of a fixed width, the height of what is in it.+private struct Pane<Content: View>: View {+ @ViewBuilder var content: Content++ var body: some View {+ Form { content }+ .formStyle(.grouped)+ .scrollDisabled(true)+ .frame(width: 500)+ .fixedSize(horizontal: false, vertical: true)+ }+}++private struct GeneralPane: View {+ @EnvironmentObject var model: SettingsModel++ var body: some View {+ Pane {+ Section {+ Toggle("Open at Login", isOn: Binding(get: { model.openAtLogin == .on }, set: model.setOpenAtLogin))+ if model.openAtLogin == .needsApproval {+ LabeledContent {+ Button("Open Login Items…") { model.setOpenAtLogin(true) }+ } label: {+ Text("Waiting for your OK in System Settings → General → Login Items.")+ .foregroundStyle(.secondary)+ }+ }+ } footer: {+ Footnote("House Control starts with your Mac and waits in the menu bar.")+ }+ Section {+ Toggle("Show the Island", isOn: Binding(get: { model.islandShown }, set: model.setIsland))+ } footer: {+ Footnote("Lamps on, the AC and scenes at a glance, in the middle of the menu bar. Click it to open it up.")+ }+ Section("Getting around") {+ Tip(symbol: "cursorarrow.click", text: "Click the house in the menu bar for the panel.")+ Tip(symbol: "contextualmenu.and.cursorarrow", text: "Right-click it for the menu: editor, iPhone, AI Access.")+ Tip(symbol: "command", text: "⌘, opens these settings from any House Control window.")+ }+ }+ }+}++private struct HomePane: View {+ @EnvironmentObject var model: SettingsModel++ var body: some View {+ Pane {+ Section {+ Picker("Floor plan", selection: Binding(get: { model.activePlan }, set: model.selectPlan)) {+ ForEach(model.plans) { Text($0.name).tag($0.id) }+ }+ .pickerStyle(.radioGroup)+ } footer: {+ Footnote("Draw your own home in the editor, or load a plan file. The demos are simulated: nothing real switches.")+ }+ Section {+ ActionRow(symbol: "pencil.and.ruler", title: "Edit Home…", detail: "Rooms, lamps, ACs, furniture and scenes", action: model.editHome)+ ActionRow(symbol: "square.and.arrow.down", title: "Load Floor Plan…", detail: "A plan file from another Mac or a backup", action: model.loadPlan)+ ActionRow(symbol: "folder", title: "Reveal Plan File", detail: "The plan as JSON, in the Finder", action: model.revealPlan)+ }+ }+ }+}++private struct ConnectionsPane: View {+ @EnvironmentObject var model: SettingsModel++ var body: some View {+ Pane {+ Section {+ ForEach(model.connections) { connection in+ LabeledContent {+ Button(connection.connected ? "Manage…" : "Connect…") { model.openConnection(connection.id) }+ } label: {+ HStack(spacing: 10) {+ Badge(symbol: connection.symbol, tint: connection.tint)+ VStack(alignment: .leading, spacing: 2) {+ Text(connection.name)+ HStack(spacing: 5) {+ Circle().fill(connection.connected ? Color.green : Color.secondary.opacity(0.5))+ .frame(width: 6, height: 6)+ Text(connection.detail).foregroundStyle(.secondary).font(.callout)+ }+ }+ }+ }+ }+ } footer: {+ Footnote("Connections are set up in the editor, where you also link each lamp and AC to its real device. Home Assistant and Hue are shared with a paired iPhone.")+ }+ }+ }+}++private struct PhonePane: View {+ @EnvironmentObject var model: SettingsModel++ var body: some View {+ Pane {+ Section {+ if model.phones.isEmpty {+ Label("No iPhone is connected right now", systemImage: "iphone.slash").foregroundStyle(.secondary)+ } else {+ ForEach(model.phones, id: \.self) { phone in+ Label { Text(phone) } icon: { Image(systemName: "iphone").foregroundStyle(.green) }+ }+ }+ ActionRow(symbol: "qrcode", title: "Pair iPhone…", detail: "Show the code to scan with House Control on the iPhone", action: model.pairPhone)+ } footer: {+ Footnote("Paired, the iPhone gets this floor plan and its connections and keeps them in step with the Mac, whichever one you edit. An iPhone stays connected while its app is open.")+ }+ }+ }+}++private struct AgentPane: View {+ @EnvironmentObject var model: SettingsModel++ var body: some View {+ Pane {+ Section {+ LabeledContent {+ if model.aiLive { Button("Stop", role: .destructive, action: model.stopAgent) }+ } label: {+ HStack(spacing: 10) {+ Badge(symbol: "sparkles", tint: .purple)+ VStack(alignment: .leading, spacing: 2) {+ Text("AI Access")+ Text(model.aiLive ? "Live: an assistant can run your home" : "Off")+ .foregroundStyle(model.aiLive ? .green : .secondary).font(.callout)+ }+ }+ }+ ActionRow(symbol: "link", title: "Open AI Access…", detail: "The link and what an assistant may do", action: model.openAgent)+ } footer: {+ Footnote("A private link that lets an AI assistant such as Claude or ChatGPT see and switch your home, with the limits you choose. It ends when you stop it or quit House Control.")+ }+ }+ }+}++private struct AboutPane: View {+ @EnvironmentObject var model: SettingsModel+ private let version = Bundle.main.infoDictionary?["CFBundleShortVersionString"] as? String ?? ""+ private let build = Bundle.main.infoDictionary?["CFBundleVersion"] as? String ?? ""++ var body: some View {+ Pane {+ Section {+ HStack(spacing: 14) {+ Image(nsImage: NSApp.applicationIconImage).resizable().frame(width: 56, height: 56)+ VStack(alignment: .leading, spacing: 3) {+ Text("House Control").font(.title3.weight(.semibold))+ Text(version.isEmpty ? "Development build" : "Version \(version)\(build.isEmpty || build == version ? "" : " (\(build))")")+ .foregroundStyle(.secondary)+ Text("Your home as a live 3D model, in the menu bar.").foregroundStyle(.secondary).font(.callout)+ }+ }+ .padding(.vertical, 4)+ }+ Section {+ LinkRow(symbol: "globe", title: "Website", url: About.website)+ LinkRow(symbol: "questionmark.circle", title: "Support", url: About.support)+ LinkRow(symbol: "hand.raised", title: "Privacy Policy", url: About.privacy)+ LinkRow(symbol: "shippingbox", title: "Source Code", url: About.source)+ LinkRow(symbol: "at", title: "\(About.developer) on X", url: About.x)+ }+ Section {+ ActionRow(symbol: "doc.text.magnifyingglass", title: "Reveal Device Log", detail: "What was sent to your devices, for a bug report", action: model.revealLog)+ }+ }+ }+}++// MARK: - Pieces++private struct Footnote: View {+ let text: String+ init(_ text: String) { self.text = text }++ var body: some View {+ Text(text).font(.callout).foregroundStyle(.secondary).fixedSize(horizontal: false, vertical: true)+ }+}++private struct Badge: View {+ let symbol: String+ let tint: Color++ var body: some View {+ Image(systemName: symbol)+ .font(.system(size: 13, weight: .semibold))+ .foregroundStyle(.white)+ .frame(width: 26, height: 26)+ .background(tint.gradient, in: RoundedRectangle(cornerRadius: 6, style: .continuous))+ }+}++private struct Tip: View {+ let symbol: String+ let text: String++ var body: some View {+ Label { Text(text) } icon: { Image(systemName: symbol).foregroundStyle(.secondary) }+ }+}++/// A row that does something: a title and what it is for, and the whole row is the button.+private struct ActionRow: View {+ let symbol: String+ let title: String+ let detail: String+ let action: () -> Void++ var body: some View {+ Button(action: action) {+ HStack(spacing: 10) {+ Image(systemName: symbol).frame(width: 20).foregroundStyle(Color.accentColor)+ VStack(alignment: .leading, spacing: 1) {+ Text(title)+ Text(detail).font(.callout).foregroundStyle(.secondary)+ }+ Spacer()+ Image(systemName: "chevron.right").font(.caption.weight(.semibold)).foregroundStyle(.tertiary)+ }+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ }+}++private struct LinkRow: View {+ let symbol: String+ let title: String+ let url: URL++ var body: some View {+ Link(destination: url) {+ HStack(spacing: 10) {+ Image(systemName: symbol).frame(width: 20).foregroundStyle(.secondary)+ Text(title).foregroundStyle(.primary)+ Spacer()+ Image(systemName: "arrow.up.right").font(.caption.weight(.semibold)).foregroundStyle(.tertiary)+ }+ .contentShape(Rectangle())+ }+ .buttonStyle(.plain)+ }+}diff --git a/web/src/editor/editor.js b/web/src/editor/editor.jsindex 722d83a..49bb107 100644--- a/web/src/editor/editor.js+++ b/web/src/editor/editor.js@@ -37,11 +37,12 @@ export async function bootEditor(root) {let doc = structuredClone(await loadRawConfig());for (const key of Object.values(KEYS)) doc[key] ||= [];- // HOUSE_OPEN_EDITOR=connections|smartlife|homeassistant|hue|homekit opens a connection screen.- const startAt = window.__HOUSE_BOOT__?.section || new URLSearchParams(location.search).get('section') || '';- let sel = startAt === 'connections' ? { kind: 'connections' }- : startAt.startsWith('service:') ? { kind: 'service', service: startAt.slice(8) }- : startAt === 'tuya' ? { kind: 'service', service: 'smartlife' } : { kind: 'home' };+ // "connections", "service:smartlife|homeassistant|hue|homekit": where the editor opens+ // (HOUSE_OPEN_EDITOR, or the Mac's Settings window through incoming.openSection).+ const sectionSel = (at) => (at === 'connections' ? { kind: 'connections' }+ : at.startsWith('service:') ? { kind: 'service', service: at.slice(8) }+ : at === 'tuya' ? { kind: 'service', service: 'smartlife' } : { kind: 'home' });+ let sel = sectionSel(window.__HOUSE_BOOT__?.section || new URLSearchParams(location.search).get('section') || '');let dirty = false;let world = null;let phone = null; // the iPhone's layout and gestures, set up by buildPhoneLayout()@@ -1175,6 +1176,7 @@ export async function bootEditor(root) {dirty = false;validate();schedulePreview(0);+ incoming.openSection = (at) => select(sectionSel(at));// A plan saved on the other device (the Mac, or the paired iPhone) while this editor is open.incoming.planArrived = (config, from) => {if (dirty) {diff --git a/web/src/main.js b/web/src/main.jsindex 3ae95fa..a0eeee6 100644--- a/web/src/main.js+++ b/web/src/main.js@@ -188,11 +188,19 @@ async function boot() {icon: openAtLogin === 'on' ? icon('check', 16, 2.4) : null,action: () => post('setOpenAtLogin', { on: openAtLogin !== 'on' }),},+ { label: 'Settings…', action: () => post('openSettings') },{ label: 'Quit House Control', action: () => post('quit') });}openMenu(panel.anchorMenu, anchor, items);}+ // ⌘, opens the Mac's Settings window, as in every Mac app (the panel has no menu bar of its own).+ if (isNative && !isPhone) {+ window.addEventListener('keydown', (ev) => {+ if (ev.metaKey && ev.key === ',') { ev.preventDefault(); post('openSettings'); }+ });+ }+const opened = window.__HOUSE_BOOT__?.openDevice || new URLSearchParams(location.search).get('device');if (store.acCfg.has(opened)) panel.openSheet({ kind: 'ac', id: opened });else if (store.lightCfg.has(opened)) panel.openSheet({ kind: 'light', id: opened });diff --git a/web/src/ui/panel.js b/web/src/ui/panel.jsindex eb3ad24..2ad3605 100644--- a/web/src/ui/panel.js+++ b/web/src/ui/panel.js@@ -43,7 +43,7 @@ export function createPanel(root, config, store, { onFocus, onMenu }) {const tooltip = h('div.tooltip');const homeSub = h('div.home-sub');const power = h('button.round.power', { title: 'Everything on / off', 'aria-label': 'Toggle everything', onclick: toggleEverything }, icon('power', 21, 2.2));- const gear = h('button.round', { title: 'Floor plan', 'aria-label': 'Floor plan menu', onclick: () => onMenu(gear) }, icon('settings', 17));+ const gear = h('button.round', { title: 'Settings and floor plans', 'aria-label': 'Settings and floor plans', onclick: () => onMenu(gear) }, icon('settings', 17));// Shown while an AI assistant has a link to this home (AI Access on the Mac).const aiBadge = h('button.ai-badge', { hidden: true, title: 'An AI assistant has access — click to manage', 'aria-label': 'AI access',onclick: () => onMenu(aiBadge, 'agent') }, icon('sparkles', 13, 2.2), h('span', 'AI'));