mirror of
https://github.com/permissionlesstech/bitchat.git
synced 2026-07-24 22:45:19 +00:00
* Live push-to-talk voice for DMs: stream while you talk, voice note as fallback Holding the mic in a DM now streams AAC frames live over the Noise session (walkie-talkie style, ~0.5s mouth-to-ear at one hop) while recording the same audio as a normal voice note. On release the note ships through the existing fileTransfer pipeline; receivers that heard the live stream absorb it silently into the same bubble (matched by the burst ID embedded in the file name), so reliability comes for free and nobody sees duplicates. Protocol: - NoisePayloadType.voiceFrame = 0x08 carrying VoiceBurstPacket (burstID + seq + START/data/END/CANCELED, length-prefixed AAC frames) - 210-byte burst-content budget keeps each Noise packet inside the 256-byte padding bucket: one BLE frame, never the fragment scheduler - fire-and-forget: frames are dropped (never queued) without an established session; live is only offered when the peer is mesh-reachable Receive: - ChatLiveVoiceCoordinator assembles bursts (jitter-ordered, 0.5s gap skip, 3s idle end, flood/size caps), persists progressively as ADTS .aac so even a partial burst is a replayable bubble - live autoplay only when the conversation is on screen, app active, and the new app-info "live voice messages" toggle is on (also gates live sending) - one-playback-at-a-time via a shared ExclusivePlayback slot Capture: - PTTCaptureEngine taps AVAudioEngine, dual-encodes: live AAC frames + the finalized .m4a (same 16kHz/mono/16kbps settings as VoiceRecorder) - VoiceRecordingViewModel now drives a pluggable VoiceCaptureSession; the composer HUD shows a pulsing LIVE treatment when streaming Includes the push-to-talk design doc, 6 new localization keys across all 29 locales, and unit tests for framing, packetizer budget, ADTS output, codec round-trip, and the assembly/absorb lifecycle. Public-mesh PTT (MessageType 0x29) lands separately on top of this. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Public-mesh push-to-talk: signed live voice bursts in the mesh channel Extends live PTT from DMs to the public mesh timeline. Holding the mic in the mesh channel now broadcasts the burst live as signed voiceFrame packets (MessageType 0x29) while the finalized voice note still ships on release — new clients hear you as you speak and absorb the note silently into the live bubble; old clients (and late joiners) keep receiving the note exactly as before, so mixed-version meshes lose nothing. Wire/relay: - MessageType.voiceFrame = 0x29: ephemeral signed broadcast, never gossip-synced (SyncTypeFlags maps it to no bit), never padded (padding to the 512 block would push every ~490-byte signed packet into fragmentation) - RelayController treats voiceFrame like media fragments: dense-graph TTL clamp contains the sustained ~15 pkt/s per-talker stream, tight 8-25 ms jitter keeps multi-hop latency inside the receiver's 350 ms jitter buffer - inbound gate mirrors public messages: broadcast-only, 30 s freshness cap, packet signature verified against the claimed sender's announce before any audio reaches the UI App: - ChatLiveVoiceCoordinator gains burst scopes: public bubbles land in the mesh timeline, autoplay only while that timeline is on screen, and the finalized-note absorb is scope-bound (a public note can't replace a DM burst or vice versa) - floor courtesy: while someone talks live in the public channel the composer mic tints red and pulses, with an accessibility value naming the talker ("%@ is speaking", localized in all 29 locales); holding still works — a decentralized mesh has no floor arbiter, the tint just discourages talk-over Tests: relay policy (sparse cap + dense clamp), public bubble + talker indicator lifecycle, note absorption into the mesh store, and scope-binding rejection; full suite green (1382 tests). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * PTT follow-ups from review + field test: peer-ID normalization, toggle gates inbound, drop-path diagnostics Codex review fixes (#1403): - makeVoiceCaptureSession normalizes the selected peer with toShort() before the reachability/session checks and binds the send target to that same routing ID — a conversation selected under the stable 64-hex Noise key no longer silently falls back to a classic note while the short-ID session is established - the live-voice toggle now gates inbound bursts too: off means classic-notes-only in both directions (no live bubble, partial file, or early notification; the finalized note still arrives), with a test Field-test diagnostics (first device run: DM frames decrypted but no bubble appeared, with no log evidence of which guard dropped them): - coordinator logs undecodable frames (size + hex prefix) and blocked drops - makeAssembly logs directory/file-handle failures instead of returning nil silently - PTTLiveVoiceSession logs capture start and finish (packet/frame/duration counts); PTTCaptureEngine logs engine start success/failure with the input format; BLEService.sendVoiceFrame logs no-session drops Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Fix iPhone live-capture failure: dead input unit (AURemoteIO -10851, 0 Hz) Field testing showed the phone's live capture failing at mic enable with AURemoteIO -10851 and an input format of 0 Hz / 2 ch — an input unit bound to an earlier (playback-only or settling) audio session. The Mac, which has no session lifecycle, captured fine, which is why public bursts from the Mac worked while phone-side sends degraded from working (first hold) to sporadic to dead across holds. Three layers of defense: - PTTCaptureEngine recreates its AVAudioEngine on every start(), after the session is configured, so the input unit binds to the session that is active now; a dead input (0 Hz or 0 channels) is now a distinct, logged error instead of a silent setup failure - PTTLiveVoiceSession retries the capture start once after a 150 ms route-settle pause - VoiceRecordingViewModel falls back to the classic VoiceRecorder within the same hold if the live engine still cannot start — a route glitch now costs the live stream, never the voice note Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Blue mic when the hold will stream live The mic button now shows readiness at a glance — and doubles as a build marker for device testing: - blue: holding will stream live (DM peer reachable with an established Noise session, or the public mesh channel) - accent (orange in DMs): holding records a classic voice note (no session yet, peer unreachable, or live voice toggled off) - red states unchanged (recording, floor busy) Refactors capture-backend selection into a single liveVoiceTarget() so the indicator and makeVoiceCaptureSession can never disagree. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Revert the blue live-ready mic to the normal accent color The build-verification marker did its job; idle mic color goes back to the accent. The LIVE recording HUD remains the signal for whether a hold is streaming. Keeps the liveVoiceTarget() refactor so backend selection stays in one place. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Leave a trace on every mic press and every inbound-frame drop Field testing read "tap does nothing" as breakage: the mic start is async (permission check + engine spin-up), so releasing before recording begins has always been a silent cancel — for classic voice notes too. Every press now logs which backend it chose and, for quick presses, that it released before recording started. Also logs the two remaining silent drops: inbound voice frames rejected by the live-voice toggle (the one unlogged guard left in the receive path) and the classic-note fallback now includes the toggle state. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Fix mic hold dying instantly in DMs: sheet swipe gesture starved the composer Field logs showed every DM mic hold ending 3-10 ms after it began, on both platforms, while public-channel holds worked — the private sheet wraps its entire content (composer included) in a high-priority swipe-right-to-leave DragGesture, and a high-priority ancestor drag cancels the mic button's press-and-hold within milliseconds. Same starvation mechanism as the DM image-reveal bug (#1402), hitting a drag instead of a tap. The swipe-to-leave gesture now lives on the message list only, so the composer's gestures (mic hold, text field, buttons) are out of its reach and the swipe still works where users actually swipe. Also stops touching the capture engine when a hold cancels before the engine ever started: probing inputNode on a never-started engine instantiates its input unit against whatever session is active and spams benign-but-alarming AURemoteIO -10851 errors into field logs. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * Reorder app info sheet: usage first, then settings, then reference New section order: HOW TO USE, then the adjustable bits (appearance, voice, network), then the reference material (features, privacy, symbols legend). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> * App info: flow HOW TO USE into one paragraph; "list" and "person" wording The six how-to-use bullets now read as a single comma-separated paragraph (same instruction strings, legacy bullet prefix stripped at render). Two wording updates across all 29 locales: the people icon opens the "list" (not "sidebar"), and you tap a "person's" name (not a "peer's") to start a DM. 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>
413 lines
15 KiB
Swift
413 lines
15 KiB
Swift
import SwiftUI
|
|
|
|
struct AppInfoView: View {
|
|
@Environment(\.dismiss) var dismiss
|
|
@ThemedPalette private var palette
|
|
@AppStorage(AppTheme.storageKey) private var appThemeRawValue = AppTheme.matrix.rawValue
|
|
|
|
/// Supplies the mesh topology map data. Nil (previews, missing wiring)
|
|
/// hides the topology row entirely.
|
|
var topologyProvider: (@MainActor () -> MeshTopologyDisplayModel)?
|
|
@State private var showTopology = false
|
|
@State private var liveVoiceEnabled = PTTSettings.liveVoiceEnabled
|
|
|
|
private var selectedTheme: AppTheme {
|
|
AppTheme(rawValue: appThemeRawValue) ?? .matrix
|
|
}
|
|
|
|
private var backgroundColor: Color { palette.background }
|
|
|
|
private var textColor: Color { palette.primary }
|
|
|
|
private var secondaryTextColor: Color { palette.secondary }
|
|
|
|
// MARK: - Constants
|
|
private enum Strings {
|
|
static let appName: LocalizedStringKey = "app_info.app_name"
|
|
static let tagline: LocalizedStringKey = "app_info.tagline"
|
|
static let appearanceTitle: LocalizedStringKey = "app_info.appearance.title"
|
|
|
|
enum Features {
|
|
static let title: LocalizedStringKey = "app_info.features.title"
|
|
static let offlineComm = AppInfoFeatureInfo(
|
|
icon: "wifi.slash",
|
|
title: "app_info.features.offline.title",
|
|
description: "app_info.features.offline.description"
|
|
)
|
|
static let encryption = AppInfoFeatureInfo(
|
|
icon: "lock.shield",
|
|
title: "app_info.features.encryption.title",
|
|
description: "app_info.features.encryption.description"
|
|
)
|
|
static let extendedRange = AppInfoFeatureInfo(
|
|
icon: "antenna.radiowaves.left.and.right",
|
|
title: "app_info.features.extended_range.title",
|
|
description: "app_info.features.extended_range.description"
|
|
)
|
|
static let mentions = AppInfoFeatureInfo(
|
|
icon: "at",
|
|
title: "app_info.features.mentions.title",
|
|
description: "app_info.features.mentions.description"
|
|
)
|
|
static let favorites = AppInfoFeatureInfo(
|
|
icon: "star.fill",
|
|
title: "app_info.features.favorites.title",
|
|
description: "app_info.features.favorites.description"
|
|
)
|
|
static let geohash = AppInfoFeatureInfo(
|
|
icon: "number",
|
|
title: "app_info.features.geohash.title",
|
|
description: "app_info.features.geohash.description"
|
|
)
|
|
}
|
|
|
|
enum Legend {
|
|
static let title: LocalizedStringKey = "app_info.legend.title"
|
|
/// Every glyph the peer lists and headers use, in one place —
|
|
/// nothing else in the app defines them.
|
|
static let items: [(icon: String, text: LocalizedStringKey)] = [
|
|
("antenna.radiowaves.left.and.right", "app_info.legend.mesh_connected"),
|
|
("point.3.filled.connected.trianglepath.dotted", "app_info.legend.mesh_relayed"),
|
|
("globe", "app_info.legend.nostr"),
|
|
("person", "app_info.legend.offline"),
|
|
("mappin.and.ellipse", "app_info.legend.location_nearby"),
|
|
("face.dashed", "app_info.legend.teleported"),
|
|
("lock.fill", "app_info.legend.encrypted"),
|
|
("lock.slash", "app_info.legend.encryption_failed"),
|
|
("checkmark.seal.fill", "app_info.legend.verified"),
|
|
("star.fill", "app_info.legend.favorite"),
|
|
("envelope.fill", "app_info.legend.unread"),
|
|
("nosign", "app_info.legend.blocked")
|
|
]
|
|
}
|
|
|
|
enum Voice {
|
|
static let title: LocalizedStringKey = "app_info.voice.title"
|
|
static let live = AppInfoFeatureInfo(
|
|
icon: "dot.radiowaves.left.and.right",
|
|
title: "app_info.voice.live.title",
|
|
description: "app_info.voice.live.description"
|
|
)
|
|
}
|
|
|
|
enum Network {
|
|
static let title: LocalizedStringKey = "app_info.network.title"
|
|
static let topology = AppInfoFeatureInfo(
|
|
icon: "point.3.connected.trianglepath.dotted",
|
|
title: "app_info.network.topology.title",
|
|
description: "app_info.network.topology.description"
|
|
)
|
|
}
|
|
|
|
enum Privacy {
|
|
static let title: LocalizedStringKey = "app_info.privacy.title"
|
|
static let noTracking = AppInfoFeatureInfo(
|
|
icon: "eye.slash",
|
|
title: "app_info.privacy.no_tracking.title",
|
|
description: "app_info.privacy.no_tracking.description"
|
|
)
|
|
static let ephemeral = AppInfoFeatureInfo(
|
|
icon: "shuffle",
|
|
title: "app_info.privacy.ephemeral.title",
|
|
description: "app_info.privacy.ephemeral.description"
|
|
)
|
|
static let panic = AppInfoFeatureInfo(
|
|
icon: "hand.raised.fill",
|
|
title: "app_info.privacy.panic.title",
|
|
description: "app_info.privacy.panic.description"
|
|
)
|
|
}
|
|
|
|
enum HowToUse {
|
|
static let title: LocalizedStringKey = "app_info.how_to_use.title"
|
|
/// The instruction strings flowed into one comma-separated
|
|
/// paragraph. The translations carry their legacy bullet-list
|
|
/// prefix ("• "), so it is stripped here.
|
|
static var paragraph: String {
|
|
[
|
|
String(localized: "app_info.how_to_use.set_nickname"),
|
|
String(localized: "app_info.how_to_use.change_channels"),
|
|
String(localized: "app_info.how_to_use.open_sidebar"),
|
|
String(localized: "app_info.how_to_use.start_dm"),
|
|
String(localized: "app_info.how_to_use.clear_chat"),
|
|
String(localized: "app_info.how_to_use.commands")
|
|
]
|
|
.map { $0.hasPrefix("• ") ? String($0.dropFirst(2)) : $0 }
|
|
.joined(separator: ", ")
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
var body: some View {
|
|
#if os(macOS)
|
|
VStack(spacing: 0) {
|
|
// Custom header for macOS
|
|
HStack {
|
|
Spacer()
|
|
Button("app_info.done") {
|
|
dismiss()
|
|
}
|
|
.buttonStyle(.plain)
|
|
.foregroundColor(textColor)
|
|
.padding()
|
|
}
|
|
.themedSurface(opacity: 0.95)
|
|
|
|
ScrollView {
|
|
infoContent
|
|
}
|
|
.themedSheetBackground()
|
|
}
|
|
.frame(width: 600, height: 700)
|
|
.sheet(isPresented: $showTopology) {
|
|
if let topologyProvider {
|
|
MeshTopologyView(provider: topologyProvider)
|
|
}
|
|
}
|
|
#else
|
|
NavigationView {
|
|
ScrollView {
|
|
infoContent
|
|
}
|
|
.themedSheetBackground()
|
|
.navigationBarTitleDisplayMode(.inline)
|
|
.toolbar {
|
|
ToolbarItem(placement: .navigationBarTrailing) {
|
|
SheetCloseButton { dismiss() }
|
|
.foregroundColor(textColor)
|
|
}
|
|
}
|
|
}
|
|
.sheet(isPresented: $showTopology) {
|
|
if let topologyProvider {
|
|
MeshTopologyView(provider: topologyProvider)
|
|
}
|
|
}
|
|
#endif
|
|
}
|
|
|
|
@ViewBuilder
|
|
private var infoContent: some View {
|
|
VStack(alignment: .leading, spacing: 24) {
|
|
// Header
|
|
VStack(alignment: .center, spacing: 8) {
|
|
Text(Strings.appName)
|
|
.bitchatFont(size: 32, weight: .bold)
|
|
.foregroundColor(textColor)
|
|
|
|
Text(Strings.tagline)
|
|
.bitchatFont(size: 16)
|
|
.foregroundColor(secondaryTextColor)
|
|
}
|
|
.frame(maxWidth: .infinity)
|
|
.padding(.vertical)
|
|
|
|
// How to Use
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
SectionHeader(Strings.HowToUse.title)
|
|
|
|
Text(verbatim: Strings.HowToUse.paragraph)
|
|
.bitchatFont(size: 14)
|
|
.foregroundColor(textColor)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
}
|
|
|
|
// Appearance — single row: label left, theme chips right
|
|
HStack(spacing: 12) {
|
|
SectionHeader(Strings.appearanceTitle)
|
|
Spacer()
|
|
ForEach(AppTheme.allCases) { theme in
|
|
Button {
|
|
appThemeRawValue = theme.rawValue
|
|
} label: {
|
|
Text(theme.displayNameKey)
|
|
.bitchatFont(size: 13, weight: selectedTheme == theme ? .semibold : .regular)
|
|
.foregroundColor(selectedTheme == theme ? palette.accent : secondaryTextColor)
|
|
.padding(.horizontal, 10)
|
|
.padding(.vertical, 6)
|
|
.background(
|
|
RoundedRectangle(cornerRadius: 8, style: .continuous)
|
|
.fill(selectedTheme == theme ? palette.accent.opacity(0.15) : Color.clear)
|
|
)
|
|
.contentShape(Rectangle())
|
|
}
|
|
.buttonStyle(.plain)
|
|
.accessibilityAddTraits(selectedTheme == theme ? .isSelected : [])
|
|
}
|
|
}
|
|
|
|
// Voice
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
SectionHeader(Strings.Voice.title)
|
|
|
|
HStack(spacing: 0) {
|
|
FeatureRow(info: Strings.Voice.live)
|
|
Toggle(Strings.Voice.live.title, isOn: $liveVoiceEnabled)
|
|
.labelsHidden()
|
|
.tint(palette.accent)
|
|
.onChange(of: liveVoiceEnabled) { newValue in
|
|
PTTSettings.liveVoiceEnabled = newValue
|
|
}
|
|
}
|
|
}
|
|
|
|
// Voice
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
SectionHeader(Strings.Voice.title)
|
|
|
|
HStack(spacing: 0) {
|
|
FeatureRow(info: Strings.Voice.live)
|
|
Toggle(Strings.Voice.live.title, isOn: $liveVoiceEnabled)
|
|
.labelsHidden()
|
|
.tint(palette.accent)
|
|
.onChange(of: liveVoiceEnabled) { newValue in
|
|
PTTSettings.liveVoiceEnabled = newValue
|
|
}
|
|
}
|
|
}
|
|
|
|
// Network diagnostics
|
|
if topologyProvider != nil {
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
SectionHeader(Strings.Network.title)
|
|
|
|
Button {
|
|
showTopology = true
|
|
} label: {
|
|
HStack(spacing: 0) {
|
|
FeatureRow(info: Strings.Network.topology)
|
|
Image(systemName: "chevron.right")
|
|
.font(.bitchatSystem(size: 12))
|
|
.foregroundColor(secondaryTextColor)
|
|
}
|
|
.contentShape(Rectangle())
|
|
}
|
|
.buttonStyle(.plain)
|
|
.accessibilityHint(Text("app_info.network.topology.hint"))
|
|
}
|
|
}
|
|
|
|
// Features
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
SectionHeader(Strings.Features.title)
|
|
|
|
FeatureRow(info: Strings.Features.offlineComm)
|
|
|
|
FeatureRow(info: Strings.Features.encryption)
|
|
|
|
FeatureRow(info: Strings.Features.extendedRange)
|
|
|
|
FeatureRow(info: Strings.Features.favorites)
|
|
|
|
FeatureRow(info: Strings.Features.geohash)
|
|
|
|
FeatureRow(info: Strings.Features.mentions)
|
|
}
|
|
|
|
// Privacy
|
|
VStack(alignment: .leading, spacing: 16) {
|
|
SectionHeader(Strings.Privacy.title)
|
|
|
|
FeatureRow(info: Strings.Privacy.noTracking)
|
|
|
|
FeatureRow(info: Strings.Privacy.ephemeral)
|
|
|
|
FeatureRow(info: Strings.Privacy.panic)
|
|
}
|
|
|
|
// Symbols legend
|
|
VStack(alignment: .leading, spacing: 10) {
|
|
SectionHeader(Strings.Legend.title)
|
|
|
|
ForEach(Strings.Legend.items, id: \.icon) { item in
|
|
HStack(alignment: .top, spacing: 12) {
|
|
Image(systemName: item.icon)
|
|
.font(.bitchatSystem(size: 14))
|
|
.foregroundColor(textColor)
|
|
.frame(width: 30)
|
|
|
|
Text(item.text)
|
|
.bitchatFont(size: 13)
|
|
.foregroundColor(secondaryTextColor)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
|
|
Spacer()
|
|
}
|
|
.accessibilityElement(children: .combine)
|
|
}
|
|
}
|
|
}
|
|
.padding()
|
|
}
|
|
}
|
|
|
|
struct AppInfoFeatureInfo {
|
|
let icon: String
|
|
let title: LocalizedStringKey
|
|
let description: LocalizedStringKey
|
|
}
|
|
|
|
struct SectionHeader: View {
|
|
let title: LocalizedStringKey
|
|
@ThemedPalette private var palette
|
|
|
|
private var textColor: Color { palette.primary }
|
|
|
|
init(_ title: LocalizedStringKey) {
|
|
self.title = title
|
|
}
|
|
|
|
var body: some View {
|
|
Text(title)
|
|
.bitchatFont(size: 16, weight: .bold)
|
|
.foregroundColor(textColor)
|
|
.padding(.top, 8)
|
|
}
|
|
}
|
|
|
|
struct FeatureRow: View {
|
|
let info: AppInfoFeatureInfo
|
|
@ThemedPalette private var palette
|
|
|
|
private var textColor: Color { palette.primary }
|
|
|
|
private var secondaryTextColor: Color { palette.secondary }
|
|
|
|
var body: some View {
|
|
HStack(alignment: .top, spacing: 12) {
|
|
Image(systemName: info.icon)
|
|
.font(.bitchatSystem(size: 20))
|
|
.foregroundColor(textColor)
|
|
.frame(width: 30)
|
|
|
|
VStack(alignment: .leading, spacing: 4) {
|
|
Text(info.title)
|
|
.bitchatFont(size: 14, weight: .semibold)
|
|
.foregroundColor(textColor)
|
|
|
|
Text(info.description)
|
|
.bitchatFont(size: 12)
|
|
.foregroundColor(secondaryTextColor)
|
|
.fixedSize(horizontal: false, vertical: true)
|
|
}
|
|
|
|
Spacer()
|
|
}
|
|
}
|
|
}
|
|
|
|
#Preview("Default") {
|
|
AppInfoView()
|
|
}
|
|
|
|
#Preview("Dynamic Type XXL") {
|
|
AppInfoView()
|
|
.environment(\.sizeCategory, .accessibilityExtraExtraExtraLarge)
|
|
}
|
|
|
|
#Preview("Dynamic Type XS") {
|
|
AppInfoView()
|
|
.environment(\.sizeCategory, .extraSmall)
|
|
}
|