Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,18 @@

## Unreleased

- Align bot and group chat attachments with the server's file API: upload raw bytes, send file IDs, retain successful uploads for retry, and fetch transcript images by file ID. Deleted files display a placeholder and hide cached images.
- Update the contract generator to 1.3.0 with upload headers, binary request bodies, binary downloads, and the group snapshot event schema.
- Replace installation-linked notification presence with independent foreground chat views for bot and group chats. Acknowledge exact visible reply text and loaded request cards, retain per-chat acknowledgement retries, and clear old views before ending sessions. Presence works without notification permission or FCM registration.

- Refresh task run labels while the task list is open.

- Use server previews for task timing and reasoning, and server-provided reply citations.

- Share generated transcript blocks and job activity types across HTTP and event streams.

- Use server projections for job activity, chat work state, and task timing.

## 0.2.0

- Remove the pages that configure the server or the account: Providers, Judge model, Vision model, Web search, Credentials, Logins, Password managers, Integrations, Coding, Message gateways, Event relay, and Users. The web app is the only client that configures them. Settings gains a Server settings row that opens the web app's settings in the browser, and the links that led to a removed page, such as Provider Settings on a failed reply, the bot editor's web search, integrations, and credentials notes, and Connect a password manager, open the matching web page. The `oauth/callback` deep link is gone with MCP sign-in. Bots' requests for credentials and logins are still answered in the chat.
Expand Down
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,15 @@ Open the navigation drawer › **Settings**, enter the server URL (`http://10.0.

The app doesn't configure the server or the account. Providers, credentials, logins, password managers, integrations, coding, users, message gateways, and the event relay are set in the web app: **Settings** › **Server settings** opens it in the browser.

## Chat files

Bot and group chats upload attachments as raw bytes, then send their file IDs with the message. Failed sends retain attachments for retry. Retries reuse confirmed uploads and the message request ID. Deleted transcript files display **File deleted** instead of an image.

Library browsing is not included.

## Shared API contract

`contract/assets/` holds a copy of the `bot` contract files from `bot/openapi/`. A running server also serves its document at `GET /openapi.json`. `scripts/generate-contract.py` generates Kotlin wire models and operations without external build-time dependencies.
`contract/assets/` holds the HTTP contract and bot, group, activity, and heartbeat event schemas from `bot/openapi/`. A running server also serves its document at `GET /openapi.json`. `scripts/generate-contract.py` generates Kotlin wire models and operations without external build-time dependencies, including upload headers and binary bodies.

```bash
python3 scripts/contract.py generate # Regenerate from contract/assets/
Expand All @@ -50,6 +56,10 @@ CRUMBLE_KEYSTORE_PATH=~/crumble-release.jks CRUMBLE_KEYSTORE_PASSWORD=... ./grad

Without `app/google-services.json`, the app builds cleanly and posts local notifications while connected to `/v1/events`. To enable background delivery via Firebase Cloud Messaging (FCM), place `google-services.json` registering `ng.crumbli.android` and `ng.crumbli.android.dev` in `app/` and set `CRUMBLE_FCM_SERVICE_ACCOUNT_PATH` on the server (see `bot/docs/native-push.md`).

The app reports foreground bot and group chats through the chat-attention API, independently of notification permission and FCM registration. The server uses these reports to suppress account-wide pushes and waits at least three seconds before delivery.

Seen acknowledgements identify the exact reply text or loaded request card visible in the chat viewport. Loading states, collapsed summaries, offscreen content, and unsupported group cards do not count as seen. Acknowledgement retries retain their original chat; account changes discard the old account's pending work.

## License

Licensed under the [GNU Affero General Public License v3.0](LICENSE) (`AGPL-3.0-only`). Third-party components retain their respective licenses.
40 changes: 20 additions & 20 deletions app/src/main/java/dev/crumble/android/MainActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,18 @@ import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.ui.Modifier
import androidx.compose.runtime.LaunchedEffect
import androidx.compose.runtime.CompositionLocalProvider
import androidx.compose.runtime.snapshotFlow
import androidx.core.content.ContextCompat
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.repeatOnLifecycle
import androidx.lifecycle.viewmodel.initializer
import androidx.lifecycle.viewmodel.viewModelFactory
import dev.crumble.android.model.AppModel
import dev.crumble.android.model.ThemeChoice
import dev.crumble.android.storage.AndroidKeyStoreCredentials
import dev.crumble.android.theme.CrumbleTheme
import dev.crumble.android.ui.CrumbleAppScreen
import dev.crumble.android.ui.LocalAttentionWindowID
import dev.crumble.android.push.PushRuntime
import kotlinx.coroutines.delay
import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch

private val LIGHT_BAR_SCRIM = Color.argb(0xe6, 0xff, 0xff, 0xff)
private val DARK_BAR_SCRIM = Color.argb(0x80, 0x1b, 0x1b, 0x1b)
Expand Down Expand Up @@ -72,6 +68,7 @@ class MainActivity : ComponentActivity() {
}
private val model: AppModel
get() = owner.model
private var attentionViewID: String? = null

private val notificationPermissionLauncher = registerForActivityResult(
ActivityResultContracts.RequestPermission(),
Expand All @@ -82,6 +79,9 @@ class MainActivity : ComponentActivity() {

override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
attentionViewID = model.newAttentionView()
model.appActive = false
model.updateChatAttention()

if (push.repliesWanted) requestNotificationPermissionIfNeeded()

Expand All @@ -93,23 +93,17 @@ class MainActivity : ComponentActivity() {
model.followActivity()
handleIncomingIntent(intent)
}
lifecycleScope.launch {
repeatOnLifecycle(Lifecycle.State.RESUMED) {
while (isActive) {
push.refreshPresence()
delay(30_000)
}
}
}

enableEdgeToEdge()
setContent {
LaunchedEffect(model) {
snapshotFlow { model.client }.collect { api -> api?.let { push.configure(it) } }
}
LaunchedEffect(model) {
snapshotFlow { model.appActive to model.route }.collect { (active, route) ->
push.updatePresence(active, route)
snapshotFlow { Triple(model.client, model.appActive, model.route) }.collect { (_, active, route) ->
if (model.attentionWindowID == attentionViewID) {
push.updateVisibility(active, route)
model.updateChatAttention()
}
}
}
val dark = when (model.theme) {
Expand All @@ -123,7 +117,9 @@ class MainActivity : ComponentActivity() {
modifier = Modifier.fillMaxSize(),
color = MaterialTheme.colorScheme.background,
) {
CrumbleAppScreen(model = model)
CompositionLocalProvider(LocalAttentionWindowID provides attentionViewID) {
CrumbleAppScreen(model = model)
}
}
}
}
Expand All @@ -136,17 +132,21 @@ class MainActivity : ComponentActivity() {

override fun onResume() {
super.onResume()
if (model.attentionWindowID != attentionViewID) return
model.appActive = true
model.notificationsAllowed = push.notificationsAllowed()
model.client?.let { push.configure(it) }
push.updatePresence(true, model.route)
push.updateVisibility(true, model.route)
model.updateChatAttention()
}

override fun onPause() {
super.onPause()
if (model.attentionWindowID != attentionViewID) return
model.appActive = false
model.saveDrafts()
push.updatePresence(false, model.route)
push.updateVisibility(false, model.route)
model.updateChatAttention()
}

override fun onDestroy() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Generated by scripts/generate-contract.py 1.2.0. Do not edit.
// Generated by scripts/generate-contract.py 1.3.0. Do not edit.
package dev.crumble.android.generated

import dev.crumble.android.network.HttpRequestData
Expand All @@ -10,8 +10,8 @@ import kotlinx.serialization.json.Json
interface ContractBoundary {
val json: Json
fun escape(value: String): String
fun request(method: String, path: String, body: ByteArray?, timeoutMs: Int): HttpRequestData
suspend fun send(method: String, path: String, body: ByteArray?, timeoutMs: Int): ByteArray
fun request(method: String, path: String, body: ByteArray?, timeoutMs: Int, headers: Map<String, String> = emptyMap()): HttpRequestData
suspend fun send(method: String, path: String, body: ByteArray?, timeoutMs: Int, headers: Map<String, String> = emptyMap()): ByteArray
}

@Serializable(with = OptionalFieldCodec::class)
Expand Down
Loading
Loading