Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Bighelp/App/RootHome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,7 @@ extension RootShellView {
onProfile: { appState.open(.simpleBotProfile(agentID: id)) }, onSwitchAgent: {},
onAsk: { askSimpleBot(id, $0, fillsBlanks: false) },
onSend: { askSimpleBot(id, $0, fillsBlanks: false, sendsAtOnce: true) },
onAskNewChat: { startNewChat(withBot: id, text: $0) },
onBlueprint: { askSimpleBot(id, $0, fillsBlanks: true) })
},
shellBoardKey: { agentBoardClientKey },
Expand Down
8 changes: 8 additions & 0 deletions Bighelp/App/RootNewChat.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,14 @@ extension RootShellView {
startNewChat(explicitAgentID: nil, tracksNewChat: true)
}

/// A new chat with this bot, the text in its message box to add notes before sending: an
/// idea that was said Let's do it to starts a job of its own, not a turn in the bot's chat.
func startNewChat(withBot agentID: String, text: String) {
appState.leaveComposerText(text)
newChatSession.start()
startNewChat(explicitAgentID: agentID, tracksNewChat: true)
}

/// New chat's parts for its own blank chat, and nil for every other chat. Decided from the
/// chat's id, never from its messages: the chat stops drawing them once something is sent.
func newChatSlot(forChat id: String, model: ChatModel) -> ChatNewChatSlot? {
Expand Down
1 change: 1 addition & 0 deletions Bighelp/App/RootSimpleBots.swift
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,7 @@ extension RootShellView {
configureShellBoard: { await configureAgentBoard($0) },
onAsk: { id, text in askSimpleBot(id, text, fillsBlanks: false) },
onSend: { id, text in askSimpleBot(id, text, fillsBlanks: false, sendsAtOnce: true) },
onAskNewChat: { id, text in startNewChat(withBot: id, text: text) },
onBlueprint: { id, text in askSimpleBot(id, text, fillsBlanks: true) }),
editUnavailableReason: editReason,
makeEditor: { profile in
Expand Down
19 changes: 12 additions & 7 deletions Bighelp/Board/AgentBoardViews.swift
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,11 @@ struct AgentBoardContext {
let onSwitchAgent: () -> Void
/// Opens a chat with this agent with the text in its message box.
let onAsk: (String) -> Void
/// Opens a chat with this agent and sends the text there (Let's do it).
/// Opens a chat with this agent and sends the text there (Do it on a post).
let onSend: (String) -> Void
/// Opens a NEW chat with this agent, the text in its message box to add to before sending
/// (Let's do it on an idea: an idea started is a job of its own). Nil asks in the bot's chat.
var onAskNewChat: ((String) -> Void)? = nil
/// Opens a chat with this agent with a blueprint in its message box, its blanks as chips.
let onBlueprint: (String) -> Void
/// Opens this agent's chat, from New chat on a board in a sheet.
Expand Down Expand Up @@ -1161,15 +1164,16 @@ private struct IdeaHeroTile: View {
.accessibilityIdentifier("board.idea.lets-do-it.\(idea.id)")
}

/// As on the idea's page: the yes is recorded by the idea's ID, and the chat that opens gets
/// only the readable text. Older plugins go straight to the chat.
/// As on the idea's page: the yes is recorded by the idea's ID, and a new chat opens with
/// only the readable text in its message box, so notes can be added before it is sent.
/// Older plugins go straight to the chat.
private func letsDoIt() async {
isAccepting = true
let outcome = await context.store.accept(idea)
isAccepting = false
guard outcome != .failed else { acceptFailed = true; return }
acceptFailed = false
context.onSend(idea.letsDoItMessage)
(context.onAskNewChat ?? context.onAsk)(idea.letsDoItMessage)
}
}

Expand Down Expand Up @@ -1343,15 +1347,16 @@ struct IdeaDetailSheet: View {
}
}

/// The yes is recorded when the person taps, by the idea's ID; then "Let's do it!" goes to
/// the chat with the idea as a card. Older plugins skip straight to the chat, as before.
/// The yes is recorded when the person taps, by the idea's ID; then a new chat opens with
/// "Let's do it!" and the idea as a card in its message box, to add notes before sending.
/// Older plugins skip straight to the chat, as before.
private func letsDoIt() async {
isAccepting = true
let outcome = await context.store.accept(idea)
isAccepting = false
guard outcome != .failed else { acceptFailed = true; return }
dismiss()
context.onSend(idea.letsDoItMessage)
(context.onAskNewChat ?? context.onAsk)(idea.letsDoItMessage)
}

@BighelpThemeReader private var theme
Expand Down
8 changes: 6 additions & 2 deletions Bighelp/SimpleBots/SimpleBotProfileView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,10 @@ struct SimpleBotDashboardHooks {
let configureShellBoard: @MainActor (RootShellView.AgentBoardClientKey) async -> Void
/// Opens the bot's chat with the text in its message box (bot ID, text); nothing is sent.
let onAsk: (String, String) -> Void
/// Opens the bot's chat and sends the text there (Let's do it).
/// Opens the bot's chat and sends the text there (Do it on a post).
let onSend: (String, String) -> Void
/// Opens a new chat with the bot, the text in its message box (Let's do it on an idea).
var onAskNewChat: ((String, String) -> Void)? = nil
/// Opens the bot's chat with a blueprint in its message box, its blanks as chips.
let onBlueprint: (String, String) -> Void
}
Expand Down Expand Up @@ -1271,7 +1273,9 @@ struct SimpleBotProfileView: View {
agentID: id, agentName: profile.name, imageURL: context.agents.avatarURL(for: profile),
activity: .idle, store: store,
onProfile: {}, onSwitchAgent: {},
onAsk: { hooks.onAsk(id, $0) }, onSend: { hooks.onSend(id, $0) }, onBlueprint: { hooks.onBlueprint(id, $0) },
onAsk: { hooks.onAsk(id, $0) }, onSend: { hooks.onSend(id, $0) },
onAskNewChat: hooks.onAskNewChat.map { send in { text in send(id, text) } },
onBlueprint: { hooks.onBlueprint(id, $0) },
onNewChat: { context.onOpenChat(id) })
}

Expand Down