Fixed problems with folder select for MCP

This commit is contained in:
2026-03-01 18:00:30 +01:00
parent 98d9ee2b51
commit 65a35cd508
6 changed files with 152 additions and 36 deletions

View File

@@ -551,6 +551,46 @@ Don't narrate future actions ("Let me...") - just use the tools.
}
}
/// Always prompts for a new name and saves a fresh copy, switching the session to that copy.
func saveAsFromMenu() {
let chatMessages = messages.filter { $0.role != .system }
guard !chatMessages.isEmpty else { return }
#if os(macOS)
let alert = NSAlert()
alert.messageText = "Save Chat As"
alert.informativeText = "Enter a name for this conversation:"
alert.addButton(withTitle: "Save")
alert.addButton(withTitle: "Cancel")
let input = NSTextField(frame: NSRect(x: 0, y: 0, width: 260, height: 24))
input.placeholderString = "Conversation name…"
if let existing = currentConversationName {
input.stringValue = existing // pre-fill with current name as a starting point
}
alert.accessoryView = input
alert.window.initialFirstResponder = input
guard alert.runModal() == .alertFirstButtonReturn else { return }
let name = input.stringValue.trimmingCharacters(in: .whitespaces)
guard !name.isEmpty else { return }
do {
let saved = try DatabaseService.shared.saveConversation(name: name, messages: chatMessages)
currentConversationId = saved.id
currentConversationName = name
savedMessageCount = chatMessages.count
showSystemMessage("Saved as \"\(name)\"")
} catch {
showSystemMessage("Save failed: \(error.localizedDescription)")
}
#endif
}
/// Called by ConversationListView after renaming a saved conversation.
/// Updates the in-session name if the renamed conversation is currently open.
func didRenameConversation(id: UUID, newName: String) {
if currentConversationId == id {
currentConversationName = newName
}
}
/// Re-save the current conversation under its existing name, or prompt if never saved.
func quickSave() {
let chatMessages = messages.filter { $0.role != .system }