Phone actions: the confirm card and the capability (harness spec 3.6.0, server e463621)
CI / check (push) Canceled after 0s
CI / check (push) Canceled after 0s
- Contract and strings pinned at server dev e463621 (event_ask_phone.json); tokens unchanged.
- Every message declares client ["phone_actions"] (POST /chats and /chats/{id}/messages).
- CardItem.phone; a phone_action card (chat card sheet, and inline in the assistant's sheet):
the model's summary, how it will be done, its facts, the map app to use when Settings leaves
it open, Google Maps' limits said; Cancel answers declined, Do it runs ActionRunner and
answers {result: {status, message}} -- done or failed with why. Locked: "unlock first".
- Executor on the spec's fields: alarm time HH:MM/days/label, timer, calendar_event
(start/end local, notes), sms_draft (numbers only; names left to the person), email_draft
with cc, dial, open_app by name, open_url, media command, torch on, settings_panel,
automation_intent (Tasker's ACTION_TASK by name with values as local variables, else
LLeMbas's own AUTOMATION broadcast), navigate (replace_route -> OsmAnd force), add_stop,
search_nearby (near), stop_navigation. Tool-result reasons in English, for the model.
- Tests: PhoneActionsTest reads the fixture; shots 35-38 phone cards.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
26 files changed
+944
-69
No files matched your search
@@ -5,7 +5,11 @@ import eu.llembas.android.actions.NavApp
|
||||
import eu.llembas.android.actions.NavIntents
|
||||
import eu.llembas.android.actions.PhoneActions
|
||||
import eu.llembas.android.actions.Place
|
||||
import eu.llembas.android.api.AskFrame
|
||||
import eu.llembas.android.api.CardAnswer
|
||||
import eu.llembas.android.api.LembasJson
|
||||
import eu.llembas.android.api.PhoneResult
|
||||
import eu.llembas.android.ui.chat.phoneFacts
|
||||
import kotlinx.serialization.json.jsonObject
|
||||
import org.junit.Assert.assertEquals
|
||||
import org.junit.Assert.assertFalse
|
||||
@@ -44,11 +48,31 @@ class PhoneActionsTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
fun aBroadcastNeverNamesASystemAction() {
|
||||
assertTrue(PhoneActions.broadcastAllowed("net.dinglisch.android.tasker.ACTION_TASK"))
|
||||
assertTrue(PhoneActions.broadcastAllowed("lembas.lights_off"))
|
||||
assertFalse(PhoneActions.broadcastAllowed("android.intent.action.BOOT_COMPLETED"))
|
||||
assertFalse(PhoneActions.broadcastAllowed("com.android.something"))
|
||||
assertFalse(PhoneActions.broadcastAllowed("has spaces"))
|
||||
fun clockTimesAndNumbersAreCheckedAgain() {
|
||||
assertEquals(7 to 5, PhoneActions.clock("07:05"))
|
||||
assertNull(PhoneActions.clock("24:00"))
|
||||
assertNull(PhoneActions.clock("7 am"))
|
||||
// A name the messaging app would have to find is left out: the person picks the contact.
|
||||
assertEquals(listOf("+421 900 123 456"), PhoneActions.smsNumbers(listOf("+421 900 123 456", "Sam")))
|
||||
assertTrue(PhoneActions.urlAllowed("HTTPS://example.org"))
|
||||
assertFalse(PhoneActions.urlAllowed("javascript:alert(1)"))
|
||||
assertFalse(PhoneActions.urlAllowed("https://"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun theCardSaysWhatWillHappenFromTheContract() {
|
||||
val frame = requireNotNull(javaClass.classLoader!!.getResource("event_ask_phone.json")).readText()
|
||||
val cards = LembasJson.decodeFromString(AskFrame.serializer(), frame).cards
|
||||
assertEquals(listOf("phone_action"), cards.map { it.kind }.distinct())
|
||||
val phones = cards.map { requireNotNull(it.items.single().phone) }
|
||||
assertEquals("07:00 · mon tue wed thu fri · Work", phoneFacts(phones[0]))
|
||||
assertEquals("Bakery (48.894, 18.044) · Home (1 Bagshot Row, Hobbiton) · drive", phoneFacts(phones[1]))
|
||||
assertEquals("Bakery (Bakery, Bywater) · Home (1 Bagshot Row, Hobbiton)", phoneFacts(phones[2]))
|
||||
assertEquals("", phoneFacts(phones[3]))
|
||||
// The answer the server reads: {"result": {"status", "message"}}, nothing else.
|
||||
assertEquals(
|
||||
"""{"result":{"status":"done","message":"ok"}}""",
|
||||
LembasJson.encodeToString(CardAnswer.serializer(), CardAnswer(result = PhoneResult("done", "ok"))),
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -27,6 +27,7 @@ import com.github.takahirom.roborazzi.captureRoboImage
|
||||
import com.github.takahirom.roborazzi.inspectionMode
|
||||
import com.github.takahirom.roborazzi.size
|
||||
import eu.llembas.android.R
|
||||
import eu.llembas.android.actions.NavApp
|
||||
import eu.llembas.android.assist.AssistActions
|
||||
import eu.llembas.android.assist.AssistSheetContent
|
||||
import eu.llembas.android.assist.AssistSheetFrame
|
||||
@@ -41,6 +42,8 @@ import eu.llembas.android.ui.chat.ChatActions
|
||||
import eu.llembas.android.ui.chat.ChatContent
|
||||
import eu.llembas.android.ui.chat.CodeBlock
|
||||
import eu.llembas.android.ui.chat.ModelPickerContent
|
||||
import eu.llembas.android.ui.chat.PhoneCardContent
|
||||
import eu.llembas.android.ui.chat.PhoneCardState
|
||||
import eu.llembas.android.ui.chat.TuneContent
|
||||
import eu.llembas.android.ui.chat.modelId
|
||||
import eu.llembas.android.ui.home.ArchivedActions
|
||||
@@ -320,6 +323,27 @@ class ScreenShots {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The phone_action cards as the server's contract has them (`event_ask_phone.json`): an
|
||||
* alarm, a route through a stop with both map apps to choose from, a stop added in Google
|
||||
* Maps (its limit said), and the phone still locked.
|
||||
*/
|
||||
@Test
|
||||
fun phoneActions() {
|
||||
val frame = requireNotNull(javaClass.classLoader!!.getResource("event_ask_phone.json")).readText()
|
||||
val phones = eu.llembas.android.api.LembasJson.decodeFromString(eu.llembas.android.api.AskFrame.serializer(), frame).cards
|
||||
.map { requireNotNull(it.items.single().phone) }
|
||||
val both = listOf(NavApp.GoogleMaps, NavApp.OsmAnd)
|
||||
val card: (Int, NavApp?, PhoneCardState) -> @Composable () -> Unit = { i, chosen, state ->
|
||||
{ Column(Modifier.fillMaxSize().padding(16.dp)) { PhoneCardContent(phones[i], both, chosen, state) } }
|
||||
}
|
||||
shoot("35-phone-alarm", content = card(0, null, PhoneCardState()))
|
||||
shoot("35-phone-alarm", Phone.Small, fontScale = 1.5f, content = card(0, null, PhoneCardState()))
|
||||
shoot("36-phone-navigate-pick", content = card(1, null, PhoneCardState()))
|
||||
shoot("37-phone-add-stop-google", content = card(2, NavApp.GoogleMaps, PhoneCardState()))
|
||||
shoot("38-phone-stop-locked", content = card(3, NavApp.OsmAnd, PhoneCardState(locked = true)))
|
||||
}
|
||||
|
||||
/** "Ask LLeMbas" from another app's share menu: a link, and a picture with a file. */
|
||||
@Test
|
||||
fun share() {
|
||||
|
||||
Reference in new issue
Block a user