# app-ui ## Goal The user-facing app: a menu-bar status item that shows every machine in the matrix with the Windows status colours and offers the everyday actions, and a native settings window that exposes every PowerToys setting (README §Settings) plus the Mac-only permissions and launch-at-login controls. It replaces the placeholder status item app-engine shipped and is the last lane before **CP1**, the first build the user tests. Everything the UI does goes through two doors: `Engine.observe` for state in, `SettingsStore.update` + `Engine.apply` for state out (app-engine Review). ## Assumptions - **AppKit for the status item, SwiftUI for the settings window.** `NSStatusItem` + `NSMenu` rebuilt on every `EngineSnapshot`; the settings window is one `NSWindow` (`.titled, .closable, .miniaturizable`, fixed at 560 × 520) hosting an `NSHostingView`. All UI is `@MainActor`; `UIBridge` (in the `mwb` target) receives snapshots on whatever thread `observe` delivers and hops to main. - **The UI never sees `EngineSnapshot`.** `MWBMac` may import neither `MWBNet` nor the executable target (README D2), and `EngineSnapshot` lives in `mwb` while `PeerStatus` lives in `MWBNet`. So the status item takes `StatusModel`/`MachineRow` — plain `MWBCore`-only values — and `UIBridge` is the mapping. This is the one shape change from the Handshakes sketch this README used to carry; everything else there shipped as written. - **Status colours** are the documented table (`doc/devdocs/modules/mousewithoutborders.md`): NA `#717171`, Resolving yellow, Connecting orange, Handshaking blue, Error red, ForceClosed purple, InvalidKey brown `#A52A2A`, Timeout pink `#FFC0CB`, SendError maroon `#800000`, Connected green `#008000`. A slot with no connection at all shows NA; the local machine shows a filled dot in the accent colour. - **Menu** (top to bottom): one row per matrix slot "● name — status" (the controlled machine gets a check mark; clicking a row switches to it, the local row switches home; ⌃⌥F1..F4 shown as **labels** only — the real hotkeys are the tap's, which sees them before any menu could); then any peer that connected without being in the matrix, shown but not clickable; separator; "Control All Computers" (`MenuAllPC`, `frmScreen.Designer.cs:174`), "Easy Mouse" (check mark, toggles), "Reconnect" and "Lock All Machines", the last two labelled with their configured shortcut; separator; the problem lines — host-name, permissions ("Permissions: OK" or "Permissions missing: …", which opens the Advanced pane), "Cannot inject events", "Input capture is not running", and the last recovery (app-engine request 2); separator; "Settings…" ⌘,; the version; "Quit Mouse Without Borders" ⌘Q. The item's icon: two overlapping rounded rectangles drawn in code (no asset catalog), a template image so AppKit tints it, with a coloured badge — and no longer a template — when anything is wrong. - **Settings panes** (a `TabView`, one file each): *Machines* — the 4 slots as text fields in a 1×4 or 2×2 grid (`MatrixOneRow`), ◀ ▶ (▲ ▼ in two rows) buttons to reorder, "Devices in a single row", "Move the mouse back to the first machine when it passes the last one" (`WrapMouse`), and this Mac's name with Copy and a "Put in slot" menu; *Security* — the key as `SecurityKey.displayText`, Show/Hide, New key, Copy, TCP port, and one "Save and reconnect" that applies both; *Behaviour* — `HideMouseAtScreenEdge`, `MoveMouseRelatively`, `BlockMouseAtScreenCorners`, the Easy Mouse picker (`Disable/Enable/Ctrl/Shift`), `DisableEasyMouseWhenForegroundWindowIsFullscreen` and its excluded-apps list, `ShareClipboard`, `TransferFile`, `BlockScreenSaverOnOtherMachines`, `ShowClipboardAndNetworkStatusMessages`; *Hotkeys* — recorders for toggle Easy Mouse, lock, reconnect and switch-to-all, each with a Clear button, plus the switch-machine base key as the PowerToys three-way choice; *Network* — `Name2IP` multi-line editor with the "name ip" per-line format explained, `ValidateRemoteMachineIP`, `SameSubnetOnly`; *Advanced* — Accessibility and Input Monitoring rows with state, "Request…" (`Permissions.request()`) and "Open System Settings" (`x-apple.systempreferences:com.apple.preference.security?Privacy_Accessibility` / `?Privacy_ListenEvent`), "Launch at login" (`SMAppService.mainApp`), Show-in-Finder for the settings and log files, and the version, host name, machine id and device id. Settings not yet backed by a lane (clipboard/extras) are shown and saved — they simply have no effect until their lane lands; a footnote on the pane says so. - **Hotkey recorder**: an `NSViewRepresentable` that becomes first responder on click, records the next key-down with its modifiers (`KeyMap.vk(forKeycode:)` for the VK; ⌘→Win, ⌥→Alt, ⌃→Ctrl, ⇧→Shift) into a `Hotkey`, shows it as "⌃⌥⌘L", Escape cancels. It never installs a global monitor. - **Every edit** is `store.update { $0.x = … }` then `await engine.apply(store.current)`. The security key, the TCP port, the matrix, `Name2IP` and the excluded-apps list are **drafts** with a Save button; every other control commits as it changes. The store is the only writer of `settings.json` and the Engine is told to re-read — there is no second path (app-engine request 1). - **Notifications** (`ShowClipboardAndNetworkStatusMessages`, `Common.cs` `ShowToolTip` call sites): `UNUserNotificationCenter` for "Connected to X" / "Lost X" / "Invalid key for X"; authorization requested when the user turns the toggle on; skipped entirely when `Bundle.main.bundleIdentifier` is nil (unbundled `swift run`). - **Launch at login**: `SMAppService.mainApp.register()` / `unregister()`, status from `.status`; disabled with a note when not running from a bundle. - **Single settings window**: reopening brings it to front; closing hides, never terminates (LSUIElement app). - **CP1 is the lead's**: after merge the lead runs `tools/bundle.sh` and hands over the checklist from TODO §7 and contracts C5. ## Handshakes ### Consumed - `app-engine`: `Engine.observe`, `EngineSnapshot`, `switchTo(slot:)`, `switchToAll`, `reconnect`, `lockAll`, `toggleEasyMouse`, `apply`, `recoverLocal(reason:)`, `SettingsStore.update`/`current`/`fileURL`, the `Settings` accessors, `Log.fileURL()`, `MWBVersion.string`. - `input-capture`: `KeyMap.vk(forKeycode:)`, `Hotkey`, `HotkeyConfig`, `Permissions.preflight`/`request`, `PermissionState`. - `wire-core`: `SecurityKey.displayText/normalize/isValid/random/minimumLength`. - `session-matrix`: `Matrix`, `SocketStatus`. - `control-channel`: `PeerStatus` (in `UIBridge` only). Nothing consumed was changed. No file outside this lane's list was edited except the status-item parts of `Sources/mwb/AppLifecycle.swift`, `Resources/Info.plist` and `TODO.md` §7, all authorised by the brief. ### Promised (to clipboard, extras) As shipped 2026-09-16. ```swift // MWBMac/StatusItem.swift public enum StatusColor { public static func nsColor(for status: SocketStatus) -> NSColor public static var local: NSColor { get } public static func name(for status: SocketStatus) -> String } public struct MachineRow: Sendable, Equatable { public var name: String; public var status: SocketStatus public var isLocal, isControlled: Bool; public var slot: Int? public init(name: String, status: SocketStatus, isLocal: Bool = false, isControlled: Bool = false, slot: Int? = nil) } public struct StatusModel: Sendable, Equatable { public var rows: [MachineRow]; public var controlled: String? public var broadcasting: Bool; public var easyMouse: EasyMouseMode public var missingPermissions: [String]; public var canInject, tapRunning: Bool public var hostnameProblem, lastRecovery: String? public var lockHotkey, reconnectHotkey: Hotkey public var switchMachineVK: Int32; public var version: String public init() } @MainActor public struct StatusActions { public var switchTo: (Int) -> Void // matrix slot public var switchHome, switchToAll, toggleEasyMouse, reconnect, lockAll, quit: () -> Void public var openSettings: (SettingsPane?) -> Void } @MainActor public final class StatusItemController { public init(actions: StatusActions) public func update(_ model: StatusModel) // no-op when nothing changed public func remove() } // MWBMac/SettingsWindow/ public enum SettingsPane: String, Sendable, CaseIterable { case machines, security, behaviour, hotkeys, network, advanced public var title: String { get } } @MainActor public final class SettingsViewModel: ObservableObject { public init(store: SettingsStore, localName: String, apply: @escaping @Sendable (Settings) async -> Void) @Published public private(set) var settings: Settings @Published public var securityKeyDraft, portDraft, name2IPDraft, excludedAppsDraft: String @Published public var slotDrafts: [String] @Published public var showSecurityKey: Bool @Published public private(set) var message: String? @Published public var permissions: PermissionState public let localName: String public var settingsFileURL: URL { get } public func binding(_ keyPath: WritableKeyPath) -> Binding public func commit(_ body: (inout Settings) -> Void) public func storeChanged(); public func refreshDrafts(); public func clearMessage() public var securityKeyIsValid, matrixHasEdits: Bool { get } public func generateKey(); public func copyKey(); public func copyLocalName() public func saveConnection(); public func saveMatrix() public func swapSlots(_ first: Int, _ second: Int); public func useLocalName(inSlot: Int) public func saveName2IP(); public func saveExcludedApps() } @MainActor public final class SettingsWindowController: NSObject, NSWindowDelegate { public init(model: SettingsViewModel) public func show(pane: SettingsPane? = nil) public var isVisible: Bool { get } } public enum HotkeyText { public static func describe(_ hotkey: Hotkey) -> String // "⌃⌥⌘L" public static func switchMachineLabel(_ baseVK: Int32, _ slot: Int) -> String? public static func keyName(_ vk: Int32) -> String? } // MWBMac/Notifications.swift @MainActor public final class Notifier { public init(); public var isAvailable: Bool { get } public func enabledChanged(_ isOn: Bool) public func post(title: String, body: String) public func connected(to machine: String); public func lost(_ machine: String) public func invalidKey(for machine: String) } // MWBMac/LaunchAgent.swift public enum LaunchAtLogin { public static var isAvailable, isEnabled, needsApproval: Bool { get } public static func set(_ enabled: Bool) throws } ``` Five deviations from the shape this section sketched at planning time: - **`StatusItemController.update` takes a `StatusModel`, not an `EngineSnapshot`** — the layering reason above. `UIBridge` owns the mapping, including which of two connections to a peer decides the dot's colour. - **`StatusActions` gained `switchToAll` and lost nothing.** ALL-machines mode is in the Windows tray menu (`MenuAllPC`) and the Engine already publishes `broadcasting`, so leaving it out would have made the hotkey the only way in. - **`SettingsViewModel.init` takes `localName`.** The Machines and Advanced panes both show it and the store does not carry it; the process resolves it (README D7) and hands it over, exactly as it does to the Engine. - **`Notifier` is `@MainActor`**, which the sketch did not say: it holds the "have we asked for authorization" flag, and everything that calls it is main-isolated anyway. - **`LaunchAtLogin.isEnabled` is read-only plus `set(_:) throws`**, with `needsApproval` added, because `SMAppService` has a third state — the registration exists but the user has to approve it in System Settings — and a two-state toggle would have looked broken in it. ### Requested of app-engine (open) 1. **`Settings` has no `drawMouseCursor` accessor.** README §Settings lists `DrawMouseCursor` (default true) and the brief asks for every property in that table to be reachable in the settings window; `Sources/MWBCore/Settings.swift` carries the property in `defaultProperties` (so it round-trips) but publishes no typed accessor, and that file is app-engine's. A one-line `public var drawMouseCursor: Bool` pair would close it. The control is **not shown** in the Behaviour pane until then, with a footnote saying the value is kept untouched for the Windows machines that read it — which is the honest position anyway, since the drawn cursor is out of scope for v1 (README D6) and a toggle that does nothing on either side is worse than no toggle. ## Status / TODO - [x] `Sources/MWBMac/StatusItem.swift`: item, icon, menu, colours (`doc/devdocs/modules/mousewithoutborders.md`; menu actions mirror `Form/frmMatrix.cs` and the tray menu in `Class/Program.cs` / `Core/Common.cs` `ShowMenu`). - [x] `Sources/MWBMac/SettingsWindow/SettingsWindow.swift`, `SettingsView.swift`, `SettingsViewModel.swift`, `MachinesPane.swift`, `SecurityPane.swift`, `BehaviourPane.swift`, `HotkeysPane.swift` (+ recorder), `NetworkPane.swift`, `AdvancedPane.swift` — every property in README §Settings reachable (`Form/Settings/*.cs` for labels and grouping), **except `DrawMouseCursor`**: no accessor exists to bind to, so it is an open Handshake request above and a footnote in the pane. - [x] `Sources/MWBMac/Notifications.swift`, `Sources/MWBMac/LaunchAgent.swift`. - [x] `Sources/mwb/UIBridge.swift`: snapshot → UI, actions → engine; replace the placeholder status item in `Sources/mwb/AppLifecycle.swift` (authorised edit, that file's status-item parts only). - [x] `docs/protocol.md`: nothing expected; **nothing appended** — this lane learned no wire fact. It reads settings and statuses that earlier lanes already transcribed. - [x] `tools/bundle.sh` / `Resources/Info.plist`: add what the bundle needs for notifications and login items (authorised). **Only `Info.plist` changed, and only by one key** — see the work log for what was checked and why nothing else was needed. ## Work log - **2026-09-16 (dev)** — lane built on `main` from `bce5c3c`; four commits. Gates green on the last; `MWB_ADHOC=1 tools/bundle.sh` produces `dist/mwb.app`. *What was built.* Thirteen new files and two edited ones. `MWBMac/StatusItem.swift` is the menu bar: the colour table, the row and model values, the drawn icon and the menu. `MWBMac/SettingsWindow/` is the window: one `NSWindow` + `NSHostingView` (`SettingsWindow.swift`), the tab chrome and the shared row/section/ toggle views (`SettingsView.swift`), the one object the panes bind to (`SettingsViewModel.swift`), and a file per pane. `Notifications.swift` and `LaunchAgent.swift` are the two macOS services the Windows side has no equivalent for. `mwb/UIBridge.swift` joins them to the Engine, and `mwb/AppLifecycle.swift` lost its placeholder status item. *Key decisions.* 1. **The UI is told, not asked.** `StatusItemController.update` takes a value and compares it to the last one, so `render` can be called on every snapshot — which it is, several times a second while connecting — and rebuilds the menu only when something a user can see has changed. 2. **`StatusModel` instead of `EngineSnapshot`.** Forced by the target layering (README D2), but it is the better shape anyway: the status item has no opinion about how two connections to one peer collapse into one dot, and `UIBridge.bestStatuses` can be read and argued about on its own. 3. **Drafts only where a keystroke is expensive.** A `Toggle` writes the settings file and re-derives the configs, which is cheap. The security key and the port tear down every socket, and a matrix edit replicates four packets to every peer — so those, plus the two multi-line editors, are drafts with a Save button, which is also what the Windows form does with its single "&Apply" (`frmMatrix.Designer.cs:440-441`). 4. **The switch-machine hotkey is a three-way picker, not a recorder.** `HotKeySwitchMachine` is the *first of four consecutive* virtual keys (`InputHook.cs:611-620`), so an arbitrary recorded key would silently claim three more. PowerToys offers exactly three choices here — F1..F4, 1..4, Disabled (`MouseWithoutBordersPage.xaml:386-392`, `SettingsPage4.Designer.cs:223-257`) — and so do we. The other four shortcuts are free-form recorders. 5. **Escape cancels the recorder rather than being recordable.** The hard escape is ⌃⌥⌘Escape (contracts C2) and is not editable; a recorder you cannot back out of is a trap when the chord you are typing is one the tap swallows. 6. **The one `Permissions.request()` call site moved** from the placeholder menu to the Advanced pane's "Request…" button. Still exactly one, still only on a click (CLAUDE.md, Workflow). 7. **A settings file that will not parse now shows a modal alert and quits** instead of leaving a status item saying "settings error". An accessory app has no window and no Dock icon; the previous behaviour was a dead end for anyone not reading the log. *Deviations from the brief and the Assumptions as written.* - **`update(_ snapshot: EngineSnapshot)`** became `update(_ model: StatusModel)`, with `UIBridge` doing the mapping. Recorded in Handshakes with the four other API changes. - **`DrawMouseCursor` is not in the pane.** No accessor exists to bind to and `Settings.swift` is app-engine's file, so this is an open Handshake request rather than a cross-lane edit. - **The menu gained "Control All Computers"** and the per-row labels for the two shortcuts, neither of which the README sketch listed. - **Clicking the local machine's row** uses the ordinary `Engine.switchTo(slot:)` when it has a matrix slot, and `recoverLocal(reason: .escapeHotkey)` only when it has none. A menu click asking for control back *is* a manual escape, so the wording that ends up in the "Control returned:" line is right, but it is a reason invented for a hotkey and worth knowing about. - **`Info.plist` gained one key and `bundle.sh` gained none.** What notifications and login items actually need was checked item by item: a bundle identifier (already there), a display name for the banner and the Login Items list (already there), and a code signature (which `bundle.sh` already applies, with D5's warning about ad-hoc identities). `UNUserNotificationCenter` needs no usage-description key and `SMAppService.mainApp` needs no plist entry at all. The key that *was* added is `NSSupportsSuddenTermination` = `false`: it is already the default for applications, and saying it out loud is cheap insurance for the one path that must never be skipped — `applicationWillTerminate`, which releases held keys, gives the pointer back and says `ByeBye` (invariant 3, contracts C2). *Verification.* `xcrun swift-format format -i --recursive Sources Package.swift`, then `tools/gates.sh` green (lint --strict, MWBCore layering, build with warnings-as-errors) — run under `tools/guard.sh`. `.build/debug/mwb --version` and `--check-permissions` behave as before (the latter exits 3 on this machine, which has neither grant) and still create no settings file, log file or tap. `MWB_ADHOC=1 tools/bundle.sh` produces `dist/mwb.app` and `codesign --verify` passes. No file is over 400 lines and no function over 50. **Neither the app nor the settings window was launched**: the app creates an event tap, opens sockets, posts TCC prompts and could post notifications (CLAUDE.md invariant 5 and the lane brief). That means every pixel here — the menu, the six panes, the recorder, the notifications, the login item — is unexercised, and CP1 is where it first runs. ## QA log - **2026-09-16 (QA)** — reviewed against CLAUDE.md, `README.md` §Settings, `docs/contracts.md` C2/C4/C5, this README (all sections) and `docs/features/app-engine/README.md` Handshakes, plus `doc/devdocs/modules/mousewithoutborders.md` for the status-colour table. Build-only per CLAUDE.md invariant 5: **neither the app nor the settings window was launched**, no permission was requested, no notification was posted, no socket was opened. *Gates.* `tools/guard.sh -- tools/gates.sh` green (`swift-format lint --strict`, `MWBCore` layering, `swift build -Xswiftc -warnings-as-errors`). `tools/guard.sh -- env MWB_ADHOC=1 tools/bundle.sh` produced `dist/mwb.app` and `codesign --verify` passed (not opened). *Completeness.* Every property in README §Settings has a bound control: `SecurityKey`/`TCPPort` (`SecurityPane`), `EasyMouse` + the fullscreen toggle and its excluded-apps list (`BehaviourPane`), `WrapMouse`/ `MachineMatrixString`/`MatrixOneRow` (`MachinesPane`), `ShareClipboard`/ `TransferFile`/`HideMouseAtScreenEdge`/`MoveMouseRelatively`/ `BlockMouseAtScreenCorners`/`BlockScreenSaverOnOtherMachines`/ `ShowClipboardAndNetworkStatusMessages` (`BehaviourPane`), `ValidateRemoteMachineIP`/`SameSubnetOnly`/`Name2IP` (`NetworkPane`), the four shortcuts + `HotKeySwitchMachine` (`HotkeysPane`), `MachineID`/ `DeviceID` shown read-only in `AdvancedPane` (Windows does not let the user edit these either). `MachinePool`, `LastX`/`LastY`/`PackageID` and the five accepted-but-ignored properties are correctly not surfaced — Windows has no control for them either. `DrawMouseCursor` is the one property with no control; the README documents why (no accessor in `Settings.swift`, which is app-engine's file) and files it as an open Handshake request rather than reaching across lanes — exactly the workflow CLAUDE.md asks for, not a defect. Every menu action in the brief is present and in the documented order (`StatusItem.swift buildMenu`): matrix rows (unlisted peers shown but disabled — `machineItem`/`isEnabled`), "Control All Computers", "Easy Mouse", "Reconnect"/"Lock All Machines" labelled with their shortcuts, the problem lines in order (hostname, permissions, cannot-inject, tap-not-running, last recovery), "Settings…" ⌘,, the version, "Quit …" ⌘Q. Status colours (`StatusColor.nsColor`) checked component-by-component against `doc/devdocs/modules/mousewithoutborders.md` § Status colors: all ten match (NA `#717171`, Resolving yellow, Connecting orange, Handshaking blue, Error red, ForceClosed purple, InvalidKey `#A52A2A`, Timeout `#FFC0CB`, SendError maroon, Connected green). Hotkey recorder (`HotkeysPane.swift` `HotkeyRecorderView.keyDown`) maps `.command`→`Hotkey.command` (Win), `.option`→`.option` (Alt), `.control`→`.control` (Ctrl), `.shift`→`.shift`, matching `MWBCore/InputTypes.swift:137-144`'s own doc comments (`command` = "Requires ⌘ (`HotkeySettings.Win`)", etc.), and reads the VK through `KeyMap.vk(forKeycode:)`, never a raw keycode. Escape (keyCode 53) cancels without recording, as documented. Every edit path goes through `SettingsViewModel.commit` → `store.update(body)` → `publishToEngine` → `engine.apply`; grepped the whole lane for `.save(` and any other `FileManager`/settings-file write — none outside `SettingsStore` itself. `Permissions.request()` has exactly one call site in the repository (`AdvancedPane.swift:128`, the "Request…" button). `Notifier.isAvailable` and `LaunchAtLogin.isAvailable` both gate on `Bundle.main.bundleIdentifier != nil` (`LaunchAtLogin` additionally requires the bundle extension to be `.app`), so neither does anything under `swift run`. `AppLifecycle.swift`'s placeholder status item (`buildStatusItem`, `render`, `setTitle`, `requestPermissions`, `reconnect`, `quit`, the `statusItem`/`titleItem` properties) is gone entirely — diffed old vs new, no remnant, no dead code. *Readability.* All 14 changed/added Swift files are 50-373 lines, well inside the 300-600 target. No function read over ~50 lines. No force-unwrap, `try!`, `fatalError` or `precondition` in any changed file (grepped every `!` and `try!`/`fatalError(`/`precondition(` — all hits are boolean negation). `MWBMac` imports checked file-by-file: only `Foundation`/`AppKit`/`SwiftUI`/`MWBCore`/`UserNotifications`/ `ServiceManagement` — no `MWBNet`, no executable-target import anywhere in `Sources/MWBMac/` (the layering gate only checks `MWBCore`; this half of D2 has to be checked by hand). Public items all carry a one-line doc comment; internal-only helpers (`StatusIcon`, `HotkeyRecorderView`, the pane structs) are correctly not `public`, matching the Handshakes' Promised list exactly. `swift build -Xswiftc -warnings-as-errors` under Swift 6 strict concurrency is clean, which rules out illegal actor- isolation escapes for every `@MainActor` type touching AppKit/SwiftUI. *Security key.* Grepped every `Log.*` call site added or touched by this lane (`SettingsViewModel.swift:79`, `AdvancedPane.swift:139`, `Notifications.swift:41,43,58`, `AppLifecycle.swift:167,178`) — none takes the key, a draft string, or a `Settings` value; the two that log an `Error` log `SettingsError`/`SMAppService`/notification errors, which carry a file name or system message, never settings content. The only two places the key reaches a system API are `SecurityPane`'s "Copy" button (`SettingsViewModel.copyKey()`, pasteboard only, only from the button action) and the key field itself, which is a `SecureField` unless "Show" is pressed. *Findings.* 1. **[correctness, PLAUSIBLE, low] `Engine` and `UIBridge` hold each other in a strong reference cycle.** `Sources/mwb/AppLifecycle.swift`'s `startEngine()` now does `await engine.observe { snapshot in Task { @MainActor in ui.render(snapshot) } }` with `ui` captured strongly (no `[weak ui]`); `Engine.observe` stores that closure forever in `observer` (`Sources/mwb/Engine.swift:286-288`, not this lane's file, but the storage shape matters here) — so the Engine actor now retains `UIBridge` for its whole life. `UIBridge` retains `Engine` right back, both directly (`private let engine: Engine`) and through closures it hands to long-lived objects it owns: `StatusActions`' eight closures each capture `[engine]` (`UIBridge.swift:192-207`) and are held by `StatusItemController`; `SettingsViewModel`'s `apply` closure also captures `[engine]` (`UIBridge.swift:36-38`). The pre-app-ui placeholder avoided exactly this: `Task { [weak self] in await engine.observe { snapshot in Task { @MainActor in self?.render(snapshot) } } }` — the removed `[weak self]` is what is missing now. In this app neither object is ever released without the other (`AppDelegate` holds both for the process's whole life and the app exits via `exit(0)`/`NSApp.terminate`, not by dropping references and expecting `deinit` — `applicationWillTerminate` already calls `ui?.stop()` explicitly rather than relying on dealloc), so this cannot leak *today*. It is still a real cycle and worth a `[weak ui]` in the `observe` closure (or `[weak self]` / `[weak engine]` on the `UIBridge` side) so the shape does not become a problem the day something creates or tears down more than one `Engine`/`UIBridge` pair — a loopback harness being the obvious future case. *Not a finding.* `badgeColour` in `StatusItem.swift` also badges the menu bar icon while a remote peer is merely `.resolving`/`.connecting`/ `.handshaking` (any non-local, non-`.na`, non-`.connected` status), which is broader than the three "cannot do its job" states app-engine's request 2 named. That is a reasonable reading of "a coloured badge when anything is wrong" (brief, Assumptions) rather than a bug — a peer mid-handshake is visibly not yet connected — and CP1 is where the user judges whether the flicker while connecting is annoying in practice. Verdict: PASS ## Review