Small feature changes and bug fixes
This commit is contained in:
@@ -12,13 +12,20 @@ import AppKit
|
||||
|
||||
struct MessageRow: View {
|
||||
let message: Message
|
||||
let viewModel: ChatViewModel?
|
||||
private let settings = SettingsService.shared
|
||||
|
||||
#if os(macOS)
|
||||
@State private var isHovering = false
|
||||
@State private var showCopied = false
|
||||
@State private var isStarred = false
|
||||
#endif
|
||||
|
||||
init(message: Message, viewModel: ChatViewModel? = nil) {
|
||||
self.message = message
|
||||
self.viewModel = viewModel
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
// Compact layout for system messages (tool calls)
|
||||
if message.role == .system && !isErrorMessage {
|
||||
@@ -45,6 +52,18 @@ struct MessageRow: View {
|
||||
Spacer()
|
||||
|
||||
#if os(macOS)
|
||||
// Star button (user/assistant messages only, visible on hover)
|
||||
if (message.role == .user || message.role == .assistant) && isHovering {
|
||||
Button(action: toggleStar) {
|
||||
Image(systemName: isStarred ? "star.fill" : "star")
|
||||
.font(.system(size: 11))
|
||||
.foregroundColor(isStarred ? .yellow : .oaiSecondary)
|
||||
}
|
||||
.buttonStyle(.plain)
|
||||
.transition(.opacity)
|
||||
.help("Star this message to always include it in context")
|
||||
}
|
||||
|
||||
// Copy button (assistant messages only, visible on hover)
|
||||
if message.role == .assistant && isHovering && !message.content.isEmpty {
|
||||
Button(action: copyContent) {
|
||||
@@ -138,6 +157,9 @@ struct MessageRow: View {
|
||||
isHovering = hovering
|
||||
}
|
||||
}
|
||||
.onAppear {
|
||||
loadStarredState()
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -235,6 +257,17 @@ struct MessageRow: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private func loadStarredState() {
|
||||
if let metadata = try? DatabaseService.shared.getMessageMetadata(messageId: message.id) {
|
||||
isStarred = metadata.user_starred == 1
|
||||
}
|
||||
}
|
||||
|
||||
private func toggleStar() {
|
||||
viewModel?.toggleMessageStar(messageId: message.id)
|
||||
isStarred.toggle()
|
||||
}
|
||||
#endif
|
||||
|
||||
private var roleIcon: some View {
|
||||
|
||||
Reference in New Issue
Block a user