feat: add persistent per-game compatibility profiles (#449)

* feat(profiles): add persistent per-game compatibility profiles

* fix(profiles): show Windows component overrides

Include per-game Windows component selections in the resolved profile summary so the session overlay marks those games as custom and shows the selected components.

* fix(session): detect Proton games across runtime paths

* fix(profiles): select the active Gamescope game

* fix(profiles): improve per-game reset feedback

* fix(profiles): align session components with game overrides

* fix(session): prefer selected Steam game during refresh

* fix(session): resume profile following when reopening games

* chore: keep local dev testing outside the repository

* test(session): remove local dev package path

* fix(session): preserve profiles when refresh fails

* fix(session): reject empty game profile reset scope

* perf(session): cache drawer inventory by refresh revision

* fix(profiles): align game presets and profile reset behavior

* fix(profiles): preserve originals and normalize shortcut ids

* fix(profiles): keep editor scope stable after rebase

* fix(tests): host Compose tests in both build variants

* fix(profiles): recover interrupted component selection saves

---------

Co-authored-by: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com>
This commit is contained in:
Juan MartíandKurt Himebauch authored and GitHub committed 2026-10-11 17:00:28 -04:00
1 parent ef4807fbd0
commit 55c51f843e
46 files changed
+3501 -150

No files matched your search

@@ -0,0 +1,59 @@
package com.droiddeck.launcher.ui
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import com.droiddeck.launcher.R
import com.droiddeck.launcher.frontend.Library
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28])
class ComponentsPageProfileTest {
@get:Rule val compose = createRobolectricComposeRule()
@Test fun gameProfilesCoexistWithTheDefaultComponentStack() {
val context = RuntimeEnvironment.getApplication()
compose.setContent {
DroidDeckTheme {
ComponentsPage(
snapshot = null,
catalog = emptyList(),
catalogAt = 0,
protonId = null,
comp = PROTON_TAB,
checking = false,
busy = null,
downloads = emptyMap(),
onProton = {},
onComp = {},
onSwap = {},
onRestore = {},
onCancelQueued = {},
onDeletePackage = {},
onDeleteOriginal = {},
onDownload = {},
onRefresh = {},
onImport = {},
onBack = {},
games = listOf(Library.SteamGame(42, "Game A", null, "internal")),
requestInitialFocus = false,
)
}
}
val stackHeading = context.getString(R.string.comp_this_proton).uppercase()
compose.onNodeWithText(stackHeading).assertExists()
compose.onNodeWithText(context.getString(R.string.comp_scope_general)).performClick()
compose.onNodeWithText("Game A").performClick()
compose.onNodeWithText(context.getString(R.string.comp_game_hint)).assertExists()
compose.onNodeWithText(stackHeading).assertDoesNotExist()
compose.onNodeWithText("Game A").performClick()
compose.onNodeWithText(context.getString(R.string.comp_scope_general)).performClick()
compose.onNodeWithText(stackHeading).assertExists()
}
}
@@ -0,0 +1,63 @@
package com.droiddeck.launcher.ui
import android.content.Context
import androidx.compose.runtime.mutableStateOf
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.onAllNodesWithText
import androidx.compose.ui.test.onLast
import androidx.compose.ui.test.onNodeWithText
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
import com.droiddeck.launcher.R
import com.droiddeck.launcher.core.GameEnvironment
import com.droiddeck.launcher.session.GameEnvironmentStore
import org.junit.Assert.assertEquals
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.RobolectricTestRunner
import org.robolectric.RuntimeEnvironment
import org.robolectric.annotation.Config
@RunWith(RobolectricTestRunner::class)
@Config(sdk = [28])
class GameEnvironmentEditorTest {
@get:Rule val compose = createRobolectricComposeRule()
@Test fun backgroundSelectionCannotRetargetAnOpenVariableEdit() {
val context: Context = RuntimeEnvironment.getApplication()
val variable = "MESA_SHADER_CACHE_MAX_SIZE"
GameEnvironmentStore.save(context, GameEnvironment.Config(games = mapOf(
"42" to mapOf(variable to "512M"),
"43" to mapOf(variable to "2G"),
)))
val selectedScope = mutableStateOf("42")
compose.setContent {
DroidDeckTheme { GameEnvironmentRow(initialScope = selectedScope.value) }
}
compose.onNodeWithText(context.getString(R.string.game_env_edit)).performClick()
compose.waitUntil(5_000) {
compose.onAllNodes(hasText("512M")).fetchSemanticsNodes().isNotEmpty()
}
compose.onNodeWithText("512M").performScrollTo().performClick()
compose.onNodeWithText(context.getString(R.string.game_env_change)).performClick()
compose.onAllNodesWithText("512M").onLast().performClick()
compose.onNodeWithText("4G").performClick()
compose.runOnIdle { selectedScope.value = "43" }
compose.onNodeWithText(context.getString(R.string.game_env_save)).performClick()
compose.waitUntil(5_000) {
GameEnvironmentStore.read(context).entries("42")[variable] == "4G"
}
assertEquals("2G", GameEnvironmentStore.read(context).entries("43")[variable])
compose.onNodeWithText("4G").assertExists()
compose.onNodeWithText(context.getString(R.string.game_env_done)).performScrollTo().performClick()
compose.waitForIdle()
compose.onNodeWithText(context.getString(R.string.game_env_edit)).performClick()
compose.waitUntil(5_000) {
compose.onAllNodes(hasText("2G")).fetchSemanticsNodes().isNotEmpty()
}
compose.onNodeWithText("2G").assertExists()
}
}
@@ -0,0 +1,15 @@
package com.droiddeck.launcher.ui
import android.content.ComponentName
import androidx.activity.ComponentActivity
import androidx.compose.ui.test.junit4.createComposeRule
import org.robolectric.RuntimeEnvironment
import org.robolectric.Shadows.shadowOf
fun createRobolectricComposeRule() = createComposeRule().also {
val context = RuntimeEnvironment.getApplication()
// Register only in Robolectric, without adding a host activity to either APK variant.
shadowOf(context.packageManager).addActivityIfNotPresent(
ComponentName(context, ComponentActivity::class.java),
)
}