From 84a04d9ead1d97c4f0a9e6ed17a6dfc49c6defa5 Mon Sep 17 00:00:00 2001 From: Kurt Himebauch <136133082+xXJSONDeruloXx@users.noreply.github.com> Date: Sun, 1 Nov 2026 19:55:18 -0500 Subject: [PATCH] fix: Steam shows cached library art when it starts without reaching Steam (#1985) --- .../usr/local/bin/droiddeck-steam-compat | 15 ++++++ tools/tests/test_steam_library_art.py | 54 +++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 tools/tests/test_steam_library_art.py diff --git a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat index 48b77da7f..0b0b1b056 100755 --- a/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat +++ b/tools/linuxfs/overlay/usr/local/bin/droiddeck-steam-compat @@ -18,6 +18,19 @@ COMPAT = runpy.run_path(os.path.join(HERE, "steam-compatibility")) BINDING = "droiddeckCompatChanged" BRIGHTNESS_BINDING = "droiddeckBrightnessChanged" CONTROLS_DIR = "/etc/droiddeck-device-controls" +LIBRARY_ART_JS = r""" +(() => { + if (window.__droiddeckLibraryArt) return "present"; + const store = typeof appStore === "object" ? appStore : null; + if (typeof store?.BHasCachedLibraryAsset !== "function") return "unavailable"; + // The client reports which cached assets exist only after a logon that reaches Steam; before that every app reads as + // uncached and the UI asks the CDN, which is blank offline. The native check still runs, so misses are still reported. + const native = store.BHasCachedLibraryAsset.bind(store); + store.BHasCachedLibraryAsset = (appid, version, type) => native(appid, version, type) || !version; + window.__droiddeckLibraryArt = true; + return "installed"; +})() +""" BRIGHTNESS_JS = r""" (() => { if (window.__droiddeckBrightness) return "present"; @@ -851,6 +864,7 @@ class Helper: if self.files_only: page.call("Runtime.addBinding", {"name": FILE_BINDING}) page.evaluate(FILE_JS) + page.evaluate(LIBRARY_ART_JS) self.page = page self.controls_state = None self.controls_installed = False @@ -861,6 +875,7 @@ class Helper: page.evaluate(VR_JS) page.call("Runtime.addBinding", {"name": FILE_BINDING}) page.evaluate(FILE_JS) + page.evaluate(LIBRARY_ART_JS) try: page.evaluate(TOUR_JS) except RuntimeError: diff --git a/tools/tests/test_steam_library_art.py b/tools/tests/test_steam_library_art.py new file mode 100644 index 000000000..04843af23 --- /dev/null +++ b/tools/tests/test_steam_library_art.py @@ -0,0 +1,54 @@ +from pathlib import Path +import runpy +import shutil +import subprocess +import tempfile +import unittest + +BIN = Path(__file__).resolve().parents[1] / "linuxfs/overlay/usr/local/bin" +LIVE = runpy.run_path(str(BIN / "droiddeck-steam-compat")) + +HARNESS = """ +const reports = []; +global.appStore = { + BHasCachedLibraryAsset(appid, version, type) { + if ((version ?? 0) & (1 << type)) return true; + reports.push([appid, type]); + return false; + }, +}; +const first = eval(process.argv[2]); +const second = eval(process.argv[2]); +const check = (name, actual, expected) => { if (actual !== expected) throw new Error(name + ": " + actual); }; +check("install", first, "installed"); +check("reinstall", second, "present"); +check("no logon", appStore.BHasCachedLibraryAsset(10, undefined, 3), true); +check("zero version", appStore.BHasCachedLibraryAsset(10, 0, 3), true); +check("reported", reports.length, 2); +check("bit set", appStore.BHasCachedLibraryAsset(10, 1 << 3, 3), true); +check("bit missing", appStore.BHasCachedLibraryAsset(10, 1 << 2, 3), false); +check("reported again", reports.length, 3); +""" + + +@unittest.skipUnless(shutil.which("node"), "node is not installed") +class LibraryArtTest(unittest.TestCase): + def run_node(self, harness): + with tempfile.TemporaryDirectory() as directory: + script = Path(directory, "harness.js") + script.write_text("global.window = {};\n" + harness) + return subprocess.run(["node", str(script), LIVE["LIBRARY_ART_JS"]], capture_output=True, text=True, timeout=20) + + def test_apps_without_a_client_cache_report_read_from_the_local_library_cache(self): + result = self.run_node(HARNESS) + self.assertEqual(result.returncode, 0, result.stderr) + + def test_a_page_without_the_app_store_is_left_alone(self): + result = self.run_node(""" +if (eval(process.argv[2]) !== "unavailable") throw new Error("installed without an app store"); +""") + self.assertEqual(result.returncode, 0, result.stderr) + + +if __name__ == "__main__": + unittest.main()