mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-21 13:55:58 +00:00
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:
1 parent
78fcb60fd5
commit
435beb7f19
46 files changed
+3501
-150
No files matched your search
@@ -208,6 +208,22 @@ class AgentTest(unittest.TestCase):
|
||||
missing = self.ask({"kind": "cdp", "expression": "1", "target": "Nope"})
|
||||
self.assertEqual("NO_TARGET", missing["error"]["code"])
|
||||
|
||||
def test_steam_selection(self):
|
||||
with patch.object(agent, "cdp_eval", return_value={"value": "3180310"}) as evaluate:
|
||||
answer = self.ask({"kind": "steam-selection"})
|
||||
self.assertEqual(3180310, answer["appId"])
|
||||
self.assertIn("document.activeElement", evaluate.call_args.args[1])
|
||||
self.assertEqual("Steam Big Picture Mode", evaluate.call_args.kwargs["target"])
|
||||
|
||||
def test_steam_selection_allows_no_highlight(self):
|
||||
with patch.object(agent, "cdp_eval", return_value={"value": None}):
|
||||
self.assertIsNone(self.ask({"kind": "steam-selection"})["appId"])
|
||||
|
||||
def test_steam_selection_rejects_invalid_app_id(self):
|
||||
with patch.object(agent, "cdp_eval", return_value={"value": "4294967296"}):
|
||||
answer = self.ask({"kind": "steam-selection"})
|
||||
self.assertEqual("INVALID_SELECTION", answer["error"]["code"])
|
||||
|
||||
def test_cdp_exception(self):
|
||||
server = FakeDevTools({"result": {"result": {"type": "object"}, "exceptionDetails": {
|
||||
"text": "Uncaught", "exception": {"description": "ReferenceError: SteamClient is not defined"}}}})
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import shutil
|
||||
@@ -52,6 +53,72 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
self.assertEqual(env["REMOVE"], "inherited")
|
||||
self.assertEqual(MODULE["apply_config"](env, config, "43")["CUSTOM"], "shared")
|
||||
|
||||
def test_component_profiles_override_general_and_restore_it_for_the_next_game(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
home = root / "home"
|
||||
component_dir = home / ".local/share/droiddeck-components"
|
||||
base = root / "proton"
|
||||
target = base / "files/lib/wine/dxvk/aarch64-windows/d3d11.dll"
|
||||
leftover = target.with_name("d3d8.dll")
|
||||
component_dir.mkdir(parents=True)
|
||||
target.parent.mkdir(parents=True)
|
||||
(base / "version").write_text("1 build-1\n")
|
||||
general = root / "general.dll"
|
||||
game = root / "game.dll"
|
||||
general.write_text("general")
|
||||
game.write_text("game")
|
||||
target.write_text("old")
|
||||
leftover.write_text("old")
|
||||
digest = lambda path: hashlib.sha256(path.read_bytes()).hexdigest()
|
||||
(component_dir / "desired.tsv").write_text(
|
||||
"*\tproton\tbuild-1\tdxvk\tfiles/lib/wine/dxvk/aarch64-windows/d3d11.dll\t%s\t%s\n"
|
||||
"42\tproton\tbuild-1\tdxvk\tfiles/lib/wine/dxvk/aarch64-windows/d3d11.dll\t%s\t%s\n"
|
||||
"42\tproton\tbuild-1\tdxvk\tfiles/lib/wine/dxvk/aarch64-windows/d3d8.dll\t-\t-\n"
|
||||
% (digest(general), general, digest(game), game)
|
||||
)
|
||||
script = COMPAT["BL_COMPONENTS_SETUP"] + '\nverb=waitforexitandrun; bl_components "$1"\n'
|
||||
env = dict(os.environ, HOME=str(home), STEAM_COMPAT_DATA_PATH="/steam/compatdata/42")
|
||||
subprocess.run(["bash", "-c", script, "test", str(base)], env=env, check=True)
|
||||
self.assertEqual(target.read_text(), "game")
|
||||
self.assertFalse(leftover.exists())
|
||||
|
||||
env["STEAM_COMPAT_DATA_PATH"] = "/steam/compatdata/43"
|
||||
subprocess.run(["bash", "-c", script, "test", str(base)], env=env, check=True)
|
||||
self.assertEqual(target.read_text(), "general")
|
||||
|
||||
def test_component_scope_matches_environment_scope_for_shortcut_ids(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
root = Path(tmp)
|
||||
component_dir = root / ".local/share/droiddeck-components"
|
||||
base = root / "proton"
|
||||
target = base / "files/lib/wine/dxvk/aarch64-windows/d3d11.dll"
|
||||
component_dir.mkdir(parents=True)
|
||||
target.parent.mkdir(parents=True)
|
||||
(base / "version").write_text("1 build-1\n")
|
||||
rows = []
|
||||
for scope in ("*", "42", "4294967295", "2147483648"):
|
||||
source = root / ("default" if scope == "*" else scope)
|
||||
source.write_text(scope)
|
||||
rows.append("%s\tproton\tbuild-1\tdxvk\t%s\t%s\t%s\n" % (
|
||||
scope, target.relative_to(base),
|
||||
hashlib.sha256(source.read_bytes()).hexdigest(), source,
|
||||
))
|
||||
(component_dir / "desired.tsv").write_text("".join(rows))
|
||||
script = COMPAT["BL_COMPONENTS_SETUP"] + '\nverb=waitforexitandrun; bl_components "$1"\n'
|
||||
for value in (
|
||||
"42", "00042", "43", "-1", "-0001", "4294967295", "-2147483648",
|
||||
"2147483648", "-1///", "0", "-0", "000", "-2147483649", "4294967296",
|
||||
"999999999999999999999999999", "not-an-id", "1+1", "",
|
||||
):
|
||||
with self.subTest(prefix=value):
|
||||
env = dict(os.environ, HOME=str(root), STEAM_COMPAT_DATA_PATH="/steam/compatdata/" + value)
|
||||
target.write_text("untouched")
|
||||
subprocess.run(["bash", "-c", script, "test", str(base)], env=env, check=True, capture_output=True)
|
||||
scope = MODULE["game_id"](env)
|
||||
expected = "untouched" if scope is None else scope if scope in {"42", "4294967295", "2147483648"} else "*"
|
||||
self.assertEqual(target.read_text(), expected)
|
||||
|
||||
def test_engine_fixes_follow_the_games_files(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
game = Path(tmp) / "Godot Game"
|
||||
@@ -109,6 +176,22 @@ class GameEnvironmentTest(unittest.TestCase):
|
||||
with self.assertRaises(ValueError):
|
||||
MODULE["apply_config"]({}, {**config, "dxvkConfig": bad}, "42")
|
||||
|
||||
def test_game_texture_filtering_overrides_default_without_leaking(self):
|
||||
default = "d3d9.samplerAnisotropy = 16"
|
||||
game = "d3d9.samplerAnisotropy = 4"
|
||||
config = {
|
||||
"version": 1,
|
||||
"shared": {},
|
||||
"games": {},
|
||||
"dxvkConfig": default,
|
||||
"dxvkConfigGames": {"42": game, "43": ""},
|
||||
}
|
||||
self.assertEqual(MODULE["apply_config"]({}, config, "42")["DXVK_CONFIG"], game)
|
||||
self.assertNotIn("DXVK_CONFIG", MODULE["apply_config"]({}, config, "43"))
|
||||
self.assertEqual(MODULE["apply_config"]({}, config, "44")["DXVK_CONFIG"], default)
|
||||
with self.assertRaises(ValueError):
|
||||
MODULE["apply_config"]({}, {**config, "dxvkConfigGames": []}, "42")
|
||||
|
||||
def test_game_ids_and_probes(self):
|
||||
for prefix in ("", "/compatdata/0", "/compatdata/0-123", "/compatdata/nope", "/compatdata/4294967296"):
|
||||
self.assertIsNone(MODULE["game_id"]({"STEAM_COMPAT_DATA_PATH": prefix}))
|
||||
@@ -353,6 +436,57 @@ class ProtonDefaultTest(unittest.TestCase):
|
||||
changes, auto = self.plan({"0": self.TOOL}, [], self.TOOL, {"10": self.TOOL})
|
||||
self.assertEqual((changes, auto), ({}, {}))
|
||||
|
||||
def test_per_game_proton_override_and_inherit_follow_steam_mappings(self):
|
||||
current = {"0": self.TOOL, "10": self.TOOL, "11": "GE-Proton11-7", "12": self.TOOL}
|
||||
overrides = {"10": "GE-Proton11-7", "11": None}
|
||||
changes, auto = COMPAT["plan_mapping"](
|
||||
current, ["10", "11", "12"], self.NAMES, COMPAT["TOOL_11"],
|
||||
{"10": self.TOOL, "12": self.TOOL}, overrides=overrides)
|
||||
self.assertEqual(changes, {"0": COMPAT["TOOL_11"], "10": "GE-Proton11-7", "11": COMPAT["TOOL_11"], "12": COMPAT["TOOL_11"]})
|
||||
self.assertEqual(auto, {"11": COMPAT["TOOL_11"], "12": COMPAT["TOOL_11"]})
|
||||
|
||||
def test_per_game_requests_resolve_identity_and_defer_a_new_live_tool(self):
|
||||
requests = {
|
||||
"10": {"valve": False, "dir": "GE-Proton11-7"},
|
||||
"11": None,
|
||||
"12": {"valve": True, "dir": "Proton 11.0 (ARM64)"},
|
||||
"0": None,
|
||||
}
|
||||
self.assertEqual(
|
||||
COMPAT["requested_games"](requests, self.CATALOG),
|
||||
{"10": "GE-Proton11-7", "11": None, "12": COMPAT["TOOL_11"]},
|
||||
)
|
||||
self.assertEqual(
|
||||
COMPAT["requested_games"](requests, self.CATALOG, [self.TOOL, COMPAT["TOOL_11"]]),
|
||||
{"10": COMPAT["DEFERRED_GAME_TOOL"], "11": None, "12": COMPAT["TOOL_11"]},
|
||||
)
|
||||
|
||||
def test_missing_per_game_proton_is_preserved_during_default_registration(self):
|
||||
with tempfile.TemporaryDirectory() as tmp:
|
||||
config = Path(tmp) / "config.vdf"
|
||||
config.write_text(config_text([
|
||||
("0", self.TOOL),
|
||||
("10", "GE-Proton9-1"),
|
||||
("11", self.TOOL),
|
||||
]))
|
||||
(Path(tmp) / "games.json").write_text(json.dumps({
|
||||
"version": 1,
|
||||
"games": {
|
||||
"10": {"valve": False, "dir": "GE-Proton9-1"},
|
||||
},
|
||||
}))
|
||||
|
||||
COMPAT["register_default"](
|
||||
str(config), ["10", "11"], default=COMPAT["TOOL_11"],
|
||||
catalog=self.CATALOG, directory=tmp,
|
||||
)
|
||||
|
||||
self.assertEqual(mapping_of(config.read_text()), {
|
||||
"0": COMPAT["TOOL_11"],
|
||||
"10": "GE-Proton9-1",
|
||||
"11": COMPAT["TOOL_11"],
|
||||
})
|
||||
|
||||
def test_the_last_side_to_change_wins(self):
|
||||
state = {"default": self.TOOL, "applied": 5}
|
||||
default, state = COMPAT["choose_default"]("GE-Proton11-7", state, {"seq": 5, "dir": "Proton 11.0 (ARM64)", "valve": True}, self.CATALOG, now=100)
|
||||
|
||||
@@ -208,6 +208,33 @@ class ReconcileTest(unittest.TestCase):
|
||||
self.assertEqual((state["pending"], state.get("applied", 0)), (TOOL_11, 0))
|
||||
self.assertTrue(self.helper.request_waiting())
|
||||
|
||||
def test_per_game_customize_and_inherit_apply_live(self):
|
||||
page = FakePage({"0": TOOL, "10": TOOL, "11": TOOL_11}, [TOOL, TOOL_11])
|
||||
(self.state / "games.json").write_text(json.dumps({
|
||||
"version": 1,
|
||||
"games": {
|
||||
"10": {"valve": True, "dir": "Proton 11.0 (ARM64)"},
|
||||
"11": None,
|
||||
},
|
||||
}))
|
||||
state = self.reconcile(page)
|
||||
self.assertEqual(page.sets, [("10", TOOL_11), ("11", TOOL)])
|
||||
self.assertEqual(state["auto"], {"11": TOOL})
|
||||
|
||||
def test_missing_per_game_proton_stays_deferred_live(self):
|
||||
page = FakePage({"0": TOOL, "10": "GE-Proton9-1", "11": TOOL_11}, [TOOL, TOOL_11])
|
||||
(self.state / "games.json").write_text(json.dumps({
|
||||
"version": 1,
|
||||
"games": {
|
||||
"10": {"valve": False, "dir": "GE-Proton9-1"},
|
||||
"11": None,
|
||||
},
|
||||
}))
|
||||
state = self.reconcile(page)
|
||||
self.assertEqual(page.sets, [("11", TOOL)])
|
||||
self.assertEqual(page.mapping["10"], "GE-Proton9-1")
|
||||
self.assertEqual(state["auto"], {"11": TOOL})
|
||||
|
||||
def test_file_mode_defers_to_the_live_helper(self):
|
||||
(self.state / "live.pid").write_text("%d\n" % os.getpid())
|
||||
self.assertTrue(COMPAT["live_helper_running"]())
|
||||
|
||||
Reference in new issue
Block a user