app-ui: three fixes found re-reading the first pass

- UIBridge remembered only the lowercased key of a peer, so a "Lost X"
  notification for a row that vanished printed the name in lower case;
  and the spelling map was built with Dictionary(uniqueKeysWithValues:),
  which traps when a peer pair has two connections carrying one name.
- SettingsWindowController.show() refreshed the drafts unconditionally,
  so opening the Advanced pane from the menu threw away a half-typed
  security key. It now refreshes only when the window was not visible.
- StatusItem: dropped the unused StatusModel.hasProblem and the dead
  fill/size argument in the icon drawing.

Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This commit is contained in:
lucioandClaude Opus 5 committed 2026-09-16 04:15:54 -07:00
1 parent 6b2b3fc65a
commit 716c5be5c5
3 files changed
+20 -18

No files matched your search

+11 -1
View File
@@ -27,6 +27,7 @@ import MWBNet
private var statusItem: StatusItemController?
private var lastStatuses: [String: SocketStatus] = [:]
private var lastNames: [String: String] = [:]
private var notificationsEnabled: Bool?
init(engine: Engine, store: SettingsStore, localName: String) {
@@ -173,10 +174,19 @@ import MWBNet
notifier.invalidKey(for: name)
}
}
// A row can vanish outright — the channel drops it when the connection is
// gone and the name is not in the matrix to be re-dialled.
for (key, previous) in lastStatuses where current[key] == nil && previous == .connected {
notifier.lost(key)
notifier.lost(lastNames[key] ?? key)
}
lastStatuses = current
// Remember the spelling, not just the key: a peer that vanished cannot be
// looked up in the snapshot any more. Two connections can carry the same
// name, so this is a loop rather than `Dictionary(uniqueKeysWithValues:)`,
// which traps on a duplicate.
for peer in snapshot.peers where !peer.name.isEmpty {
lastNames[peer.name.lowercased()] = peer.name
}
}
private func displayName(_ key: String, _ snapshot: EngineSnapshot) -> String? {