Your phone, on your command. Gotcha is world's first fully on-device AI copilot for Android that turns natural language into real device actions — safely.
feat: update chat compaction to use trimmed history and display summary in UI
Rishabh Bajpaidb223c0563e0
diff --git a/app/src/main/java/com/gotcha/agent/ChatViewModel.kt b/app/src/main/java/com/gotcha/agent/ChatViewModel.ktindex ed0401c..a9ed2ee 100644--- a/app/src/main/java/com/gotcha/agent/ChatViewModel.kt+++ b/app/src/main/java/com/gotcha/agent/ChatViewModel.kt@@ -237,14 +237,15 @@ class ChatViewModel(application: Application) : AndroidViewModel(application) {)try {- val response = llm.chat(listOf(compactionSystem) + llmHistory)+ val response = llm.chat(listOf(compactionSystem) + trimmedHistory())val summary = response.choices.firstOrNull()?.message?.contentif (!summary.isNullOrBlank()) {llmHistory.clear()llmHistory.add(ChatMessage(role = "assistant", content = summary))activeSessionTokenCount = response.usage?.totalTokens ?: 0updateContextUsage()- // Keep the UI messages intact for the user, but history is wiped for the agent+ // Show the compacted message in the chat UI as an assistant message+ appendUi(MessageKind.ASSISTANT, "[System: History Compacted]\n$summary")}} catch (e: Exception) {// If compaction fails, we just continue with normal truncated history