adds the ability to rename chats

This commit is contained in:
2026-05-28 22:22:55 -07:00
parent f79e5e02c5
commit cb8ea935fa
10 changed files with 455 additions and 59 deletions

View File

@@ -851,6 +851,40 @@ final class SybilViewModel {
}
}
func renameChat(chatID: String, title: String) async {
guard isAuthenticated else {
return
}
let trimmedTitle = title.trimmingCharacters(in: .whitespacesAndNewlines)
guard !trimmedTitle.isEmpty else {
errorMessage = "Enter a chat title."
return
}
SybilLog.info(SybilLog.ui, "Renaming chat \(chatID)")
errorMessage = nil
do {
let updated = try await client().updateChatTitle(chatID: chatID, title: trimmedTitle)
chats.removeAll(where: { $0.id == updated.id })
chats.insert(updated, at: 0)
upsertWorkspaceChat(updated)
if selectedChat?.id == updated.id {
selectedChat?.title = updated.title
selectedChat?.updatedAt = updated.updatedAt
selectedChat?.initiatedProvider = updated.initiatedProvider
selectedChat?.initiatedModel = updated.initiatedModel
selectedChat?.lastUsedProvider = updated.lastUsedProvider
selectedChat?.lastUsedModel = updated.lastUsedModel
}
} catch {
errorMessage = normalizeAPIError(error)
SybilLog.error(SybilLog.ui, "Rename failed", error: error)
}
}
func refreshAfterSettingsChange() async {
SybilLog.info(SybilLog.ui, "Settings changed, reconnecting")
settings.persist()