feat(chat): Swift chat parity (abort/sessions/stream)

This commit is contained in:
Peter Steinberger
2025-12-17 15:51:31 +01:00
parent cc235fc312
commit 428a82e734
16 changed files with 1131 additions and 54 deletions

View File

@@ -4,6 +4,7 @@ import SwiftUI
public struct ClawdisChatView: View {
@State private var viewModel: ClawdisChatViewModel
@State private var scrollerBottomID = UUID()
@State private var showSessions = false
public init(viewModel: ClawdisChatViewModel) {
self._viewModel = State(initialValue: viewModel)
@@ -24,6 +25,9 @@ public struct ClawdisChatView: View {
}
.frame(maxWidth: .infinity, maxHeight: .infinity, alignment: .top)
.onAppear { self.viewModel.load() }
.sheet(isPresented: self.$showSessions) {
ChatSessionsSheet(viewModel: self.viewModel)
}
}
private var messageList: some View {
@@ -42,6 +46,16 @@ public struct ClawdisChatView: View {
.frame(maxWidth: .infinity, alignment: .leading)
}
if !self.viewModel.pendingToolCalls.isEmpty {
ChatPendingToolsBubble(toolCalls: self.viewModel.pendingToolCalls)
.frame(maxWidth: .infinity, alignment: .leading)
}
if let text = self.viewModel.streamingAssistantText, !text.isEmpty {
ChatStreamingAssistantBubble(text: text)
.frame(maxWidth: .infinity, alignment: .leading)
}
Color.clear
.frame(height: 1)
.id(self.scrollerBottomID)
@@ -64,6 +78,23 @@ public struct ClawdisChatView: View {
Text(self.viewModel.healthOK ? "Connected" : "Connecting…")
.font(.caption)
.foregroundStyle(.secondary)
Spacer(minLength: 0)
Button {
self.showSessions = true
} label: {
Image(systemName: "tray.full")
}
.buttonStyle(.borderless)
.help("Sessions")
Button {
self.viewModel.refresh()
} label: {
Image(systemName: "arrow.clockwise")
}
.buttonStyle(.borderless)
.help("Refresh")
}
.padding(.horizontal, 10)
.padding(.vertical, 6)