Empty-mesh liveliness: nearby conversations, echoes, wave, dead drops, radar (#1409)

* Empty-mesh liveliness: nearby conversations, echoes, wave action, dead drops, radar

The empty mesh timeline was a dead end: a grey zero and "nobody in range
yet". This turns it into a live surface and gives the app pull when the
mesh wakes up:

- Nearest conversation: background geohash sampling now tracks actual
  chat messages (not just presence) per regional channel; the empty state
  surfaces the busiest nearby conversation with a preview, one tap to
  join (GeohashChatActivityTracker, fed from GeoPresenceTracker).
- Echoes: the carried 6h store-and-forward window renders as dimmed
  "heard here earlier" rows at launch (new Transport
  collectArchivedPublicMessages -> GossipSyncManager snapshot, decoded
  with signature-derived nicknames; content-identity dedup guards
  against re-synced duplicates).
- Wave: the "bitchatters nearby" notification gains a "wave" quick
  action that broadcasts a mesh 👋 straight from the notification, even
  backgrounded (first UNNotificationCategory in the app).
- Dead drops: /drop pins a note to the current building geohash as a
  kind-1 location note with a 24h NIP-40 expiry; expired notes are now
  dropped client-side at ingest; the notices sheet shows "fades in Xh";
  a "location notes" toggle plus location-permission controls live in
  app info (also fixes the duplicated Voice section).
- Radar: an ambient sonar animation shows the radio scanning, with a
  privacy-safe daily tally ("N devices passed within range today" via
  salted per-day hashes) and a "notes left here" hint that opens the
  notices geo tab.

All new user-facing strings ship in all 29 locales. 1403 tests green,
including new suites for the activity tracker, sightings tally, and
note expiry/drop publishing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Review round: app-info polish, urgent/expiry parity, centered radar, pin fill, Codex P2s

- App info: LOCATION header uppercased like sibling sections; location
  notes and live voice descriptions shortened (29 locales); redundant
  "location access granted" line removed.
- Notices parity: urgent + expiry controls now show on the geo tab too;
  the bridged Nostr note carries ["t","urgent"] and NIP-40 so relay-side
  readers see both; urgent parsed back from incoming notes.
- Radar moved from the top of the empty state to the center of the chat
  area, below the help text (empty state fills the visible height).
- Header pin fills whenever the scope has notices (was: only unseen),
  and Nostr-only nearby notes now light it too.
- Codex P2 fixes: notification completion deferred until the wave action
  is handled (background suspension dropped the send); NIP-40 notes now
  prune on a timer when they expire while displayed; the location-notes
  kill switch retargets the nearby-notes counter immediately.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Hide macOS segmented picker's built-in label in notices composer (duplicate 'expires in')

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Geo notes: permanent (∞) expiry default, urgent stays mesh-only

- Geo expiry picker gains ∞ as the default: a permanent note posts as a
  pure relay note (no NIP-40 tag, no mesh-board copy — a board copy must
  fade within days, contradicting the ∞ the user picked). 1/3/7d keep
  the board + bridged-note path with NIP-40.
- The notes manager is now owned by the notices sheet (not the list) so
  the composer local-echoes ∞ notes into the list; it revives via
  refresh() after a tab-switch cancel, and its expiry-prune timer
  survives cancel (weak self, dies with the instance).
- Urgent toggle returns to mesh-only per review — notes are ambient;
  the read-side urgent-tag parse stays so tagged notes still render.
- macOS: hide the segmented picker's built-in label (duplicate
  "expires in").

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Clearing the mesh timeline dismisses echoes for good; tighter divider copy

