Skip to content

Refactor: improve summarization and memory management - #765

Merged
haiphucnguyen merged 2 commits into
mainfrom
feature/improvements
Oct 14, 2026
Merged

haiphucnguyen merged 2 commits into
mainfrom
feature/improvements

Conversation

@haiphucnguyen

Copy link
Copy Markdown
Collaborator

Summary

  • Introduce TokenAwareSummarizingMemory for better chat summarization
  • Enhance memory management with auto-prepopulations on fork
  • Improve ChatSessionService with better session handling
  • Add summarization progress tracking to UI

Related Issue(s)

Type of Change

  • 🐛 Bug fix
  • ✨ New feature
  • 💥 Breaking change
  • 📝 Documentation
  • ♻️ Refactor (no functional change)
  • 🧪 Tests
  • 🔧 Chore / tooling / CI

What Changed & Why

How to Test

./gradlew test

Screenshots / Recordings (if applicable)

Checklist

  • I have read the CONTRIBUTING guide
  • My branch is up to date with main
  • I ran ./gradlew spotlessApply and ./gradlew detekt locally
  • I ran ./gradlew test and all tests pass
  • I added/updated tests for my changes (if applicable)
  • I added/updated documentation (if applicable)
  • My commits are signed off (DCO) — git commit -s
  • This PR is focused on a single feature/fix

Additional Notes

- Introduce TokenAwareSummarizingMemory for better chat summarization
- Enhance memory management with auto-prepopulations on fork
- Improve ChatSessionService with better session handling
- Add summarization progress tracking to UI
Copilot AI balanced review requested due to automatic review settings October 14, 2026 04:00

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

Forked history can be lost from model memory, and summarization status has concurrency races.

2 open findings
What changed in this PR

Improves session memory continuity, summarization progress reporting, and local LLM diagnostics.

Changes:

  • Tracks summarization state reactively in the desktop UI.
  • Pre-populates memory when conversations are forked.
  • Resets session-specific UI state and adds slot-status logging.
File Description
LlamaServerProcessManager.kt Logs chat and embedding slot status changes.
TokenAwareSummarizingMemory.kt Exposes reactive summarization state.
ChatSessionService.kt Pre-populates memory for forked sessions.
ChatViewModel.kt Resets session state and observes summarization progress.
ChatView.kt Displays compression progress in the memory banner.
ChatSessionServiceIT.kt Tests forking when memory pre-population fails.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

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.

🔵 Needs a closer look

Fresh and provider-less forked sessions can still lose working-memory continuity or omit progress updates.

0 open findings

2 resolved since last review
Previously missed (2)

In code that hasn't changed since last review

Medium severity Subscribe to memory pressure for newly created sessions

desktop-shared/​src/​main/​kotlin/​io/​askimo/​ui/​chat/​ChatViewModel.kt:1588

This collector is only installed from resumeSession(). Fresh chats take the lazy SessionManager.sendMessage() path, and project chats use bindNewSession(); neither calls subscribeToMemoryPressure(). Consequently isCompressing (and the pressure banner that exposes compression) never updates for a newly created session until the user leaves and reopens it. Start the subscription when a new session becomes bound/created as well.

Medium severity Preserve forked memory when provider initialization fails

shared-jvm/​src/​main/​kotlin/​io/​askimo/​core/​chat/​service/​ChatSessionService.kt:537

If memory construction fails here (the exact no-provider case covered by the new test), the fork has copied display rows but no persisted working memory. Later getOrCreateSharedMemory() only restores session_memory; it never rebuilds from chat_messages, so configuring a provider and sending the next turn starts with empty AI context. Persist the copied memory without requiring a utility client, or retain enough deferred state to populate it on the next successful creation.

🧠 Review effort: Balanced

@haiphucnguyen
haiphucnguyen merged commit cbefb12 into main Oct 14, 2026
12 of 13 checks passed
@haiphucnguyen
haiphucnguyen deleted the feature/improvements branch October 14, 2026 04:27
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