mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-24 23:45:18 +00:00
* 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>
114 lines
4.2 KiB
Swift
114 lines
4.2 KiB
Swift
//
|
|
// GeohashChatActivityTrackerTests.swift
|
|
// bitchatTests
|
|
//
|
|
// This is free and unencumbered software released into the public domain.
|
|
// For more information, see <https://unlicense.org>
|
|
//
|
|
|
|
import Foundation
|
|
import Testing
|
|
@testable import bitchat
|
|
|
|
@MainActor
|
|
struct GeohashChatActivityTrackerTests {
|
|
|
|
private let baseDate = Date(timeIntervalSince1970: 1_700_000_000)
|
|
|
|
private func makeTracker(window: TimeInterval = 900, now: Date? = nil) -> (GeohashChatActivityTracker, (Date) -> Void) {
|
|
var currentNow = now ?? baseDate
|
|
let tracker = GeohashChatActivityTracker(window: window, now: { currentNow })
|
|
return (tracker, { currentNow = $0 })
|
|
}
|
|
|
|
private func channel(_ geohash: String, _ level: GeohashChannelLevel) -> GeohashChannel {
|
|
GeohashChannel(level: level, geohash: geohash)
|
|
}
|
|
|
|
@Test
|
|
func recordsAndCountsMessagesInWindow() {
|
|
let (tracker, _) = makeTracker()
|
|
tracker.recordChatMessage(geohash: "9Q8YY", senderName: "alice#ab12", content: "hi", timestamp: baseDate)
|
|
tracker.recordChatMessage(geohash: "9q8yy", senderName: "bob#cd34", content: "yo", timestamp: baseDate)
|
|
|
|
#expect(tracker.messageCount(for: "9q8yy") == 2)
|
|
#expect(tracker.lastMessage(for: "9q8YY")?.senderName == "bob#cd34")
|
|
}
|
|
|
|
@Test
|
|
func dropsMessagesOlderThanWindow() {
|
|
let (tracker, advance) = makeTracker(window: 900)
|
|
tracker.recordChatMessage(geohash: "9q8yy", senderName: "alice#ab12", content: "hi", timestamp: baseDate)
|
|
|
|
advance(baseDate.addingTimeInterval(901))
|
|
|
|
#expect(tracker.messageCount(for: "9q8yy") == 0)
|
|
#expect(tracker.lastMessage(for: "9q8yy") == nil)
|
|
}
|
|
|
|
@Test
|
|
func ignoresMessagesAlreadyOutsideWindow() {
|
|
let (tracker, _) = makeTracker(window: 900)
|
|
tracker.recordChatMessage(
|
|
geohash: "9q8yy",
|
|
senderName: "alice#ab12",
|
|
content: "old",
|
|
timestamp: baseDate.addingTimeInterval(-1000)
|
|
)
|
|
|
|
#expect(tracker.messageCount(for: "9q8yy") == 0)
|
|
}
|
|
|
|
@Test
|
|
func keepsNewestPreview() {
|
|
let (tracker, _) = makeTracker()
|
|
tracker.recordChatMessage(geohash: "9q8yy", senderName: "a#1111", content: "newer", timestamp: baseDate)
|
|
tracker.recordChatMessage(geohash: "9q8yy", senderName: "b#2222", content: "older", timestamp: baseDate.addingTimeInterval(-60))
|
|
|
|
#expect(tracker.lastMessage(for: "9q8yy")?.content == "newer")
|
|
#expect(tracker.messageCount(for: "9q8yy") == 2)
|
|
}
|
|
|
|
@Test
|
|
func mostActivePicksBusiestChannel() {
|
|
let (tracker, _) = makeTracker()
|
|
tracker.recordChatMessage(geohash: "9q8yy", senderName: "a#1111", content: "one", timestamp: baseDate)
|
|
tracker.recordChatMessage(geohash: "9q8", senderName: "b#2222", content: "two", timestamp: baseDate)
|
|
tracker.recordChatMessage(geohash: "9q8", senderName: "c#3333", content: "three", timestamp: baseDate)
|
|
|
|
let channels = [channel("9q8yy", .city), channel("9q8", .province)]
|
|
let best = tracker.mostActiveConversation(among: channels)
|
|
|
|
#expect(best?.channel.geohash == "9q8")
|
|
#expect(best?.messageCount == 2)
|
|
}
|
|
|
|
@Test
|
|
func mostActiveTieGoesToMoreLocalChannel() {
|
|
let (tracker, _) = makeTracker()
|
|
tracker.recordChatMessage(geohash: "9q8yyzz1", senderName: "a#1111", content: "local", timestamp: baseDate)
|
|
tracker.recordChatMessage(geohash: "9q", senderName: "b#2222", content: "regional", timestamp: baseDate)
|
|
|
|
let channels = [channel("9q", .region), channel("9q8yyzz1", .building)]
|
|
let best = tracker.mostActiveConversation(among: channels)
|
|
|
|
#expect(best?.channel.geohash == "9q8yyzz1")
|
|
}
|
|
|
|
@Test
|
|
func mostActiveIsNilWithoutMessages() {
|
|
let (tracker, _) = makeTracker()
|
|
#expect(tracker.mostActiveConversation(among: [channel("9q8yy", .city)]) == nil)
|
|
}
|
|
|
|
@Test
|
|
func clearRemovesEverything() {
|
|
let (tracker, _) = makeTracker()
|
|
tracker.recordChatMessage(geohash: "9q8yy", senderName: "a#1111", content: "hi", timestamp: baseDate)
|
|
tracker.clear()
|
|
|
|
#expect(tracker.messageCount(for: "9q8yy") == 0)
|
|
#expect(tracker.mostActiveConversation(among: [channel("9q8yy", .city)]) == nil)
|
|
}
|
|
}
|