Skip to content

Open source Grok Bot alternative, Bring your own agent and subscription: message Claude Code, Codex, Gemini CLI, Cursor, Copilot and 40+ AI agents as bots on your own computer, from iPhone, Mac, Windows, Linux or terminal. Agent-agnostic and free. Also a Muse and Dots alternative. Built in Rust.

1.2 KB
Raw Blame
import CodyncKit
import SwiftUI

public extension View {
    /// The one "Delete <bot>?" confirmation, used wherever a bot can be deleted.
    /// Setting `bot` presents it; `onDeleted` runs after the store deletes it.
    func deleteBotConfirmation(_ bot: Binding<Bot?>, onDeleted: @escaping () -> Void = {}) -> some View {
        modifier(DeleteBotConfirmation(bot: bot, onDeleted: onDeleted))
    }

}

private struct DeleteBotConfirmation: ViewModifier {
    @Binding var bot: Bot?
    let onDeleted: () -> Void
    @Environment(BotStore.self) private var model

    func body(content: Content) -> some View {
        content.codyncDialog(
            "Delete \(bot?.name ?? "bot")?",
            isPresented: Binding(get: { bot != nil }, set: { if !$0 { bot = nil } }),
            message: bot?.isGroup == true ? "Its bots and their own chats stay." : "Files it changed on your computer stay as they are."
        ) {
            // Captured now: the dialog clears `bot` before running the action.
            let target = bot
            return [DialogAction("Delete bot and its conversation", destructive: true) {
                if let target { model.delete(target) }
                onDeleted()
            }]
        }
    }
}