chore: comment cleanup pass ahead of open-sourcing
Removes leftover debug scaffolding (stray Console.WriteLine/NSLog traces, dead nick_buf_ptr, a no-op --print-config flag now implemented for real), fixes stale/misleading comments (channel passwords are no longer a "future M5+" feature, a wrong cross-reference, a stale TlsContext::close() mention, an incomplete BanRecord::subject_type doc, and a smoke test pointing at a build/m1-dev preset that no longer exists), strips internal M1-M5 milestone jargon from comments now that the roadmap is done, trims comments that just restated the following line, and consolidates a few "why" explanations that were duplicated 2-3 times in the same file. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -116,16 +116,6 @@ final class AppState {
|
||||
ServerListStore.shared.save(servers)
|
||||
}
|
||||
|
||||
// MARK: - Teardown
|
||||
|
||||
/// `AppState` is the @Observable app root owned by the SwiftUI `App`; it lives for the
|
||||
/// whole app process and is torn down only on process exit, at which point OS cleanup
|
||||
/// suffices. Reconnect state (the in-flight `Task` and the `NWPathMonitor`) is cancelled
|
||||
/// via `cancelReconnect()` driven by `disconnect()`/`cancelConnect()` and on successful
|
||||
/// restore — those run on user-initiated teardown, which is the only path that matters.
|
||||
/// (The `Task` captures `[weak self]` and guards on `nil`/`userInitiatedDisconnect`, so a
|
||||
/// stray task left running when AppState is gone is a no-op; the monitor similarly guards.)
|
||||
|
||||
// MARK: - Connect flow
|
||||
|
||||
/// Public connect entry. Always starts a fresh session (no restore).
|
||||
@@ -245,6 +235,13 @@ final class AppState {
|
||||
/// Cancel any in-flight reconnect task and stop the path monitor. Safe to call when nothing
|
||||
/// is armed (no-op). Does NOT touch `userInitiatedDisconnect` or `lastSession` — callers set
|
||||
/// those as needed (disconnect/cancelConnect clear them; scheduleReconnect keeps them).
|
||||
///
|
||||
/// `AppState` is the @Observable app root owned by the SwiftUI `App`; it lives for the
|
||||
/// whole app process and is torn down only on process exit, at which point OS cleanup
|
||||
/// suffices. This method is driven by `disconnect()`/`cancelConnect()` and on successful
|
||||
/// restore — those run on user-initiated teardown, which is the only path that matters.
|
||||
/// (The reconnect `Task` captures `[weak self]` and guards on `nil`/`userInitiatedDisconnect`,
|
||||
/// so a stray task left running when AppState is gone is a no-op; the monitor similarly guards.)
|
||||
private func cancelReconnect() {
|
||||
reconnectTask?.cancel()
|
||||
reconnectTask = nil
|
||||
@@ -310,15 +307,12 @@ final class AppState {
|
||||
if prevSig == nil { return }
|
||||
|
||||
if self.session != nil {
|
||||
// Connected — tear down + reconnect on a meaningful path change.
|
||||
// `.unsatisfied` (all radios off) OR a primary-interface change (Wi-Fi↔cellular)
|
||||
// almost always breaks the live TCP connection; reconnecting proactively beats
|
||||
// waiting for the C core's keepalive/reaper timeout.
|
||||
// See this method's doc comment for why these conditions trigger a
|
||||
// proactive reconnect.
|
||||
if path.status != .satisfied || sig != prevSig {
|
||||
self.proactiveReconnect()
|
||||
}
|
||||
} else if self.lastSession != nil {
|
||||
// Mid-reconnect — a path is available again; fast-fresh the next attempt.
|
||||
if path.status == .satisfied {
|
||||
self.reconnectAttempt = 0
|
||||
self.scheduleReconnect()
|
||||
|
||||
Reference in New Issue
Block a user