Skip to content
Merged
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
5 changes: 5 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ change in both repos.
(`showComposerText`) and taken by the chat Hermes makes (`takeComposerText`). The canvas is thrown
away when that chat arrives, and its draft doesn't always get across in time: text only the canvas
took was lost about every other time.
- An idea, Feed post or goal goes to a chat as a card (`ChatBoardCard`): a block before the person's
words in the message's own text, so the agent reads all of it and a reread draws it in their bubble.
Discuss puts it in the message box (`ChatModel.boardCardDraft`). Let's do it sends "Let's do it!"
with the idea at once (`leaveComposerText(sendsAtOnce:)`, `ChatModel.sendFromOutside`), never
touching the box, and the idea moves to Ideas › Completed (the plugin's `answer`, `answeredAt`).
- Code mode is a second home, not a second app: ☰ gets a mode switch on top and Code's places while it's
the home (`AppTab.code`, `appState.homeTab`). Chat stays the out-of-box home.
- The modes are Bots, Chat and Code (`BighelpMode`; `settings.switchMode`). Settings › Modes has one picker
Expand Down
12 changes: 12 additions & 0 deletions Bighelp.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
06306AA92F9CE0D334C1033C /* WorkspaceContracts.swift in Sources */ = {isa = PBXBuildFile; fileRef = 9DBEA050720EFD509842B1C6 /* WorkspaceContracts.swift */; };
068864D988E15F2B4CA8C773 /* ChatModel+BigFiles.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DC4E597FA288CBDD2DB0319 /* ChatModel+BigFiles.swift */; };
0696F09D9FDBD8C418B03759 /* BighelpUsageWidgetLockScreen.swift in Sources */ = {isa = PBXBuildFile; fileRef = 902E06ADA277EE9D8806B818 /* BighelpUsageWidgetLockScreen.swift */; };
06BB7A5FB7AAF542E44FCA86 /* ChatBoardCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = CDDE2652D6BECAC1152A81D3 /* ChatBoardCard.swift */; };
06F99F6B3D43F9DB4D62BE05 /* CompanionEnvironment.swift in Sources */ = {isa = PBXBuildFile; fileRef = A719EC8CA6038F1E58FCA152 /* CompanionEnvironment.swift */; };
070CD600683A27FFFF11BC55 /* WatchPhone.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2B2A93A6AF8DA5497A0408EB /* WatchPhone.swift */; };
0713CE767A50A04AE6334BD8 /* BighelpMacUpdates.swift in Sources */ = {isa = PBXBuildFile; fileRef = 52D7663820814CF769807B82 /* BighelpMacUpdates.swift */; };
Expand Down Expand Up @@ -717,6 +718,7 @@
59D953650AB3262332C459D4 /* DeviceGeofenceTool.swift in Sources */ = {isa = PBXBuildFile; fileRef = 83409EC359A93949A1A1A2CB /* DeviceGeofenceTool.swift */; };
5A03AFA13C6289B7BB80E8E9 /* HermesToolsList.swift in Sources */ = {isa = PBXBuildFile; fileRef = 25B42C0520EEAFCC064E8825 /* HermesToolsList.swift */; };
5A044C9061C88CA10BBD96F6 /* HermesFacePlayer.swift in Sources */ = {isa = PBXBuildFile; fileRef = B790E89E45A355459ABFB9FB /* HermesFacePlayer.swift */; };
5A06094B12516F4C88133FE8 /* ChatBoardCardTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 5EBC42DDD3A3EF941FC8F001 /* ChatBoardCardTests.swift */; };
5A394E6D02D5BA8702A671C1 /* BighelpRailCard.swift in Sources */ = {isa = PBXBuildFile; fileRef = D3839FB429704BEC09A1DF03 /* BighelpRailCard.swift */; };
5A5C26429791A98EBF3DF089 /* PendingShareLedger.swift in Sources */ = {isa = PBXBuildFile; fileRef = EBEB6BA3161F76CD081422A8 /* PendingShareLedger.swift */; };
5A5E28837861B4344C9C4451 /* ChatToolCodeCellTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 955EF8DC3E8F0CC2CFB5D6C9 /* ChatToolCodeCellTests.swift */; };
Expand Down Expand Up @@ -1441,6 +1443,7 @@
B114F8B6C0F6E61915A7AB01 /* ZipArchiveExtractor.swift in Sources */ = {isa = PBXBuildFile; fileRef = 687949CFACF582DCB8685E39 /* ZipArchiveExtractor.swift */; };
B11E653400EF8354295D41EF /* BighelpUsageWidgetParts.swift in Sources */ = {isa = PBXBuildFile; fileRef = DEC8CA83E1771ACA442E7CBA /* BighelpUsageWidgetParts.swift */; };
B1214CC75367254984FD4565 /* BighelpCardValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = 193FB3F79D5331CD5035BE1A /* BighelpCardValidator.swift */; };
B12EF1DA1FE757C8BEEE9FE3 /* ChatBoardCardViews.swift in Sources */ = {isa = PBXBuildFile; fileRef = 0A0CAEF0ED1025A8195B7486 /* ChatBoardCardViews.swift */; };
B140375ABF770C6F5215857B /* OnDeviceVoiceLiveTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 18E94A655AC6FD5808D8F386 /* OnDeviceVoiceLiveTests.swift */; };
B167522D81630E6BD2577047 /* SystemPageFixture.swift in Sources */ = {isa = PBXBuildFile; fileRef = 880A1627E9A029C69713613D /* SystemPageFixture.swift */; };
B1A7F7D9B87F938E77192942 /* ReferenceDeliveryAcceptanceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 14785604C02D2E7707B79C3F /* ReferenceDeliveryAcceptanceTests.swift */; };
Expand Down Expand Up @@ -2301,6 +2304,7 @@
09FE7AF3652707DEC52C692C /* FleetStoreTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FleetStoreTests.swift; sourceTree = "<group>"; };
0A044AC6EE1343EDBF6F530F /* FocusedTextEditor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = FocusedTextEditor.swift; sourceTree = "<group>"; };
0A08E4F2667799009DAF1479 /* CredentialVault.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = CredentialVault.swift; sourceTree = "<group>"; };
0A0CAEF0ED1025A8195B7486 /* ChatBoardCardViews.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatBoardCardViews.swift; sourceTree = "<group>"; };
0A26DC30FABB27D7EDEBDADE /* ComposioAccount.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ComposioAccount.swift; sourceTree = "<group>"; };
0A319B9E00DA53C7BB4B58F9 /* ReferenceHistoryView.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ReferenceHistoryView.swift; sourceTree = "<group>"; };
0A3F66FAB8AF9CF45DBC1D7C /* ChatModel.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatModel.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -2980,6 +2984,7 @@
5E2E69C77E0356A64595B016 /* BotBodies.json */ = {isa = PBXFileReference; lastKnownFileType = text.json; path = BotBodies.json; sourceTree = "<group>"; };
5E3A8F019E59F4BEE6DDF45E /* HomeWorkAcceptanceFixture.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = HomeWorkAcceptanceFixture.swift; sourceTree = "<group>"; };
5E45B7FBC8B435DDF94BAF6E /* DeviceToolEnvironment.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceToolEnvironment.swift; sourceTree = "<group>"; };
5EBC42DDD3A3EF941FC8F001 /* ChatBoardCardTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatBoardCardTests.swift; sourceTree = "<group>"; };
5ECA70B7C1A6646021728982 /* VoiceModelTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = VoiceModelTests.swift; sourceTree = "<group>"; };
5ED7AA71154BB0B11EE43FE7 /* soul-muse.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = "soul-muse.md"; sourceTree = "<group>"; };
5EEED5396B4A5CA08D8C5836 /* BotModeRoomStore+NativeEvents.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "BotModeRoomStore+NativeEvents.swift"; sourceTree = "<group>"; };
Expand Down Expand Up @@ -3883,6 +3888,7 @@
CD8CEE35C3DA794958BBBB9B /* DirectHermesOwnedRPC.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectHermesOwnedRPC.swift; sourceTree = "<group>"; };
CDA65FB5CDACAC184E55451B /* DirectHermesSessionCatalogRowTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DirectHermesSessionCatalogRowTests.swift; sourceTree = "<group>"; };
CDCFBB5C4E5985D8EC6C78FD /* AgentProfileSheet.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AgentProfileSheet.swift; sourceTree = "<group>"; };
CDDE2652D6BECAC1152A81D3 /* ChatBoardCard.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChatBoardCard.swift; sourceTree = "<group>"; };
CDE853A92392551EBA916C0E /* WikiNavigation.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WikiNavigation.swift; sourceTree = "<group>"; };
CE0D46B41203E5ABB073CFB3 /* DeviceToolCoordinator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DeviceToolCoordinator.swift; sourceTree = "<group>"; };
CE11871CC7E3CE3213E44774 /* SimpleBotsHomeSections.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SimpleBotsHomeSections.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -5608,6 +5614,7 @@
FF33B10BBB5C75516E3D7032 /* ChatAttentionTests.swift */,
5839EBC64D344E43871E5958 /* ChatAttributionTests.swift */,
827FB1BAC0E8E4C2F4FFE359 /* ChatBackgroundResultTests.swift */,
5EBC42DDD3A3EF941FC8F001 /* ChatBoardCardTests.swift */,
86E766D96E35643FF00B36D1 /* ChatBotModeIntegrationTests.swift */,
C563DE2C670A96AC2D4E48B2 /* ChatCanvasGeometryTests.swift */,
DC3FE4EE90C9C2ABFF8CBE6D /* ChatCardMessageProjectionTests.swift */,
Expand Down Expand Up @@ -7088,6 +7095,8 @@
4FB152CCFD82E237A8543E00 /* ChatBackgroundResult.swift */,
C554359955749145E7E3FFEB /* ChatBackgroundResultCard.swift */,
70E27D7C36503753B5BF5C26 /* ChatBlueprintDraft.swift */,
CDDE2652D6BECAC1152A81D3 /* ChatBoardCard.swift */,
0A0CAEF0ED1025A8195B7486 /* ChatBoardCardViews.swift */,
346E60E2A592A84C62801324 /* ChatCameraPicker.swift */,
ACFD343C02B210E5028EAECA /* ChatCapabilityControlSheet.swift */,
3FD7F747650F9C1AEB8642FF /* ChatCardImageCopy.swift */,
Expand Down Expand Up @@ -8180,6 +8189,8 @@
B6C40DC2D80992F3CD7B405A /* ChatBackgroundResultCard.swift in Sources */,
DCEAA98BEEBAAD8DBE293509 /* ChatBigFile.swift in Sources */,
7CC97AB51B2E888D2F9F5B4F /* ChatBlueprintDraft.swift in Sources */,
06BB7A5FB7AAF542E44FCA86 /* ChatBoardCard.swift in Sources */,
B12EF1DA1FE757C8BEEE9FE3 /* ChatBoardCardViews.swift in Sources */,
9C275F3044E17BFF11E7CF52 /* ChatCameraPicker.swift in Sources */,
FCA9EEBC3708BFEBBBA82FE5 /* ChatCapabilityControlSheet.swift in Sources */,
A72D48948B447E5C97EE084F /* ChatCardImageCopy.swift in Sources */,
Expand Down Expand Up @@ -9329,6 +9340,7 @@
B532598FCEB85F153DA7919C /* ChatAttentionTests.swift in Sources */,
348AB2B95F565F4AE42D3649 /* ChatAttributionTests.swift in Sources */,
CF95DFCDD58FBA3A83DE41D5 /* ChatBackgroundResultTests.swift in Sources */,
5A06094B12516F4C88133FE8 /* ChatBoardCardTests.swift in Sources */,
89055BA34023126D9C86613B /* ChatBotModeIntegrationTests.swift in Sources */,
A5F1CA216DBB2489904CB112 /* ChatCanvasGeometryTests.swift in Sources */,
556808D1B218893EAC7C564B /* ChatCardMessageProjectionTests.swift in Sources */,
Expand Down
21 changes: 15 additions & 6 deletions Bighelp/App/AppState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ final class AppState {
var suspendedChat: SuspendedChat?
/// `pendingComposerText` is a blueprint: its `[blanks]` show as chips to fill in (`ChatBlueprintDraft`).
var pendingComposerFillsBlanks = false
/// `pendingComposerText` is a message to send, not a draft (Let's do it): the chat that takes
/// it sends it and leaves its message box alone.
var pendingComposerSendsAtOnce = false
/// The bot whose own chat may take `pendingComposerText` even though it has history: a bot's
/// Dashboard opens that bot's Bot Chat, never a new one. Only an empty message box takes it.
var pendingComposerAgentID: String?
Expand Down Expand Up @@ -266,9 +269,12 @@ final class AppState {
/// Leaves text for the next chat's message box. Each request replaces the last one whole, so
/// an earlier bot or blueprint never sticks to new text. Only a blueprint sets `fillsBlanks`:
/// brackets in anything else (a post's title, text the person typed) are just text.
func leaveComposerText(_ text: String, fillsBlanks: Bool = false, agentID: String? = nil, now: Date = .now) {
/// `sendsAtOnce`: the chat sends the text as a message of its own (Let's do it).
func leaveComposerText(_ text: String, fillsBlanks: Bool = false, sendsAtOnce: Bool = false,
agentID: String? = nil, now: Date = .now) {
pendingComposerText = text
pendingComposerFillsBlanks = fillsBlanks
pendingComposerSendsAtOnce = sendsAtOnce
pendingComposerShown = false
pendingComposerAgentID = agentID
pendingComposerSince = now
Expand All @@ -278,31 +284,34 @@ final class AppState {
/// The canvas is thrown away when the chat arrives and its draft doesn't always get across in
/// time, so the text stays here for that chat to take.
func showComposerText(now: Date = .now) -> (text: String, fillsBlanks: Bool)? {
guard pendingComposerAgentID == nil, let text = pendingComposerText, let since = pendingComposerSince,
now.timeIntervalSince(since) <= Self.pendingComposerLifetime else { return nil }
// A message to send isn't a draft: the canvas leaves it for the chat that sends it.
guard pendingComposerAgentID == nil, !pendingComposerSendsAtOnce, let text = pendingComposerText,
let since = pendingComposerSince, now.timeIntervalSince(since) <= Self.pendingComposerLifetime
else { return nil }
pendingComposerShown = true
return (text, pendingComposerFillsBlanks)
}

/// The text, if this chat should take it: a new chat on top, or the named bot's own chat on top.
/// `wasShown`: a blank canvas already showed it, so this chat may hold it (and what the person
/// changed) from the canvas's draft.
func takeComposerText(isNewChat: Bool, isNamedBotChat: Bool,
now: Date = .now) -> (text: String, fillsBlanks: Bool, wasShown: Bool)? {
func takeComposerText(isNewChat: Bool, isNamedBotChat: Bool, now: Date = .now)
-> (text: String, fillsBlanks: Bool, sendsAtOnce: Bool, wasShown: Bool)? {
guard let text = pendingComposerText else { return nil }
guard let since = pendingComposerSince, now.timeIntervalSince(since) <= Self.pendingComposerLifetime else {
clearComposerText()
return nil
}
guard pendingComposerAgentID == nil ? isNewChat : isNamedBotChat else { return nil }
let taken = (text, pendingComposerFillsBlanks, pendingComposerShown)
let taken = (text, pendingComposerFillsBlanks, pendingComposerSendsAtOnce, pendingComposerShown)
clearComposerText()
return taken
}

private func clearComposerText() {
pendingComposerText = nil
pendingComposerFillsBlanks = false
pendingComposerSendsAtOnce = false
pendingComposerShown = false
pendingComposerAgentID = nil
pendingComposerSince = nil
Expand Down
9 changes: 9 additions & 0 deletions Bighelp/App/ChatDestinationView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -727,6 +727,15 @@ struct ChatDestinationView: View {
let isNamedBotChat = isOnTop && appState.pendingComposerAgentID.map { model.memberIDs == [$0] } == true
guard let pending = appState.takeComposerText(isNewChat: isOnTop && model.transcriptEntries.isEmpty,
isNamedBotChat: isNamedBotChat) else { return }
if pending.sendsAtOnce {
// Let's do it: a message of its own, whatever the box holds. If it can't go, it
// waits in an empty box for Send. Taking the text restarts this task, so the send
// runs on its own.
Task { [model] in
if await !model.sendFromOutside(pending.text), model.draft.isEmpty { model.draft = pending.text }
}
return
}
if pending.wasShown, !model.draft.isEmpty {
// It came across from the canvas, with whatever the person changed there. Its chips
// came too (`prepareNewChat`), unless the text is still as the blueprint wrote it.
Expand Down
7 changes: 7 additions & 0 deletions Bighelp/App/RootAgentHome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,12 @@ extension RootShellView {
startNewChat(explicitAgentID: homeAgent?.id)
}

/// Let's do it: a new chat with this agent, the message sent at once.
func sendToAgent(_ text: String) {
appState.leaveComposerText(text, sendsAtOnce: true)
startNewChat(explicitAgentID: homeAgent?.id)
}

/// A blueprint: a new chat with it in the message box, its blanks as chips. Nothing is sent.
func useBlueprint(_ text: String) {
appState.leaveComposerText(text, fillsBlanks: true)
Expand Down Expand Up @@ -500,6 +506,7 @@ extension RootShellView {
onProfile: { profileAgentID = agent.id },
onSwitchAgent: { isAgentSwitcherPresented = true },
onAsk: askAgent,
onSend: sendToAgent,
onBlueprint: useBlueprint,
onMenu: { isHomeDrawerPresented.toggle() },
onNewChat: { startHomeChat(with: agent.id) },
Expand Down
6 changes: 4 additions & 2 deletions Bighelp/App/RootSimpleBots.swift
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,7 @@ extension RootShellView {
shellBoardKey: { agentBoardClientKey },
configureShellBoard: { await configureAgentBoard($0) },
onAsk: { id, text in askSimpleBot(id, text, fillsBlanks: false) },
onSend: { id, text in askSimpleBot(id, text, fillsBlanks: false, sendsAtOnce: true) },
onBlueprint: { id, text in askSimpleBot(id, text, fillsBlanks: true) })
)
}
Expand All @@ -381,8 +382,9 @@ extension RootShellView {

/// The bot's own chat with the text in its message box (a Dashboard's Ask, Do it or template).
/// It's the Bot Chat, history and all; only an empty message box takes the text.
func askSimpleBot(_ agentID: String, _ text: String, fillsBlanks: Bool) {
appState.leaveComposerText(text, fillsBlanks: fillsBlanks, agentID: agentID)
/// `sendsAtOnce`: Let's do it sends the text there instead, and the box stays as it was.
func askSimpleBot(_ agentID: String, _ text: String, fillsBlanks: Bool, sendsAtOnce: Bool = false) {
appState.leaveComposerText(text, fillsBlanks: fillsBlanks, sendsAtOnce: sendsAtOnce, agentID: agentID)
openSimpleBotChat(agentID)
}

Expand Down
Loading