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.

feat(macos): start group chats from the To: page

leepokai13d3e61ada2c
diff --git a/apps/macos/Views/ChatWindow.swift b/apps/macos/Views/ChatWindow.swift
index b4959157..7393f001 100644
--- a/apps/macos/Views/ChatWindow.swift
+++ b/apps/macos/Views/ChatWindow.swift
@@ -136,8 +136,8 @@ private struct ChatSplitView: View {
@State private var composing = false
@State private var newMenu = false
@State private var railNewMenu = false
- /// The computer a new group chat is being set up on.
- @State private var newGroupComputer: ComputerID?
+ /// The compose page gathers a group chat ("New group chat") rather than any chat.
+ @State private var composingGroup = false
/// The computer a new chat goes to.
@State private var composeComputer: ComputerID?
@State private var previousSelection: BotReference?
@@ -272,12 +272,12 @@ private struct ChatSplitView: View {
VStack(spacing: 0) {
if onlineStores.count > 1 { computerPicker }
// The To: row takes the title bar's place instead of sitting under an empty one.
- NewChatView {
+ NewChatView(group: composingGroup) {
composing = false
if accounts.selection == nil { accounts.selection = previousSelection }
}
.environment(store)
- .id(store.computer.id)
+ .id("\(store.computer.id)-\(composingGroup)")
}
.ignoresSafeArea(.container, edges: .top)
@@ -298,7 +298,7 @@ private struct ChatSplitView: View {
.foregroundStyle(Palette.secondary)
.multilineTextAlignment(.center)
.frame(maxWidth: 420)
- Button("New Bot", action: compose)
+ Button("New Bot") { compose() }
.buttonStyle(.primary)
.disabled(onlineStores.isEmpty)
}
@@ -387,13 +387,6 @@ private struct ChatSplitView: View {
.frame(width: min(920, windowSize.width - 80), height: sheetHeight)
}
}
- .codyncSheet(isPresented: Binding(get: { newGroupComputer != nil }, set: { if !$0 { newGroupComputer = nil } })) {
- if let store = newGroupComputer.flatMap(accounts.store(for:)) {
- GroupEditorView()
- .environment(store)
- .frame(width: 520, height: min(680, sheetHeight))
- }
- }
.codyncSheet(isPresented: $showComputers) {
ComputersView()
.frame(width: 620, height: sheetHeight)
@@ -403,7 +396,7 @@ private struct ChatSplitView: View {
}
.background {
collapseButton.hidden()
- Button("New chat", action: compose)
+ Button("New chat") { compose() }
.keyboardShortcut("n")
.disabled(onlineStores.isEmpty)
.hidden()
@@ -447,10 +440,10 @@ private struct ChatSplitView: View {
}
#if DEBUG
.onAppear {
- // Screenshot/UI checks: CODYNC_DEBUG_OPEN=compose | plugins | computers | <bot name>
+ // Screenshot/UI checks: CODYNC_DEBUG_OPEN=compose | group | plugins | computers | <bot name>
let target = ProcessInfo.processInfo.environment["CODYNC_DEBUG_OPEN"]
- if target == "compose" {
- compose()
+ if target == "compose" || target == "group" {
+ compose(group: target == "group")
} else if target == "plugins" {
marketplace = host.store?.computer.id
} else if target == "computers" {
@@ -664,19 +657,14 @@ extension ChatSplitView {
.background(Palette.surface)
}
- /// The "+" menu: a chat with one or more bots, or a group chat set up with a name and purpose.
+ /// The "+" menu: a chat with one or more bots, or a group chat. Both use the To: page.
fileprivate func newItems() -> [MenuItem] {
- [MenuItem("New chat", icon: "square.and.pencil", action: compose),
- MenuItem("New group chat", icon: "person.2", action: newGroup)]
- }
-
- /// A group chat gathers bots of one computer: the selected bot's if it's online, else this Mac's.
- fileprivate func newGroup() {
- let target = [selectedStore, host.store].compactMap { $0 }.first { shownIDs.contains($0.computer.id) && $0.connection == .online } ?? onlineStores.first
- newGroupComputer = target?.computer.id
+ [MenuItem("New chat", icon: "square.and.pencil") { compose() },
+ MenuItem("New group chat", icon: "person.2") { compose(group: true) }]
}
- fileprivate func compose() {
+ fileprivate func compose(group: Bool = false) {
+ composingGroup = group
// The selected bot's computer if it's online, else this Mac, else any online one.
let target = [selectedStore, host.store].compactMap { $0 }.first { shownIDs.contains($0.computer.id) && $0.connection == .online } ?? onlineStores.first
guard let target else { return }
diff --git a/kit/Sources/CodyncUI/Bots/NewChatView.swift b/kit/Sources/CodyncUI/Bots/NewChatView.swift
index 3d39bb7c..a0caa0bd 100644
--- a/kit/Sources/CodyncUI/Bots/NewChatView.swift
+++ b/kit/Sources/CodyncUI/Bots/NewChatView.swift
@@ -5,7 +5,9 @@ import SwiftUI
/// bots or creates a new one, with ⌘1…⌘9 shortcuts, and the message box underneath.
/// Picked bots become chips in the To: field; one opens its chat, several start a
/// group chat with them (or open the one they already share). Whatever you typed is sent.
+/// `group` is "New group chat": the same page, but it only gathers bots and needs two.
public struct NewChatView: View {
+ let group: Bool
let close: () -> Void
@Environment(BotStore.self) private var model
@State private var query = ""
@@ -14,13 +16,16 @@ public struct NewChatView: View {
@State private var creating = false
@FocusState private var toFocused: Bool
- public init(close: @escaping () -> Void) { self.close = close }
+ public init(group: Bool = false, close: @escaping () -> Void) {
+ self.group = group
+ self.close = close
+ }
/// Bots not picked yet; a group can only be opened on its own, so groups go once someone's picked.
private var matches: [Bot] {
let q = query.trimmingCharacters(in: .whitespaces)
return model.roster.filter {
- !recipients.contains($0.id) && !($0.isGroup && !recipients.isEmpty)
+ !recipients.contains($0.id) && !($0.isGroup && (group || !recipients.isEmpty))
&& (q.isEmpty || $0.name.localizedCaseInsensitiveContains(q))
}
}
@@ -38,7 +43,7 @@ public struct NewChatView: View {
BotChip(bot: bot) { remove(bot.id) }
.transition(.scale(scale: 0.85).combined(with: .opacity))
}
- TextField(recipients.isEmpty ? "Search or create bots" : "Add another bot", text: $query)
+ TextField(toPrompt, text: $query)
.textFieldStyle(.plain)
.focused($toFocused)
.frame(minWidth: 200)
@@ -119,8 +124,14 @@ public struct NewChatView: View {
}
}
+ private var toPrompt: String {
+ if group { return recipients.count < 2 ? "Add bots to the group" : "Add another bot" }
+ return recipients.isEmpty ? "Search or create bots" : "Add another bot"
+ }
+
private var placeholder: String {
switch picked.count {
+ case _ where group: picked.count < 2 ? "Pick at least two bots" : "Message the group"
case 0: "Message Bot"
case 1: "Message \(picked[0].name)"
default: "Message \(picked.map(\.name).joined(separator: ", "))"
@@ -155,7 +166,9 @@ public struct NewChatView: View {
private func start() {
switch recipients.count {
case 0: return
- case 1: open(recipients[0])
+ case 1:
+ guard !group else { return }
+ open(recipients[0])
default:
let names = picked.map(\.name).joined(separator: ", ")
Task {
@@ -188,7 +201,7 @@ public struct NewChatView: View {
d.name = name
bot = try await model.save(d)
}
- if recipients.isEmpty {
+ if recipients.isEmpty && !group {
open(bot.id)
} else {
// `createDefaultBot` selected it; stay here and add it to the others.