Triple-tap /clear emptied the timeline but the next launch re-seeded
"heard here earlier" from the persisted archive. A MeshEchoSettings
watermark now records the clear; only messages heard after it come back
(the archive itself still carries everything for peers' sync). The
echo dedup keys reset with it, and panic wipe drops the watermark.

Divider copy tightened to "heard here earlier · last 6h" (29 locales).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Echoes visual polish: tinted history block, radar-captioned tally, ambient footer

Device-test feedback on the echoes screen:
- Archived echoes now sit on a subtle tinted background (secondary at
  8%) in addition to the dim, so "heard here earlier" reads as one
  distinct block; the divider carries the echo ID prefix to join it.
- "N devices passed within range today" moves out of the narration
  lines to sit centered under the radar as its caption.
- When the timeline holds only echoes/system lines, a compact ambient
  footer (small radar + tally + live hints) renders below the history
  instead of the whole ambient layer vanishing.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Notes strip persists above the mesh chat; leaner empty-state narration

- The 📍 "notes left here" line was empty-state-only, so starting a
  conversation hid it. It is now a tappable strip pinned above the mesh
  timeline whenever unexpired notes exist at this place (opens the
  notices geo tab); the nearby-notes counter runs for the whole mesh
  timeline, not just the empty state.
- Empty state narration drops "nobody in range yet..." (the radar and
  the sightings caption already say it) and the nearby-conversation
  hint moves below the help line instead of splitting the narration.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

* Radar means searching: hide the sweep once mesh peers are connected or reachable

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>

---------

Co-authored-by: jack <jackjackbits@users.noreply.github.com>
Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
jack
2026-07-08 13:24:44 +02:00
committed by GitHub
co-authored by jack Claude Fable 5
parent ef848857b7
commit 74b8a47d02
37 changed files with 4633 additions and 100 deletions
+118 -31
View File
@@ -31,10 +31,18 @@ struct NoticesView: View {
@State private var tab: Tab
@State private var draft: String = ""
@State private var urgent = false
@State private var expiryDays = 7
/// Days until the notice fades; `permanentExpiry` (geo default) means no
/// NIP-40 tag the note stays until its relay drops it.
@State private var expiryDays: Int
/// Sentinel picker tag for the option (geo tab only).
private static let permanentExpiry = 0
/// Injected notes manager for tests; live use derives one per geohash.
private let notesManager: LocationNotesManager?
/// Live manager owned by the sheet so the composer can post pure Nostr
/// notes ( expiry has no mesh-board copy) and the list can render them.
@State private var liveGeoManager: LocationNotesManager?
init(
senderNickname: String,
@@ -46,6 +54,27 @@ struct NoticesView: View {
self.board = board
self.notesManager = notesManager
_tab = State(initialValue: initialTab)
_expiryDays = State(initialValue: initialTab == .geo ? Self.permanentExpiry : 7)
}
private var activeNotesManager: LocationNotesManager? {
notesManager ?? liveGeoManager
}
/// Creates (or retargets/revives) the sheet-owned notes manager for the
/// current geo scope.
private func ensureGeoNotesManager() {
guard notesManager == nil, tab == .geo, let geohash = geoGeohash else { return }
if let manager = liveGeoManager {
if manager.geohash != geohash.lowercased() {
manager.setGeohash(geohash)
} else if manager.state == .idle {
// Cancelled on a tab switch; returning re-subscribes.
manager.refresh()
}
} else {
liveGeoManager = LocationNotesManager(geohash: geohash)
}
}
private var maxDraftLines: Int { dynamicTypeSize.isAccessibilitySize ? 5 : 3 }
@@ -90,6 +119,7 @@ struct NoticesView: View {
static let send = String(localized: "board.accessibility.post", defaultValue: "Post notice", comment: "Accessibility label for the board post button")
static let deleteAction = String(localized: "board.action.delete", defaultValue: "delete", comment: "Delete action for own board posts")
static let expiryLabel = String(localized: "board.compose.expiry", defaultValue: "expires in", comment: "Label for the board post expiry picker")
static let permanentOption = String(localized: "notices.expiry.permanent", defaultValue: "permanent", comment: "Accessibility label for the ∞ (never expires) option in the geo notes expiry picker")
static let closeHint = String(localized: "notices.accessibility.close", defaultValue: "Close notices", comment: "Accessibility label for the notices close button")
static let meshSource = String(localized: "notices.source.mesh", defaultValue: "mesh", comment: "Source badge for notices carried by the mesh")
static let nostrSource = String(localized: "notices.source.nostr", defaultValue: "net", comment: "Source badge for notices seen on internet relays")
@@ -109,6 +139,16 @@ struct NoticesView: View {
)
}
static func fades(_ expiresAt: Date) -> String {
let formatter = RelativeDateTimeFormatter()
formatter.unitsStyle = .abbreviated
return String(
format: String(localized: "notices.fades", defaultValue: "fades %@", comment: "Shown on notices with an expiry; placeholder is a localized relative time like 'in 23h'"),
locale: .current,
formatter.localizedString(for: expiresAt, relativeTo: Date())
)
}
static func rowAccessibilityLabel(author: String, content: String, urgent: Bool) -> String {
let base = String(
format: String(localized: "board.accessibility.post_row", defaultValue: "Notice from %@: %@", comment: "Accessibility label for a board post row"),
@@ -132,18 +172,29 @@ struct NoticesView: View {
.frame(minWidth: 420, idealWidth: 440, minHeight: 620, idealHeight: 680)
#endif
.themedSheetBackground()
.onAppear { beginGeoLocationIfNeeded() }
.onAppear {
beginGeoLocationIfNeeded()
ensureGeoNotesManager()
}
.onChange(of: tab) { newTab in
if newTab == .geo {
beginGeoLocationIfNeeded()
ensureGeoNotesManager()
} else {
locationChannelsModel.endLiveRefresh()
}
// Each tab keeps its natural default: geo notes stay until
// deleted (), mesh board posts fade within a week.
expiryDays = newTab == .geo ? Self.permanentExpiry : 7
urgent = false
}
// Catches permission granted from the geo tab's enable button.
.onChange(of: locationChannelsModel.permissionState) { _ in
beginGeoLocationIfNeeded()
}
.onChange(of: geoGeohash) { _ in
ensureGeoNotesManager()
}
.onDisappear { locationChannelsModel.endLiveRefresh() }
}
@@ -207,7 +258,14 @@ struct NoticesView: View {
)
case .geo:
if let geohash = geoGeohash {
GeoNoticesList(geohash: geohash, board: board, manager: notesManager)
if let manager = activeNotesManager {
GeoNoticesList(geohash: geohash, board: board, manager: manager)
} else {
// Manager is created on appear; visible for one frame.
Color.clear
.frame(maxWidth: .infinity, maxHeight: .infinity)
.onAppear { ensureGeoNotesManager() }
}
} else {
locationUnavailableSection
}
@@ -252,11 +310,10 @@ struct NoticesView: View {
.disabled(!sendEnabled)
.accessibilityLabel(Strings.send)
}
// Urgency and expiry only travel with the mesh copy the bridged
// Nostr note carries neither, so relay-side readers would never
// see them. Offer the controls only where they fully apply.
if tab == .mesh {
HStack(spacing: 12) {
// Both tabs pick an expiry (geo notes may be ); urgency is a
// mesh-board concept notes are ambient by nature.
HStack(spacing: 12) {
if tab == .mesh {
Toggle(isOn: $urgent) {
Text(Strings.urgentToggle)
.bitchatFont(size: 12)
@@ -265,19 +322,30 @@ struct NoticesView: View {
.toggleStyle(.switch)
.fixedSize()
.accessibilityLabel(Strings.urgentToggle)
Spacer()
Text(Strings.expiryLabel)
.bitchatFont(size: 12)
.foregroundColor(palette.secondary)
Picker(Strings.expiryLabel, selection: $expiryDays) {
ForEach([1, 3, 7], id: \.self) { days in
Text(Strings.expiryDaysOption(days)).tag(days)
}
}
.pickerStyle(.segmented)
.fixedSize()
.accessibilityLabel(Strings.expiryLabel)
}
Spacer()
Text(Strings.expiryLabel)
.bitchatFont(size: 12)
.foregroundColor(palette.secondary)
Picker(Strings.expiryLabel, selection: $expiryDays) {
// Mesh board posts must fade (the wire caps their
// lifetime); only relay-backed geo notes can be .
if tab == .geo {
Text(verbatim: "")
.accessibilityLabel(Strings.permanentOption)
.tag(Self.permanentExpiry)
}
ForEach([1, 3, 7], id: \.self) { days in
Text(Strings.expiryDaysOption(days)).tag(days)
}
}
.pickerStyle(.segmented)
// macOS segmented pickers render their own label; the themed
// Text alongside already carries it (and accessibility keeps
// the explicit label below).
.labelsHidden()
.fixedSize()
.accessibilityLabel(Strings.expiryLabel)
}
}
.padding(.horizontal, 16)
@@ -293,14 +361,27 @@ struct NoticesView: View {
private func send() {
guard let geohash = activeGeohash, let content = draft.trimmedOrNilIfEmpty else { return }
// Geo posts go to the board and are bridged to Nostr by BoardManager,
// so mesh and internet see the same notice. They always use the
// defaults: non-urgent, 7-day expiry (NIP-40 on the bridged copy).
// (geo default): a pure relay note with no NIP-40 tag. It skips
// the mesh board deliberately a board copy must fade within days,
// which would contradict the permanence the user just picked.
if tab == .geo, expiryDays == Self.permanentExpiry {
guard let manager = activeNotesManager else { return }
manager.send(content: content, nickname: senderNickname, expiresAt: nil)
draft = ""
urgent = false
return
}
// Expiring posts go to the board and are bridged to Nostr by
// BoardManager, so mesh and internet see the same notice with the
// chosen expiry (expiresAt on mesh, NIP-40 on the bridged note).
// Urgency is mesh-only.
let sent = board.createPost(
content: content,
geohash: geohash,
urgent: tab == .mesh && urgent,
expiryDays: tab == .mesh ? expiryDays : 7,
expiryDays: expiryDays,
nickname: senderNickname
)
if sent {
@@ -310,18 +391,19 @@ struct NoticesView: View {
}
}
/// The geo tab's list: owns the Nostr notes subscription for the scope
/// geohash and merges it with the board posts for the same geohash.
/// The geo tab's list: renders the sheet-owned Nostr notes subscription
/// merged with the board posts for the same geohash. The manager lives on
/// `NoticesView` so the composer can post through the same instance (
/// notes local-echo into this list).
private struct GeoNoticesList: View {
let geohash: String
@ObservedObject var board: BoardManager
@StateObject private var notesManager: LocationNotesManager
@ObservedObject var notesManager: LocationNotesManager
init(geohash: String, board: BoardManager, manager: LocationNotesManager? = nil) {
let gh = geohash.lowercased()
self.geohash = gh
init(geohash: String, board: BoardManager, manager: LocationNotesManager) {
self.geohash = geohash.lowercased()
self.board = board
_notesManager = StateObject(wrappedValue: manager ?? LocationNotesManager(geohash: gh))
self.notesManager = manager
}
var body: some View {
@@ -475,6 +557,11 @@ private struct NoticesList: View {
Text(Self.timestampText(for: item.createdAt))
.bitchatFont(size: 11)
.foregroundColor(palette.secondary)
if let expiresAt = item.expiresAt, expiresAt > Date() {
Text(Strings.fades(expiresAt))
.bitchatFont(size: 11)
.foregroundColor(palette.secondary.opacity(0.8))
}
Spacer()
if showsSource {
sourceBadge(item)