Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
756833d
Start the native Android preview with tested Hermes framing
promptclickrun Oct 27, 2026
c0c285c
Keep Android history clear and clarify setup feedback
promptclickrun Oct 27, 2026
03530e8
Run Android CI within the repository action policy
promptclickrun Oct 27, 2026
591c44d
Avoid stale pooled sockets during Android host discovery
promptclickrun Oct 27, 2026
6f721ff
Record Android preview verification and remaining milestones
promptclickrun Oct 27, 2026
ac54ff8
Plan the functioning Android app and parity acceptance
promptclickrun Oct 27, 2026
c65c476
Track Android parity and match current refresh rejection behavior
promptclickrun Oct 27, 2026
97b5db4
Add encrypted storage for Android sign-in records
promptclickrun Oct 27, 2026
e2d20f3
Handle Android credential key loss and storage failures safely
promptclickrun Oct 27, 2026
f421b45
Restrict record-key helpers and record verified Android storage
promptclickrun Oct 27, 2026
32a6ee9
Add real Hermes authentication and ordered gateway transport
promptclickrun Oct 27, 2026
3d85e28
Persist Android sign-ins and configured computers securely
promptclickrun Oct 27, 2026
1223a15
Android chat connects over a bounded, ordered Hermes WebSocket
promptclickrun Oct 27, 2026
12a79d5
Android computer setup, sign-in and removal run one action at a time
promptclickrun Oct 27, 2026
1b8b1ff
Android chat repository: sessions, history, streaming, sends and prompts
promptclickrun Oct 27, 2026
fb5d452
Android app connects to Hermes: sign-in, saved computers, agents, ses…
promptclickrun Oct 27, 2026
943608a
Android chat recovers from cancelled sends, queue overflow, socket sw…
promptclickrun Oct 27, 2026
9eb8e8d
Gateway hard-close fallback survives the owner scope being cancelled
promptclickrun Oct 27, 2026
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
51 changes: 51 additions & 0 deletions .github/workflows/android.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Android

on:
pull_request:
paths:
- 'android/**'
- 'docs/hermes/**'
- '.github/workflows/android.yml'
push:
branches: [main]
paths:
- 'android/**'
- 'docs/hermes/**'
- '.github/workflows/android.yml'

permissions:
contents: read

concurrency:
group: android-${{ github.ref }}
cancel-in-progress: true

