From fe1dd9301f663240e7452051bda81eeceb7410a2 Mon Sep 17 00:00:00 2001 From: Waozi Date: Thu, 19 Nov 2026 00:40:11 -0300 Subject: [PATCH] Return Lumi answers to their private Telegram message --- apps/lumi/CHANGELOG.md | 1 + mk/tests-lumi.mk | 4 +- src/apps/lumi_online.zi | 10 +++ src/apps/lumi_telegram.zi | 116 +++++++++++++++++++++++++- tests/lumi_connection_behavior.zi | 36 ++++++++ tests/lumi_connection_test.sh | 6 +- tests/lumi_telegram_input_behavior.zi | 44 ++++++++-- tests/lumi_telegram_input_zi_test.sh | 27 +++--- 8 files changed, 213 insertions(+), 31 deletions(-) diff --git a/apps/lumi/CHANGELOG.md b/apps/lumi/CHANGELOG.md index 8537c87f2..52ecda68d 100644 --- a/apps/lumi/CHANGELOG.md +++ b/apps/lumi/CHANGELOG.md @@ -2,6 +2,7 @@ ## [Unreleased] +- Return Lumi's answer to the private Telegram message that requested it. - Send private developer turns from the owner's Android debug build. - Review complete feedback from the referenced list before one Send or Cancel choice; retries keep the same proposal. diff --git a/mk/tests-lumi.mk b/mk/tests-lumi.mk index fc168c27c..61acfcd79 100644 --- a/mk/tests-lumi.mk +++ b/mk/tests-lumi.mk @@ -68,8 +68,8 @@ lumi-narration-test: $(ZI2C_BIN) sh tests/lumi_narration_test.sh $(ZIRAN_BUILD_DIR)/bin .PHONY: lumi-telegram-input-test -lumi-telegram-input-test: $(ZIRAN_BIN) $(LIBOQS_A) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) | build-laws - @sh tests/lumi_telegram_input_zi_test.sh $(ZIRAN_BIN) $(LIBOQS_A) +lumi-telegram-input-test: $(ZIRAN_BIN) $(LIBOQS_A) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) $(AUDIO_OPUS_A) $(AUDIO_MP3_A) $(AUDIO_VORBIS_LIBS) | build-laws + @AUDIO_CODECS_BUILD_DIR="$(abspath $(AUDIO_CODECS_BUILD_DIR))" sh tests/lumi_telegram_input_zi_test.sh $(ZIRAN_BIN) $(LIBOQS_A) .PHONY: lumi-feedback-delivery-test lumi-feedback-delivery-test: $(ZIRAN_BIN) $(LIBOQS_A) $(SQLITE_SRC) $(SQLITE_AMALGAMATION_H) | build-laws diff --git a/src/apps/lumi_online.zi b/src/apps/lumi_online.zi index 61939d26f..2df4c1b0d 100644 --- a/src/apps/lumi_online.zi +++ b/src/apps/lumi_online.zi @@ -164,6 +164,7 @@ LumiProviderCancel :: () { } LumiOnlineCancel :: () { + lumi_telegram_online = .{} AppToolBeginTurn("") CancelStoredOperation(*lumi_online_operation) LumiProviderCancel() @@ -589,6 +590,10 @@ LumiOnlineAnswer :: (app: *InnerBreeze) -> bool { return false } LumiOnlineAppend(text) + if lumi_telegram_online.id > 0 { + LumiTelegramSaveReply(lumi_telegram_online, text) + lumi_telegram_online = .{} + } LumiOnlineRemember("assistant", text) return true } @@ -788,6 +793,7 @@ LumiFeedbackReplies :: () { // Ends a conversation turn: the answer or a notice, then the actions the // tools asked for. Another round may already be queued. LumiOnlineFinishTurn :: (app: *InnerBreeze, success: bool, status: s32) { + first := ifx lumi_telegram_online.id > 0 then LumiStoreCount() else 0 lumi_pending_route = -1 lumi_pending_practice = -1 if !success || !LumiOnlineAnswer(app) { @@ -808,6 +814,7 @@ LumiOnlineFinishTurn :: (app: *InnerBreeze, success: bool, status: s32) { app_apply_nav_route(app, lumi_pending_route) } if !LumiOnlineWaiting() { + LumiTelegramFinishOnline(first) LumiOnlineNextTurn() } unused LumiStoreSave() @@ -836,6 +843,7 @@ LumiOnlineEnforce :: () { } if (lumi_online_queued || lumi_online_stage == 0) && !turn_allowed && lumi_online_messages.count > 0 && !lumi_online_operation.active { + lumi_telegram_online = .{} lumi_online_queued = false lumi_online_fresh = false lumi_online_provider_turn = false @@ -930,10 +938,12 @@ app_lumi_pump :: (app: *InnerBreeze) { return } if !LumiOnlineRequest(app) { + first := ifx lumi_telegram_online.id > 0 then LumiStoreCount() else 0 lumi_online_queued = false text := LocaleText("lumi_online_unavailable") LumiOnlineAppend(text) LumiOnlineRemember("assistant", text) + LumiTelegramFinishOnline(first) LumiOnlineNextTurn() unused LumiStoreSave() } diff --git a/src/apps/lumi_telegram.zi b/src/apps/lumi_telegram.zi index dd4ce15b4..8a51d266d 100644 --- a/src/apps/lumi_telegram.zi +++ b/src/apps/lumi_telegram.zi @@ -53,6 +53,14 @@ lumi_telegram_response: [65536]u8; lumi_telegram_connection: TelegramConnection; lumi_telegram_current: *InnerBreeze; +LumiTelegramTurn :: struct { + id: s64 + owner: [65]u8 + client: [65]u8 +} +lumi_telegram_online: LumiTelegramTurn; +lumi_telegram_reply_client: [65]u8; + LumiTelegramLink :: () { lumi_telegram_connection.error = false lumi_telegram_connection.link_requested = true @@ -89,9 +97,33 @@ LumiTelegramStatusKey :: () -> string { return ifx lumi_telegram_connection.linked then "lumi_telegram_connected" else "lumi_telegram_body" } +LumiTelegramReplyKey :: (id: s64, client: string) -> string { + key: Vec(u8) + BuilderPrint(*key, "telegram.reply.%.%", client, id) + return BuilderFinish(key) +} + LumiTelegramRequest :: (method: string, path: string, body: string) -> bool { + request := body + lumi_telegram_reply_client = .{} + defer { if request != body { PackageFree(request) } } + if path == "/api/v1/lumi/telegram/ack" && lumi_telegram_connection.ack > 0 && + ReadStringText(body, FieldAt(body, 0, "client"), lumi_telegram_reply_client[:]) == 64 { + key := LumiTelegramReplyKey(lumi_telegram_connection.ack, TextUntilNul(lumi_telegram_reply_client[:])) + reply := storage_get_setting_text(key) + PackageFree(key) + if reply.count > 0 { + out: Vec(u8) + BuilderPrint(*out, "%,\"reply\":", body[:body.count - 1]) + LumiJsonString(*out, reply) + BuilderPrint(*out, "}") + request = BuilderFinish(out) + } else { + lumi_telegram_reply_client = .{} + } + } if BeginStoredRequest(*lumi_telegram_operation, "https://api.waozi.xyz", - NetworkTransport(*lumi_telegram_transfer), method, path, body, + NetworkTransport(*lumi_telegram_transfer), method, path, request, lumi_telegram_response[:], false, *lumi_telegram_session) { unused AppCopyText(AppTextFromCString(storage_user_id_buffer(), 64), lumi_telegram_connection.owner[:]) return true @@ -100,6 +132,49 @@ LumiTelegramRequest :: (method: string, path: string, body: string) -> bool { return false } +// Only rows written during this Telegram turn's execution can form its reply. +LumiTelegramFinish :: (turn: LumiTelegramTurn, first: s32) { + if turn.id <= 0 { return } + out: Vec(u8) + for index: first..LumiStoreCount() - 1 { + row := LumiStoreRow(index) + if row.user || row.developer || row.kind != LUMI_CHAT_TEXT || row.text.count == 0 { continue } + if out.count >= 4096 { break } + if out.count > 0 { BuilderPrint(*out, "\n") } + BuilderPrint(*out, "%", row.text) + } + reply := BuilderFinish(out) + defer { PackageFree(reply) } + LumiTelegramSaveReply(turn, reply) +} + +// Store the answer before acknowledging the claim so a lost transfer can retry. +LumiTelegramSaveReply :: (turn: LumiTelegramTurn, text: string) { + if turn.id <= 0 || TextUntilNul(turn.owner[:]) != AppTextFromCString(storage_user_id_buffer(), 64) { + return + } + end := text.count + if end > 4096 { + end = 4096 + while (text[end] & cast(u8)192) == cast(u8)128 { end -= 1 } + } + reply := text[:end] + if reply.count > 0 { + key := LumiTelegramReplyKey(turn.id, TextUntilNul(turn.client[:])) + defer { PackageFree(key) } + storage_set_setting_text(key, reply) + if storage_setting_text_equals(key, reply) == 0 { return } + } + lumi_telegram_connection.ack = turn.id + lumi_telegram_connection.retry = 0 +} + +LumiTelegramFinishOnline :: (first: s32) { + turn := lumi_telegram_online + lumi_telegram_online = .{} + LumiTelegramFinish(turn, first) +} + // Telegram cannot show an Inner Breeze screen, so the commands that open // Lists or Habits answer with their current content instead. LumiTelegramOverview :: (app: *InnerBreeze, command: string) -> string { @@ -220,6 +295,7 @@ LumiTelegramApply :: (app: *InnerBreeze, document: string) { unused FeedbackChoice(text, cast(s32)choice.value) } } else if type == "message" && text.count < LUMI_INPUT_MAX { + first := LumiStoreCount() // A remote message never moves this device's screen to Lumi. overview := LumiTelegramOverview(app, text) if overview.count > 0 { @@ -229,6 +305,23 @@ LumiTelegramApply :: (app: *InnerBreeze, document: string) { } else { unused LumiSubmit(app, text) } + if id > 0 && MatchLiteral(document, FieldAt(document, at, "can_reply"), "true") { + archive := PackageText("cell.lumi.message.", stable_id) + defer { PackageFree(archive) } + if LumiStoreLatestUserKey() == archive { + turn := LumiTelegramTurn.{.id = id} + unused AppCopyText(AppTextFromCString(storage_user_id_buffer(), 64), turn.owner[:]) + client := storage_get_setting_text("lumi_telegram_client") + if client.count == 64 && AppCopyText(client, turn.client[:]) { + lumi_telegram_connection.ack = 0 + if LumiOnlineWaiting() { + lumi_telegram_online = turn + } else { + LumiTelegramFinish(turn, first) + } + } + } + } } lumi_next_message_id = "" unused LumiStoreSave() @@ -253,8 +346,10 @@ LumiTelegramPump :: (app: *InnerBreeze) { lumi_authorization_disconnect_ready = false lumi_telegram_connection.disconnect_requested = true } + has_account := storage_has_sync_account() != 0 + // Copy the client before another settings read can reuse its buffer. client := storage_get_setting_text("lumi_telegram_client") - if storage_has_sync_account() != 0 && client.count != 64 { + if has_account && client.count != 64 { bytes: [65]u8 if !NativeNonce(null, bytes[:]) { return } storage_set_setting_text("lumi_telegram_client", TextFromCString(*bytes[0])) @@ -266,19 +361,32 @@ LumiTelegramPump :: (app: *InnerBreeze) { TelegramBot.{.name = "inlumi_bot", .relay = "/api/v1/lumi/telegram"}, TelegramTransport.{.start = LumiTelegramRequest, .poll = LumiTelegramPoll, .cancel = LumiTelegramCancel, .receive = LumiTelegramReceive}, - AppTextFromCString(storage_user_id_buffer(), 64), storage_has_sync_account() != 0, + AppTextFromCString(storage_user_id_buffer(), 64), has_account, LumiNodeTrafficAllowed(), LumiOnlineWaiting(), TextUntilNul(client_bytes[:]), TelegramNow(null)) } LumiTelegramPoll :: (output: []u8) -> s32 { if !PollStoredOperation(*lumi_telegram_operation) { return 0 } lumi_telegram_session = lumi_telegram_operation.session - if lumi_telegram_operation.result != cast(s32)AuthResult.AUTH_OK { return -1 } + success := lumi_telegram_operation.result == cast(s32)AuthResult.AUTH_OK + if lumi_telegram_connection.stage == 3 && lumi_telegram_reply_client[0] != 0 && + TextUntilNul(lumi_telegram_connection.owner[:]) == AppTextFromCString(storage_user_id_buffer(), 64) { + // A conflict after a lost response means the same claim may already be + // consumed. If it still exists, the next poll can acknowledge it empty. + if success || lumi_telegram_operation.request.status == 409 { + key := LumiTelegramReplyKey(lumi_telegram_connection.ack, TextUntilNul(lumi_telegram_reply_client[:])) + storage_set_setting_text(key, "") + PackageFree(key) + return 1 + } + } + if !success { return -1 } return ifx CopyCString(TextUntilNul(lumi_telegram_response[:]), output) then 1 else -1 } LumiTelegramCancel :: () { CancelStoredOperation(*lumi_telegram_operation) lumi_telegram_session = Session.{} + lumi_telegram_reply_client = .{} } LumiTelegramReceive :: (document: string) { if lumi_telegram_current != null { LumiTelegramApply(lumi_telegram_current, document) } diff --git a/tests/lumi_connection_behavior.zi b/tests/lumi_connection_behavior.zi index 641577bdd..2750857fc 100644 --- a/tests/lumi_connection_behavior.zi +++ b/tests/lumi_connection_behavior.zi @@ -54,6 +54,8 @@ developer_id: [33]u8; provider_requests: s32; feedback_requests: s32; telegram_requests: s32; +telegram_update_pending: bool; +telegram_answers: s32; spelling_requests: s32; icon_requests: s32; icon_habits: Habits; @@ -136,6 +138,9 @@ ConnectionStart :: (context: *void, request: HttpRequest, output: []u8) -> bool if continuation_test { return ContinuationReply(request, output) } + if telegram_update_pending { + return AppCopyText("{\"message\":{\"role\":\"assistant\",\"content\":\"Telegram answer\"}}", output) + } return AppCopyText("{\"message\":{\"role\":\"assistant\",\"content\":\"Hello from the server\"},\"remaining\":19}", output) } if request.url == "https://api.waozi.xyz/api/v1/lumi/developer" { @@ -171,8 +176,21 @@ ConnectionStart :: (context: *void, request: HttpRequest, output: []u8) -> bool feedback_requests += 1 return AppCopyText("{\"feedback\":[]}", output) } + if request.url == "https://api.waozi.xyz/api/v1/lumi/telegram/ack" { + telegram_answers += 1 + check_true("acknowledgement retains the Telegram update ID", contains(request.body, "\"id\":38")) + check_true("acknowledgement carries a reply", FieldAt(request.body, 0, "reply") >= 0) + answer: [64]u8 + check_true("only the final answer of the claimed turn reaches Telegram", + ToolString(request.body, "reply", answer[:]) == "Telegram answer") + telegram_update_pending = false + return AppCopyText("true", output) + } if contains(request.url, "/api/v1/lumi/telegram") { telegram_requests += 1 + if telegram_update_pending { + return AppCopyText("{\"linked\":true,\"update\":{\"id\":38,\"kind\":\"message\",\"text\":\"Can you explain this?\",\"can_reply\":true}}", output) + } return AppCopyText("{\"linked\":false}", output) } if request.url.count > 17 && request.url[:17] == "http://127.0.0.1:" { @@ -240,6 +258,12 @@ Ask :: (text: string) -> bool { return LumiOnlineStart(text) } +#program_export +TelegramFixtureSubmit :: (text: string) -> bool { + LumiStoreAppend(text, true) + return LumiOnlineStart(text, false) +} + ProviderTail :: (expected: []string) { body := TextUntilNul(provider_body[:]) messages := FieldAt(body, 0, "messages") @@ -433,6 +457,18 @@ Check :: () -> s32 { Pump(*app) check_int("one request to the server's AI", chat_requests, 1) check_true("the server's answer arrives", LastRow() == "Hello from the server") + telegram_update_pending = true + for step: cast(s32)0..29 { + lumi_telegram_connection.retry = 0 + LumiTelegramPump(*app) + if LumiOnlineWaiting() { break } + } + check_true("Telegram receipt waits for the asynchronous answer", LumiOnlineWaiting() && telegram_answers == 0) + check_true("Telegram input keeps the asynchronous turn's origin", lumi_telegram_online.id == 38) + check_true("a regular app turn queues behind the Telegram turn", Ask("Regular app question")) + Pump(*app) + check_int("only the Telegram turn is acknowledged", telegram_answers, 1) + check_true("the app turn completes locally", LastRow() == "Hello from the server") #if #defined(ANDROID_DEBUG) { input := "/dev Review the private coding fixture" check_true("private user request is saved locally", LumiStoreAppendRow(LumiChatRow.{.text = input, .user = true}, true)) diff --git a/tests/lumi_connection_test.sh b/tests/lumi_connection_test.sh index 6a1fa3720..9b0d0af43 100755 --- a/tests/lumi_connection_test.sh +++ b/tests/lumi_connection_test.sh @@ -63,13 +63,11 @@ String __wrap_app_tools_AppToolExecute(InnerBreeze *app, String name, String arg return package_files_PackageText((String){.data = "{\"ok\":true}", .length = 11}, (String){.data = "", .length = 0}); } -/* Telegram input runs Lumi's interpreter, which needs the app's window; - here the relay itself is under test. */ +/* Use the interpreter's normal append and online host calls without a window. */ bool __wrap_lumi_screen_LumiSubmit(InnerBreeze *app, String input) { (void)app; - (void)input; - return false; + return TelegramFixtureSubmit(input); } int main(void) { diff --git a/tests/lumi_telegram_input_behavior.zi b/tests/lumi_telegram_input_behavior.zi index 41fdc22a0..5b35decbd 100644 --- a/tests/lumi_telegram_input_behavior.zi +++ b/tests/lumi_telegram_input_behavior.zi @@ -3,10 +3,12 @@ #import "transaction" #import, file "../src/app/text_buffers.zi"; #import, file "../src/app/app_types.zi"; +#import, file "../src/app/app_clock_host.zi"; #import, file "../src/apps/inbe_types.zi"; #import, file "../src/apps/lumi_types.zi"; #import, file "../src/apps/lumi_online.zi"; #import, file "../src/apps/lumi_connection.zi"; +#import, file "../src/apps/app_tools.zi"; #import, file "../src/storage/storage_settings.zi"; #import, file "../src/storage/sync_async.zi"; #import "keys" @@ -19,7 +21,7 @@ #import, file "../src/apps/lumi_telegram.zi"; #import, file "../src/apps/lumi_store.zi"; #import, file "../src/storage/sync_account.zi"; -#import "crypto" +#import "mesh_client/crypto" #import, file "../src/storage/account_types.zi"; c :: #system_library "c"; @@ -28,6 +30,10 @@ owner: AccountKeys; mirrors: s32; polls: s32; acks: s32; +replies: s32; +reply_status: s32; +claim_client: [65]u8; +fixture_app: InnerBreeze; FakeStart :: (context: *void, request: HttpRequest, output: []u8) -> bool { unused context @@ -51,18 +57,40 @@ FakeStart :: (context: *void, request: HttpRequest, output: []u8) -> bool { } if request.url == "https://api.waozi.xyz/api/v1/lumi/telegram/ack" { acks += 1 + client: [65]u8 + check_true("acknowledgement uses the same client as the claim", + ToolString(request.body, "client", client[:]) == TextUntilNul(claim_client[:])) + if contains(request.body, "\"reply\":") { + replies += 1 + check_true("only the exact update's answer is sent", + contains(request.body, "\"id\":17") && contains(request.body, "\"reply\":\"No habits yet.\"") && + !contains(request.body, "App response")) + reply_status = 202 + } return AppCopyText("true", output) } poll_url := "https://api.waozi.xyz/api/v1/lumi/telegram/updates?client=" - check_true("only input poll reaches transport", request.method == "GET" && - request.url.count == poll_url.count + 64 && request.url[:poll_url.count] == poll_url) + valid_poll := request.method == "GET" && request.url.count == poll_url.count + 64 && + request.url[:poll_url.count] == poll_url + check_true("only input poll reaches transport", valid_poll) + if !valid_poll { return false } + client := request.url[poll_url.count:] + if polls == 0 { + check_true("claim has a client", AppCopyText(client, claim_client[:])) + } else { + check_true("follow-up polls use the same client", client == TextUntilNul(claim_client[:])) + } polls += 1 - return AppCopyText("{\"linked\":true,\"linked_at\":1,\"update\":{\"id\":17,\"kind\":\"message\",\"text\":\"/habits\"}}", output) + return AppCopyText("{\"linked\":true,\"linked_at\":1,\"update\":{\"id\":17,\"kind\":\"message\",\"text\":\"/habits\",\"can_reply\":true}}", output) } FakePoll :: (context: *void, status: *s32) -> s32 { unused context status.* = 200 + if reply_status != 0 { + status.* = reply_status + reply_status = 0 + } return 1 } @@ -105,26 +133,26 @@ Check :: () -> s32 { LumiOnlineAppend("App response") expected := LumiStoreCount() + 2 check_int("full preexisting archive", expected, 144) - app: InnerBreeze - app.enabled_apps = APP_LUMI | APP_HABITS + fixture_app.enabled_apps = APP_LUMI | APP_HABITS lumi_telegram_connection.linked = true lumi_telegram_connection.linked_at = 1 // Exercise persisted post-link history, inbound execution, acknowledgement, // and duplicate input replays through the actual pump and real SQLite. for step: cast(s32)0..29 { lumi_telegram_connection.retry = 0 - LumiTelegramPump(*app) + LumiTelegramPump(*fixture_app) } check_int("app history never posts to Telegram", mirrors, 0) check_true("input polling retained", polls > 0) check_true("input acknowledged", acks > 0) + check_int("unconfirmed response consumes the reply without replay", replies, 1) incoming_record := storage_get_setting_text("cell.lumi.message.telegram-17") check_true("incoming message archived", contains(incoming_record, "/habits")) check_true("incoming message records Telegram as its source", contains(incoming_record, "\"payload\":\"telegram\"")) check_true("incoming message exposes Telegram in the chat row", LumiStoreRow(142).payload == "telegram") check_true("local app message stays unlabelled", LumiStoreRow(140).payload == "") check_true("incoming execution claim retained", storage_get_setting_int("telegram.update.17", 0) == 1) - check_true("input schedules regular account sync", app.ui.sync_requested) + check_true("input schedules regular account sync", fixture_app.ui.sync_requested) check_int("input and its response appended once", LumiStoreCount(), expected) check_true("Lumi response retained", LumiStoreRow(expected - 1).text == "No habits yet." && !LumiStoreRow(expected - 1).user) check_int("all history still enters account outbox", read_db_count("SELECT COUNT(*) FROM sync_outbox WHERE entity_type='cell_record' AND entity_id LIKE 'cell.lumi.message.%'"), expected) diff --git a/tests/lumi_telegram_input_zi_test.sh b/tests/lumi_telegram_input_zi_test.sh index 3ad0fc846..f4d027a68 100644 --- a/tests/lumi_telegram_input_zi_test.sh +++ b/tests/lumi_telegram_input_zi_test.sh @@ -4,20 +4,16 @@ root=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd) ziran=${1:-"$root/build/packages/ziran/build/bin/ziran"} liboqs=${2:-"$root/vendor-builds/linux/x86_64/inbe-liboqs/lib/liboqs.a"} work=${LUMI_TELEGRAM_INPUT_TEST_OUTPUT:-"$root/build/lumi-telegram-input-test"} +audio_dir=${AUDIO_CODECS_BUILD_DIR:-"$root/vendor-builds/linux/x86_64/audio-codecs"} exec 9>"$work.lock" flock 9 unset DISPLAY WAYLAND_DISPLAY XAUTHORITY DBUS_SESSION_BUS_ADDRESS export YUE_DESKTOP_RECOVERY=0 mkdir -p "$work/generated" -"$ziran" build --target=c --define PLATFORM_DESKTOP --root "$root/tests" \ - --module-path "$root/src" --module-path "$root/build/packages/kryon/src/ui" \ - --module-path "$root/build/packages/css/src" $(sh "$root/scripts/package-paths.sh" "$root/build/packages") \ - --module-path "$root/build/packages/kryon/src/backend" \ - --module-path "$root/build/packages/game2d/src" \ - --module-path "$root/build/packages/ziran/std" \ - --module-path "$root/build/packages/mesh-client" \ - --entry lumi_telegram_input_behavior:Check -o "$work/generated" \ - "$root/tests/lumi_telegram_input_behavior.zi" "$root/tests/sync_test_host.zi" +(cd "$root" && + "$ziran" build --project --offline --target=c --no-main --prune-stale \ + --define PLATFORM_DESKTOP --define DESKTOP_HOST --define STORAGE_TEST_REAL_HOST_SERVICES \ + --root "$root" -o "$work/generated" "$root/tests/lumi_telegram_input_behavior.zi") cat > "$work/generated/main.c" <<'C' #include #include @@ -67,13 +63,18 @@ int main(void) C monocypher=$root/build/packages/monocypher/src "${CC:-cc}" -std=c11 -O0 -ffunction-sections -fdata-sections \ - -I"$root/build/packages/ziran/include" -iquote "$work/generated" \ + -I"$root/build/packages/ziran/include" -iquote "$work/generated" -iquote "$work/generated/tests" \ -I"$root/vendor-builds/sqlite" -I"$root/vendor-builds/linux/x86_64/inbe-liboqs/include" \ -I"$monocypher" -I"$monocypher/optional" \ - "$work/generated"/*.c "$root/vendor-builds/sqlite/sqlite3.c" \ + "$work/generated"/*.c "$work/generated/tests"/*.c "$root/vendor-builds/sqlite/sqlite3.c" \ "$monocypher/monocypher.c" "$monocypher/optional/monocypher-ed25519.c" \ - "$liboqs" -Wl,--gc-sections -Wl,--wrap=network_transport_NetworkTransport -Wl,--wrap=AppsInstalledMask -Wl,--wrap=lumi_screen_LumiSubmit -Wl,--wrap=lumi_telegram_LumiTelegramOpen -ldl -lpthread -lz -lm -o "$work/test" + "$liboqs" -Wl,--gc-sections -Wl,--wrap=network_transport_NetworkTransport \ + -Wl,--wrap=AppsInstalledMask -Wl,--wrap=lumi_screen_LumiSubmit -Wl,--wrap=lumi_telegram_LumiTelegramOpen \ + "$audio_dir/libopus/libopus.a" "$audio_dir/libziran_mp3.a" \ + "$audio_dir/libvorbisfile.a" "$audio_dir/libvorbis.a" "$audio_dir/libogg.a" \ + $(pkg-config --libs sdl2 cairo pangocairo fontconfig freetype2 gio-2.0 x11) \ + -ldl -lpthread -lz -lm -o "$work/test" APP_DATA_ROOT=/tmp/inbe-lumi-telegram-input-test/data \ env -u DISPLAY -u WAYLAND_DISPLAY -u XAUTHORITY -u DBUS_SESSION_BUS_ADDRESS \ YUE_DESKTOP_RECOVERY=0 "$work/test" -printf '%s\n' 'Lumi one-way Telegram input, complete persisted history and account outbox checks passed' +printf '%s\n' 'Lumi Telegram input and private reply, persisted history and account outbox checks passed'