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 78fcb60fd5
commit 435beb7f19
46 files changed
+3501 -150

No files matched your search

@@ -85,6 +85,63 @@ object AgentGuest {
fun focus(context: Context): JSONObject? =
if (SessionState.running) readJson(File(dir(context), "focus.json")) else null
/** The Steam library game whose tile currently has controller or keyboard focus. */
fun selectedSteamAppId(context: Context): Long? {
val result = call(context, JSONObject().put("kind", "steam-selection"), 6_000)
if (!result.optBoolean("ok") || result.isNull("appId")) return null
return result.optLong("appId").takeIf { it in 1..4_294_967_295L }
}
/** The installed game Gamescope is presenting, including while Steam's overlay has focus. */
fun activeSteamAppId(context: Context, installedAppIds: Set<Long>): Long? {
val snapshot = focus(context) ?: return null
val focusedAppId = snapshot.optLong("focusedApp").takeIf { snapshot.has("focusedApp") }
val focusableAppIds = snapshot.optJSONArray("focusableApps")?.let { apps ->
buildList {
for (index in 0 until apps.length()) {
apps.optLong(index).takeIf { it > 0 }?.let(::add)
}
}
}.orEmpty()
val baselayerAppIds = snapshot.optJSONArray("baselayerAppIds")?.let { apps ->
buildList {
for (index in 0 until apps.length()) {
apps.optLong(index).takeIf { it > 0 }?.let(::add)
}
}
}.orEmpty()
return activeInstalledSteamAppId(focusedAppId, focusableAppIds, installedAppIds, baselayerAppIds)
}
internal fun focusedInstalledSteamAppId(focusedAppId: Long?, installedAppIds: Set<Long>): Long? =
focusedAppId?.takeIf { it in installedAppIds }
internal fun activeInstalledSteamAppId(
focusedAppId: Long?,
focusableAppIds: List<Long>,
installedAppIds: Set<Long>,
baselayerAppIds: List<Long> = emptyList(),
): Long? = focusedInstalledSteamAppId(focusedAppId, installedAppIds)
?: focusableAppIds.filter { it in installedAppIds }.distinct().singleOrNull()
?: baselayerAppIds.filter { it in installedAppIds }.distinct().singleOrNull()
internal fun preferredInstalledSteamAppId(
selectedAppId: Long?,
activeAppId: Long?,
installedAppIds: Set<Long>,
): Long? = selectedAppId?.takeIf { it in installedAppIds }
?: activeAppId?.takeIf { it in installedAppIds }
internal fun selectedOrActiveInstalledSteamAppId(
selectedAppId: Result<Long?>,
activeAppId: Long?,
installedAppIds: Set<Long>,
): Long? {
preferredInstalledSteamAppId(selectedAppId.getOrNull(), activeAppId, installedAppIds)?.let { return it }
selectedAppId.exceptionOrNull()?.let { throw it }
return null
}
/** Send one request and wait for its answer. Throws [AgentException] with a stable code. */
fun call(context: Context, request: JSONObject, timeoutMs: Long): JSONObject {
if (request.optString("kind") in setOf("exec", "cdp")) AgentAccess.requireCommands(context)