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.

test: verify bot exchange message placement

Sean Ferguson15731e2873a6
diff --git a/apps/desktop/src/renderer/views/thread/bot-exchange.test.ts b/apps/desktop/src/renderer/views/thread/bot-exchange.test.ts
index 30026739..e2aa0699 100644
--- a/apps/desktop/src/renderer/views/thread/bot-exchange.test.ts
+++ b/apps/desktop/src/renderer/views/thread/bot-exchange.test.ts
@@ -30,6 +30,20 @@ const notice = (id: string, chat: string, seq: number, status: string, extra: Ex
}
const parsed = (e: Entry) => botExchange(e)!
+test('bot replies stay in the popup while independent reports stay in the main chat', () => {
+ const ask = notice('ask', 'owen', 1, 'completed', { intent: 'ask', reply: 'Answer for Egan' })
+ const trace: Entry = { ...ask, id: 'trace', seq: 2, kind: 'agent', data: { text: 'Answer for Egan' } }
+ const independent = notice('message', 'owen', 3, 'completed')
+ const report: Entry = { ...trace, id: 'report', seq: 4, data: { text: 'Report for the user', final: true } }
+ const entries = [ask, trace, independent, report]
+ const main = groupExchanges(entries)
+ assert.deepEqual(main.map((slot) => slot.entry.id), ['ask', 'report'])
+ const popup = buildBotConversation(botConversation([], entries, 'egan'))
+ assert.deepEqual(popup.filter((row) => row.kind === 'message').map((row) => row.text), [
+ 'Inspect this.', 'Answer for Egan', 'Inspect this.',
+ ])
+})
+
test('decodes the wire JSON and reads direction and verb from either chat', () => {
const wire = JSON.parse('{"id":"n","seq":1,"botId":"egan","rev":3,"kind":"notice","turn":0,"createdAt":5,"updatedAt":5,"data":{"text":"Messaged Owen: Hi\\nQueued. Outcome will appear in Owen\'s chat.","heading":"Messaged Owen: Hi","style":"info","status":"queued","delegationId":"d","sourceBotId":"egan","targetBotId":"owen","botMessage":{"sourceBotId":"egan","targetBotId":"owen","text":"Hi"}}}') as Entry
const out = botExchange(wire)!
diff --git a/apps/ios/Kit/Tests/CodyncKitTests/BotExchangeTests.swift b/apps/ios/Kit/Tests/CodyncKitTests/BotExchangeTests.swift
index 596262aa..bbe8a783 100644
--- a/apps/ios/Kit/Tests/CodyncKitTests/BotExchangeTests.swift
+++ b/apps/ios/Kit/Tests/CodyncKitTests/BotExchangeTests.swift
@@ -34,6 +34,28 @@ private func notice(_ id: String, chat: String = "egan", seq: Int64 = 1, rev: In
#expect(x.text == "Review" && x.reply == "LGTM" && x.outcome == .done)
}
+@Test func botRepliesStayInThePopupAndIndependentReportsStayInMainChat() {
+ let ask = notice("ask", chat: "owen", status: "completed", reply: "Answer for Egan", intent: "ask")
+ var trace = ask
+ trace.id = "trace"
+ trace.seq = 2
+ trace.kind = "agent"
+ trace.data = EntryData(text: "Answer for Egan")
+ let independent = notice("message", chat: "owen", seq: 3, status: "completed")
+ var report = trace
+ report.id = "report"
+ report.seq = 4
+ report.data = EntryData(text: "Report for the user")
+ report.data.final = true
+ let entries = [ask, trace, independent, report]
+ #expect(entries.filter(\.isChat).map(\.id) == ["ask", "message", "report"])
+ let rows = BotConversationRow.build(BotExchange.conversation(fetched: [], live: entries, peer: "egan"))
+ let bodies = rows.compactMap { row -> String? in
+ if case .message(_, _, let text, _) = row { text } else { nil }
+ }
+ #expect(bodies == ["Check this", "Answer for Egan", "Check this"])
+}
+
@Test func structuredRequestIsIndependentOfDisplayedVerb() throws {
for (intent, chat) in [("ask", "egan"), ("ask", "owen"), ("message", "egan"), ("message", "owen")] {
let x = try #require(BotExchange(notice("a", chat: chat, request: "Do it", intent: intent)))
diff --git a/host/src/tui/app/exchange.rs b/host/src/tui/app/exchange.rs
index 175fe1b6..71f66cad 100644
--- a/host/src/tui/app/exchange.rs
+++ b/host/src/tui/app/exchange.rs
@@ -290,6 +290,25 @@ mod tests {
assert_eq!(reply(&m), None);
}
+ #[test]
+ fn bot_replies_stay_in_the_popup_and_user_reports_stay_in_main_chat() {
+ let mut message = msg("a", "b", "question");
+ message["reply"] = "answer for a".into();
+ let ask = notice("ask", 1, 0, &message, "completed");
+ let mut trace = ask.clone();
+ trace.id = "trace".into();
+ trace.kind = Kind::Agent;
+ trace.data = json!({"text": "answer for a"});
+ let mut report = trace.clone();
+ report.id = "report".into();
+ report.data = json!({"text": "report for the user", "final": true});
+ let entries = [ask, trace, report];
+ assert_eq!(grouped("b", &entries, true), ["ask", "report"]);
+ let popup = conversation("b", &entries, None, "a");
+ assert_eq!(popup.len(), 1);
+ assert_eq!(popup[0].reply.as_deref(), Some("answer for a"));
+ }
+
#[test]
fn status_maps_to_an_outcome() {
let mut m = msg("a", "b", "hi");