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.
fix(ui): the bell shows the interrupted-task entry as unread straight away (#105)
Durganshu7e871c75fea4
diff --git a/app/src/main/java/com/gotcha/MainActivity.kt b/app/src/main/java/com/gotcha/MainActivity.ktindex 0be4309..506efaa 100644--- a/app/src/main/java/com/gotcha/MainActivity.kt+++ b/app/src/main/java/com/gotcha/MainActivity.kt@@ -325,6 +325,13 @@ class MainActivity : ComponentActivity() {}}+ // An inbox entry added after onResume read the badge (issue #105).+ lifecycleScope.launch {+ chatViewModel.inboxChanges.collect {+ inboxUnread = withContext(Dispatchers.IO) { localNotificationStore.unreadCount() }+ }+ }+// Collect exported chat content and launch a share sheetlifecycleScope.launch {chatViewModel.exportContent.collect { markdown ->diff --git a/app/src/main/java/com/gotcha/agent/ChatViewModel.kt b/app/src/main/java/com/gotcha/agent/ChatViewModel.ktindex 917e1d0..281255e 100644--- a/app/src/main/java/com/gotcha/agent/ChatViewModel.kt+++ b/app/src/main/java/com/gotcha/agent/ChatViewModel.kt@@ -432,6 +432,14 @@ class ChatViewModel(application: Application) : AndroidViewModel(application), Aval permissionRequests: SharedFlow<String> = _permissionRequests.asSharedFlow()/** Exported chat markdown content the Activity should share. */+ /**+ * Bumped when the view model adds an inbox entry of its own (an interrupted+ * run, issue #105), so the bell re-reads its unread count: the Activity's+ * read in onResume can come before the entry exists.+ */+ private val _inboxChanges = MutableStateFlow(0)+ val inboxChanges: StateFlow<Int> = _inboxChanges.asStateFlow()+private val _exportContent = MutableSharedFlow<String>(extraBufferCapacity = 2)val exportContent: SharedFlow<String> = _exportContent.asSharedFlow()@@ -924,6 +932,7 @@ class ChatViewModel(application: Application) : AndroidViewModel(application), Abody = INTERRUPTED_INBOX_BODY,target = NotificationTarget.Chat(sessionId))+ _inboxChanges.update { it + 1 }}withContext(Dispatchers.IO) { runMarker.clear() }}diff --git a/app/src/test/java/com/gotcha/agent/ChatViewModelInterruptedRunTest.kt b/app/src/test/java/com/gotcha/agent/ChatViewModelInterruptedRunTest.ktindex f676437..363b80c 100644--- a/app/src/test/java/com/gotcha/agent/ChatViewModelInterruptedRunTest.kt+++ b/app/src/test/java/com/gotcha/agent/ChatViewModelInterruptedRunTest.kt@@ -91,8 +91,10 @@ class ChatViewModelInterruptedRunTest {saveHalfFinishedChat()anotherProcess().mark(sessionId)- startGotcha()+ val viewModel = startGotcha()+ // The bell re-reads its badge: the entry arrives after onResume read it.+ assertEquals(1, viewModel.inboxChanges.value)val session = runBlocking { historyRepository.loadSession(sessionId) }!!assertEquals(MessageKind.ERROR, session.displayMessages.last().kind)assertTrue(session.displayMessages.last().text.startsWith("This task was interrupted"))