mirror of
https://github.com/wu736139669/hapi.git
synced 2026-12-05 07:07:04 +00:00
feat(ios): H5-style session rows and fix stuck queued actions
Session rows now match the web sidebar: the second line shows the last two path components, active shares get a "Shared" pill, relative ages read like the H5 list (now, 5 min ago, 10 hours ago, 2 days ago, then a date), and the list font scale reaches 60%. The running spinner is drawn from a timeline instead of ProgressView: UIKit-backed spinners stop animating when a List cell is reconfigured, which read as a spinner that often failed. Working rows also keep their spinner while a pending approval is shown, as on web. Queued-message actions no longer look dead. Cancelling a row the hub reports as `busy` because it is already indeterminate used to restore the row unchanged; it now keeps a `queueDismissed` hold (web #1839), so Cancel and Retry take effect while the durable record stays available for a late consume. Steer is hidden for flavors that cannot take it (agy needs acp, cursor needs acp) via a port of the web steering gate. via [HAPI](https://hapi.run) Co-Authored-By: HAPI <noreply@hapi.run>
This commit is contained in:
@@ -304,6 +304,20 @@ public enum MessageWindowLogic {
|
||||
trimLimit: Int = MessageWindowConstants.visibleWindowSize
|
||||
) -> MessageWindowState {
|
||||
let retainedResponseMessages = responseMessages.filter { shouldRetainWindowMessage($0) }
|
||||
// Web `applyLatestResponse`: a force-dismissed indeterminate row keeps
|
||||
// its hold when the authoritative page re-delivers it (#1839).
|
||||
let dismissedIds = Set(
|
||||
previous.messages
|
||||
.filter(\.queueDismissed)
|
||||
.map(\.id)
|
||||
)
|
||||
let retainedWithHolds = retainedResponseMessages.map { message in
|
||||
dismissedIds.contains(message.id)
|
||||
&& message.invokedAtNumber == nil
|
||||
&& message.status == .indeterminate
|
||||
? message.withQueueDismissed(true)
|
||||
: message
|
||||
}
|
||||
let concurrentServerRows = previous.messages.filter { message in
|
||||
!message.isOptimistic && requestBaseline[message.id] !== message
|
||||
}
|
||||
@@ -312,7 +326,7 @@ public enum MessageWindowLogic {
|
||||
message.isOptimistic || requestBaseline[message.id] !== message
|
||||
}
|
||||
: previous.messages
|
||||
let authoritative = MessageMerge.mergeMessages(preserved, retainedResponseMessages)
|
||||
let authoritative = MessageMerge.mergeMessages(preserved, retainedWithHolds)
|
||||
let incoming = MessageMerge.mergeMessages(authoritative, concurrentServerRows)
|
||||
let trim = trimPreservingQueued(
|
||||
incoming,
|
||||
@@ -700,16 +714,38 @@ public enum MessageWindowLogic {
|
||||
public static func markRequeued(
|
||||
_ previous: MessageWindowState,
|
||||
localIds: [String]
|
||||
) -> MessageWindowState { if localIds.isEmpty { return previous }
|
||||
let idSet = Set(localIds)
|
||||
var changed = false
|
||||
let messages = previous.messages.map { message -> WindowMessage in
|
||||
guard let localId = message.localId, idSet.contains(localId),
|
||||
message.status == .indeterminate || message.queueDismissed else {
|
||||
return message
|
||||
}
|
||||
changed = true
|
||||
// Web `markMessagesRequeued`: clearing the hold includes the
|
||||
// force-dismiss, so a row that came back to the FIFO is visible.
|
||||
return message.withStatus(.queued).withQueueDismissed(false)
|
||||
}
|
||||
return changed ? settingMessages(previous, messages) : previous
|
||||
}
|
||||
|
||||
/// Web `markMessagesIndeterminate` honouring the force-dismiss hold: an
|
||||
/// already-hidden row stays hidden.
|
||||
public static func markQueueDismissed(
|
||||
_ previous: MessageWindowState,
|
||||
localIds: [String]
|
||||
) -> MessageWindowState {
|
||||
if localIds.isEmpty { return previous }
|
||||
let idSet = Set(localIds)
|
||||
var changed = false
|
||||
let messages = previous.messages.map { message -> WindowMessage in
|
||||
guard let localId = message.localId, idSet.contains(localId), message.status == .indeterminate else {
|
||||
guard let localId = message.localId, idSet.contains(localId),
|
||||
message.status == .indeterminate, !message.queueDismissed else {
|
||||
return message
|
||||
}
|
||||
changed = true
|
||||
return message.withStatus(.queued)
|
||||
return message.withQueueDismissed(true)
|
||||
}
|
||||
return changed ? settingMessages(previous, messages) : previous
|
||||
}
|
||||
@@ -746,11 +782,15 @@ public enum MessageWindowLogic {
|
||||
}
|
||||
let needsStatus = message.status != .sent
|
||||
let needsInvokedAt = message.hasExplicitNullInvokedAt
|
||||
if !needsStatus && !needsInvokedAt { return message }
|
||||
let needsClearDismiss = message.queueDismissed
|
||||
if !needsStatus && !needsInvokedAt && !needsClearDismiss { return message }
|
||||
changed = true
|
||||
var next = message
|
||||
if needsStatus { next = next.withStatus(.sent) }
|
||||
if needsInvokedAt { next = next.withInvokedAt(invokedAt) }
|
||||
// Web `markMessagesConsumed` also clears the force-dismiss hold:
|
||||
// the row now belongs to the transcript, not the bar.
|
||||
if needsClearDismiss { next = next.withQueueDismissed(false) }
|
||||
return next
|
||||
}
|
||||
if !changed { return previous }
|
||||
|
||||
Reference in New Issue
Block a user