r/androiddev • • 3h ago

Open Source Open-source native Kotlin + Jetpack Compose client for DeepSeek Harness (2.8 MB APK, no WebView)

Built a small native Android client for DeepSeek Harness (DSH) over the weekend because using it from a mobile browser was painful. Pure Kotlin + Jetpack Compose, no WebView, ~2.8 MB APK, MIT licensed.

A few implementation details:

  • Custom Compose Markdown/code rendering, collapsible reasoning traces, compact tool-call rows, and interactive question cards above the composer.
  • OkHttp unary POST RPC + a single multiplexed remote.mux WebSocket stream (plus a read-only session/control stream so a dropped phone connection never stalls tool approvals on desktop).
  • QR pairing with device credentials encrypted via Android Keystore (CredentialVault).
  • Background notifications via WatchService when an agent turn finishes or asks a question, and AttachmentReader to downscale oversized photos (HEIC/50 MP -> <=2048px JPEG) without heavy media libs.
  • Built-in offline Demo mode behind the same DshApi interface so you can poke around the UI without setting up a host.

Repo: https://github.com/bekov001/dsh-android

Curious how folks here keep Compose recompositions low during fast token streaming and handle imePadding() cleanly across OEM keyboards.

1 Upvotes

2 comments sorted by

1

u/FeelingFlamingo9387 3h ago

Very clean footprint at 2.8 MB. For fast token streaming without recomposition storms, two patterns have worked well for me in Compose:

  1. Coalesce token deltas off the UI thread (buffer incoming WebSocket/SSE chunks and emit snapshots on ~24-32ms ticks instead of per-token) and isolate the active streaming message in its own leaf composable so settled messages above it in the LazyColumn remain structurally identical and skipped.
  2. Only re-parse the tail Markdown block while streaming — closed blocks above the active paragraph stay cached as immutable AnnotatedString/block items.

For imePadding() across OEM skins (HyperOS, OneUI, ColorOS), enableEdgeToEdge() plus consumeWindowInsets(innerPadding) from Scaffold before applying imePadding() on the bottom bar prevents double insets and jumpiness when adjustResize interacts inconsistently across Android versions.

Are you re-parsing the full active message string per delta right now, or slicing finished blocks incrementally?

1

u/Fit-Suggestion-8526 2h ago

Right now it still re-parses the full active message string inside remember(source) { parseMarkdown(source) }. Stable key = { it.id } on the LazyColumn keeps finished messages untouched, and an unclosed code fence at the end stays rendered as a code block so it doesn't flicker, but caching closed blocks above the active tail and coalescing deltas on a ~30ms tick is definitely the cleaner next step once responses get long.

Appreciate the consumeWindowInsets tip too. I skipped Scaffold and went straight with systemBarsPadding().imePadding() on the root column, which has been fine on my device so far, though I haven't tested HyperOS yet.