Repository navigation
feat(chat): Introduce structured content timelines for turns - #690
Conversation
haiphucnguyen
commented
Sep 3, 2026
- Persist ordered sequences of tool calls and response tokens into the database.
- Enables accurate auditing of agent interactions and tool usage history.
- Updates desktop UI to display completed turn timelines for the user.
- Refines agent interfaces to explicitly differentiate between status updates and tool invocations.
- Persist ordered sequences of tool calls and response tokens into the database. - Enables accurate auditing of agent interactions and tool usage history. - Updates desktop UI to display completed turn timelines for the user. - Refines agent interfaces to explicitly differentiate between status updates and tool invocations.
There was a problem hiding this comment.
🟡 Changes recommended
There are confirmed UI/operational issues in the new timeline rendering and persistence paths (thinking visibility for completed messages, unstable Compose keys, and missing/trust-breaking truncation/logging) that should be addressed before approval.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Introduces an ordered, structured “turn timeline” (tool calls + streamed response tokens) that can be persisted and later rendered to accurately audit and replay what happened during a chat/agent turn, including true interleaving (text → tool → text).
Changes:
- Adds
content_jsonpersistence for orderedcontentBlocksonchat_messagesandagent_run_history, plus DTO/domain plumbing to carry it end-to-end. - Refactors desktop streaming state from separate chunks/tool/thinking flows into a single ordered timeline, and updates chat/agent UI to render grouped chronological timelines.
- Refines external agent interfaces to differentiate structured tool invocations (
onToolCall) from general status updates (onStatus).
File summaries
| File | Description |
|---|---|
| shared/src/main/kotlin/io/askimo/core/db/DatabaseManager.kt | Adds DB migrations for new content_json columns on chat/agent history tables. |
| shared/src/main/kotlin/io/askimo/core/chat/service/ChatSessionService.kt | Extends AI-response save path to accept and persist contentBlocks. |
| shared/src/main/kotlin/io/askimo/core/chat/repository/ChatMessageRepository.kt | Encodes/decodes contentBlocks to/from content_json for chat messages. |
| shared/src/main/kotlin/io/askimo/core/chat/mapper/ChatMessageMapper.kt | Includes contentBlocks when mapping domain → DTO. |
| shared/src/main/kotlin/io/askimo/core/chat/dto/TurnTimelineEntry.kt | Defines timeline entry types and grouping/collapse utilities for rendering/persistence. |
| shared/src/main/kotlin/io/askimo/core/chat/dto/ToolCallInfo.kt | Makes tool-call DTOs serializable for timeline persistence. |
| shared/src/main/kotlin/io/askimo/core/chat/dto/ChatMessageDTO.kt | Adds persisted contentBlocks to message DTOs. |
| shared/src/main/kotlin/io/askimo/core/chat/domain/ChatMessage.kt | Adds contentBlocks to domain model and content_json column to Exposed table. |
| shared/src/main/kotlin/io/askimo/core/agent/repository/AgentRunHistoryRepository.kt | Persists and decodes agent-run contentBlocks via content_json. |
| shared/src/main/kotlin/io/askimo/core/agent/ExternalAgentTemplate.kt | Threads new onToolCall callback through stdout parsing pipeline. |
| shared/src/main/kotlin/io/askimo/core/agent/ExternalAgent.kt | Updates agent contract to separate tool calls from status updates. |
| shared/src/main/kotlin/io/askimo/core/agent/domain/AgentRunRecord.kt | Adds contentBlocks to agent-run records and content_json to table. |
| shared/src/main/kotlin/io/askimo/core/agent/CursorAgent.kt | Adapts Cursor agent parsing signature to include onToolCall (TODO remains). |
| shared/src/main/kotlin/io/askimo/core/agent/CodexAgent.kt | Adapts Codex agent parsing signature to include onToolCall (TODO remains). |
| shared/src/main/kotlin/io/askimo/core/agent/ClaudeAgent.kt | Routes Claude tool-use blocks to structured onToolCall and filters blank thinking. |
| shared/src/main/kotlin/io/askimo/core/agent/AntigravityAgent.kt | Adapts Antigravity agent parsing signature to include onToolCall (TODO remains). |
| desktop-shared/src/main/kotlin/io/askimo/ui/shell/NavigationSidebar.kt | Adds optimistic selection to reduce perceived navigation lag when resuming sessions. |
| desktop-shared/src/main/kotlin/io/askimo/ui/session/SessionManager.kt | Replaces chunk/tool/thinking state with a unified ordered timeline for streaming turns. |
| desktop-shared/src/main/kotlin/io/askimo/ui/common/theme/AppComponents.kt | Simplifies marquee-on-hover using basicMarquee. |
| desktop-shared/src/main/kotlin/io/askimo/ui/chat/MessageComponents.kt | Adds timeline rendering (turnTimelineView) and uses persisted/completed timelines in chat bubbles. |
| desktop-shared/src/main/kotlin/io/askimo/ui/chat/ChatViewModel.kt | Moves streaming UI to activeTimeline and caches completed per-message groups in-session. |
| desktop-shared/src/main/kotlin/io/askimo/ui/chat/ChatView.kt | Wires timeline-based state into the chat view. |
| desktop-shared/src/main/kotlin/io/askimo/ui/chat/ChatState.kt | Updates state model to carry timeline + completed timeline groups. |
| desktop-shared/src/main/kotlin/io/askimo/ui/agent/AgentView.kt | Adds “New chat” affordance to agent header and plumbs conversation state. |
| desktop-shared/src/main/kotlin/io/askimo/ui/agent/AgentRunArea.kt | Switches agentic UI streaming to timeline rendering and persists ordered tool/text blocks. |
| cli/src/test/kotlin/io/askimo/core/chat/dto/TurnTimelineEntryCollapsedEffectiveToolsTest.kt | Adds tests for tool-retry collapsing and grouping behavior. |
Review details
- Files reviewed: 26/26 changed files
- Comments generated: 4
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| val fallbackThinkingContent = if (!hasToolCalls && isLastAiMsg) { | ||
| resolvedGroups | ||
| .filterIsInstance<TurnTimelineGroup.ThinkingGroup>() | ||
| .joinToString("") { it.text } | ||
| } else { | ||
| "" | ||
| } |
| /** | ||
| * Renders timeline groups in chronological order — tool-call and thinking groups reuse this | ||
| * file's own collapsible sections ([toolCallsSection]/[thinkingSection]); token groups render | ||
| * as normal markdown; status groups show as a small muted subtitle. Each group gets its own | ||
| * remembered expand/collapse state, keyed by position — stable since groups are only ever | ||
| * appended at the end for a given message. | ||
| * | ||
| * Used both for the live streaming turn (agentic runs) and for finalized/historical AI | ||
| * messages (via [messageBubble]'s `customBody`), so order is preserved identically in both. | ||
| */ | ||
| @Composable | ||
| internal fun turnTimelineView(groups: List<TurnTimelineGroup>) { | ||
| Column( | ||
| modifier = Modifier.fillMaxWidth(), | ||
| verticalArrangement = Arrangement.spacedBy(Spacing.extraSmall), | ||
| ) { | ||
| groups.forEachIndexed { index, group -> | ||
| key(index) { | ||
| when (group) { |
| val detail = input | ||
| ?.let { it["file_path"] ?: it["command"] ?: it.values.firstOrNull() } | ||
| ?.toString() | ||
| onToolCall(toolName, detail) | ||
| } |
| private val chatContentJson = Json { ignoreUnknownKeys = true } | ||
|
|
||
| private fun decodeChatContentBlocks(raw: String?): List<TurnTimelineEntry> { | ||
| if (raw.isNullOrBlank()) return emptyList() | ||
| return runCatching { chatContentJson.decodeFromString<List<TurnTimelineEntry>>(raw) } | ||
| .getOrDefault(emptyList()) | ||
| } |