games-voxels: parse join link on cold start so taps send a join request
- Commit
56bff6df43f54dbfc6701c6e823f7fcae789d9a9- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-08 02:54 UTC (28 days ago)
- Parents
5fb1084
Tapping a voxels://join invite link with the app closed launched MenuActivity with the link as its launch intent, but only onNewIntent parsed it. Because the activity is singleTop, a cold start goes through onCreate, never onNewIntent, so the link was silently dropped: no toast, no join request, and the user just landed on the menu. Fix: parse the launch intent in onCreate into pendingJoinLink, the same state the existing warm-start path and the join-request effect already consume. No behavior change for warm starts. Verified with a new MenuActivityOnlineTest case that launches the activity cold via a VIEW intent and asserts the sealed request lands in the owner's inbox on FakeVoxelsRelay. Full module suite :games:voxels:testDevUnitTest passes (90 tests, 0 failures).
Diff
games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/MenuActivity.kt
diff --git a/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/MenuActivity.kt b/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/MenuActivity.ktindex 5644907040..1693d9b8a6 100644--- a/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/MenuActivity.kt+++ b/games/voxels/src/main/java/com/vayunmathur/games/voxels/platform/MenuActivity.kt@@ -81,6 +81,10 @@ class MenuActivity : ComponentActivity() { override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState)+ // Cold start: a tapped voxels://join link arrives as this activity's launch intent.+ // singleTop only routes warm starts to onNewIntent, so without this the link is+ // silently dropped and no join request is ever sent.+ parseJoinLink(intent)?.let { pendingJoinLink.value = it } enableEdgeToEdge() setContent { // Standard app theme (Material You / system colors), matching the other apps — the menu
games/voxels/src/test/java/com/vayunmathur/games/voxels/platform/MenuActivityOnlineTest.kt
diff --git a/games/voxels/src/test/java/com/vayunmathur/games/voxels/platform/MenuActivityOnlineTest.kt b/games/voxels/src/test/java/com/vayunmathur/games/voxels/platform/MenuActivityOnlineTest.ktindex 0770b07ad0..5217a28584 100644--- a/games/voxels/src/test/java/com/vayunmathur/games/voxels/platform/MenuActivityOnlineTest.kt+++ b/games/voxels/src/test/java/com/vayunmathur/games/voxels/platform/MenuActivityOnlineTest.kt@@ -166,4 +166,27 @@ class MenuActivityOnlineTest { } assertTrue(sent) }++ @Test fun `cold start join link sends join request`() {+ // A tapped voxels://join link with the app closed launches MenuActivity via a VIEW+ // intent (cold start → onCreate, not onNewIntent). The join request must still go out.+ val joinIntent = Intent(ctx, MenuActivity::class.java).apply {+ action = Intent.ACTION_VIEW+ data = Uri.parse("voxels://join/cold-world-9?owner=owner-remote")+ }+ // Scenario (not a bare Robolectric controller): a bare controller's Compose content+ // never gets its initial composition under Robolectric, so the join effect would+ // never run. The rule's waitForIdle pumps the scenario activity's frames.+ val scenario = androidx.test.core.app.ActivityScenario.launch<MenuActivity>(joinIntent)+ val deadline = System.currentTimeMillis() + 10000+ var sent = false+ while (System.currentTimeMillis() < deadline) {+ composeRule.waitForIdle()+ sent = FakeVoxelsRelay.logs["inbox:owner-remote"].orEmpty().isNotEmpty()+ if (sent) break+ Thread.sleep(50)+ }+ scenario.close()+ assertTrue(sent, "inbox:owner-remote=${FakeVoxelsRelay.logs["inbox:owner-remote"]}")+ } }