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(desktop): smooth thinking and show inline previews

leepokai50237e48c200
diff --git a/apps/android/app/src/androidTest/kotlin/com/codync/android/ThinkingPreviewTest.kt b/apps/android/app/src/androidTest/kotlin/com/codync/android/ThinkingPreviewTest.kt
new file mode 100644
index 00000000..a0f6acdc
--- /dev/null
+++ b/apps/android/app/src/androidTest/kotlin/com/codync/android/ThinkingPreviewTest.kt
@@ -0,0 +1,63 @@
+package com.codync.android
+
+import androidx.compose.foundation.layout.Box
+import androidx.compose.foundation.layout.PaddingValues
+import androidx.compose.foundation.layout.height
+import androidx.compose.foundation.layout.size
+import androidx.compose.foundation.lazy.LazyColumn
+import androidx.compose.foundation.lazy.LazyListState
+import androidx.compose.foundation.lazy.rememberLazyListState
+import androidx.compose.material3.Text
+import androidx.compose.runtime.mutableStateOf
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.platform.testTag
+import androidx.compose.ui.test.*
+import androidx.compose.ui.test.junit4.createComposeRule
+import androidx.compose.ui.unit.dp
+import com.codync.android.core.Bot
+import org.junit.Assert.assertEquals
+import org.junit.Assert.assertFalse
+import org.junit.Rule
+import org.junit.Test
+
+class ThinkingPreviewTest {
+ @get:Rule val compose = createComposeRule()
+
+ @Test fun thinkingExpansionAndStreamingFollowTheBottomButLeaveHistoryInPlace() {
+ // The live orb runs a frame loop; advance motion explicitly instead of waiting for it to stop.
+ compose.mainClock.autoAdvance = false
+ val thought = mutableStateOf("First thinking line")
+ lateinit var list: LazyListState
+ compose.setContent {
+ Hosted {
+ list = rememberLazyListState()
+ rememberFollowing(list, "message", 1, working = true, bottom = 0.dp)
+ LazyColumn(Modifier.size(320.dp).testTag("conversation"), state = list, contentPadding = PaddingValues(0.dp)) {
+ items(30) { Box(Modifier.height(48.dp)) { Text("Message $it") } }
+ item("working") { WorkingIndicator(Bot("bot", "Bot", status = "working"), thought.value) }
+ }
+ }
+ }
+ compose.mainClock.advanceTimeBy(1000)
+ compose.waitForIdle()
+ compose.onNodeWithText("Working…").performClick()
+ compose.mainClock.advanceTimeBy(1000)
+ compose.onNodeWithText("First thinking line").assertIsDisplayed()
+ compose.runOnIdle { assertFalse(list.canScrollForward) }
+ compose.runOnIdle { thought.value = (1..12).joinToString("\n") { "Thinking line $it" } }
+ compose.mainClock.advanceTimeBy(1000)
+ compose.waitForIdle()
+ compose.runOnIdle { assertFalse(list.canScrollForward) }
+ compose.onNodeWithTag("conversation").performTouchInput { swipeDown() }
+ compose.mainClock.advanceTimeBy(1000)
+ compose.waitForIdle()
+ var place = 0 to 0
+ compose.runOnIdle {
+ place = list.firstVisibleItemIndex to list.firstVisibleItemScrollOffset
+ thought.value += "\nAnother thinking line"
+ }
+ compose.mainClock.advanceTimeBy(1000)
+ compose.waitForIdle()
+ compose.runOnIdle { assertEquals(place, list.firstVisibleItemIndex to list.firstVisibleItemScrollOffset) }
+ }
+}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ChatRows.kt b/apps/android/app/src/main/kotlin/com/codync/android/ChatRows.kt
index 79c6fbf4..026d996b 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/ChatRows.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ChatRows.kt
@@ -2,7 +2,13 @@ package com.codync.android
import android.content.ClipData
import android.content.ClipboardManager
+import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.animateContentSize
+import androidx.compose.animation.core.animateFloatAsState
+import androidx.compose.animation.expandVertically
+import androidx.compose.animation.fadeIn
+import androidx.compose.animation.fadeOut
+import androidx.compose.animation.shrinkVertically
import androidx.compose.foundation.background
import androidx.compose.foundation.clickable
import androidx.compose.foundation.layout.Arrangement
@@ -28,6 +34,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.clip
+import androidx.compose.ui.draw.rotate
import androidx.compose.ui.graphics.Color
import androidx.compose.ui.platform.LocalContext
import androidx.compose.ui.semantics.Role
@@ -51,7 +58,6 @@ import kotlinx.serialization.json.jsonArray
import kotlinx.serialization.json.jsonObject
import kotlinx.serialization.json.jsonPrimitive
import kotlinx.serialization.json.longOrNull
-
/** One row of a conversation, as iOS `ChatItem` builds them. */
internal sealed interface ChatItem {
val id: String
@@ -356,20 +362,29 @@ internal val Entry.botReactions: Map<String, List<String>> get() =
/**
* The bot's live activity line: a turning orb, what it's doing and for how long. Tapping it
- * opens Full conversation, where its thinking and steps come in as it works.
+ * unfolds the current thinking text in place.
*/
-@Composable internal fun WorkingIndicator(bot: Bot, openTrace: () -> Unit) {
+@Composable internal fun WorkingIndicator(bot: Bot, thought: String?) {
+ var expanded by remember(bot.startedAt) { mutableStateOf(false) }
val needs = bot.status == "needsInput"
- Row(Modifier.fillMaxWidth().padding(top = 6.dp, end = 40.dp)) {
+ Column(Modifier.fillMaxWidth().padding(top = 6.dp, end = 40.dp)) {
Row(Modifier.clip(RoundedRectangle(18.dp)).background(Palette.bubbleAgent)
- .clickable(role = Role.Button, onClickLabel = "Show what it's doing", onClick = openTrace)
+ .clickable(role = Role.Button, onClickLabel = if (expanded) "Hide thinking" else "Show thinking", onClick = { expanded = !expanded })
.padding(horizontal = 16.dp, vertical = 12.dp),
verticalAlignment = Alignment.CenterVertically, horizontalArrangement = Arrangement.spacedBy(8.dp)) {
ThinkingOrb(if (needs) ThinkingOrbState.Listening else ThinkingOrbState.Working, 16.dp, if (needs) Palette.warning else Palette.secondary)
Text(bot.activity.ifEmpty { "Working…" }, Modifier.weight(1f, fill = false), style = Type.subheadline,
color = if (needs) Palette.warning else Palette.secondary, maxLines = 1, overflow = TextOverflow.Ellipsis)
bot.startedAt?.let { Elapsed(it) }
- Symbol("chevron.right", size = 12.dp, tint = Palette.tertiary)
+ val angle by animateFloatAsState(if (expanded) 90f else 0f, Motion.morph(), label = "Thinking disclosure")
+ Symbol("chevron.right", Modifier.rotate(angle), size = 12.dp, tint = Palette.tertiary)
+ }
+ AnimatedVisibility(expanded, enter = fadeIn(Motion.layout()) + expandVertically(Motion.layout(), expandFrom = Alignment.Top),
+ exit = fadeOut(Motion.layout()) + shrinkVertically(Motion.layout(), shrinkTowards = Alignment.Top)) {
+ SelectionContainer {
+ Text(thought ?: "No thinking text yet.", Modifier.fillMaxWidth().padding(start = 16.dp, end = 16.dp, top = 10.dp, bottom = 4.dp),
+ style = Type.footnote, color = Palette.secondary)
+ }
}
}
}
@@ -402,4 +417,4 @@ internal val Entry.botReactions: Map<String, List<String>> get() =
}
}
-internal fun JsonObject.text(key: String): String? = this[key]?.jsonPrimitive?.contentOrNull
+internal fun JsonObject.text(key: String): String? = this[key]?.jsonPrimitive?.contentOrNull
\ No newline at end of file
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt b/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt
index 52731d61..4a091466 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ChatScreen.kt
@@ -251,6 +251,6 @@ import com.kyant.shapes.Capsule
is ChatItem.Exchanges -> BotMessageRow(item.group, state) { openPeer(item.group.peerId) }
}
}
- if (working) item("working") { WorkingIndicator(bot) { store.showTrace(true) } }
+ if (working) item("working") { WorkingIndicator(bot, latestThought(state.entries.filter { it.botId == bot.id })) }
}
}
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/ConversationList.kt b/apps/android/app/src/main/kotlin/com/codync/android/ConversationList.kt
index 9b2919bd..7abca01d 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/ConversationList.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/ConversationList.kt
@@ -74,6 +74,17 @@ import kotlinx.coroutines.launch
snapshotFlow { list.layoutInfo.totalItemsCount }.first { it > 0 }
list.scrollToEnd(animated = false)
}
+ // The thinking disclosure can grow without a new chat entry. Follow its measured size,
+ // not its offset (scrolling itself changes offsets), and always yield to the reader.
+ LaunchedEffect(list) {
+ snapshotFlow {
+ val layout = list.layoutInfo
+ layout.visibleItemsInfo.lastOrNull()?.takeIf { it.index == layout.totalItemsCount - 1 }
+ ?.let { Triple(it.key, it.size, layout.viewportEndOffset - layout.viewportStartOffset) }
+ }.collect { size ->
+ if (size != null && following.value && !touched.value) list.scrollToEnd(animated = false)
+ }
+ }
// A new message, or the box growing (keyboard, more lines): stay on the newest.
LaunchedEffect(last, rev, working, bottom) {
if (following.value && !touched.value && list.layoutInfo.totalItemsCount > 0) list.scrollToEnd(animated = true)
diff --git a/apps/android/app/src/main/kotlin/com/codync/android/TraceView.kt b/apps/android/app/src/main/kotlin/com/codync/android/TraceView.kt
index 5e9e25a6..0893c589 100644
--- a/apps/android/app/src/main/kotlin/com/codync/android/TraceView.kt
+++ b/apps/android/app/src/main/kotlin/com/codync/android/TraceView.kt
@@ -59,6 +59,11 @@ import kotlinx.serialization.json.jsonPrimitive
internal fun runningTurn(entries: List<Entry>, working: Boolean): Long? =
if (working) entries.filter { it.status != "queued" }.maxOfOrNull { it.turn } else null
+internal fun latestThought(entries: List<Entry>): String? {
+ val turn = runningTurn(entries, working = true)
+ return entries.lastOrNull { it.turn == turn && it.kind == "thought" && it.text.isNotBlank() }?.text
+}
+
/** The running turn's thoughts start `unfolded`, so its reasoning reads as it comes in. */
@Composable private fun TraceRow(entry: Entry, unfolded: Boolean) {
val d = entry.data
diff --git a/apps/android/app/src/test/kotlin/com/codync/android/TraceTest.kt b/apps/android/app/src/test/kotlin/com/codync/android/TraceTest.kt
index ac9a8a26..74b0256f 100644
--- a/apps/android/app/src/test/kotlin/com/codync/android/TraceTest.kt
+++ b/apps/android/app/src/test/kotlin/com/codync/android/TraceTest.kt
@@ -8,12 +8,19 @@ import org.junit.Assert.assertNull
import org.junit.Test
class TraceTest {
- private fun entry(id: String, turn: Long, status: String? = null) =
- Entry(id, 0, "bot", 0, "user", turn, buildJsonObject { put("text", id); if (status != null) put("status", status) })
+ private fun entry(id: String, turn: Long, status: String? = null, kind: String = "user") =
+ Entry(id, 0, "bot", 0, kind, turn, buildJsonObject { put("text", id); if (status != null) put("status", status) })
@Test fun `the trace unfolds the running turn, not a queued message holding the next`() {
val entries = listOf(entry("u1", 1), entry("t1", 1), entry("q", 2, status = "queued"))
assertEquals(1L, runningTurn(entries, working = true))
assertNull(runningTurn(entries, working = false))
}
+ @Test fun `thinking preview shows only the latest nonempty thought in this turn`() {
+ val entries = listOf(entry("old", 1, kind = "thought"), entry("latest", 2, kind = "thought"),
+ entry(" ", 2, kind = "thought"), entry("tool", 2, kind = "tool"), entry("queued", 3, status = "queued"))
+ assertEquals("latest", latestThought(entries))
+ assertNull(latestThought(entries + entry("new", 3)))
+ assertNull(latestThought(emptyList()))
+ }
}
diff --git a/apps/desktop/src/renderer/views/thread/ChatRows.tsx b/apps/desktop/src/renderer/views/thread/ChatRows.tsx
index 88947a66..d48e3e69 100644
--- a/apps/desktop/src/renderer/views/thread/ChatRows.tsx
+++ b/apps/desktop/src/renderer/views/thread/ChatRows.tsx
@@ -219,23 +219,28 @@ export function NoticeRow({ entry, addFallback }: { entry: Entry; addFallback?:
}
}
-/**
- * The bot's live activity line: a turning orb, what it's doing and for how long. Clicking it
- * opens Full conversation, where its thinking and steps come in as it works.
- */
-export function WorkingIndicator({ bot, openTrace }: { bot: Bot; openTrace: () => void }) {
+/** The live activity unfolds just the current thinking text, right in the conversation. */
+export function WorkingIndicator({ bot, thought }: { bot: Bot; thought?: string }) {
const waiting = needsInput(bot)
+ const [expanded, setExpanded] = useState(false)
return (
- <HStack gap={10} className="agent-inset">
- <button className="working" onClick={openTrace} title="Show what it's doing">
+ <VStack align="flex-start" className="agent-inset">
+ <button className="working" onClick={() => setExpanded((value) => !value)} aria-expanded={expanded} title={expanded ? 'Hide thinking' : 'Show thinking'}>
<HStack as="span" gap={8}>
<ThinkingOrb state={waiting ? 'listening' : 'working'} size={16} color={waiting ? 'var(--warning)' : 'var(--secondary)'} />
<Text size="subheadline" tone={waiting ? 'attention' : 'secondary'} truncate>{bot.activity || 'Working…'}</Text>
{bot.startedAt ? <Timer since={bot.startedAt} /> : null}
- <Icon name="chevron.right" size={10} weight="semibold" color="var(--tertiary)" />
+ <span className={`disclosure-chevron${expanded ? ' open' : ''}`}>
+ <Icon name="chevron.right" size={10} weight="semibold" color="var(--tertiary)" />
+ </span>
</HStack>
</button>
- </HStack>
+ <div className={`working-thought ${expanded ? 'shown' : ''}`} inert={!expanded} aria-hidden={!expanded}>
+ <div className="chat-working-clip">
+ <Text as="div" size="footnote" tone="secondary" className="working-thought-text selectable">{thought || 'No thinking text yet.'}</Text>
+ </div>
+ </div>
+ </VStack>
)
}
diff --git a/apps/desktop/src/renderer/views/thread/ThreadView.tsx b/apps/desktop/src/renderer/views/thread/ThreadView.tsx
index c4a4c034..4a46515e 100644
--- a/apps/desktop/src/renderer/views/thread/ThreadView.tsx
+++ b/apps/desktop/src/renderer/views/thread/ThreadView.tsx
@@ -12,7 +12,9 @@ import { useStore } from '../../store/context'
import { UpdateNeededCard } from '../UpdateNeededCard'
import { buildChat, rowIn, useArrivals, type ChatItem } from './chat-items'
import { BotConversationView, BotMessageRow } from './BotConversation'
-import { ChatRow, TimeSeparator, WorkingIndicator } from './ChatRows'
+import { ChatRow, TimeSeparator } from './ChatRows'
+import { latestThought } from './trace-turns'
+import { WorkingTransition } from './WorkingTransition'
import { RoutineNotice } from './RoutineNotice'
import { Composer } from './Composer'
import { ChatSidePanel } from './ChatSidePanel'
@@ -279,7 +281,7 @@ const Transcript = memo(function Transcript({ botId, openTrace, onReply, openRou
const keepPlace = useRef<number | null>(null)
const last = items[items.length - 1]
const jump = usePresence(!following && items.length > 0, 200)
- const arrivals = useArrivals([...items.map((i) => i.id), ...(live ? ['working'] : [])], following)
+ const arrivals = useArrivals(items.map((i) => i.id), following)
const toBottom = (smooth = false) => {
const el = scroller.current
@@ -363,11 +365,7 @@ const Transcript = memo(function Transcript({ botId, openTrace, onReply, openRou
<Row item={item} chat={bot} openTrace={openTrace} onReply={onReply} openRoutine={openRoutine} openAgent={openAgent} openBotChat={openBotChat} />
</div>
))}
- {bot && live ? (
- <div className={arrivals.has('working') ? 'chat-working row-in' : 'chat-working'}>
- <WorkingIndicator bot={bot} openTrace={openTrace} />
- </div>
- ) : null}
+ {bot ? <WorkingTransition bot={bot} visible={live} thought={latestThought(entries)} /> : null}
<div className="chat-end" />
</div>
</div>
diff --git a/apps/desktop/src/renderer/views/thread/WorkingTransition.tsx b/apps/desktop/src/renderer/views/thread/WorkingTransition.tsx
new file mode 100644
index 00000000..cd60494a
--- /dev/null
+++ b/apps/desktop/src/renderer/views/thread/WorkingTransition.tsx
@@ -0,0 +1,24 @@
+import { useLayoutEffect, useRef } from 'react'
+import type { Bot } from '@shared/models'
+import { usePresence } from '../../components/Overlay'
+import { WorkingIndicator } from './ChatRows'
+
+/** Keep the activity and its space alive until the exit finishes, including a quick restart. */
+export function WorkingTransition({ bot, visible, thought }: { bot: Bot; visible: boolean; thought?: string }) {
+ // Matches --working-duration; initial history appears without an entrance animation.
+ const presence = usePresence(visible, 420, false)
+ const lastActive = useRef({ bot, thought })
+ useLayoutEffect(() => {
+ if (visible) lastActive.current = { bot, thought }
+ }, [bot, thought, visible])
+ const active = visible ? { bot, thought } : lastActive.current
+ return (
+ <div className={`chat-working ${presence.shown ? 'shown' : ''}`} inert={!visible} aria-hidden={!visible}>
+ <div className="chat-working-clip">
+ <div className="chat-working-content">
+ {presence.mounted ? <WorkingIndicator key={active.bot.startedAt} bot={active.bot} thought={active.thought} /> : null}
+ </div>
+ </div>
+ </div>
+ )
+}
diff --git a/apps/desktop/src/renderer/views/thread/thread.css b/apps/desktop/src/renderer/views/thread/thread.css
index 57f3dd05..674115f6 100644
--- a/apps/desktop/src/renderer/views/thread/thread.css
+++ b/apps/desktop/src/renderer/views/thread/thread.css
@@ -321,8 +321,29 @@
.agent-inset {
padding-right: 40px;
}
-.chat-working {
+.chat-working, .working-thought {
+ --working-duration: 0.42s;
+ display: grid;
+ grid-template-rows: 0fr;
+ opacity: 0;
+ transition: grid-template-rows var(--working-duration) var(--spring), opacity var(--working-duration) var(--ease-out);
+}
+.chat-working.shown, .working-thought.shown {
+ grid-template-rows: 1fr;
+ opacity: 1;
+}
+.chat-working-clip {
+ min-height: 0;
+ overflow: hidden;
+}
+.chat-working-content {
padding-top: 6px;
+ transform: translateY(6px) scale(0.98);
+ transform-origin: top left;
+ transition: transform var(--working-duration) var(--spring);
+}
+.chat-working.shown .chat-working-content {
+ transform: none;
}
.working {
display: flex;
@@ -389,7 +410,21 @@
}
}
@media (prefers-reduced-motion: reduce) {
+ .chat-working, .chat-working-content, .working-thought {
+ transition: none;
+ transform: none;
+ }
.row-in {
animation: fade-in 0.12s both;
}
}
+
+.working-thought {
+ width: 100%;
+}
+.working-thought-text {
+ padding: 10px 16px 4px;
+ white-space: pre-wrap;
+ overflow-wrap: anywhere;
+ line-height: 1.5;
+}
diff --git a/apps/desktop/src/renderer/views/thread/trace-turns.test.ts b/apps/desktop/src/renderer/views/thread/trace-turns.test.ts
index 6b3f4d1c..1c83874d 100644
--- a/apps/desktop/src/renderer/views/thread/trace-turns.test.ts
+++ b/apps/desktop/src/renderer/views/thread/trace-turns.test.ts
@@ -1,6 +1,6 @@
import assert from 'node:assert/strict'
import { test } from 'node:test'
-import { runningTurn, scrolledToEnd, traceTurns } from './trace-turns.ts'
+import { latestThought, runningTurn, scrolledToEnd, traceTurns } from './trace-turns.ts'
import type { Entry } from '../../../shared/models.ts'
const entry = (id: string, turn: number, kind = 'agent', status?: string): Entry => ({
@@ -23,3 +23,11 @@ test('the trace follows new steps only while scrolled to the end', () => {
assert.equal(scrolledToEnd({ scrollHeight: 1000, scrollTop: 595, clientHeight: 400 }), true)
assert.equal(scrolledToEnd({ scrollHeight: 1000, scrollTop: 500, clientHeight: 400 }), false)
})
+
+test('thinking preview uses the latest nonempty thought in the active turn', () => {
+ const entries = [entry('old', 1, 'thought'), entry('first', 2, 'thought'), entry('latest', 2, 'thought'),
+ entry(' ', 2, 'thought'), entry('tool output', 2, 'tool'), entry('queued', 3, 'user', 'queued')]
+ assert.equal(latestThought(entries), 'latest')
+ assert.equal(latestThought([...entries, entry('new turn', 3, 'user')]), undefined)
+ assert.equal(latestThought([]), undefined)
+})
diff --git a/apps/desktop/src/renderer/views/thread/trace-turns.ts b/apps/desktop/src/renderer/views/thread/trace-turns.ts
index b575de8f..7cf070ae 100644
--- a/apps/desktop/src/renderer/views/thread/trace-turns.ts
+++ b/apps/desktop/src/renderer/views/thread/trace-turns.ts
@@ -17,3 +17,9 @@ export function runningTurn(entries: Entry[], working: boolean): number | undefi
export function scrolledToEnd(el: { scrollHeight: number; scrollTop: number; clientHeight: number }) {
return el.scrollHeight - el.scrollTop - el.clientHeight < 8
}
+
+/** A compact live preview never leaks thoughts from a previous turn or a queued request. */
+export function latestThought(entries: Entry[]): string | undefined {
+ const turn = runningTurn(entries, true)
+ return entries.findLast((e) => e.turn === turn && e.kind === 'thought' && e.data.text?.trim())?.data.text
+}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/ChatRows.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/ChatRows.swift
index 669276cb..843dbdbe 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Thread/ChatRows.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/ChatRows.swift
@@ -255,15 +255,18 @@ struct NoticeRow: View {
}
}
-/// The bot's live activity line: a turning orb, what it's doing and for how long. Tapping it
-/// opens Full conversation, where its thinking and steps come in as it works.
+/// The live activity unfolds just the current thinking text, right in the conversation.
struct WorkingIndicator: View {
let bot: Bot
- let openTrace: () -> Void
+ let thought: String?
+ @State private var expanded = false
+ @Environment(\.accessibilityReduceMotion) private var reduceMotion
var body: some View {
- HStack(alignment: .center, spacing: 10) {
- Button(action: openTrace) {
+ VStack(alignment: .leading, spacing: 0) {
+ Button {
+ withAnimation(Motion.reduced(Motion.layout, reduceMotion)) { expanded.toggle() }
+ } label: {
HStack(spacing: 8) {
ThinkingOrb(state: bot.needsInput ? .listening : .working, size: 16, color: bot.needsInput ? Palette.warning : Palette.secondary)
Text(bot.activity.isEmpty ? "Working…" : bot.activity)
@@ -276,6 +279,7 @@ struct WorkingIndicator: View {
.foregroundStyle(Palette.tertiary)
}
Image(systemName: "chevron.right")
+ .rotationEffect(.degrees(expanded ? 90 : 0))
.font(.caption2.weight(.semibold))
.foregroundStyle(Palette.tertiary)
}
@@ -284,9 +288,27 @@ struct WorkingIndicator: View {
.background(Palette.bubbleAgent, in: RoundedRectangle(cornerRadius: 18, style: .continuous))
}
.buttonStyle(.plain)
- .accessibilityHint("Shows what it's doing")
- Spacer(minLength: 40)
+ .accessibilityHint(expanded ? "Hide thinking" : "Show thinking")
+ .accessibilityValue(expanded ? "Expanded" : "Collapsed")
+ // Clip only the disclosure, so collapsing text cannot cross the status bubble.
+ VStack(alignment: .leading, spacing: 0) {
+ if expanded {
+ Text(thought ?? "No thinking text yet.")
+ .font(.footnote)
+ .foregroundStyle(Palette.secondary)
+ .textSelection(.enabled)
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .fixedSize(horizontal: false, vertical: true)
+ .padding(.horizontal, 16)
+ .padding(.top, 10)
+ .padding(.bottom, 4)
+ .transition(.opacity)
+ }
+ }
+ .clipped()
}
+ .frame(maxWidth: .infinity, alignment: .leading)
+ .padding(.trailing, 40)
}
}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift
index 452408f2..01bb1566 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/ThreadView.swift
@@ -349,7 +349,8 @@ extension ThreadView {
// Offline, "working" is only what the computer last said; don't show it as live.
if let bot, working {
rows.append(ConversationRow("working") {
- WorkingIndicator(bot: bot) { showTrace = true }
+ WorkingIndicator(bot: bot, thought: TraceView.latestThought(model.chat(botId)))
+ .id(bot.startedAt)
.padding(.top, 6)
})
}
diff --git a/apps/ios/Kit/Sources/CodyncUI/Thread/TraceView.swift b/apps/ios/Kit/Sources/CodyncUI/Thread/TraceView.swift
index a3d5a3d6..e4995852 100644
--- a/apps/ios/Kit/Sources/CodyncUI/Thread/TraceView.swift
+++ b/apps/ios/Kit/Sources/CodyncUI/Thread/TraceView.swift
@@ -45,6 +45,11 @@ public struct TraceView: View {
.tracked(.screenViewed(.trace))
}
+ nonisolated static func latestThought(_ entries: [Entry]) -> String? {
+ let turn = runningTurn(entries, working: true)
+ return entries.last { $0.turn == turn && $0.kind == "thought" && !($0.data.text ?? "").trimmingCharacters(in: .whitespacesAndNewlines).isEmpty }?.data.text
+ }
+
/// The turn running now while the bot works in this chat; a queued message already holds the next turn.
nonisolated static func runningTurn(_ entries: [Entry], working: Bool) -> Int64? {
working ? entries.filter { $0.data.status != "queued" }.map(\.turn).max() : nil
diff --git a/apps/ios/Kit/Tests/CodyncUITests/ChatItemTests.swift b/apps/ios/Kit/Tests/CodyncUITests/ChatItemTests.swift
index 253aca19..0620bb5b 100644
--- a/apps/ios/Kit/Tests/CodyncUITests/ChatItemTests.swift
+++ b/apps/ios/Kit/Tests/CodyncUITests/ChatItemTests.swift
@@ -76,3 +76,16 @@ import Testing
#expect(TraceView.runningTurn(entries, working: true) == 1)
#expect(TraceView.runningTurn(entries, working: false) == nil)
}
+
+@Test func thinkingPreviewUsesOnlyLatestNonemptyThoughtInRunningTurn() {
+ func entry(_ text: String, turn: Int64, kind: String, status: String? = nil) -> Entry {
+ Entry(id: text, seq: 0, botId: "b", rev: 0, kind: kind, turn: turn,
+ data: EntryData(text: text, status: status), createdAt: 0, updatedAt: 0)
+ }
+ let entries = [entry("old", turn: 1, kind: "thought"), entry("latest", turn: 2, kind: "thought"),
+ entry(" ", turn: 2, kind: "thought"), entry("tool", turn: 2, kind: "tool"),
+ entry("queued", turn: 3, kind: "user", status: "queued")]
+ #expect(TraceView.latestThought(entries) == "latest")
+ #expect(TraceView.latestThought(entries + [entry("new", turn: 3, kind: "user")]) == nil)
+ #expect(TraceView.latestThought([]) == nil)
+}
diff --git a/apps/ios/WhatsNew.md b/apps/ios/WhatsNew.md
index bc0c1da7..5c86eb89 100644
--- a/apps/ios/WhatsNew.md
+++ b/apps/ios/WhatsNew.md
@@ -10,7 +10,7 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o
### zh-Hant
- 用麥克風聽寫時,麥克風按鈕會變成錄音膠囊:停止鍵、錄了多久,還有跟著你說話起伏的點點
-- Bot 工作中時點一下狀態列,就能即時看它的思考過程和每個步驟
+- Bot 工作中時點一下箭頭,就能在對話裡展開簡單的思考文字,再點一次收起
- 麥克風旁的向上箭頭可以選聽寫要用裝置內建語音,還是用你自己的 OpenAI 或 Gemini 金鑰
- iPad 接實體鍵盤時,在輸入框按 Return 會換行,⌘↩ 送出
- 群組裡被提及的 bot 若正在別的對話忙,群組會顯示它在忙,忙完就回來回答
@@ -18,7 +18,7 @@ a version without one gets a generic "Bug fixes and improvements" line. Delete o
### en-US
- While you dictate, the mic turns into a recording pill: a stop button, how long you've been talking, and dots that follow your voice
-- While a bot works, tap its status line to watch its thinking and each step live
+- Tap the arrow while a bot works to expand its thinking text right in the chat, and tap again to collapse
- The arrow beside the mic picks how dictation hears you: on-device speech, or your own OpenAI or Gemini key
- On iPad with a hardware keyboard, Return starts a new line in the message box and ⌘↩ sends
- In a group, a bot you mention that's busy in another chat now says so, and answers once it's done
diff --git a/docs/architecture/conversation-runtime.md b/docs/architecture/conversation-runtime.md
index 9ffcb4c0..23d33426 100644
--- a/docs/architecture/conversation-runtime.md
+++ b/docs/architecture/conversation-runtime.md
@@ -7,4 +7,4 @@
- **A session that fails** with an internal error its agent gives no category (JSON-RPC `-32603` without `data.errorKind`) is closed right after the turn, when the agent can close and load sessions: Claude's adapter otherwise answers every later prompt on it with "The Claude Agent session has ended". The next message loads it again and the conversation carries on (`acp::may_end_session`).
- Bot collaboration: built-in `team` MCP (`chat/team.rs`) lists visible bots and asks one for a reply or sends it an independent message through its actor queue. Asks are separate turns, cycle-checked and cancellable; native subagents stay with the harness. See [docs/features/bot-collaboration.md](../features/bot-collaboration.md).
- **Context & memory**: frozen instruction snapshot per session + compaction epoch (Claude gets it as a system prompt), profile edits as update blocks, memory in the host (a layer shared by all bots and one per bot, written by the user, the bots' tools and dreaming), busy-time messages folded into one turn, interrupted turns resumed: [docs/features/context-and-memory.md](../features/context-and-memory.md).
-- **Chat shows only**: user messages, the bot's messages (`data.final`: each `send_message` call from the built-in `chat` MCP, Grok Bot's way; a turn that sent none falls back to its last text, unless it reacted to the user's message instead or passed), permission cards, notices. Nothing streams into a bubble; narration, thoughts, tool calls, plans are trace entries (Full conversation sheet): [docs/features/chat-messages.md](../features/chat-messages.md).
+- **Chat shows only**: user messages, the bot's messages (`data.final`: each `send_message` call from the built-in `chat` MCP, Grok Bot's way; a turn that sent none falls back to its last text, unless it reacted to the user's message instead or passed), permission cards, notices. Nothing streams into a bubble; narration, thoughts, tool calls, plans are trace entries (Full conversation sheet; the live activity can also unfold its latest thinking text inline): [docs/features/chat-messages.md](../features/chat-messages.md).
diff --git a/docs/features/chat-messages.md b/docs/features/chat-messages.md
index 757daa69..3fc18fc0 100644
--- a/docs/features/chat-messages.md
+++ b/docs/features/chat-messages.md
@@ -63,11 +63,15 @@ it has no pointer tooltip or link-opening action.
## While it works
The working line under the last message shows the bot's activity; composing a `send_message`
-reads as **Typing…** (`activity()` in `agent/bot.rs`). Thoughts and tool calls stay in the
-Full conversation sheet. The working line ends in a `chevron.right` and opens that sheet, which
-follows the run: it stays at the end while new steps arrive (until the reader scrolls up), and
-the running turn's thoughts start unfolded (finished turns' stay folded). The terminal UI says
-"N steps so far · t shows them live" under its working line instead.
+reads as **Typing…** (`activity()` in `agent/bot.rs`). Its chevron expands or collapses a plain-text
+preview in the conversation: only the latest nonempty `thought` entry from the running turn.
+Queued messages do not advance that turn. Until the agent shares text, the preview says
+“No thinking text yet.” Each new turn starts collapsed.
+
+Full conversation remains available from the conversation menu. It contains narration, all
+thoughts, tools and previous turns, and follows new steps until the reader scrolls up.
+On the terminal, click the activity row or press `>` to toggle the inline preview; `t` still
+opens Full conversation, and the working line retains the count of steps so far.
## Motion and scrolling
@@ -82,3 +86,8 @@ the running turn's thoughts start unfolded (finished turns' stay folded). The te
below the turning arrow, then eases back. A pull that isn't full refreshes nothing. The desktop
reconnects from the computer menu instead.
- The terminal UI lists the same messages; its steps line goes under the turn's last message.
+
+- Electron keeps the activity row mounted during its 0.42 s exit and animates its height,
+ opacity and a small scale change together. The transition honors Reduce Motion and reverses
+ when work restarts during an exit. iPhone conversation insertion, removal and scrolling
+ keep their existing animations.
diff --git a/host/src/tui/app/input.rs b/host/src/tui/app/input.rs
index 37a885fd..7e7141d5 100644
--- a/host/src/tui/app/input.rs
+++ b/host/src/tui/app/input.rs
@@ -270,6 +270,7 @@ impl App {
}
KeyCode::Char('{') => self.step_turn(-1),
KeyCode::Char('}') => self.step_turn(1),
+ KeyCode::Char('>') => self.toggle_thinking(),
KeyCode::Char('t') => {
self.trace = if self.trace == TraceMode::Pane { TraceMode::Off } else { TraceMode::Pane };
if self.trace == TraceMode::Off && self.focus == Focus::Trace {
@@ -408,6 +409,7 @@ impl App {
}
Some(Click::Composer) => self.start_typing(),
Some(Click::BotChat(entry)) => self.open_bot_chat(&entry),
+ Some(Click::Thinking) => self.toggle_thinking(),
None => {
if self.overlays.is_empty() {
if self.hits.trace.contains(at) {
diff --git a/host/src/tui/app/mod.rs b/host/src/tui/app/mod.rs
index 7e71af17..caf76437 100644
--- a/host/src/tui/app/mod.rs
+++ b/host/src/tui/app/mod.rs
@@ -12,12 +12,14 @@ mod navigate;
mod new_bot;
mod overlay_keys;
mod slash;
+mod thinking;
mod ui;
pub use editor::Editor;
pub use exchange::{ConversationRow, Exchange, Item, Outcome, conversation, group, rows};
pub use model::{After, AgentModel, Bot, Entry, Kind, Mark, ModelOption, Msg, Status};
pub use slash::SlashAction;
+pub(super) use thinking::{latest_thought, running_turn};
pub use ui::{
ACTIONS, Action, COLORS, Click, Confirm, ConfirmAct, Dir, FIELDS, FILTERS, Field, Focus, FolderPicker, Form, Goto,
GotoItem, GroupField, GroupForm, Hits, NewBot, NewBotField, Overlay, PairCode, SHAPES, Toast, Toggle, TraceMode,
@@ -76,6 +78,8 @@ pub struct App {
pub chat_scroll: usize,
pub trace_scroll: usize,
pub trace: TraceMode,
+ /// The bot and turn whose inline thinking preview is open.
+ pub thinking: Option<(String, i64)>,
/// Turn shown in the trace; `None` follows the latest.
pub trace_turn: Option<i64>,
pub compact: bool,
@@ -151,6 +155,7 @@ impl App {
chat_scroll: 0,
trace_scroll: 0,
trace: TraceMode::Off,
+ thinking: None,
trace_turn: None,
compact: false,
overlays: vec![],
diff --git a/host/src/tui/app/thinking.rs b/host/src/tui/app/thinking.rs
new file mode 100644
index 00000000..e12722de
--- /dev/null
+++ b/host/src/tui/app/thinking.rs
@@ -0,0 +1,58 @@
+//! The inline activity disclosure is presentation state, scoped to one bot and turn.
+
+use super::{App, Entry, Kind, Status};
+
+pub(in crate::tui) fn running_turn(entries: &[&Entry]) -> Option<i64> {
+ entries.iter().filter(|e| e.data["status"] != "queued").map(|e| e.turn).max()
+}
+
+pub(in crate::tui) fn latest_thought<'a>(entries: &[&'a Entry]) -> Option<&'a str> {
+ let turn = running_turn(entries)?;
+ entries
+ .iter()
+ .rev()
+ .find(|e| e.turn == turn && e.kind == Kind::Thought && !e.text().trim().is_empty())
+ .map(|e| e.text())
+}
+
+impl App {
+ pub(super) fn toggle_thinking(&mut self) {
+ let Some(bot) = self
+ .bot()
+ .filter(|b| self.online && b.works_here() && matches!(b.status, Status::Working | Status::NeedsInput))
+ else {
+ return;
+ };
+ let Some(turn) = running_turn(&self.lane(&bot.id)) else { return };
+ let key = (bot.id.clone(), turn);
+ self.thinking = if self.thinking.as_ref() == Some(&key) { None } else { Some(key) };
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+ use serde_json::json;
+
+ fn entry(turn: i64, kind: Kind, text: &str, status: &str) -> Entry {
+ Entry { id: text.into(), seq: 0, turn, kind, data: json!({"text": text, "status": status}), created_at: 0 }
+ }
+
+ #[test]
+ fn preview_uses_latest_thought_without_queued_or_tool_text() {
+ let entries = [
+ entry(1, Kind::Thought, "earlier", ""),
+ entry(1, Kind::Thought, "latest", ""),
+ entry(1, Kind::Tool, "tool output", ""),
+ entry(2, Kind::User, "next", "queued"),
+ ];
+ assert_eq!(latest_thought(&entries.iter().collect::<Vec<_>>()), Some("latest"));
+ }
+
+ #[test]
+ fn new_turn_does_not_reuse_previous_thinking() {
+ let entries =
+ [entry(1, Kind::Thought, "old", ""), entry(2, Kind::User, "new", ""), entry(2, Kind::Thought, " ", "")];
+ assert_eq!(latest_thought(&entries.iter().collect::<Vec<_>>()), None);
+ }
+}
diff --git a/host/src/tui/app/ui.rs b/host/src/tui/app/ui.rs
index 92a642ac..9668a928 100644
--- a/host/src/tui/app/ui.rs
+++ b/host/src/tui/app/ui.rs
@@ -317,6 +317,7 @@ pub enum Click {
},
Filter(usize),
Composer,
+ Thinking,
/// A bot-message row (entry id): opens the conversation.
BotChat(String),
}
diff --git a/host/src/tui/view/activity.rs b/host/src/tui/view/activity.rs
new file mode 100644
index 00000000..f5fdb49e
--- /dev/null
+++ b/host/src/tui/view/activity.rs
@@ -0,0 +1,38 @@
+//! A compact activity row with an optional plain-text thinking preview.
+
+use ratatui::text::{Line, Span};
+
+use super::super::app::{App, Bot, Click, Entry, Kind, latest_thought, running_turn};
+use super::super::md::{self, truncate};
+use super::buffer::u;
+use super::style::{spin, theme};
+use super::transcript::{Built, gap, name_style};
+
+pub(super) fn activity(out: &mut Built, app: &App, bot: &Bot, entries: &[&Entry], width: usize) {
+ let t = theme();
+ gap(out);
+ out.lines.push(Line::from(Span::styled(format!(" {}", bot.name), name_style(&bot.color))));
+ let expanded =
+ app.thinking.as_ref().is_some_and(|(id, turn)| id == &bot.id && Some(*turn) == running_turn(entries));
+ let text = if bot.activity.is_empty() { "Working…" } else { &bot.activity };
+ let row = out.lines.len();
+ out.lines.push(Line::from(vec![
+ Span::styled(format!(" {} ", spin(app)), t.secondary),
+ Span::styled(truncate(text, width.saturating_sub(8)), t.secondary),
+ Span::styled(if expanded { " v" } else { " >" }, t.dim),
+ ]));
+ out.buttons.push((row, 0, u(width), Click::Thinking));
+ let turn = running_turn(entries);
+ let steps = entries.iter().filter(|entry| Some(entry.turn) == turn && entry.kind == Kind::Tool).count();
+ let hint = if steps == 0 {
+ " > thinking · t full conversation".to_owned()
+ } else {
+ format!(" {steps} steps so far · > thinking · t full conversation")
+ };
+ out.lines.push(Line::from(Span::styled(hint, t.dim)));
+ if expanded {
+ let text = latest_thought(entries).unwrap_or("No thinking text yet.");
+ let prefix = [Span::raw(" ")];
+ out.lines.extend(md::wrap(&[Span::styled(text.to_owned(), t.secondary)], width, &prefix, &prefix));
+ }
+}
diff --git a/host/src/tui/view/help.rs b/host/src/tui/view/help.rs
index 8a49f55a..4a4f5fd8 100644
--- a/host/src/tui/view/help.rs
+++ b/host/src/tui/view/help.rs
@@ -9,7 +9,7 @@ use super::buffer::{centered, frame_box, put, u};
use super::overlay::field_line;
use super::style::theme;
-const HELP: [(&str, &str, &str); 63] = [
+const HELP: [(&str, &str, &str); 64] = [
("MOVE", "j k ↑ ↓", "next / previous bot"),
("MOVE", "[ ]", "previous / next bot"),
("MOVE", "1…9", "jump to bot 1–9"),
@@ -26,6 +26,7 @@ const HELP: [(&str, &str, &str); 63] = [
("CHAT", "N", "reject and say why"),
("CHAT", "1…9", "pick an approval option"),
("CHAT", "s", "stop the bot"),
+ ("CHAT", ">", "expand / collapse thinking"),
("CHAT", "o", "last turn's steps"),
("CHAT", "c", "copy the last reply"),
("CHAT", "C", "open connection / login request"),
diff --git a/host/src/tui/view/mod.rs b/host/src/tui/view/mod.rs
index 48b66d6d..1f38b1a7 100644
--- a/host/src/tui/view/mod.rs
+++ b/host/src/tui/view/mod.rs
@@ -6,6 +6,7 @@
// Drawing code reads best with x / y / w / t (theme) / r (rect).
#![allow(clippy::many_single_char_names, clippy::similar_names)]
+mod activity;
mod analytics;
mod bot_chat;
mod buffer;
diff --git a/host/src/tui/view/transcript.rs b/host/src/tui/view/transcript.rs
index dd3763bc..43dada9a 100644
--- a/host/src/tui/view/transcript.rs
+++ b/host/src/tui/view/transcript.rs
@@ -83,23 +83,9 @@ pub(super) fn build_chat(app: &App, b: &Bot, width: usize) -> Built {
}
}
// A turn in flight: who's on it and what they're doing.
- let last_turn = entries.iter().map(|e| e.turn).max().unwrap_or(0);
// A message doesn't end the turn: the bot may send several.
- if b.status == Status::Working && b.works_here() {
- gap(&mut out);
- out.lines.push(Line::from(Span::styled(format!(" {}", b.name), name_style(&b.color))));
- let act = if b.activity.is_empty() { "Working…".to_owned() } else { b.activity.clone() };
- out.lines.push(Line::from(vec![
- Span::styled(format!(" {} ", spin(app)), t.secondary),
- Span::styled(truncate(&act, width.saturating_sub(4)), t.secondary),
- ]));
- let steps = info.get(&last_turn).map_or(0, |ti| ti.steps);
- if steps > 0 {
- out.lines.push(Line::from(Span::styled(
- format!(" {steps} step{} so far · t shows them live", if steps == 1 { "" } else { "s" }),
- t.dim,
- )));
- }
+ if app.online && matches!(b.status, Status::Working | Status::NeedsInput) && b.works_here() {
+ super::activity::activity(&mut out, app, b, &entries, width);
} else if let Some(group) = b.away().filter(|_| matches!(b.status, Status::Working | Status::NeedsInput)) {
// Busy in a group it's in.
let place = app.author_name(Some(group));