ios: trace raw core->UI subs payload + actual app state in subs poll

Add a second tracing layer to find why the chat-list indicator stays empty
while the servers-summary detail view shows 100%:

- API.swift sendSimpleXCmd: log the raw bytes the core returns for the
  "/get subs total" query, before decoding. getAgentSubsTotal is sent with
  log:false, so nothing currently records its raw response; and
  decodeAPIResult swallows decode errors (catch {}), so a JSON/shape
  mismatch would silently produce empty values. This shows what the core
  actually sends vs the decoded ssActive/ssPending we already log.
- ChatListView poll: log the actual AppChatState value (not just the
  active bool) when a tick is gated out, to see which state it is stuck in
  in the lock / return-from-background cases.
This commit is contained in:
Narasimha-sc
2026-06-22 10:41:34 +00:00
parent 195316b8bf
commit becabb955d
2 changed files with 13 additions and 4 deletions
@@ -605,7 +605,8 @@ struct SubsStatusIndicator: View {
task = Task {
logger.debug("SUBS_TRACE poll loop: started")
while !Task.isCancelled {
let appActive = AppChatState.shared.value == .active
let appState = AppChatState.shared.value
let appActive = appState == .active
let running = ChatModel.shared.chatRunning == true
if appActive, running {
do {
@@ -620,7 +621,7 @@ struct SubsStatusIndicator: View {
logger.error("getSubsTotal error: \(responseError(error))")
}
} else {
logger.debug("SUBS_TRACE poll skipped tick: appActive=\(appActive) chatRunning=\(running) (gated out, not fetching)")
logger.debug("SUBS_TRACE poll skipped tick: appState=\(appState.rawValue) appActive=\(appActive) chatRunning=\(running) (gated out, not fetching)")
}
try? await Task.sleep(nanoseconds: 1_000_000_000) // Sleep for 1 second
}
+10 -2
View File
@@ -114,9 +114,17 @@ public func resetChatCtrl() {
@inline(__always)
public func sendSimpleXCmd<R: ChatAPIResult>(_ cmd: ChatCmdProtocol, _ ctrl: chat_ctrl? = nil, retryNum: Int32 = 0) -> APIResult<R> {
if let d = sendSimpleXCmdStr(cmd.cmdString, ctrl, retryNum: retryNum) {
decodeAPIResult(d)
// SUBS_TRACE: log the exact bytes the core sends back for the subs-total query,
// before any decoding this is what the UI actually receives from the core.
if cmd.cmdString.hasPrefix("/get subs total") {
logger.debug("SUBS_TRACE raw core->UI for '\(cmd.cmdString)': \(dataToString(d))")
}
return decodeAPIResult(d)
} else {
APIResult.error(.invalidJSON(json: nil))
if cmd.cmdString.hasPrefix("/get subs total") {
logger.debug("SUBS_TRACE raw core->UI for '\(cmd.cmdString)': nil (core returned no data)")
}
return APIResult.error(.invalidJSON(json: nil))
}
}