ios: preserve chat scroll position on resume
All checks were successful
TestFlight / testflight (push) Successful in 1m46s

This commit is contained in:
2026-07-12 13:57:45 -07:00
parent 93ca8a76c3
commit 622659f6ca
3 changed files with 8 additions and 3 deletions

View File

@@ -67,7 +67,6 @@ struct SybilChatTranscriptView: View {
.scrollDismissesKeyboard(.interactively)
.onAppear {
syncKnownToolCallMessageIDs()
scrollToBottom(with: proxy, animated: false)
}
.onChange(of: toolCallMessageIDSignature) { _, _ in
syncKnownToolCallMessageIDs()

View File

@@ -1752,13 +1752,16 @@ final class SybilViewModel {
switch target {
case let .chat(chatID):
SybilLog.debug(SybilLog.app, "Refreshing chat \(chatID)")
let isSelectingDifferentChat = selectedChat?.id != chatID
let chat = try await client.getChat(chatID: chatID)
guard selectedItem == target, draftKind == nil else {
return
}
selectedChat = chat
selectedSearch = nil
requestChatBottomPin()
if isSelectingDifferentChat {
requestChatBottomPin()
}
if let provider = chat.lastUsedProvider,
let model = chat.lastUsedModel,

View File

@@ -544,12 +544,14 @@ private func makeToolCallMessage(id: String, date: Date, summary: String = "Ran
@MainActor
@Test func foregroundChatRefreshReloadsSelectedTranscript() async throws {
let date = Date(timeIntervalSince1970: 1_700_000_100)
let staleDetail = makeChatDetail(id: "chat-2", date: date, body: "stale transcript")
let detail = makeChatDetail(id: "chat-2", date: date, body: "refreshed transcript")
let client = MockSybilClient(chatDetails: ["chat-2": detail])
let viewModel = SybilViewModel(settings: testSettings(named: #function)) { _ in client }
viewModel.isAuthenticated = true
viewModel.isCheckingSession = false
viewModel.selectedItem = .chat("chat-2")
viewModel.selectedChat = staleDetail
await viewModel.refreshVisibleContent(refreshCollections: false, refreshSelection: true)
@@ -559,7 +561,7 @@ private func makeToolCallMessage(id: String, date: Date, summary: String = "Ran
#expect(snapshot.listSearches == 0)
#expect(snapshot.getChat == 1)
#expect(viewModel.selectedChat?.messages.first?.content == "refreshed transcript")
#expect(viewModel.chatBottomPinRequestID == 1)
#expect(viewModel.chatBottomPinRequestID == 0)
}
@MainActor
@@ -675,6 +677,7 @@ private func makeToolCallMessage(id: String, date: Date, summary: String = "Ran
#expect(viewModel.displayedMessages.first?.content == "fresh transcript")
#expect(!viewModel.isLoadingSelection)
#expect(viewModel.chatBottomPinRequestID == 1)
}
@MainActor