jobs:
build:
runs-on: ubuntu-24.04
defaults:
run:
working-directory: android
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: '17'
cache: gradle
cache-dependency-path: |
android/**/*.gradle.kts
android/gradle/wrapper/gradle-wrapper.properties
- name: Validate Gradle wrapper
run: echo '81a82aaea5abcc8ff68b3dfcb58b3c3c429378efd98e7433460610fecd7ae45f gradle/wrapper/gradle-wrapper.jar' | sha256sum --check --strict
# The pinned GitHub runner includes these SDK packages; use no unapproved setup actions.
- name: Verify Android SDK
run: |
test -d "$ANDROID_HOME/platforms/android-36"
test -d "$ANDROID_HOME/build-tools/35.0.0"
- name: Test, lint and build
run: ./gradlew :hermes:test :app:testDebugUnitTest :app:lintDebug :app:assembleDebug
- uses: actions/upload-artifact@v4
with:
name: bighelp-android-debug
path: android/app/build/outputs/apk/debug/*.apk
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ xcodebuild test -project Bighelp.xcodeproj -scheme Bighelp \
| `BighelpMacUpdater/` | The Mac app's updates (Sparkle) |
| `BighelpTests/`, `BighelpUITests/`, `BighelpVisionUITests/`, `BighelpWatchUITests/` | Tests |
| `BighelpMac/`, `BighelpMacTests/` | An early desktop prototype on sample data. It is not the Mac app. |
| `android/` | Native Kotlin/Compose Android foundation; see its README for build instructions and current limits |
| `services/` | Cloudflare Workers: the notification service, the template and avatar catalogs, and the provider logos |
| `Scripts/` | Tests against real Hermes hosts, the Mac release, and other tools |
| `Design/AvatarKit/` | Avatar artwork and the tools that export it |
Expand All @@ -119,6 +120,7 @@ that work on the code.
For an Android or other client port, start with the platform-neutral
[Hermes transport contract](docs/NATIVE_TRANSPORT.md), including API references,
recovery rules and portable conformance vectors.
The native Kotlin/Compose build-out is in [`android/`](android/README.md).

## Contributing

Expand Down
2 changes: 2 additions & 0 deletions android/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
gradlew text eol=lf
gradlew.bat text eol=crlf
7 changes: 7 additions & 0 deletions android/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.gradle/
.kotlin/
.idea/
local.properties
captures/
*.jks
*.keystore
58 changes: 58 additions & 0 deletions android/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# bighelp for Android

Native Kotlin and Jetpack Compose build-out, tracked in [#644](https://github.com/promptclickrun/bighelp/issues/644).

The integration authority is [the Hermes transport contract](../docs/NATIVE_TRANSPORT.md). The first milestone is described in [the design](../docs/superpowers/specs/2026-10-27-android-foundation-design.md) and [implementation plan](../docs/superpowers/plans/2026-10-27-android-foundation.md).

## Build

Install JDK 17 and an Android SDK with platform 36 and build tools 35.0.0. Set `ANDROID_HOME` or create a local, ignored `local.properties` with `sdk.dir=/absolute/path/to/sdk`. Open this directory in Android Studio, or run from the repository root:

```sh
cd android
./gradlew :hermes:test :app:testDebugUnitTest :app:lintDebug :app:assembleDebug
```

The debug APK is `app/build/outputs/apk/debug/app-debug.apk`, with application ID `app.bighelp.android.debug`. Release signing, Play upload and the permanent release ID are not configured.

The wrapper pins Gradle 8.13 and its distribution checksum. AGP 8.13.2 supports API 36 with JDK 17 and Gradle 8.13 ([Android compatibility table](https://developer.android.com/build/releases/agp-8-13-0-release-notes)). Kotlin and Compose dependencies are pinned; this foundation uses the stable Compose BOM 2025.10.01. Android's [Compose BOM guide](https://developer.android.com/develop/ui/compose/bom) explains dependency alignment.

## Structure

- `hermes/`: pure JVM endpoint and wire policy; tests read `../docs/hermes/vectors/wire.json` directly.
- `app/`: Android lifecycle, platform storage, Compose screens and explicit demo fixtures. In `app/src/main/kotlin/app/bighelp/android/`:
- State, no Android types: `AppState.kt` (routes, setup, demo data), `BighelpAppModel.kt` (every action and rule), `DemoContent.kt` (invented sample chats and the fixed example reply).
- Network: `HostDiscovery.kt` (`HostDiscovery.check(endpoint, consentGranted)`) and `HostStatus.kt` (strict `/api/status` decoding). This is the only code that opens a connection.
- Platform: `MainActivity.kt` (Activity, `ViewModel`, privacy-policy link), `PreviewPreferences.kt` (consent and appearance in app-private preferences).
- Screens and theme: `BighelpApp.kt` (routing and Back), `WelcomeScreens.kt`, `SetupScreen.kt`, `SessionsScreen.kt`, `ChatScreen.kt`, `AgentsScreen.kt`, `SettingsScreen.kt`, `PlacesMenu.kt` (the one menu), `Components.kt`, `BighelpTheme.kt`, `NoodleMark.kt`.
- `../.github/workflows/android.yml`: JVM tests, Android unit checks, lint and APK build on Android/contract changes.

## Evidence and release gates

The foundation is not an Android feature-parity or release-readiness claim. Record executed verification in the PR. Shared framing fixtures and scripted tests do not establish real-host compatibility, physical-device lifecycle, browser callbacks, credential rotation, or notification delivery.

### What the first app milestone does

- **Try the demo** opens sample chats, agents and Settings. Everything is invented and stays on the phone; every demo screen says so, and every reply is the same fixed, labeled example. It needs no agreement because nothing is sent. Controls that work: New chat, Send, search, agent choice, Light/Dark/Same as phone, drafts kept while you look elsewhere, Latest button and Android Back.
- **Connect your computer** asks for the one-time AI data agreement first (stored as `bighelp.privacy.ai-data-agreed` in app-private preferences, excluded from backup and device transfer), then checks one typed address with `GET /api/status`. A host that answers is reported as *found*, never *connected*. It collects no token or password, stores no address or sign-in, opens no gateway and sends no chat.
- Discovery sends no cookies, tokens or custom headers, follows no redirect, reads at most 16,384 decoded bytes, and keeps no response text. Each status request sends `Connection: close` to avoid reusing a closed HTTP/1.x connection; automatic retries remain disabled. HTTPS uses the platform's certificate checks, and `network_security_config.xml` trusts only the phone's built-in (system) certificate authorities. A certificate signed by a private authority that you installed on the phone is not trusted, so a host that uses one looks like "No Hermes computer answered". Use a certificate from a public authority, or plain HTTP on a private network. This preview offers no way to trust a private authority.

### Plain HTTP on a private network

`HermesEndpoint.parse` allows `http://` only with the explicit private-network switch **and** a host that is private by its syntax (see [the connection contract](../docs/hermes/CONNECTION.md)). Android's network security config cannot list those ranges, so `res/xml/network_security_config.xml` permits cleartext at the platform level, and the typed client is the gate: `HostDiscovery` requests only a validated `HermesEndpoint`, and nothing else in the app opens a connection (no WebView, no other HTTP client). Anyone adding network code must go through `HermesEndpoint`, or tighten that file first.

### Tests in this milestone

`app/src/test` holds JVM tests only: `AppModelTest` (consent gating, address refusal, one check at a time, stale and cancelled results, demo send, drafts, search, Back), `HostStatusTest` (strict status shape and bounds) and `HostDiscoveryTest` (real requests to a local scripted server: the GET and its headers, no credentials, no redirect, only HTTP 200, malformed bodies, the 16,384-byte limit with and without a declared length, a cancelled check cancelling the real call, and repeated checks of closing and keep-alive HTTP/1.x hosts). Emulator verification is recorded separately; there are no automated UI tests yet. Demo drafts and chats survive navigation and rotation, but reset after process death or leaving the demo. UI localization is not implemented yet.

### Verified preview snapshot: 2026-10-27

At source commit `591c44d`, all 57 core and 41 app JVM tests pass, debug assemble succeeds, and lint reports 0 errors and 9 dependency-version notices. [Android CI passed on that commit](https://github.com/promptclickrun/bighelp/actions/runs/40552550144). The core suite includes all 55 shared wire vectors; changing the shared vector file invalidates Gradle's test result.

Manual checks on an Android 16 / API 36 emulator exercised demo controls, drafts, keyboard/Back, history/Latest, rotation, light/dark appearance, consent and setup. After the HTTP/1.x connection fix, the initial status check and eight consecutive Check again taps each showed Found with exactly one matching local-fixture receipt and response. A separate two-second delayed check passed. The installed APK's on-device SHA-256 matched the built file.

These are demo and synthetic HTTP/1.0 fixture results. No real Hermes host, HTTPS/HTTP/2 discovery, physical device, lower API level or TalkBack behavior was verified. The rotation checks did not reproduce the suspected jump; they do not rule out a timing race.

Before a working live-chat milestone, implement and test authenticated ordered WebSocket readiness, prompt handlers, the exclusive-submit gate, distinct runtime/stored IDs, a durable uncertainty journal, streaming/history reconciliation and reconnect/replay. Do not expose live Send before those acceptance cases pass. Follow [PORTING.md](../docs/hermes/PORTING.md) in order.

Before Play release, settle the permanent application ID and signing ownership, complete personal developer registration and verification, verify on a physical Android device, add the Android delivery adapter if push is offered, and complete Google's current test/release requirements. No production service is deployed by the Android foundation.
59 changes: 59 additions & 0 deletions android/app/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
plugins {
id("com.android.application")
kotlin("android")
id("org.jetbrains.kotlin.plugin.compose")
}

android {
namespace = "app.bighelp.android"
compileSdk = 36

defaultConfig {
applicationId = "app.bighelp.android"
minSdk = 26
targetSdk = 36
versionCode = 1
versionName = "0.1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
applicationIdSuffix = ".debug"
versionNameSuffix = "-dev"
}
release {
isMinifyEnabled = true
proguardFiles(getDefaultProguardFile("proguard-android-optimize.txt"))
}
}
buildFeatures { compose = true }
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
packaging { resources.excludes += "/META-INF/{AL2.0,LGPL2.1}" }
}

kotlin {
compilerOptions { jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17) }
}

dependencies {
implementation(project(":hermes"))
implementation(platform("androidx.compose:compose-bom:2025.10.01"))
implementation("androidx.activity:activity-compose:1.11.0")
implementation("androidx.lifecycle:lifecycle-viewmodel-compose:2.9.4")
implementation("androidx.lifecycle:lifecycle-runtime-compose:2.9.4")
implementation("androidx.compose.material3:material3")
implementation("androidx.compose.material:material-icons-extended")
implementation("androidx.compose.ui:ui-tooling-preview")
debugImplementation("androidx.compose.ui:ui-tooling")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.10.2")
implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.9.0")
implementation("com.squareup.okhttp3:okhttp:4.12.0")
testImplementation("junit:junit:4.13.2")
testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.2")
testImplementation("com.squareup.okhttp3:mockwebserver:4.12.0")
androidTestImplementation("androidx.test:runner:1.7.0")
androidTestImplementation("androidx.test.ext:junit:1.3.0")
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package app.bighelp.android.live

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import app.bighelp.hermes.HermesEndpoint
import app.bighelp.hermes.SavedConnection
import app.bighelp.hermes.StaleCredentialException
import app.bighelp.hermes.StoredAuth
import java.util.UUID
import kotlinx.coroutines.runBlocking
import org.junit.Assert.*
import org.junit.Test
import org.junit.runner.RunWith

@RunWith(AndroidJUnit4::class)
class AndroidCredentialAdapterTest {
@Test fun credentialCodecRotationAndComputerIsolationUseTheRealAndroidStore() = runBlocking {
val context = InstrumentationRegistry.getInstrumentation().targetContext
val firstID = UUID.randomUUID()
val secondID = UUID.randomUUID()
val endpoint = HermesEndpoint.parse("https://storage-probe.example.test/hermes")
val first = SavedConnection(endpoint, StoredAuth.Bearer("synthetic-access-one", "synthetic-refresh-one", 1_950_000_000), "basic", "fixture")
val next = SavedConnection(endpoint, StoredAuth.Bearer("synthetic-access-two", "synthetic-refresh-two", 1_950_000_001), "basic", "fixture")
val other = SavedConnection(endpoint, StoredAuth.Bearer("synthetic-independent", null, null), "basic", "fixture")
fun firstVault() = AndroidCredentialStore.create(context, firstID)
fun secondVault() = AndroidCredentialStore.create(context, secondID)
try {
firstVault().replace(null, first)
secondVault().replace(null, other)
assertEquals(first, firstVault().load(first.authority))
assertEquals(other, secondVault().load(other.authority))
firstVault().replace(first, next)
try {
firstVault().delete(first)
fail("A stale sign-out must not delete the new token")
} catch (_: StaleCredentialException) {
}
assertEquals(next, firstVault().load(next.authority))
assertEquals(other, secondVault().load(other.authority))
} finally {
firstVault().load(first.authority)?.let { firstVault().delete(it) }
secondVault().load(other.authority)?.let { secondVault().delete(it) }
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
package app.bighelp.android.storage

import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import app.bighelp.hermes.chat.ChatStoreException
import app.bighelp.hermes.chat.ConversationScope
import app.bighelp.hermes.chat.DraftRecord
import app.bighelp.hermes.chat.HostScope
import app.bighelp.hermes.chat.RecordKey
import app.bighelp.hermes.chat.RecordKind
import app.bighelp.hermes.chat.StoreOp
import java.io.File
import java.util.UUID
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.runBlocking
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Assert.assertTrue
import org.junit.Test
import org.junit.runner.RunWith

/**
* The chat store on the phone's own filesystem: flushing, the atomic rename that compaction relies on, the
* directory sync and a restart (a second store over the same folder). Synthetic data, in a folder of its own.
*/
@RunWith(AndroidJUnit4::class)
class AndroidChatStoreDeviceTest {
private val context = InstrumentationRegistry.getInstrumentation().targetContext
private val directory = File(context.noBackupFilesDir, "chat-store-device-test-${UUID.randomUUID()}")
private val host = HostScope(UUID.randomUUID().toString(), "https://device-probe.example.test", "dashboard-session")
private val scope = ConversationScope(host, "default", "anchor-1")

@After fun clean() { directory.deleteRecursively() }

private fun draft(text: String) = StoreOp.Put(RecordKey.draft(scope), DraftRecord(scope, text, updatedAtMillis = 1).encode())

@Test fun aCommitAndACacheSurviveANewStoreOverTheSameFolderOnTheRealFilesystem() = runBlocking {
val first = AndroidChatStore(directory, Dispatchers.IO)
first.commit(listOf(draft("typed on the device")))
first.putCache(RecordKey.history(scope), ByteArray(2_000) { 5 })
first.close()

val second = AndroidChatStore(directory, Dispatchers.IO)
assertEquals("typed on the device", DraftRecord.decode(scope, second.read(RecordKey.draft(scope))!!).text)
assertEquals(2_000, second.read(RecordKey.history(scope))!!.size)
assertEquals(listOf("anchor-1"), second.keys(host, RecordKind.Draft).map { it.anchor })
}

@Test fun compactionRenamesTheNewLogOverTheOldOneAndTheRecordsAreStillThere() = runBlocking {
val store = AndroidChatStore(directory, Dispatchers.IO, SystemChatStoreFiles, ChatStoreTuning(compactionMinimumGarbage = 20_000))
repeat(120) { store.commit(listOf(draft("edit $it " + "x".repeat(500)))) }
assertTrue("The log stayed small: ${File(directory, AndroidChatStore.LOG_NAME).length()}", File(directory, AndroidChatStore.LOG_NAME).length() < 120_000)
store.close()
val reopened = AndroidChatStore(directory, Dispatchers.IO)
assertEquals("edit 119 " + "x".repeat(500), DraftRecord.decode(scope, reopened.read(RecordKey.draft(scope))!!).text)
assertNull(File(directory, AndroidChatStore.COMPACT_NAME).takeIf { it.exists() })
}

@Test fun anOversizeDraftIsRefusedOnTheDeviceToo() = runBlocking {
val store = AndroidChatStore(directory, Dispatchers.IO)
val failure = runCatching { store.commit(listOf(StoreOp.Put(RecordKey.draft(scope), ByteArray(RecordKind.Draft.maximumBytes + 1)))) }.exceptionOrNull()
assertEquals(ChatStoreException.Kind.TooLarge, (failure as ChatStoreException).kind)
assertTrue(store.keys(host, RecordKind.Draft).isEmpty())
}
}
Loading
Loading