Repository navigation
feat(agent): Introduce persistent title for agent run records - #694
Merged
Merged
Conversation
- Agent run records now include a persistent, human-readable title. - Title generation logic is centralized in `TitleGenerator`. - UI components are updated to display the run title in history panels. - Added event signaling for when a run title is updated.
There was a problem hiding this comment.
🟡 Changes recommended
There are confirmed upgrade/runtime correctness risks (missing DB migration for the new column and a token accumulation race) that can break persistence behavior in production.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
This PR introduces a persistent, human-readable title for agent-run conversations, centralizing deterministic title generation and updating the desktop UI to display and live-refresh these titles in agent history and run views.
Changes:
- Add
titlepersistence foragent_run_historyrecords, plus repository support to bulk-update titles byconversationId. - Introduce shared deterministic fallback title generation via
TitleGeneratorand reuse it in chat session title creation. - Refactor agent UI logic into view models and add an internal event (
AgentRunTitleUpdatedEvent) to patch titles live in the UI.
File summaries
| File | Description |
|---|---|
| shared/src/main/kotlin/io/askimo/core/event/internal/AgentRunTitleUpdatedEvent.kt | Adds an internal event for live title refresh in UI components. |
| shared/src/main/kotlin/io/askimo/core/db/DatabaseManager.kt | Extends agent_run_history schema to include a title column. |
| shared/src/main/kotlin/io/askimo/core/chat/TitleGenerator.kt | Centralizes deterministic fallback title generation logic. |
| shared/src/main/kotlin/io/askimo/core/chat/repository/ChatSessionRepository.kt | Reuses TitleGenerator instead of local title-generation logic. |
| shared/src/main/kotlin/io/askimo/core/agent/repository/AgentRunHistoryRepository.kt | Persists titles and adds bulk update by conversation. |
| shared/src/main/kotlin/io/askimo/core/agent/domain/AgentRunRecord.kt | Adds title to domain model and table definition. |
| desktop-shared/src/main/kotlin/io/askimo/ui/agent/AgentView.kt | Moves workspace/history logic out of composable into AgentsViewModel. |
| desktop-shared/src/main/kotlin/io/askimo/ui/agent/AgentsViewModel.kt | New view model to manage workspace + history list + title event patching. |
| desktop-shared/src/main/kotlin/io/askimo/ui/agent/AgentRunViewModel.kt | New view model owning agent-run execution, transcript state, and title generation/persistence. |
| desktop-shared/src/main/kotlin/io/askimo/ui/agent/AgentRunArea.kt | Refactors composable to delegate most state/behavior to AgentRunViewModel. |
| desktop-shared/src/main/kotlin/io/askimo/ui/agent/AgentHistoryPanel.kt | Displays record.title instead of record.userInput in history rows. |
| cli/src/test/kotlin/io/askimo/core/agent/repository/AgentRunHistoryRepositoryIT.kt | Updates test fixtures to include the new title field. |
Review details
- Files reviewed: 12/12 changed files
- Comments generated: 5
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
724
to
728
| id TEXT PRIMARY KEY, | ||
| workspace_id TEXT NOT NULL REFERENCES workspaces(id), | ||
| conversation_id TEXT NOT NULL, | ||
| title TEXT NOT NULL DEFAULT '', | ||
| user_input TEXT NOT NULL DEFAULT '', |
Comment on lines
+98
to
+102
| val scope = rememberCoroutineScope() | ||
| val historyRepo = remember { DatabaseManager.getInstance().getAgentRunHistoryRepository() } | ||
|
|
||
| // ── Agent state ────────────────────────────────────────────────────────── | ||
| val allAgents = remember { ExternalAgentLoader.all() } | ||
| var agentStateVersion by remember { mutableStateOf(0) } | ||
| var agentStateMap by remember { mutableStateOf(mapOf<String, AgentCardState>()) } | ||
| LaunchedEffect(agentStateVersion) { | ||
| val map = withContext(Dispatchers.IO) { | ||
| allAgents.associate { agent -> | ||
| agent.id to when { | ||
| !agent.isBinaryAvailable() -> AgentCardState.NOT_INSTALLED | ||
| !agent.isConfigured() -> AgentCardState.NEEDS_SETUP | ||
| else -> AgentCardState.READY | ||
| } | ||
| } | ||
| } | ||
| agentStateMap = map | ||
| } | ||
|
|
||
| var selectedAgentId by remember { | ||
| mutableStateOf(ApplicationPreferences.getSelectedAgentId()) | ||
| } | ||
| // Resolve selected agent; fall back to first ready one if saved pref is unavailable | ||
| val selectedAgent = remember(selectedAgentId, allAgents, agentStateMap) { | ||
| allAgents.firstOrNull { it.id == selectedAgentId && agentStateMap[it.id] == AgentCardState.READY } | ||
| ?: allAgents.firstOrNull { agentStateMap[it.id] == AgentCardState.READY } | ||
| } | ||
|
|
||
| val selectedAgentRaw = remember(selectedAgentId, allAgents) { | ||
| allAgents.firstOrNull { it.id == selectedAgentId } ?: allAgents.firstOrNull() | ||
| val latestOnRunCompleted = rememberUpdatedState(onRunCompleted) | ||
| val viewModel = remember(workspace.id) { | ||
| AgentRunViewModel( | ||
| workspace = workspace, |
Comment on lines
+438
to
+442
| val utilityChatClient = AppContext.getInstance().createUtilityClient() | ||
| val aiTitle = utilityChatClient.sendMessage(prompt).trim() | ||
|
|
||
| if (aiTitle.isNotBlank()) { | ||
| withContext(Dispatchers.IO) { historyRepo.updateTitleForConversation(conversationId, aiTitle) } |
Comment on lines
+108
to
+112
| fun updateTitleForConversation(conversationId: String, newTitle: String) { | ||
| transaction(database) { | ||
| AgentRunHistoryTable.update({ AgentRunHistoryTable.conversationId eq conversationId }) { | ||
| it[title] = newTitle | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TitleGenerator.