Modern Apps git

← Modern-Apps.git

kart: show the LAN pairing code and driver names in the lobby

Commit
78e925fb730367514e45ed81b14f7df39eccab67
Author
Vayun Mathur <[email protected]>
When
2026-12-05 13:45 UTC (19 hours ago)
Parents
daaf93d
LAN multiplayer could not actually be joined for the first time:
the controller host puts a six-digit pair code on this device when
an unknown phone handshakes, and the joining phone (Games Hub
controller pad) asks its user to type the code shown on the host -
but kart never displayed it, so first-time pairing stalled forever
and only previously remembered phones could ever get in.

- KartHost mirrors the inner host's pairing code into a
  pairingCodeFlow (the SDK exposes it as a plain property, so it is
  polled at 250 ms while the host runs); KartViewModel re-exposes
  it and KartGamePage passes it to the screen.
- The lobby now shows the code while a phone is pairing, and lists
  the seated drivers by name under the seat count.
- RacePhase.Racing/Results carry a seat-id to display-name map
  snapshotted at race start, so standings and results name LAN
  drivers (and gamepads) instead of calling everyone You; AI seats
  still render as rivals.
- Lobby copy and host/pairing comments describe the phone host
  instead of a TV (the persisted identity key prefix is unchanged -
  it is a stored key name, and changing it would orphan pairings).

Tests: lobby renders the pairing code and driver names and hides
the code row when nobody is pairing; racing standings use the LAN
names; the host flow starts null; the ViewModel exposes no code
until a phone is mid-handshake.

Diff

