Skip to content

refactor(core): Enhance stability and refactor core logic and database access - #702

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

haiphucnguyen merged 2 commits into
mainfrom
feature/improvements

Conversation

@haiphucnguyen

Copy link
Copy Markdown
Collaborator
  • Improve database concurrency by enabling WAL mode and setting busy timeouts.
  • Correct agent timeline rendering to properly handle streaming and tool retry loops.
  • Refactor ViewModel lifecycle management to consistently use viewModelScope.
  • Update agent classes to handle detailed errors and status markers more gracefully.
  • Apply various UI and style refinements across chat and desktop views.

…e access

- Improve database concurrency by enabling WAL mode and setting busy timeouts.
- Correct agent timeline rendering to properly handle streaming and tool retry loops.
- Refactor ViewModel lifecycle management to consistently use `viewModelScope`.
- Update agent classes to handle detailed errors and status markers more gracefully.
- Apply various UI and style refinements across chat and desktop views.
Copilot AI lite review requested due to automatic review settings September 6, 2026 19:11

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 correctness issues affecting concurrency/finalization in agent run streaming state, and a .gitignore pattern that breaks ignore-glob parsers (e.g. ripgrep).

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR refactors core streaming/timeline logic and database access to improve stability under concurrency, while also tightening ViewModel lifecycle cancellation and refining several desktop UI interactions.

Changes:

  • Enable SQLite WAL + busy timeout via JDBC properties to reduce SQLITE_BUSY under concurrent writers.
  • Fix/strengthen timeline rendering for streaming + tool retry loops, including stable Compose keys and improved tool-group behavior.
  • Refactor desktop ViewModel coroutine ownership to ensure cached/evicted ViewModels cancel all of their work deterministically; plus assorted UI polish (selection, styling, history readability).
File summaries
File Description
shared/src/main/kotlin/io/askimo/core/db/SQLiteDataSourceFactory.kt Removes the standalone SQLite DataSource factory (consolidating creation elsewhere).
shared/src/main/kotlin/io/askimo/core/db/DatabaseManager.kt Adds WAL/busy-timeout/synchronous settings via SQLite JDBC config properties.
shared/src/main/kotlin/io/askimo/core/db/AbstractSQLiteRepository.kt Reuses a lazily connected Exposed Database instance for transactions.
shared/src/main/kotlin/io/askimo/core/chat/dto/TurnTimelineEntry.kt Refines “effective tool call” collapsing to keep successful calls and preserve final failures.
shared/src/main/kotlin/io/askimo/core/agent/CodexAgent.kt Stops emitting lifecycle-only status rows to the user.
shared/src/main/kotlin/io/askimo/core/agent/ClaudeAgent.kt Stops emitting lifecycle-only init/result status rows; keeps usage extraction.
shared/src/main/kotlin/io/askimo/core/agent/AntigravityAgent.kt Improves tool-call parsing and error propagation from result events.
desktop/src/main/kotlin/io/askimo/desktop/settings/VoiceSettingsSection.kt Uses theme surface color for selector cards.
desktop/src/main/kotlin/io/askimo/desktop/project/ProjectView.kt Makes project title/identifiers selectable for easier copying.
desktop-shared/src/test/kotlin/io/askimo/ui/chat/TurnTimelineGroupRenderKeyTest.kt Adds regression tests for stable render keys during streaming.
desktop-shared/src/main/kotlin/io/askimo/ui/shell/EventLogPanel.kt Refactors compact event rows (selection + surface styling).
desktop-shared/src/main/kotlin/io/askimo/ui/common/theme/AppColors.kt Adjusts outlined text-field container color behavior.
desktop-shared/src/main/kotlin/io/askimo/ui/chat/MessageComponents.kt Improves tool timeline rendering (stable keys, auto-collapse, capped scrolling list).
desktop-shared/src/main/kotlin/io/askimo/ui/chat/ChatViewModel.kt Introduces a ViewModel-owned scope and cancels it in cleanup to prevent leaks.
desktop-shared/src/main/kotlin/io/askimo/ui/chat/ChatView.kt Makes session title selectable in the header.
desktop-shared/src/main/kotlin/io/askimo/ui/chat/ChatMessageList.kt Updates day separator label to include time.
desktop-shared/src/main/kotlin/io/askimo/ui/agent/AgentRunViewModel.kt Adds mutex + turn-id invalidation to prevent concurrent/stale timeline writes during streaming/cancel.
desktop-shared/src/main/kotlin/io/askimo/ui/agent/AgentRunArea.kt Passes isStreaming=true for live agent timeline; improves history list readability.
desktop-shared/src/main/kotlin/io/askimo/ui/agent/AgentHistoryPanel.kt Displays agent name in run history rows/tooltips.
cli/src/test/kotlin/io/askimo/core/chat/dto/TurnTimelineEntryCollapsedEffectiveToolsTest.kt Expands regression coverage for the new “effective tool” collapse behavior.
.gitignore Adds .agents ignore entry.
Review details
  • Files reviewed: 20/21 changed files
  • Comments generated: 1
  • 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 541 to +545
onToken = { token ->
currentTurnResponse += token
scope.launch {
isWaitingForFirstEvent = false
timeline = timeline + TurnTimelineEntry.Token(token)
appendTimelineEntry(turnId, TurnTimelineEntry.Token(token))
@haiphucnguyen
haiphucnguyen merged commit 64f2b3d into main Sep 6, 2026
9 of 10 checks passed
@haiphucnguyen
haiphucnguyen deleted the feature/improvements branch September 6, 2026 19:22
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