Skip to content

feat(agent): Introduce persistent title for agent run records - #694

Merged
haiphucnguyen merged 2 commits into
mainfrom
feature/improvements
Sep 4, 2026
Merged

haiphucnguyen merged 2 commits into
mainfrom
feature/improvements

Conversation

@haiphucnguyen

Copy link
Copy Markdown
Collaborator
  • 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.

- 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.
Copilot AI lite review requested due to automatic review settings September 4, 2026 01:45

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 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 title persistence for agent_run_history records, plus repository support to bulk-update titles by conversationId.
  • Introduce shared deterministic fallback title generation via TitleGenerator and 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
}
@haiphucnguyen
haiphucnguyen merged commit 8c031dd into main Sep 4, 2026
9 of 10 checks passed
@haiphucnguyen
haiphucnguyen deleted the feature/improvements branch September 4, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants