Chats as a daily driver: agent chats, photos, copy, rename, offline and recovery
CI / check (push) Canceled after 0s

- New agent chat (Agents tab FAB, route new-agent): GET /devices for the devices linked now; a
  device chip, an optional folder (empty = the device's first root, the server's rule) and the
  mode (manual/edit/auto/plan) go into POST /chats as kind/device/directory/mode. No device
  linked: a sentence saying how. An open agent chat's mode is a chip too.
- Attach: Take a photo (TakePicture into a FileProvider cache file, deleted once uploaded; no
  CAMERA permission), Choose photos (PickMultipleVisualMedia), Choose files.
- Copy under every reply (its text steps) and user message; Rename chat in the menu.
- The new chat's effort is held until the first message and sent with it (EffortChip called
  PATCH, which needs a chat, so the choice was dropped).
- Follow the reply while it streams, decided when the person's own scroll comes to rest; the
  first scroll goes to the real last item (the "older" row shifted the index by one).
- ui/Errors.kt explain(): the server's sentence for a refusal, one "cannot be reached" sentence
  for UnknownHost/Connect/SocketTimeout/NoRouteToHost, used everywhere an error was shown raw.
- A failed send hands its text and attachments back to the composer. A replaced follow's
  CancellationException is no longer shown as an error. A refused stream re-reads the chat.
- The chat list reloads on resume (quietly if rows are shown) and offers Try again.
- Strings: 15 new; Rename chat, Copy message, Copied., Save, Try again, Device and Auto from the
  server's catalogue, the rest translated in strings_own.json. "Plan" was the price plan in
  de/fr/hu (Tarif/Forfait/Csomag) and "Manual" untranslated: own entries fix both.
- ClientTest: an agent chat's body, a plain chat's, and what counts as unreachable.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
HomerandClaude Opus 5.5 committed 2026-11-09 08:09:53 +00:00
1 parent f4891ba402
commit 41dd3c893c
26 files changed
+736 -87

No files matched your search

@@ -1,19 +1,24 @@
package eu.llembas.android
import eu.llembas.android.api.AgentTarget
import eu.llembas.android.api.ApiClient
import eu.llembas.android.api.ApiException
import eu.llembas.android.api.CardAnswer
import eu.llembas.android.api.ShowCard
import eu.llembas.android.api.normaliseBase
import eu.llembas.android.ui.unreachable
import kotlinx.coroutines.test.runTest
import okhttp3.mockwebserver.MockResponse
import okhttp3.mockwebserver.MockWebServer
import org.junit.After
import org.junit.Assert.assertEquals
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import org.junit.Before
import org.junit.Test
import java.net.ConnectException
import java.net.UnknownHostException
class ClientTest {
private lateinit var server: MockWebServer
@@ -34,6 +39,35 @@ class ClientTest {
assertEquals("http://10.1.2.3:8080", normaliseBase("http://10.1.2.3:8080"))
}
@Test
fun anAgentChatNamesItsDeviceAndFolder() = runTest {
server.enqueue(MockResponse().setResponseCode(201).setBody("""{"chat":{"id":"c1","kind":"agent"}}"""))
val made = client().createChat("Look around", mode = "edit", agent = AgentTarget("tok1", " ~/src/shire "))
assertEquals("agent", made.chat.kind)
val body = server.takeRequest().body.readUtf8()
assertTrue(body, body.contains("\"kind\":\"agent\""))
assertTrue(body, body.contains("\"device\":\"tok1\""))
assertTrue(body, body.contains("\"directory\":\"~/src/shire\""))
assertTrue(body, body.contains("\"mode\":\"edit\""))
}
@Test
fun aPlainChatSaysNothingOfDevices() = runTest {
server.enqueue(MockResponse().setResponseCode(201).setBody("""{"chat":{"id":"c2"}}"""))
client().createChat("Hello", effort = "low")
val body = server.takeRequest().body.readUtf8()
assertFalse(body, body.contains("device"))
assertFalse(body, body.contains("kind"))
assertTrue(body, body.contains("\"effort\":\"low\""))
}
@Test
fun unreachableIsNotARefusal() {
assertTrue(unreachable(UnknownHostException("llm.example.org")))
assertTrue(unreachable(ConnectException("refused")))
assertFalse(unreachable(ApiException(403, "No.")))
}
@Test
fun everyCallCarriesTheToken() = runTest {
server.enqueue(MockResponse().setBody("""{"api":1,"account":{"name":"Frodo","email":"f@shire.test"}}"""))