games/kart/src/main/java/com/vayunmathur/games/kart/domain/GameInputLoop.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/domain/GameInputLoop.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/domain/GameInputLoop.ktindex 41a105cabd..de9898df57 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/domain/GameInputLoop.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/domain/GameInputLoop.kt@@ -32,7 +32,7 @@ data class KartControl(  * one [KartControl] per player per tick.  *  * Deadzones and the cubic curve match the voxels `Joystick` feel (0.15 deadzone, then- * `0.2a + 0.8a³`), so a phone stick and a TV gamepad with the same deflection drive the same line.+ * `0.2a + 0.8a³`), so a phone stick and a gamepad with the same deflection drive the same line.  * The game reads the output on its own tick; samples are idempotent snapshots, so a missed frame  * costs one tick of staleness and repairs itself.  */
games/kart/src/main/java/com/vayunmathur/games/kart/platform/AppBackupAgent.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/AppBackupAgent.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/AppBackupAgent.ktindex 7e3c1b3916..58dee37565 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/AppBackupAgent.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/AppBackupAgent.kt@@ -8,7 +8,7 @@ class AppBackupAgent : BaseBackupAgent() {      * The "settings" file alone: it holds the cup pointer and the lifetime      * counters. The pairing identity lives in its own `kart_identity` file,      * deliberately off this list — restoring identity keys onto a different-     * TV would let that TV impersonate this one to an already-paired phone.+     * phone would let that phone impersonate this one to an already-paired phone.      */     override val datastoreNames: List<String> get() = listOf("settings") }
games/kart/src/main/java/com/vayunmathur/games/kart/platform/GamepadDirect.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/GamepadDirect.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/GamepadDirect.ktindex 5a10da4b24..97ea2e23f9 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/GamepadDirect.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/GamepadDirect.kt@@ -23,7 +23,7 @@ private const val TAG = "GamepadDirect" private const val HAT_THRESHOLD = 0.5f  /**- * Physical gamepads plugged into the TV: enumeration, buttons, sticks, hot-plug.+ * Physical gamepads connected to this device: enumeration, buttons, sticks, hot-plug.  *  * Each pad takes a seat through the same [ControllerHost] local-player path the phones use, so  * downstream everything is indistinguishable: the race loop reads `host.inputs` and `host.lobby`
games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartHost.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartHost.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartHost.ktindex d3464a739e..85a34fb639 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartHost.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartHost.kt@@ -26,15 +26,18 @@ private const val TAG = "KartHost" private const val PREFS = "kart_host" private const val KEY_HOST_ID = "host_id" +/** How often the pairing code is mirrored from the host into [KartHost.pairingCodeFlow]. */+private const val PAIRING_POLL_MS = 250L+ /**- * The TV-side lobby owner: advertises `_gamepad._tcp`, accepts phones, and exposes the+ * The LAN lobby owner: advertises `_gamepad._tcp`, accepts phones, and exposes the  * [ControllerHost] fan-in the race loop reads.  *  * Key material is injectable: [publicBundle] is the ML-KEM+ML-DSA bundle from `:library:e2ee-p2p`  * (`PqcIdentity.publicBundle`), [unsealSecret] opens a sealed session secret with the KEM private  * half. When [pairingStore] is present, device keys and the host id live in the same non-backed-up- * file as the identity, so a restored backup can neither impersonate this TV nor silently inherit- * its paired phones; without it (tests) they fall back to private prefs. Either way the host id+ * file as the identity, so a restored backup can neither impersonate this phone nor silently+ * inherit its paired phones; without it (tests) they fall back to private prefs. Either way the host id  * is a stable id minted once, so re-pairing survives restarts.  *  * PQC stays behind the lambdas deliberately: this module never touches the native library@@ -81,6 +84,15 @@ class KartHost(     /** The pair code on screen, if a phone is mid-handshake. Null until [start]. */     val pairingCode: String? get() = inner?.pairingCode +    private val _pairingCode = MutableStateFlow<String?>(null)++    /**+     * [pairingCode] as a flow, for the lobby UI. The inner host only exposes+     * the code as a plain property, so it is polled while the host runs;+     * a code that appears between polls shows within a quarter second.+     */+    val pairingCodeFlow: StateFlow<String?> = _pairingCode.asStateFlow()+     /**      * Resolve the host id, build the [ControllerHost], and start advertising + accepting. Safe to      * call repeatedly; the second call is a no-op rather than a second lobby.@@ -100,6 +112,12 @@ class KartHost(         inner = host         scope.launch { host.lobby.collect { _lobby.value = it } }         scope.launch { host.inputs.collect { _inputs.value = it } }+        scope.launch {+            while (true) {+                _pairingCode.value = host.pairingCode+                kotlinx.coroutines.delay(PAIRING_POLL_MS)+            }+        }         scope.launch { acceptLoop(hostId, host) }     } @@ -120,7 +138,7 @@ class KartHost(             return         }         advertiser.advertise(-            friendlyName = android.os.Build.MODEL ?: "TV",+            friendlyName = android.os.Build.MODEL ?: "Phone",             deviceId = hostId,             port = server.localPort,             gameId = "kart",
games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartPairingStore.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartPairingStore.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartPairingStore.ktindex 0b66c0b313..30f01510ba 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartPairingStore.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartPairingStore.kt@@ -12,13 +12,13 @@ import kotlinx.coroutines.flow.map private val Context.kartIdentityStore by preferencesDataStore(name = "kart_identity")  /**- * The TV's long-term secrets: its own ML-KEM identity, and one device key per paired phone.+ * The phone's long-term secrets: its own ML-KEM identity, and one device key per paired phone.  *  * Follows the cast/tv `PairingStore` shape (an [E2eeKeyStore] for  * `PqcIdentity.loadOrCreate`, plus remembered device keys), with one deliberate  * difference: keys live in their own `kart_identity` DataStore file, NOT in the  * shared `datastore_default` that [AppBackupAgent] ships to cloud. Restoring- * identity keys onto a different TV would let that TV impersonate this one to+ * identity keys onto a different phone would let that phone impersonate this one to  * an already-paired phone, with no code shown to give it away — so the file  * stays off the backup list by living outside `datastoreNames`.  *@@ -51,7 +51,7 @@ class KartPairingStore(private val context: Context) : E2eeKeyStore {     }      /**-     * This TV's own stable id, generated once.+     * This phone's own stable id, generated once.      *      * Not derived from the ML-KEM bundle: the id is published in the mDNS      * record, and a public identifier derived from a key is one more thing to
games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartViewModel.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartViewModel.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartViewModel.ktindex dd05b6b847..a1ee7f09ac 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartViewModel.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/KartViewModel.kt@@ -44,7 +44,7 @@ class KartViewModel(application: Application) : AndroidViewModel(application),     val uiState: StateFlow<KartUiState> = _uiState.asStateFlow()      /**-     * The TV lobby, backed by a real post-quantum identity.+     * The LAN lobby, backed by a real post-quantum identity.      *      * The identity loads off the main thread (keygen on first run touches the      * native PQC library): until it lands, [KartHost] refuses handshakes@@ -70,6 +70,9 @@ class KartViewModel(application: Application) : AndroidViewModel(application),         pairingStore = pairingStore,     ) +    /** LAN pair code to show while another phone is joining; null when nobody is pairing. */+    val pairingCode: StateFlow<String?> = kartHost.pairingCodeFlow+     private val _racePhase = MutableStateFlow<RacePhase>(RacePhase.Lobby(kartHost.lobby.value))     /** Lobby → countdown → race → results. The garage reads this alongside [uiState]. */     val racePhase: StateFlow<RacePhase> = _racePhase.asStateFlow()@@ -236,12 +239,14 @@ class KartViewModel(application: Application) : AndroidViewModel(application),     }      private fun beginRace(seat: String) {-        val playerIds = kartHost.latestLobby().slots.map { it.playerId }+        val slots = kartHost.latestLobby().slots+        val playerIds = slots.map { it.playerId }         val seats = if (playerIds.isEmpty()) listOf(seat) else playerIds+        val names = slots.associate { it.playerId to it.displayName }         if (KartNative.isAvailable) {-            beginNativeRace(seat, seats)+            beginNativeRace(seat, seats, names)         } else {-            beginPlaceholderRace(seat, seats)+            beginPlaceholderRace(seat, seats, names)         }     } @@ -249,7 +254,7 @@ class KartViewModel(application: Application) : AndroidViewModel(application),      * The native race: the Rust engine owns the sim (seats, AI, items, laps) and ticks itself on      * its own render thread; this loop only feeds inputs and polls standings for the HUD.      */-    private fun beginNativeRace(seat: String, seats: List<String>) {+    private fun beginNativeRace(seat: String, seats: List<String>, names: Map<String, String>) {         KartNative.startRace(seats)         kartHost.host?.startRace()         val itemLatch = mutableMapOf<String, Boolean>()@@ -291,6 +296,7 @@ class KartViewModel(application: Application) : AndroidViewModel(application),                         winner = ordered.first().player,                         order = order,                         bestLapMs = lapState.times.bestLapMs,+                        names = names,                     )                     return@launch                 }@@ -303,12 +309,13 @@ class KartViewModel(application: Application) : AndroidViewModel(application),                     totalLaps = RACE_LAPS,                     lastLapMs = lapState.times.lastLapMs,                     bestLapMs = lapState.times.bestLapMs,+                    names = names,                 )             }         }     } -    private fun beginPlaceholderRace(seat: String, seats: List<String>) {+    private fun beginPlaceholderRace(seat: String, seats: List<String>, names: Map<String, String>) {         val newRace = PlaceholderRace(playerIds = seats)         race = newRace         kartHost.host?.startRace()@@ -355,6 +362,7 @@ class KartViewModel(application: Application) : AndroidViewModel(application),                         winner = newRace.winner() ?: order.first(),                         order = order,                         bestLapMs = lapState.times.bestLapMs,+                        names = names,                     )                     return@launch                 }@@ -368,11 +376,17 @@ class KartViewModel(application: Application) : AndroidViewModel(application),                     totalLaps = RACE_LAPS,                     lastLapMs = lapState.times.lastLapMs,                     bestLapMs = lapState.times.bestLapMs,+                    names = names,                 )             }         }     }-    private fun finishRace(winner: String, order: List<String>, bestLapMs: Long?) {+    private fun finishRace(+        winner: String,+        order: List<String>,+        bestLapMs: Long?,+        names: Map<String, String> = emptyMap(),+    ) {         tickJob?.cancel()         tickJob = null         // Celebration buzz for every remote phone still on the grid.@@ -382,7 +396,7 @@ class KartViewModel(application: Application) : AndroidViewModel(application),         if (winner == localPlayerId) achievementsManager.onAchievementUnlocked("first_win")         // Finishing banks the next cup below, so a finish is a cup completion.         achievementsManager.onAchievementUnlocked("cup_complete")-        _racePhase.value = RacePhase.Results(winner = winner, order = order)+        _racePhase.value = RacePhase.Results(winner = winner, order = order, names = names)         val state = _uiState.value         viewModelScope.launch {             KartRules.nextCup(state.progress.currentCup)?.let { dataStore.saveCup(it) }
games/kart/src/main/java/com/vayunmathur/games/kart/platform/RacePhase.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/RacePhase.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/RacePhase.ktindex 3163c537c0..c8f00d0377 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/platform/RacePhase.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/platform/RacePhase.kt@@ -25,8 +25,15 @@ sealed interface RacePhase {         val totalLaps: Int,         val lastLapMs: Long? = null,         val bestLapMs: Long? = null,+        /** Seat id to join display name, snapshotted at race start. AI seats are absent. */+        val names: Map<String, String> = emptyMap(),     ) : RacePhase      /** Across the line. [winner] may be an AI id; [order] is the final standing. */-    data class Results(val winner: String, val order: List<String>) : RacePhase+    data class Results(+        val winner: String,+        val order: List<String>,+        /** Seat id to join display name, snapshotted at race start. AI seats are absent. */+        val names: Map<String, String> = emptyMap(),+    ) : RacePhase }
games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGamePage.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGamePage.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGamePage.ktindex a77971f608..76378c3f48 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGamePage.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGamePage.kt@@ -16,9 +16,11 @@ fun KartGamePage( ) {     val uiState by viewModel.uiState.collectAsState()     val racePhase by viewModel.racePhase.collectAsState()+    val pairingCode by viewModel.pairingCode.collectAsState()     KartGameScreen(         state = uiState,         phase = racePhase,         actions = viewModel,+        pairingCode = pairingCode,     ) }
games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGameScreen.kt
diff --git a/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGameScreen.kt b/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGameScreen.ktindex 08ffd16786..08df03ac79 100644--- a/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGameScreen.kt+++ b/games/kart/src/main/java/com/vayunmathur/games/kart/ui/KartGameScreen.kt@@ -48,6 +48,7 @@ fun KartGameScreen(     state: KartUiState,     phase: RacePhase,     actions: KartGameActions,+    pairingCode: String? = null, ) {     AppScaffold(         title = state.cup?.let { stringResource(R.string.cup_title, it.name) }@@ -70,7 +71,7 @@ fun KartGameScreen(             verticalArrangement = Arrangement.spacedBy(Spacing.md),         ) {             when (val p = phase) {-                is RacePhase.Lobby -> LobbyBody(state, p, actions)+                is RacePhase.Lobby -> LobbyBody(state, p, actions, pairingCode)                 is RacePhase.Countdown -> CountdownBody(p)                 is RacePhase.Racing -> RacingBody(p, actions)                 is RacePhase.Results -> ResultsBody(p, actions)@@ -84,6 +85,7 @@ private fun LobbyBody(     state: KartUiState,     phase: RacePhase.Lobby,     actions: KartGameActions,+    pairingCode: String?, ) {     val cup = state.cup     if (cup == null) {@@ -120,6 +122,23 @@ private fun LobbyBody(                 style = MaterialTheme.typography.bodyMedium,                 color = MaterialTheme.colorScheme.onSurfaceVariant,             )+            Text(+                stringResource(+                    R.string.lobby_drivers,+                    phase.lobby.slots.joinToString(", ") { it.displayName },+                ),+                style = MaterialTheme.typography.bodyMedium,+                color = MaterialTheme.colorScheme.onSurfaceVariant,+                textAlign = TextAlign.Center,+            )+        }+        if (pairingCode != null) {+            Text(+                stringResource(R.string.lan_pairing_code, pairingCode),+                style = MaterialTheme.typography.titleMedium,+                color = MaterialTheme.colorScheme.primary,+                textAlign = TextAlign.Center,+            )         }         Button(             onClick = { actions.startRace() },@@ -200,7 +219,7 @@ private fun ColumnScope.RacingBody(phase: RacePhase.Racing, actions: KartGameAct             verticalAlignment = Alignment.CenterVertically,         ) {             Text(-                stringResource(R.string.race_place, place + 1, displayName(id)),+                stringResource(R.string.race_place, place + 1, displayName(id, phase.names)),                 style = MaterialTheme.typography.bodyMedium,             )             LinearProgressIndicator(@@ -293,7 +312,8 @@ private fun formatLapTime(ms: Long): String { }  /** Short label for a seat: players keep their join name, AI karts show as rivals. */-private fun displayName(id: String): String = if (id.startsWith("ai-")) "Rival ${id.removePrefix("ai-")}" else "You"+private fun displayName(id: String, names: Map<String, String> = emptyMap()): String =+    if (id.startsWith("ai-")) "Rival ${id.removePrefix("ai-")}" else names[id] ?: "You"  @Composable private fun ResultsBody(phase: RacePhase.Results, actions: KartGameActions) {@@ -304,7 +324,7 @@ private fun ResultsBody(phase: RacePhase.Results, actions: KartGameActions) {     )     phase.order.forEachIndexed { place, id ->         Text(-            stringResource(R.string.race_place, place + 1, displayName(id)),+            stringResource(R.string.race_place, place + 1, displayName(id, phase.names)),             style = MaterialTheme.typography.bodyMedium,             color = if (id == phase.winner) MaterialTheme.colorScheme.primary             else MaterialTheme.colorScheme.onSurface,
games/kart/src/main/res/values/strings.xml
diff --git a/games/kart/src/main/res/values/strings.xml b/games/kart/src/main/res/values/strings.xmlindex fccc67cfeb..cf7148eb60 100644--- a/games/kart/src/main/res/values/strings.xml+++ b/games/kart/src/main/res/values/strings.xml@@ -20,7 +20,11 @@     <!-- KartGameScreen: Shown while the cup has not loaded yet. Sentence -->     <string name="garage_loading">Warming up the engines…</string>     <!-- KartGameScreen: Hint under the race button explaining what is coming. Sentence -->-    <string name="how_to_play">Connect a phone as a controller, or plug in a gamepad</string>+    <string name="how_to_play">Drive with the touch controls or a gamepad. Friends on the same Wi-Fi can join this lobby from the Games Hub app.</string>+    <!-- KartGameScreen: Drivers currently seated in the LAN lobby. %1$s = comma-joined names -->+    <string name="lobby_drivers">In the lobby: <xliff:g id="names" example="You, Pixel 9">%1$s</xliff:g></string>+    <!-- KartGameScreen: Pair code a joining phone must type, shown while it pairs. %1$s = six digits -->+    <string name="lan_pairing_code">LAN pairing code: <xliff:g id="code" example="482916">%1$s</xliff:g> — type it on the joining phone</string>     <!-- KartGameScreen: Seats taken in the lobby. %1$d = seat count, e.g. 2 -->     <plurals name="lobby_seats">         <item quantity="one"><xliff:g id="count" example="1">%1$d</xliff:g> driver in the lobby</item>
games/kart/src/test/java/com/vayunmathur/games/kart/platform/KartHostAndNativeTest.kt
diff --git a/games/kart/src/test/java/com/vayunmathur/games/kart/platform/KartHostAndNativeTest.kt b/games/kart/src/test/java/com/vayunmathur/games/kart/platform/KartHostAndNativeTest.ktindex e5d3655da0..bfd78813c2 100644--- a/games/kart/src/test/java/com/vayunmathur/games/kart/platform/KartHostAndNativeTest.kt+++ b/games/kart/src/test/java/com/vayunmathur/games/kart/platform/KartHostAndNativeTest.kt@@ -25,6 +25,7 @@ class KartHostAndNativeTest {         assertTrue(host.inputs.value.isEmpty())         assertNull(host.host)         assertNull(host.pairingCode)+        assertNull(host.pairingCodeFlow.value)         host.start()         // Idempotent: a second start is a no-op, not a second lobby.         host.start()
games/kart/src/test/java/com/vayunmathur/games/kart/platform/KartViewModelTest.kt
diff --git a/games/kart/src/test/java/com/vayunmathur/games/kart/platform/KartViewModelTest.kt b/games/kart/src/test/java/com/vayunmathur/games/kart/platform/KartViewModelTest.ktindex a99cf8c7cb..e4a24f3475 100644--- a/games/kart/src/test/java/com/vayunmathur/games/kart/platform/KartViewModelTest.kt+++ b/games/kart/src/test/java/com/vayunmathur/games/kart/platform/KartViewModelTest.kt@@ -159,6 +159,13 @@ class KartViewModelTest {         }     } +    @Test fun pairingCodeIsQuietUntilSomeoneJoins() {+        val vm = KartViewModel(app)+        await("cup loads") { vm.uiState.value.cup != null }+        // Nobody is mid-handshake, so the lobby shows no code to type anywhere.+        assertEquals(null, vm.pairingCode.value)+    }+     @Test fun secondViewModelSeesPersistedCupState() {         val vm = KartViewModel(app)         await("cup loads") { vm.uiState.value.cup != null }
games/kart/src/test/java/com/vayunmathur/games/kart/ui/KartGameScreenTest.kt
diff --git a/games/kart/src/test/java/com/vayunmathur/games/kart/ui/KartGameScreenTest.kt b/games/kart/src/test/java/com/vayunmathur/games/kart/ui/KartGameScreenTest.ktindex 05ccedc679..9645396733 100644--- a/games/kart/src/test/java/com/vayunmathur/games/kart/ui/KartGameScreenTest.kt+++ b/games/kart/src/test/java/com/vayunmathur/games/kart/ui/KartGameScreenTest.kt@@ -69,6 +69,51 @@ class KartGameScreenTest {         assertEquals(0, actions.backs)     } +    @Test fun lobbyShowsPairingCodeAndDriverNames() {+        val lobby = LobbyState(+            gameId = "kart",+            slots = listOf(+                PlayerSlot("p1", "You", remote = false),+                PlayerSlot("p2", "Pixel 9", remote = true),+            ),+        )+        rule.setContent {+            KartGameScreen(+                KartUiState(cup = CUPS[0], progress = KartProgress()),+                RacePhase.Lobby(lobby),+                KartGameActions.Noop,+                pairingCode = "482916",+            )+        }+        rule.onNodeWithText(str(R.string.lan_pairing_code, "482916")).assertIsDisplayed()+        rule.onNodeWithText(str(R.string.lobby_drivers, "You, Pixel 9")).assertIsDisplayed()+    }++    @Test fun lobbyWithoutPairingHidesCodeRow() {+        rule.setContent {+            KartGameScreen(+                KartUiState(cup = CUPS[0], progress = KartProgress()),+                RacePhase.Lobby(LobbyState(gameId = "kart")),+                KartGameActions.Noop,+            )+        }+        rule.onNodeWithText(str(R.string.lan_pairing_code, "482916")).assertDoesNotExist()+    }++    @Test fun racingShowsLanDriverNames() {+        val phase = RacePhase.Racing(+            order = listOf("p1", "p2", "ai-0"),+            lapProgress = emptyMap(),+            playerLap = 0,+            totalLaps = 3,+            names = mapOf("p1" to "You", "p2" to "Pixel 9"),+        )+        rule.setContent { KartGameScreen(KartUiState(cup = CUPS[0]), phase, KartGameActions.Noop) }+        rule.onNodeWithText(str(R.string.race_place, 1, "You")).assertExists()+        rule.onNodeWithText(str(R.string.race_place, 2, "Pixel 9")).assertExists()+        rule.onNodeWithText(str(R.string.race_place, 3, "Rival 0")).assertExists()+    }+     @Test fun lobbyWithoutWinsOrSeatsHidesThoseRows() {         rule.setContent {             KartGameScreen(