jump to next attention item

This commit is contained in:
Ian Gulliver
2026-10-19 12:22:39 -07:00
parent d55218d1db
commit 43d68d1d71
3 changed files with 20 additions and 4 deletions
+18 -2
View File
@@ -337,14 +337,27 @@ final class ChatModel {
return groups
}
var held: Int? {
var attentionRows: [Int] {
let ids = Set(attention().flatMap(\.rows))
guard let first = builder.root.rows.first(where: { ids.contains($0.id) })?.id, first != released else {
return builder.root.rows.filter { ids.contains($0.id) }.map(\.id)
}
var held: Int? {
guard let first = attentionRows.first, first != released else {
return nil
}
return first
}
func closed(_ old: [Int], _ new: [Int]) {
guard let gone = old.first(where: { !new.contains($0) }), let first = new.first else {
return
}
let rows = builder.root.rows
let at = rows.firstIndex { $0.id == gone } ?? rows.endIndex
scrollTo(rows[at...].first { new.contains($0.id) }?.id ?? first)
}
func release() {
released = held ?? released
}
@@ -812,6 +825,9 @@ private struct TranscriptScroll: View {
position.scrollTo(edge: .bottom)
}
}
.onChange(of: model.attentionRows) { old, new in
model.closed(old, new)
}
.onChange(of: model.older == nil) {
if !scrolling {
model.prependOlder()