iOS Live Activity Updates
Nucleic-Session: 665980BA-E8A5-4E84-9DF4-1757CF792353 Co-authored-by: Nucleic <[email protected]>
This commit is contained in:
@@ -136,8 +136,18 @@ final class LiveActivityManager {
|
|||||||
/// totals on every transcript edit but no status) doesn't spend ActivityKit's update budget. The
|
/// totals on every transcript edit but no status) doesn't spend ActivityKit's update budget. The
|
||||||
/// fresh churn still rides along on the next status-driven push.
|
/// fresh churn still rides along on the next status-driven push.
|
||||||
private func push(_ state: NucleicSessionAttributes.ContentState, hostName: String) {
|
private func push(_ state: NucleicSessionAttributes.ContentState, hostName: String) {
|
||||||
guard state.attentionSignature != lastState?.attentionSignature else { return }
|
// Apply immediately when the attention signature shifts (start/finish/approval/input — the
|
||||||
|
// alert-worthy changes). Otherwise the only difference is mid-turn churn (diff totals); let
|
||||||
|
// that refresh on a slow cadence so it stays roughly current without spending ActivityKit's
|
||||||
|
// budget on every delta. Elapsed-time gate, not a sleeping timer — a status change is never
|
||||||
|
// held behind it.
|
||||||
|
let signatureChanged = state.attentionSignature != lastState?.attentionSignature
|
||||||
|
let churnRefreshDue = lastPushAt.map {
|
||||||
|
Date().timeIntervalSince($0) >= Self.churnRefreshInterval
|
||||||
|
} ?? true
|
||||||
|
guard signatureChanged || (state != lastState && churnRefreshDue) else { return }
|
||||||
lastState = state
|
lastState = state
|
||||||
|
lastPushAt = Date()
|
||||||
|
|
||||||
guard let activity else {
|
guard let activity else {
|
||||||
// Recover an Activity that survived an app relaunch before starting a new one; the
|
// Recover an Activity that survived an app relaunch before starting a new one; the
|
||||||
|
|||||||
Reference in New Issue
Block a user