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.

fix(kit): show only the reply being generated while a bot works

leepokaib2e0e0cb814d
diff --git a/kit/Sources/CodyncUI/Thread/RepliesView.swift b/kit/Sources/CodyncUI/Thread/RepliesView.swift
index 805b109e..d840d803 100644
--- a/kit/Sources/CodyncUI/Thread/RepliesView.swift
+++ b/kit/Sources/CodyncUI/Thread/RepliesView.swift
@@ -45,7 +45,7 @@ struct RepliesView: View {
}
.padding(.vertical, 12)
}
- ForEach(ChatItem.build(replies)) { item in
+ ForEach(ChatItem.build(replies, streaming: chat?.isWorking(in: botId, thread: rootId) == true && !model.isOffline)) { item in
if case let .entry(e, groupStart) = item.kind {
ChatRow(entry: e, groupStart: groupStart, chat: chat) { showTrace = true }
}
diff --git a/kit/Sources/CodyncUI/Thread/ThreadView.swift b/kit/Sources/CodyncUI/Thread/ThreadView.swift
index 02d3a275..c41f9085 100644
--- a/kit/Sources/CodyncUI/Thread/ThreadView.swift
+++ b/kit/Sources/CodyncUI/Thread/ThreadView.swift
@@ -86,7 +86,7 @@ public struct ThreadView: View {
@ViewBuilder private var conversation: some View {
let thread = model.chat(botId)
- let items = ChatItem.build(thread)
+ let items = ChatItem.build(thread, streaming: bot?.isWorking(in: botId, thread: nil) == true && !model.isOffline)
ScrollViewReader { proxy in
ScrollView {
LazyVStack(alignment: .leading, spacing: 0) {
@@ -458,13 +458,15 @@ struct ChatItem: Identifiable {
let kind: Kind
/// Chat-visible entries plus time separators (gaps > 1 h) and author grouping.
- static func build(_ entries: [Entry]) -> [ChatItem] {
+ /// `streaming`: a turn is running in this chat, so the text being generated right now
+ /// (the lane's last entry, still `final == false`) shows in place and never pops in later.
+ /// Earlier segments of the turn, tool calls in between, and a room pass stay trace-only.
+ static func build(_ entries: [Entry], streaming: Bool = false) -> [ChatItem] {
var out: [ChatItem] = []
var lastDate: Date?
var lastAuthor: String?
- // Agent text is streamed as a stable entry with final=false, then updated in place.
- // Render that same row while it is generating so the completed answer never pops in later.
- for e in entries where e.isChat || (e.kind == "agent" && e.data.final == false && !(e.data.text ?? "").isEmpty) {
+ let live = streaming ? entries.last.flatMap { $0.kind == "agent" && $0.data.final == false ? $0.id : nil } : nil
+ for e in entries where e.isChat || (e.id == live && !(e.data.text ?? "").isEmpty && e.data.text != "(pass)") {
let date = e.date
let id = e.kind == "user" ? e.data.clientNonce.map { "user-\($0)" } ?? e.id : e.id
if lastDate.map({ date.timeIntervalSince($0) > 3600 }) ?? true {
diff --git a/kit/Tests/CodyncUITests/ChatItemTests.swift b/kit/Tests/CodyncUITests/ChatItemTests.swift
new file mode 100644
index 00000000..c1d5606e
--- /dev/null
+++ b/kit/Tests/CodyncUITests/ChatItemTests.swift
@@ -0,0 +1,26 @@
+import Foundation
+import Testing
+@testable import CodyncKit
+@testable import CodyncUI
+
+/// The chat shows user messages and final replies; while a turn runs, only the text being
+/// generated right now joins them. Earlier narration and room passes never do.
+@Test func chatShowsOnlyFinalRepliesAndTheTextBeingGenerated() {
+ func entry(_ seq: Int64, _ kind: String, _ text: String? = nil, final: Bool? = nil) -> Entry {
+ var data = EntryData(text: text)
+ data.final = final
+ return Entry(id: "e\(seq)", seq: seq, botId: "b", rev: seq, kind: kind, turn: 1, data: data, createdAt: 0, updatedAt: 0)
+ }
+ let ids = { (items: [ChatItem]) in items.compactMap { if case let .entry(e, _) = $0.kind { e.id } else { nil } } }
+
+ // Mid-turn: narration closed by a tool call, then the answer streaming.
+ let running = [entry(1, "user", "Fix it"), entry(2, "agent", "I'll read it first.", final: false),
+ entry(3, "tool_call", "Read"), entry(4, "agent", "Done. It raced", final: false)]
+ #expect(ids(ChatItem.build(running, streaming: true)) == ["e1", "e4"])
+ #expect(ids(ChatItem.build(running)) == ["e1"])
+ // Idle: the last text has been marked final; narration stays trace-only.
+ let done = [running[0], running[1], running[2], entry(4, "agent", "Done. It raced the refresh.", final: true)]
+ #expect(ids(ChatItem.build(done)) == ["e1", "e4"])
+ // A room pass is being generated: still not chat.
+ #expect(ids(ChatItem.build([running[0], entry(2, "agent", "(pass)", final: false)], streaming: true)) == ["e1"])
+}