diff --git a/ios/Hapi/Features/Chat/Blocks/ToolTextContent.swift b/ios/Hapi/Features/Chat/Blocks/ToolTextContent.swift index 75a11552..371f9cdd 100644 --- a/ios/Hapi/Features/Chat/Blocks/ToolTextContent.swift +++ b/ios/Hapi/Features/Chat/Blocks/ToolTextContent.swift @@ -27,7 +27,7 @@ struct ToolTextContent: View { if terminal { TerminalTextView(text: code, isError: isError) } else { - CodeBlockView(language: language, code: code) + CodeBlockView(language: language, code: code, collapsible: false) } } else { PagedToolText(language: language, code: code, terminal: terminal, isError: isError) @@ -53,7 +53,7 @@ private struct PagedToolText: View { if terminal { TerminalTextView(text: page, isError: isError) } else { - CodeBlockView(language: language, code: page) + CodeBlockView(language: language, code: page, collapsible: false) } } if visiblePages < pages.count { diff --git a/ios/Hapi/Features/Sessions/SessionListView.swift b/ios/Hapi/Features/Sessions/SessionListView.swift index 21f242eb..da4e2780 100644 --- a/ios/Hapi/Features/Sessions/SessionListView.swift +++ b/ios/Hapi/Features/Sessions/SessionListView.swift @@ -778,11 +778,12 @@ private struct BucketHeader: View { } } +} + private struct ListIdentity: Hashable { let filters: SessionListFilters let order: SessionListOrder } -} struct SessionRowView: View { @Environment(\.hapiTheme) private var theme @@ -869,8 +870,8 @@ struct SessionRowView: View { .fixedSize() .layoutPriority(1) .accessibilityLabel(Text("Running")) - } else if let status = row.status, let symbol = status.symbolName { - Image(systemName: symbol) + } else if let status = row.status { + Image(systemName: status.symbolName) .symbolVariant(.none) .symbolRenderingMode(.monochrome) .foregroundStyle(attentionColor) @@ -894,7 +895,7 @@ struct SessionRowView: View { /// Thinking rows get the green spinner; background-only work gets the /// blue one. Pending attention keeps its symbol instead. private var showsSpinner: Bool { - if row.status == .running { return true } + if row.status == nil && row.summary.thinking { return true } return row.status == nil && row.summary.active && row.summary.backgroundTaskCount > 0 @@ -913,7 +914,7 @@ struct SessionRowView: View { } private var spinnerColor: Color { - row.status == .running ? theme.success : theme.accent + row.summary.thinking ? theme.success : theme.accent } private var detailText: String? { diff --git a/ios/HapiTests/SessionListCoveredRefreshTests.swift b/ios/HapiTests/SessionListCoveredRefreshTests.swift index 05355b05..4d9004a9 100644 --- a/ios/HapiTests/SessionListCoveredRefreshTests.swift +++ b/ios/HapiTests/SessionListCoveredRefreshTests.swift @@ -20,6 +20,7 @@ final class SessionListCoveredRefreshTests: XCTestCase { func fullResync() async throws {} func applySessionEvent(_ event: SyncEvent) {} func setPinMode(sessionId: String, mode: SessionPinMode) async throws {} + func setGroup(sessionId: String, group: String?) async throws {} func archiveSession(sessionId: String) async throws {} func renameSession(sessionId: String, name: String) async throws {} func deleteSession(sessionId: String) async throws {} diff --git a/ios/HapiTests/SessionListFilterTests.swift b/ios/HapiTests/SessionListFilterTests.swift index 07cdf8ac..f4524836 100644 --- a/ios/HapiTests/SessionListFilterTests.swift +++ b/ios/HapiTests/SessionListFilterTests.swift @@ -318,6 +318,10 @@ final class HomeFilterTestSessions: SessionListStoring { sessions = sortSessionSummaries(sessions) } func archiveSession(sessionId: String) async throws { sessions.removeAll { $0.id == sessionId } } + func setGroup(sessionId: String, group: String?) async throws { + guard let index = sessions.firstIndex(where: { $0.id == sessionId }) else { return } + sessions[index].metadata?.group = group + } func renameSession(sessionId: String, name: String) async throws { guard let index = sessions.firstIndex(where: { $0.id == sessionId }) else { return } sessions[index].metadata?.name = name diff --git a/ios/Packages/HapiKit/Sources/HapiUI/Chat/AnchoredTranscriptList.swift b/ios/Packages/HapiKit/Sources/HapiUI/Chat/AnchoredTranscriptList.swift index ced3a073..2056acd5 100644 --- a/ios/Packages/HapiKit/Sources/HapiUI/Chat/AnchoredTranscriptList.swift +++ b/ios/Packages/HapiKit/Sources/HapiUI/Chat/AnchoredTranscriptList.swift @@ -303,7 +303,6 @@ private final class TranscriptCollectionView: UICollectionView { /// SwiftUI wrapper reads the latest builder and inherited environment, /// including action captures. SwiftUI can diff the resulting row instead of UIKit /// reinstalling every visible hosting configuration and measuring it again. -@MainActor @Observable /// Lets the keyboard-dismiss tap run alongside cell gestures instead of /// waiting for them to fail. private final class SimultaneousGestureDelegate: NSObject, UIGestureRecognizerDelegate { @@ -311,6 +310,7 @@ private final class SimultaneousGestureDelegate: NSObject, UIGestureRecognizerDe shouldRecognizeSimultaneouslyWith other: UIGestureRecognizer) -> Bool { true } } +@MainActor @Observable private final class TranscriptContent { var render: (Item) -> AnyView = { _ in AnyView(EmptyView()) } var environment = EnvironmentValues() diff --git a/ios/Packages/HapiKit/Sources/HapiUI/Code/CodeBlockView.swift b/ios/Packages/HapiKit/Sources/HapiUI/Code/CodeBlockView.swift index 879b88f7..c7c49083 100644 --- a/ios/Packages/HapiKit/Sources/HapiUI/Code/CodeBlockView.swift +++ b/ios/Packages/HapiKit/Sources/HapiUI/Code/CodeBlockView.swift @@ -11,6 +11,10 @@ import SwiftUI public struct CodeBlockView: View { public let language: String? public let code: String + /// Long blocks collapse to a height cap in the transcript; tool inspectors + /// render the complete content instead (they already provide their own + /// scroll and paging). + public let collapsible: Bool @Environment(\.hapiTheme) private var theme @Environment(\.hapiTypography) private var typography @@ -23,9 +27,10 @@ public struct CodeBlockView: View { @State private var wrapLines = false @State private var expanded = false - public init(language: String?, code: String) { + public init(language: String?, code: String, collapsible: Bool = true) { self.language = language self.code = code + self.collapsible = collapsible } private var displayLanguage: String { @@ -42,7 +47,7 @@ public struct CodeBlockView: View { max(1, code.split(separator: "\n", omittingEmptySubsequences: false).count) } - private var isCollapsible: Bool { lineCount > 18 } + private var isCollapsible: Bool { collapsible && lineCount > 18 } private var isCollapsed: Bool { isCollapsible && !expanded && !wrapLines }