Skip to content

Open-source Xbox-inspired desktop launcher for Xodus on Linux

TypeScript

fix(runtime): follow installed family updates without changing game prefixes

domsvoboda0906f4bf1c38
diff --git a/assets/locales/de.json b/assets/locales/de.json
index bf04c3a..3e4bded 100644
--- a/assets/locales/de.json
+++ b/assets/locales/de.json
@@ -1,10 +1,9 @@
{
- "runtime.build_changed": "Der installierte Laufzeit-Build wurde geändert oder noch nicht genehmigt. Prüfe ihn und wähle ausdrücklich ein neues separates Präfix. Lokale Spielstände bleiben im alten Präfix.",
"runtime.game_runtime": "Spiel-Laufzeit",
"runtime.use_default": "Standard-Laufzeit verwenden",
"runtime.unavailable": "{{name}} (nicht verfügbar)",
- "runtime.separate_prefix": "Separates Präfix für diesen Laufzeit-Build verwenden",
- "runtime.prefix_warning": "Für jeden Laufzeit-Build wird ein separates Präfix erstellt. Vorhandene lokale Spielstände bleiben im alten Präfix. Sie werden nicht automatisch kopiert oder übertragen.",
+ "runtime.separate_prefix": "Separates Präfix für diese Laufzeitfamilie verwenden",
+ "runtime.prefix_warning": "Updates innerhalb dieser Laufzeitfamilie verwenden dasselbe Präfix und dieselben lokalen Spielstände. Beim Wechsel der Familie wird ein separates Präfix verwendet. Vorhandene lokale Spielstände bleiben im alten Präfix und werden nicht automatisch kopiert oder übertragen.",
"auth.browser": "Im Browser fortfahren",
"auth.browser_error": "Die Anmeldung konnte nicht im Browser geöffnet werden. Google Chrome muss installiert sein. Versuche es erneut oder wähle eine andere Methode.",
"auth.cancel_passkey": "Passkey Abfrage abbrechen",
diff --git a/assets/locales/en.json b/assets/locales/en.json
index 86b957c..fcca6a2 100644
--- a/assets/locales/en.json
+++ b/assets/locales/en.json
@@ -10,14 +10,11 @@
"auth.sign_out_active_help": "Signs out active Store and player accounts and removes device registration. Saved Store accounts remain available until forgotten.",
"auth.active_signed_out": "Active accounts signed out. Saved Store accounts are retained.",
"auth.sign_out_all": "Sign out all accounts",
- "runtime.new_build_available": "Another runtime build is installed. Your approved build and its local saves remain selected until you choose another build.",
- "runtime.use_installed_build": "Use the newly installed build with a separate prefix",
- "runtime.build_changed": "The installed runtime build changed or has not been approved. Review it and explicitly choose a new separate prefix. Existing local saves stay in the old prefix.",
"runtime.game_runtime": "Game runtime",
"runtime.use_default": "Use default runtime",
"runtime.unavailable": "{{name}} (unavailable)",
- "runtime.separate_prefix": "Use a separate prefix for this runtime build",
- "runtime.prefix_warning": "This creates a separate prefix for each runtime build. Existing local saves stay in the old prefix. Saves are not copied or transferred automatically.",
+ "runtime.separate_prefix": "Use a separate prefix for this runtime family",
+ "runtime.prefix_warning": "Updates within this family reuse the same prefix and local saves. Switching families uses a separate prefix. Existing local saves stay in the old prefix and are not copied or transferred automatically.",
"library.stop_update_check": "Stop checking updates",
"notifications.title": "Notifications",
"notifications.unread_one": "Notifications, {{count}} unread",
diff --git a/assets/locales/es.json b/assets/locales/es.json
index b9453ba..b881a41 100644
--- a/assets/locales/es.json
+++ b/assets/locales/es.json
@@ -1,10 +1,9 @@
{
- "runtime.build_changed": "La compilación del entorno cambió o no se ha aprobado. Revísala y elige explícitamente un nuevo prefijo independiente. Las partidas locales permanecen en el prefijo anterior.",
"runtime.game_runtime": "Entorno del juego",
"runtime.use_default": "Usar el entorno predeterminado",
"runtime.unavailable": "{{name}} (no disponible)",
- "runtime.separate_prefix": "Usar un prefijo independiente para esta compilación",
- "runtime.prefix_warning": "Se crea un prefijo independiente para cada compilación del entorno. Las partidas locales existentes permanecen en el prefijo anterior. No se copian ni transfieren automáticamente.",
+ "runtime.separate_prefix": "Usar un prefijo independiente para esta familia de entornos",
+ "runtime.prefix_warning": "Las actualizaciones de esta familia reutilizan el mismo prefijo y las partidas locales. Cambiar de familia usa un prefijo independiente. Las partidas existentes permanecen en el prefijo anterior y no se copian ni transfieren automáticamente.",
"auth.browser": "Continuar en el navegador",
"auth.browser_error": "No se ha podido abrir el inicio de sesión en el navegador. Google Chrome debe estar instalado. Inténtalo de nuevo o elige otro método.",
"auth.cancel_passkey": "Cancelar solicitud de llave de acceso",
diff --git a/assets/locales/fr.json b/assets/locales/fr.json
index cf99b9e..ab87f0d 100644
--- a/assets/locales/fr.json
+++ b/assets/locales/fr.json
@@ -1,10 +1,9 @@
{
- "runtime.build_changed": "La version installée a changé ou n’a pas été approuvée. Vérifiez-la et choisissez explicitement un nouveau préfixe séparé. Les sauvegardes locales restent dans l’ancien préfixe.",
"runtime.game_runtime": "Environnement du jeu",
"runtime.use_default": "Utiliser l’environnement par défaut",
"runtime.unavailable": "{{name}} (indisponible)",
- "runtime.separate_prefix": "Utiliser un préfixe séparé pour cette version",
- "runtime.prefix_warning": "Un préfixe séparé est créé pour chaque version de l’environnement. Les sauvegardes locales restent dans l’ancien préfixe. Elles ne sont pas copiées ni transférées automatiquement.",
+ "runtime.separate_prefix": "Utiliser un préfixe séparé pour cette famille d’environnements",
+ "runtime.prefix_warning": "Les mises à jour de cette famille réutilisent le même préfixe et les sauvegardes locales. Changer de famille utilise un préfixe séparé. Les sauvegardes existantes restent dans l’ancien préfixe et ne sont ni copiées ni transférées automatiquement.",
"auth.browser": "Continuer dans le navigateur",
"auth.browser_error": "Impossible d'ouvrir la connexion dans le navigateur. Google Chrome doit être installé. Réessayez ou choisissez une autre méthode.",
"auth.passkey_label": "Aide pour la clé d'accès de Nexus Launcher",
diff --git a/assets/locales/it.json b/assets/locales/it.json
index e90053a..522d793 100644
--- a/assets/locales/it.json
+++ b/assets/locales/it.json
@@ -1,10 +1,9 @@
{
- "runtime.build_changed": "La versione installata è cambiata o non è stata approvata. Verificala e scegli esplicitamente un nuovo prefisso separato. I salvataggi locali restano nel vecchio prefisso.",
"runtime.game_runtime": "Ambiente del gioco",
"runtime.use_default": "Usa l’ambiente predefinito",
"runtime.unavailable": "{{name}} (non disponibile)",
- "runtime.separate_prefix": "Usa un prefisso separato per questa versione",
- "runtime.prefix_warning": "Viene creato un prefisso separato per ogni versione dell’ambiente. I salvataggi locali esistenti restano nel vecchio prefisso. Non vengono copiati o trasferiti automaticamente.",
+ "runtime.separate_prefix": "Usa un prefisso separato per questa famiglia di ambienti",
+ "runtime.prefix_warning": "Gli aggiornamenti di questa famiglia riutilizzano lo stesso prefisso e i salvataggi locali. Cambiare famiglia usa un prefisso separato. I salvataggi esistenti restano nel vecchio prefisso e non vengono copiati o trasferiti automaticamente.",
"auth.browser": "Continua nel browser",
"auth.browser_error": "Impossibile aprire il browser per accedere. Google Chrome deve essere installato. Prova di nuovo o scegli un altro metodo.",
"auth.cancel_passkey": "Annulla la richiesta di passkey",
diff --git a/assets/locales/pl-PL.json b/assets/locales/pl-PL.json
index 0a228df..cb6b57e 100644
--- a/assets/locales/pl-PL.json
+++ b/assets/locales/pl-PL.json
@@ -1,10 +1,9 @@
{
- "runtime.build_changed": "Zainstalowana kompilacja zmieniła się lub nie została zatwierdzona. Sprawdź ją i wyraźnie wybierz nowy osobny prefiks. Lokalne zapisy pozostają w starym prefiksie.",
"runtime.game_runtime": "Środowisko gry",
"runtime.use_default": "Użyj domyślnego środowiska",
"runtime.unavailable": "{{name}} (niedostępne)",
- "runtime.separate_prefix": "Użyj osobnego prefiksu dla tej kompilacji",
- "runtime.prefix_warning": "Dla każdej kompilacji środowiska tworzony jest osobny prefiks. Istniejące lokalne zapisy pozostają w starym prefiksie. Nie są automatycznie kopiowane ani przenoszone.",
+ "runtime.separate_prefix": "Użyj osobnego prefiksu dla tej rodziny środowisk",
+ "runtime.prefix_warning": "Aktualizacje tej rodziny używają tego samego prefiksu i lokalnych zapisów. Zmiana rodziny używa osobnego prefiksu. Istniejące zapisy pozostają w starym prefiksie i nie są automatycznie kopiowane ani przenoszone.",
"common.view_all": "Pokaż wszystkie ({{count}})",
"downloads.active_summary": "Kolejka instalacji, instalacje w toku: {{count}}, {{state}}, {{game}}",
"downloads.current": "{{state}} ({{current}}/{{total}})",
diff --git a/assets/locales/pt-BR.json b/assets/locales/pt-BR.json
index cd6bd9e..c66931c 100644
--- a/assets/locales/pt-BR.json
+++ b/assets/locales/pt-BR.json
@@ -1,10 +1,9 @@
{
- "runtime.build_changed": "A compilação instalada mudou ou não foi aprovada. Revise-a e escolha explicitamente um novo prefixo separado. Os salvamentos locais permanecem no prefixo antigo.",
"runtime.game_runtime": "Ambiente do jogo",
"runtime.use_default": "Usar o ambiente padrão",
"runtime.unavailable": "{{name}} (indisponível)",
- "runtime.separate_prefix": "Usar um prefixo separado para esta compilação",
- "runtime.prefix_warning": "Um prefixo separado é criado para cada compilação do ambiente. Os salvamentos locais existentes permanecem no prefixo antigo. Eles não são copiados ou transferidos automaticamente.",
+ "runtime.separate_prefix": "Usar um prefixo separado para esta família de ambientes",
+ "runtime.prefix_warning": "As atualizações desta família reutilizam o mesmo prefixo e os salvamentos locais. Mudar de família usa um prefixo separado. Os salvamentos existentes permanecem no prefixo antigo e não são copiados ou transferidos automaticamente.",
"auth.browser": "Continuar no navegador",
"auth.browser_error": "Não foi possível abrir o login no navegador. O Google Chrome precisa estar instalado. Tente novamente ou escolha outro método.",
"auth.cancel_passkey": "Cancelar solicitação de chave de acesso",
diff --git a/assets/locales/zh-CN.json b/assets/locales/zh-CN.json
index b3e1142..56c9ee0 100644
--- a/assets/locales/zh-CN.json
+++ b/assets/locales/zh-CN.json
@@ -1,10 +1,9 @@
{
- "runtime.build_changed": "已安装的运行环境版本已更改或尚未获准。请检查后明确选择新的独立前缀。现有本地存档保留在旧前缀中。",
"runtime.game_runtime": "游戏运行环境",
"runtime.use_default": "使用默认运行环境",
"runtime.unavailable": "{{name}}(不可用)",
- "runtime.separate_prefix": "为此运行环境版本使用独立前缀",
- "runtime.prefix_warning": "每个运行环境版本都会创建独立前缀。现有本地存档保留在旧前缀中,不会自动复制或转移。",
+ "runtime.separate_prefix": "为此运行环境系列使用独立前缀",
+ "runtime.prefix_warning": "同一系列的更新会继续使用相同的前缀和本地存档。切换系列会使用独立前缀。现有本地存档保留在旧前缀中,不会自动复制或转移。",
"auth.browser": "在浏览器中继续",
"auth.browser_error": "未能打开浏览器登录页面。必须安装Google Chrome。请重试或选择其他方式。",
"auth.cancel_passkey": "取消通行密钥请求",
diff --git a/assets/locales/zh-Hant.json b/assets/locales/zh-Hant.json
index f5b1cc6..dcffe8f 100644
--- a/assets/locales/zh-Hant.json
+++ b/assets/locales/zh-Hant.json
@@ -1,10 +1,9 @@
{
- "runtime.build_changed": "已安裝的執行環境版本已變更或尚未獲准。請檢查後明確選擇新的獨立前綴。現有本機存檔保留在舊前綴中。",
"runtime.game_runtime": "遊戲執行環境",
"runtime.use_default": "使用預設執行環境",
"runtime.unavailable": "{{name}}(無法使用)",
- "runtime.separate_prefix": "為此執行環境版本使用獨立前綴",
- "runtime.prefix_warning": "每個執行環境版本都會建立獨立前綴。現有本機存檔保留在舊前綴中,不會自動複製或轉移。",
+ "runtime.separate_prefix": "為此執行環境系列使用獨立前綴",
+ "runtime.prefix_warning": "同一系列的更新會繼續使用相同的前綴和本機存檔。切換系列會使用獨立前綴。現有本機存檔保留在舊前綴中,不會自動複製或轉移。",
"auth.browser": "在瀏覽器中繼續",
"auth.browser_error": "無法開啟瀏覽器登入。必須已安裝 Google Chrome。請重試或選擇其他方式。",
"auth.cancel_passkey": "取消金鑰(Passkey)請求",
diff --git a/scripts/ui/runtime-settings-smoke.cjs b/scripts/ui/runtime-settings-smoke.cjs
index a816887..c124bdf 100644
--- a/scripts/ui/runtime-settings-smoke.cjs
+++ b/scripts/ui/runtime-settings-smoke.cjs
@@ -1,7 +1,7 @@
// Run with Electron. Exercises only the launcher's session-only demo runtime-settings UI with explicitly synthetic family descriptors.
// XODUS_UI_SMOKE_OUTPUT must be a new private directory. Optional
// XODUS_UI_SMOKE_SOURCE selects a built checkout (defaults to this checkout).
-// Spanish is the default language for this long-label fixture.
+// English is the default language for review captures.
const {app,session,ipcMain} = require('electron');
const fs = require('node:fs/promises');
const path = require('node:path');
@@ -12,7 +12,7 @@ if (!output || !path.isAbsolute(output)) throw Error('Set XODUS_UI_SMOKE_OUTPUT
if (process.argv.some(value=>value==='--launch-game'||value==='--nexus-profile')) throw Error('Demo fixture does not accept game or profile arguments');
process.env.XODUS_DEMO = '1';
app.disableHardwareAcceleration();
-const language=process.env.XODUS_UI_SMOKE_LANG || 'es-ES';
+const language=process.env.XODUS_UI_SMOKE_LANG || 'en-US';
app.commandLine.appendSwitch('lang',language);
// Never inherit another capture action or a developer server from the caller.
for (const name of ['VITE_DEV_SERVER_URL','XODUS_DEMO_CAPTURE_DIR','XODUS_DEMO_TOUR','XODUS_NEXUS_SMOKE_SCREENSHOT','XODUS_NEXUS_SMOKE_STORE','XODUS_NEXUS_SMOKE_STORE_QUERY','XODUS_NEXUS_FONTCONFIG','XODUS_NEXUS_FONTCONFIG_ORIGINAL','XODUS_NEXUS_FONTCONFIG_ORIGINAL_SET']) delete process.env[name];
@@ -45,8 +45,8 @@ async function capture(window) {
// account, runtime, prefix or installed-game filesystem operation is invoked.
ipcMain.removeHandler('runtime-families');ipcMain.handle('runtime-families',()=>choices);
ipcMain.removeHandler('update-game');ipcMain.handle('update-game',(_event,id,patch)=>{requests.push({id,patch});return {...snapshot.games[0],...patch};});
- const spanish=JSON.parse(await fs.readFile(path.join(source,'assets/locales/es.json'),'utf8'));
- const settingsLabel=spanish['ui.game_settings_fece860'];
+ const labels=JSON.parse(await fs.readFile(path.join(source,'assets/locales',language.startsWith('es')?'es.json':'en.json'),'utf8'));
+ const settingsLabel=labels['ui.game_settings_fece860'];
await ready(window,'.sidebar nav button:nth-child(2)');
await evaluate(window,()=>document.querySelector('.sidebar nav button:nth-child(2)').click());
await ready(window,'.library-card-menu-button');
@@ -84,10 +84,11 @@ async function capture(window) {
});
if(before.documentWidth>width||before.dialog.left<0||before.dialog.right>width||before.dialog.top<0||before.dialog.bottom>height||!before.focusInDialog||!before.focusIsInitial)throw Error('Runtime settings bounds/focus failed: '+JSON.stringify(before));
if(variant==='default'&&(before.options.length!==1||before.selected!=='default'||before.consent!==undefined))throw Error('Default must not advertise an uninstalled family');
- if(variant==='unavailable'&&(!before.options.some(option=>option.value===family&&option.disabled)||before.selected!==family||before.consent!==false))throw Error('Unavailable persisted family must not fall back or preapprove');
+ if(variant==='unavailable'&&(!before.options.some(option=>option.value===family&&option.disabled)||before.selected!==family||before.consent!==true))throw Error('Unavailable persisted family must preserve family selection and consent');
let consentGeometry;
if(variant==='synthetic-installed-update') {
- if(before.selected!==family||before.consent!==false)throw Error('Build B must require fresh consent');
+ if(before.selected!==family||before.consent!==true)throw Error('Family update must retain consent');
+ await evaluate(window,()=>document.querySelector('.game-dialog input[type="checkbox"][required]').click());
// Native form validation must keep Save from invoking even the demo handler.
await evaluate(window,()=>document.querySelector('.game-dialog button.primary').click());await settle(window);
if(requests.length)throw Error('Unchecked consent submitted a settings request');
@@ -102,12 +103,11 @@ async function capture(window) {
if(!cancelFocus.restored||requests.length)throw Error('B cancellation failed focus restoration or submitted settings: '+JSON.stringify({width,height,variant,cancelFocus,requests}));
if(variant==='synthetic-installed-update') {
await open();
- await evaluate(window,()=>{const input=document.querySelector('.game-dialog input[type="checkbox"][required]');if(input.checked)throw Error('Reopened B consent was prefilled');input.focus();});
- await press(0);
+ await evaluate(window,()=>{const input=document.querySelector('.game-dialog input[type="checkbox"][required]');if(!input.checked)throw Error('Family consent was lost on reopen');input.focus();});
await evaluate(window,()=>{const save=document.querySelector('.game-dialog button.primary');save.scrollIntoView({block:'center'});save.focus();});
await press(0);await closed();
const sent=requests[0]?.patch;
- if(requests.length!==1||sent.runtime!==family||sent.runtimeApproveBuild!==true||JSON.stringify(sent.runtimeExpectedBuild)!==JSON.stringify(b))throw Error('Explicit B approval payload mismatch: '+JSON.stringify(requests));
+ if(requests.length!==1||sent.runtime!==family||sent.runtimeSeparatePrefix!==true||'runtimeApproveBuild' in sent||'runtimeExpectedBuild' in sent)throw Error('Family selection payload mismatch: '+JSON.stringify(requests));
}
results.push({...before,width,height,variant,consentGeometry,cancelRestoredFocus:cancelFocus,requests:structuredClone(requests)});
}
diff --git a/src/main/game-runtime-readiness.ts b/src/main/game-runtime-readiness.ts
index dc6c2e2..9d33264 100644
--- a/src/main/game-runtime-readiness.ts
+++ b/src/main/game-runtime-readiness.ts
@@ -1,12 +1,12 @@
import type {Game} from '../shared/types.js';
import {resolveGameRuntime} from './runtime-prefix-binding.js';
export interface RuntimeReadinessState {
- game?:Pick<Game,'id'|'runtime'|'runtimeSeparatePrefix'|'runtimeBuild'>;
+ game?:Pick<Game,'id'|'runtime'|'runtimeSeparatePrefix'|'runtimeBuild'|'runtimePrefixes'>;
runtimeRoot:string;dataRoot:string;defaultWine:string|undefined;arch?:string;
}
function identity(state:RuntimeReadinessState):string {
const game=state.game;
- return JSON.stringify([game?.id,game?.runtime,game?.runtimeSeparatePrefix,game?.runtimeBuild?.buildId,game?.runtimeBuild?.manifestSha256,game?.runtimeBuild?.sourceCommit,state.runtimeRoot,state.dataRoot,state.defaultWine,state.arch]);
+ return JSON.stringify([game?.id,game?.runtime,game?.runtimeSeparatePrefix,game?.runtimeBuild?.buildId,game?.runtimeBuild?.manifestSha256,game?.runtimeBuild?.sourceCommit,game?.runtimePrefixes,state.runtimeRoot,state.dataRoot,state.defaultWine,state.arch]);
}
/** Read-only readiness hint. No prefix binding, runtime execution or account
* queries. Actual launch independently resolves and verifies its captured build. */
@@ -14,7 +14,7 @@ export async function gameRuntimeReadiness(read:()=>RuntimeReadinessState,resolv
try {
const state=structuredClone(read()),before=identity(state);
if(!state.game)return false;
- await resolve({runtimeRoot:state.runtimeRoot,dataRoot:state.dataRoot,gameId:state.game.id,selection:state.game.runtime,separatePrefix:state.game.runtimeSeparatePrefix,approvedBuild:state.game.runtimeBuild,defaultWine:state.defaultWine,arch:state.arch});
+ await resolve({runtimeRoot:state.runtimeRoot,dataRoot:state.dataRoot,gameId:state.game.id,selection:state.game.runtime,separatePrefix:state.game.runtimeSeparatePrefix,approvedBuild:state.game.runtimeBuild,prefixAnchor:state.game.runtime&&state.game.runtime!=='default'?state.game.runtimePrefixes?.[state.game.runtime]:undefined,defaultWine:state.defaultWine,arch:state.arch});
return before===identity(read());
}catch{return false;}
}
diff --git a/src/main/index.ts b/src/main/index.ts
index ced6900..3f2e9b4 100644
--- a/src/main/index.ts
+++ b/src/main/index.ts
@@ -800,7 +800,7 @@ async function gameContent(id: string) {
const identity = `${authState.username}:${backend.current.binaryPath}:${currentMarket()}`;
accountLibrary.select(authState.username, backend.current.capabilities.library ? backend.current.binaryPath : undefined, currentMarket());
const selectedRuntime=await resolveGameRuntime({runtimeRoot:store.settings.runtimeRoot,dataRoot:path.dirname(store.settings.runtimeRoot),gameId:game.id,
- selection:game.runtime,separatePrefix:game.runtimeSeparatePrefix,approvedBuild:game.runtimeBuild,defaultWine:selectedWinePath(store.settings.winePath,store.settings.runtimeRoot,runtime.current.winePath)});
+ selection:game.runtime,separatePrefix:game.runtimeSeparatePrefix,approvedBuild:game.runtimeBuild,prefixAnchor:game.runtime&&game.runtime!=='default'?game.runtimePrefixes?.[game.runtime]:undefined,defaultWine:selectedWinePath(store.settings.winePath,store.settings.runtimeRoot,runtime.current.winePath)});
const result = await contentManager().plan(game, () => accountLibrary.access(true), currentMarket());
const wine = selectedRuntime.winePath;
result.plan.runtimeSupported = Boolean(wine && await storeContentRuntime(wine));
@@ -1133,7 +1133,7 @@ async function gameLaunchOptions(id: string): Promise<GameLaunchOptions> {
let wine: string;
try {
wine=(await resolveGameRuntime({runtimeRoot:store.settings.runtimeRoot,dataRoot:path.dirname(store.settings.runtimeRoot),gameId:game.id,
- selection:game.runtime,separatePrefix:game.runtimeSeparatePrefix,approvedBuild:game.runtimeBuild,defaultWine:selectedWinePath(store.settings.winePath,store.settings.runtimeRoot,runtime.current.winePath)})).winePath;
+ selection:game.runtime,separatePrefix:game.runtimeSeparatePrefix,approvedBuild:game.runtimeBuild,prefixAnchor:game.runtime&&game.runtime!=='default'?game.runtimePrefixes?.[game.runtime]:undefined,defaultWine:selectedWinePath(store.settings.winePath,store.settings.runtimeRoot,runtime.current.winePath)})).winePath;
} catch(error) { const reason=(error as Error).message;return {cloudSaves:false,cloudReason:reason,vcInstall:false,vcReason:reason}; }
if (!wine) return { cloudSaves: false, cloudReason: 'Select Xodus Runtime in Settings.', vcInstall: false, vcReason: 'Select Xodus Runtime in Settings.' };
const wineAvailable = await fs.access(wine, constants.X_OK).then(() => true, () => false);
@@ -1216,7 +1216,7 @@ async function prepareGameLaunch(id: string, steam?: SteamGameContext): Promise<
const locale = supportedGameLocale(game.locale ?? '');
const titleId = await gameTitleId(game).catch(() => undefined);
const runtimeContext = await resolveGameRuntime({runtimeRoot:store.settings.runtimeRoot,dataRoot:path.dirname(store.settings.runtimeRoot),gameId:game.id,
- selection:game.runtime,separatePrefix:game.runtimeSeparatePrefix,approvedBuild:game.runtimeBuild,defaultWine:selectedWinePath(store.settings.winePath,store.settings.runtimeRoot,runtime.current.winePath)});
+ selection:game.runtime,separatePrefix:game.runtimeSeparatePrefix,approvedBuild:game.runtimeBuild,prefixAnchor:game.runtime&&game.runtime!=='default'?game.runtimePrefixes?.[game.runtime]:undefined,defaultWine:selectedWinePath(store.settings.winePath,store.settings.runtimeRoot,runtime.current.winePath)});
const wine = runtimeContext.winePath;
await bindRuntimePrefix(runtimeContext);
if (!wine) throw new Error('Select a Wine / Proton binary in Settings.');
@@ -1509,7 +1509,7 @@ async function installGameVcRuntime(id: string): Promise<void> {
const inspected = await inspectGameDirectory(game.path);
if (inspected.installState !== 'ready') throw new Error(inspected.installMessage ?? 'The game installation is not ready.');
const runtimeContext = await resolveGameRuntime({runtimeRoot:store.settings.runtimeRoot,dataRoot:path.dirname(store.settings.runtimeRoot),gameId:game.id,
- selection:game.runtime,separatePrefix:game.runtimeSeparatePrefix,approvedBuild:game.runtimeBuild,defaultWine:selectedWinePath(store.settings.winePath,store.settings.runtimeRoot,runtime.current.winePath)});
+ selection:game.runtime,separatePrefix:game.runtimeSeparatePrefix,approvedBuild:game.runtimeBuild,prefixAnchor:game.runtime&&game.runtime!=='default'?game.runtimePrefixes?.[game.runtime]:undefined,defaultWine:selectedWinePath(store.settings.winePath,store.settings.runtimeRoot,runtime.current.winePath)});
const wine = runtimeContext.winePath;
await bindRuntimePrefix(runtimeContext);
if (!wine) throw new Error('Select Xodus Runtime in Settings first.');
@@ -2043,11 +2043,11 @@ function registerIpc(): void {
ipcMain.handle('runtime-families', async () => {const families=await runtime.refreshFamilies();emitSnapshot();return families;});
ipcMain.handle('update-game', async (_event, id: string, patch: Partial<Game>&RuntimeSettingsRequest) => {
const allowed: Partial<Game> = {};
- if ('runtime' in patch || 'runtimeSeparatePrefix' in patch || 'runtimeApproveBuild' in patch) {
+ if ('runtime' in patch || 'runtimeSeparatePrefix' in patch) {
const current=store.games.find(game=>game.id===id);
if(!current)throw Error('Game not found.');
const selection=gameRuntimeSelection('runtime' in patch?patch.runtime:current.runtime);
- if(selection!==(current.runtime??'default')||patch.runtimeApproveBuild===true||selection!=='default'&&patch.runtimeSeparatePrefix!==undefined&&patch.runtimeSeparatePrefix!==current.runtimeSeparatePrefix)ensureIdle();
+ if(selection!==(current.runtime??'default')||selection!=='default'&&patch.runtimeSeparatePrefix!==undefined&&patch.runtimeSeparatePrefix!==current.runtimeSeparatePrefix)ensureIdle();
Object.assign(allowed,await approvedRuntimeSettings(current,patch,store.settings.runtimeRoot));
}
for (const key of ['title', 'executable', 'launchArgs'] as const) if (typeof patch[key] === 'string') allowed[key] = patch[key];
diff --git a/src/main/runtime-families.test.ts b/src/main/runtime-families.test.ts
index 845506b..e1ebe39 100644
--- a/src/main/runtime-families.test.ts
+++ b/src/main/runtime-families.test.ts
@@ -218,50 +218,38 @@ async function switchBuild(id:string) {
return {buildId:id,sourceCommit,manifestSha256:hash(bytes)};
}
const savedGame=():Game=>({id:'test',path:'/synthetic/game',title:'Synthetic',installState:'ready',addedAt:'2026-01-01'});
-it('pins explicit build approval: A to B never creates a fresh prefix from old consent and preserves A local progress',async()=>{
- await fixture();let game=savedGame();const approvedA=await approval();
- Object.assign(game,await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true,runtimeApproveBuild:true,runtimeExpectedBuild:approvedA},root));
- const options=()=>({runtimeRoot:root,dataRoot:root,gameId:game.id,selection:game.runtime,separatePrefix:game.runtimeSeparatePrefix,approvedBuild:game.runtimeBuild,defaultWine:'/default/wine',arch:'x64'});
- const a=await resolveGameRuntime(options());await bindRuntimePrefix(a);const progress=path.join(a.compatibilityDataPath,'synthetic-progress');await fs.writeFile(progress,'A progress');
- const approvedB=await switchBuild('d'.repeat(64));const bRoot=path.join(root,'runtime-prefixes',family,approvedB.buildId,game.id);
- await expect(resolveGameRuntime(options())).rejects.toThrow('build changed');
- expect(await fs.readFile(progress,'utf8')).toBe('A progress');await expect(fs.stat(bRoot)).rejects.toMatchObject({code:'ENOENT'});
- const noResolve=vi.fn(()=>{throw Error('Ordinary settings Save must not approve a new build');});
- const ordinary=await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true},root,noResolve);
- expect(ordinary.runtimeBuild).toEqual(approvedA);expect(noResolve).not.toHaveBeenCalled();
- await expect(approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true,runtimeApproveBuild:true,runtimeExpectedBuild:approvedA},root)).rejects.toThrow('settings were open');
- const forged=await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true,runtimeBuild:approvedB} as never,root);
- expect(forged.runtimeBuild).toEqual(approvedA);
- Object.assign(game,await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true,runtimeApproveBuild:true,runtimeExpectedBuild:approvedB},root));
- expect(game.runtimeBuild).toEqual(approvedB);await expect(fs.stat(bRoot)).rejects.toMatchObject({code:'ENOENT'}); // Saving the choice still does not create a prefix.
- const b=await resolveGameRuntime(options());await bindRuntimePrefix(b);
- expect(await fs.readdir(b.compatibilityDataPath)).toEqual(['.nexus-runtime-family.json']);expect(await fs.readFile(progress,'utf8')).toBe('A progress');
-});
-it('does not adopt a legacy family-wide consent or rebind on unrelated title/locale Save',async()=>{
- await fixture();const game={...savedGame(),runtime:family,runtimeSeparatePrefix:true} as Game;
- await expect(approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true},root)).rejects.toThrow('explicitly approve');
- await expect(resolveGameRuntime({runtimeRoot:root,dataRoot:root,gameId:game.id,selection:family,separatePrefix:true,defaultWine:'/default/wine',arch:'x64'})).rejects.toThrow('not been approved');
- const trusted=await approval();Object.assign(game,await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true,runtimeApproveBuild:true,runtimeExpectedBuild:trusted},root));
- await switchBuild('d'.repeat(64));
- const {StateStore}=await import('./store');const store=new StateStore(path.join(root,'profile'));await store.upsertGame(game);
- await store.patchGame(game.id,{...await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true},root),title:'New title',locale:'de-DE'});
- const loaded=new StateStore(path.join(root,'profile'));await loaded.load();expect(loaded.games[0]).toMatchObject({title:'New title',locale:'de-DE',runtimeBuild:trusted});
-});
-it('captures the approved descriptor once and cannot authorize C if pointer changes after resolving B',async()=>{
- await fixture();const game=savedGame();const expectedB=await approval();
- const resolve=vi.fn(async()=>{const b=await resolveRuntimeFamily(root,family,'x64');await switchBuild('d'.repeat(64));return b;});
- const patch=await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true,runtimeApproveBuild:true,runtimeExpectedBuild:expectedB},root,resolve);
- expect(resolve).toHaveBeenCalledOnce();expect(patch.runtimeBuild).toEqual(expectedB);
- await expect(resolveGameRuntime({runtimeRoot:root,dataRoot:root,gameId:game.id,selection:patch.runtime,separatePrefix:patch.runtimeSeparatePrefix,approvedBuild:patch.runtimeBuild,defaultWine:'/default/wine',arch:'x64'})).rejects.toThrow('build changed');
+it('follows verified current B with the same new-family prefix and existing saves, while captured A remains immutable',async()=>{
+ await fixture();let game=savedGame();Object.assign(game,await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true},root));
+ const options=()=>({runtimeRoot:root,dataRoot:root,gameId:game.id,selection:game.runtime,separatePrefix:game.runtimeSeparatePrefix,prefixAnchor:game.runtimePrefixes?.[family],defaultWine:'/default/wine',arch:'x64'});
+ const a=await resolveGameRuntime(options());await bindRuntimePrefix(a);const save=path.join(a.compatibilityDataPath,'save');await fs.writeFile(save,'real synthetic progress');const ino=(await fs.stat(save)).ino;
+ await retainRuntimeFamilyBuild(root,family,'x64');await switchBuild('d'.repeat(64));
+ const b=await resolveGameRuntime(options());await bindRuntimePrefix(b);expect(b.winePath).not.toBe(a.winePath);expect(b.compatibilityDataPath).toBe(a.compatibilityDataPath);expect(a.managed?.buildId).toBe(buildId);expect(b.managed?.buildId).toBe('d'.repeat(64));
+ expect(await fs.readFile(save,'utf8')).toBe('real synthetic progress');expect((await fs.stat(save)).ino).toBe(ino);
+ const noResolve=vi.fn(()=>{throw Error('Ordinary Save must not need a new build approval');});
+ expect((await approvedRuntimeSettings(game,{},root,noResolve)).runtimePrefixes).toEqual(game.runtimePrefixes);expect(noResolve).not.toHaveBeenCalled();
+});
+it('preserves old build-specific prefix origin across default and back without moving or resetting progress',async()=>{
+ await fixture();const origin=await approval();let game={...savedGame(),runtime:family,runtimeSeparatePrefix:true,runtimeBuild:origin} as Game;
+ const old=await resolveGameRuntime({runtimeRoot:root,dataRoot:root,gameId:game.id,selection:family,separatePrefix:true,approvedBuild:origin,defaultWine:'/default/wine',arch:'x64'});await bindRuntimePrefix(old);
+ const save=path.join(old.compatibilityDataPath,'save');await fs.writeFile(save,'old progress');const marker=await fs.readFile(path.join(old.compatibilityDataPath,'.nexus-runtime-family.json'),'utf8');
+ Object.assign(game,await approvedRuntimeSettings(game,{runtime:'default'},root));expect(game.runtimeBuild).toBeUndefined();expect(game.runtimePrefixes?.[family]).toEqual({layout:'build',origin});
+ await switchBuild('d'.repeat(64));Object.assign(game,await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true},root));
+ const next=await resolveGameRuntime({runtimeRoot:root,dataRoot:root,gameId:game.id,selection:family,separatePrefix:true,prefixAnchor:game.runtimePrefixes?.[family],defaultWine:'/default/wine',arch:'x64'});await bindRuntimePrefix(next);
+ expect(next.compatibilityDataPath).toBe(old.compatibilityDataPath);expect(next.winePath).not.toBe(old.winePath);expect(await fs.readFile(save,'utf8')).toBe('old progress');expect(await fs.readFile(path.join(next.compatibilityDataPath,'.nexus-runtime-family.json'),'utf8')).toBe(marker);
+ const {StateStore}=await import('./store');const store=new StateStore(path.join(root,'profile'));await store.upsertGame(game);await store.patchGame(game.id,{title:'Renamed'});const loaded=new StateStore(path.join(root,'profile'));await loaded.load();expect(loaded.games[0].runtimePrefixes).toEqual(game.runtimePrefixes);
+});
+it('requires first family consent, accepts updates without fresh consent, and ignores renderer-forged prefix identities',async()=>{
+ await fixture();const game=savedGame();await expect(approvedRuntimeSettings(game,{runtime:family},root)).rejects.toThrow('separate prefix');
+ const patch=await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true,runtimePrefixes:{[family]:{layout:'build',origin:await approval()}}} as never,root);
+ expect(patch.runtimePrefixes).toEqual({[family]:{layout:'family'}});expect(patch.runtimeBuild).toBeUndefined();
+ Object.assign(game,patch);await switchBuild('d'.repeat(64));expect((await approvedRuntimeSettings(game,{},root)).runtimePrefixes).toEqual(game.runtimePrefixes);
await expect(fs.stat(path.join(root,'runtime-prefixes'))).rejects.toMatchObject({code:'ENOENT'});
});
-it('requires a fresh transient approval and exact expected descriptor, and clears the binding only when default is chosen',async()=>{
- await fixture();const game=savedGame(),expected=await approval();
- await expect(approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true},root)).rejects.toThrow('Fresh explicit');
- await expect(approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true,runtimeApproveBuild:true,runtimeExpectedBuild:{...expected,manifestSha256:'f'.repeat(64)}},root)).rejects.toThrow('settings were open');
- const approved=await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true,runtimeApproveBuild:true,runtimeExpectedBuild:expected},root);
- expect(approved.runtimeBuild).toEqual(expected);
- expect(await approvedRuntimeSettings({...game,...approved},{runtime:'default'},root)).toEqual({runtime:'default',runtimeSeparatePrefix:false,runtimeBuild:undefined});
+it('same-family ordinary Save preserves compatibility origin even when current runtime is unavailable',async()=>{
+ await fixture();const origin=await approval(),game={...savedGame(),runtime:family,runtimeSeparatePrefix:true,runtimeBuild:origin} as Game;
+ await fs.unlink(path.join(root,'variants',family,'current.json'));
+ const patch=await approvedRuntimeSettings(game,{},root);expect(patch.runtimePrefixes).toEqual({[family]:{layout:'build',origin}});
+ await expect(resolveGameRuntime({runtimeRoot:root,dataRoot:root,gameId:game.id,selection:family,separatePrefix:true,prefixAnchor:patch.runtimePrefixes?.[family],defaultWine:'/default/wine',arch:'x64'})).rejects.toThrow();
});
async function installNextFixture() {
@@ -276,22 +264,13 @@ async function installNextFixture() {
await fs.writeFile(path.join(root,'variants',family,'current.json'),JSON.stringify(pointer));
return previous;
}
-it('retains approved A across current B, and only explicit B approval creates a new prefix',async()=>{
- await fixture();const a=await approval();
- const options={runtimeRoot:root,dataRoot:root,gameId:'retained',selection:family,separatePrefix:true,defaultWine:'/default/wine',arch:'x64'};
- const old=await resolveGameRuntime({...options,approvedBuild:a});await bindRuntimePrefix(old);
- await fs.writeFile(path.join(old.compatibilityDataPath,'synthetic-save'),'A progress');
- await retainRuntimeFamilyBuild(root,family,'x64');await retainRuntimeFamilyBuild(root,family,'x64');
- await installNextFixture();
- const retained=await resolveGameRuntime({...options,approvedBuild:a});
- expect(retained.winePath).toBe(old.winePath);expect(retained.compatibilityDataPath).toBe(old.compatibilityDataPath);
- expect(await fs.readFile(path.join(retained.compatibilityDataPath,'synthetic-save'),'utf8')).toBe('A progress');
- const game={id:'retained',runtime:family,runtimeSeparatePrefix:true,runtimeBuild:a} as Game;
- const ordinary=await approvedRuntimeSettings(game,{},root);expect(ordinary.runtimeBuild).toEqual(a);
- const b=await approval();const patch=await approvedRuntimeSettings(game,{runtimeApproveBuild:true,runtimeExpectedBuild:b},root);
- const fresh=await resolveGameRuntime({...options,approvedBuild:patch.runtimeBuild});await bindRuntimePrefix(fresh);
- expect(fresh.compatibilityDataPath).not.toBe(old.compatibilityDataPath);
- expect(await fs.readdir(fresh.compatibilityDataPath)).toEqual(['.nexus-runtime-family.json']);
+it('retains A for rollback but next launch follows B with the same compatibility prefix',async()=>{
+ await fixture();const a=await approval();const options={runtimeRoot:root,dataRoot:root,gameId:'retained',selection:family,separatePrefix:true,defaultWine:'/default/wine',arch:'x64',approvedBuild:a};
+ const old=await resolveGameRuntime(options);await bindRuntimePrefix(old);await fs.writeFile(path.join(old.compatibilityDataPath,'save'),'A progress');await retainRuntimeFamilyBuild(root,family,'x64');await installNextFixture();
+ const next=await resolveGameRuntime(options);await bindRuntimePrefix(next);expect(next.winePath).not.toBe(old.winePath);expect(next.compatibilityDataPath).toBe(old.compatibilityDataPath);expect(await fs.readFile(path.join(next.compatibilityDataPath,'save'),'utf8')).toBe('A progress');
+ expect((await resolveRuntimeFamilyBuild(root,family,a,'x64')).winePath).toBe(old.winePath);
+ await fs.writeFile(path.join(root,'variants',family,'current.json'),JSON.stringify({schema:1,family,sourceRepository,...a}));
+ expect((await resolveGameRuntime(options)).winePath).toBe(old.winePath);
});
it('does not reconstruct missing A receipts from an approved identity or an existing release directory',async()=>{
await fixture();const a=await approval();await installNextFixture();
@@ -358,11 +337,11 @@ it('fails closed when retained A payload disappears while current B remains vali
expect((await resolveRuntimeFamily(root,family,'x64')).buildId).not.toBe(buildId);
});
-it('reports retained A ready with missing or corrupt current B, but never missing or corrupt A',async()=>{
+it('reports unavailable for missing or corrupt current B despite retaining A for rollback',async()=>{
await fixture();const a=await approval();await retainRuntimeFamilyBuild(root,family,'x64');const previous=await installNextFixture();
const state:RuntimeReadinessState={game:{id:'readiness',runtime:family,runtimeSeparatePrefix:true,runtimeBuild:a},runtimeRoot:root,dataRoot:root,defaultWine:undefined,arch:'x64'};
const current=path.join(root,'variants',family,'current.json');await fs.writeFile(current,'{corrupt B');
- expect(await gameRuntimeReadiness(()=>state)).toBe(true);await fs.unlink(current);expect(await gameRuntimeReadiness(()=>state)).toBe(true);
+ expect(await gameRuntimeReadiness(()=>state)).toBe(false);await fs.unlink(current);expect(await gameRuntimeReadiness(()=>state)).toBe(false);
await fs.appendFile(path.join(previous,'files/bin/wine'),'corrupt A');expect(await gameRuntimeReadiness(()=>state)).toBe(false);
await fs.rm(previous,{recursive:true});expect(await gameRuntimeReadiness(()=>state)).toBe(false);
await expect(fs.access(path.join(root,'runtime-prefixes'))).rejects.toThrow();
@@ -374,3 +353,17 @@ it.each(['approval','runtimeRoot'])('rejects readiness if %s changes during veri
if(changed==='approval')state.game={...state.game!,runtimeBuild:{...state.game!.runtimeBuild!,buildId:'d'.repeat(64)}};else state.runtimeRoot+='-changed';
resume();expect(await result).toBe(false);
});
+
+it('preserves independent family anchors and saves through family1 to family2 to family1',async()=>{
+ await fixture();const second='nexus';const secondRoot=path.join(root,'variants',second);await fs.cp(path.join(root,'variants',family),secondRoot,{recursive:true});
+ const manifestFile=path.join(secondRoot,'releases',buildId,'nexus-family.json');const manifest=JSON.parse(await fs.readFile(manifestFile,'utf8'));manifest.family=second;manifest.sourceRepository='domsvoboda/nexus-runtime';const bytes=JSON.stringify(manifest);await fs.writeFile(manifestFile,bytes);await fs.writeFile(path.join(secondRoot,'current.json'),JSON.stringify({schema:1,family:second,buildId,sourceRepository:manifest.sourceRepository,sourceCommit,manifestSha256:hash(bytes)}));
+ let game=savedGame();const context=()=>resolveGameRuntime({runtimeRoot:root,dataRoot:root,gameId:game.id,selection:game.runtime,separatePrefix:game.runtimeSeparatePrefix,prefixAnchor:game.runtimePrefixes?.[game.runtime as typeof family],defaultWine:'/default/wine',arch:'x64'});
+ Object.assign(game,await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true},root));const first=await context();await bindRuntimePrefix(first);await fs.writeFile(path.join(first.compatibilityDataPath,'save'),'family1');
+ await expect(approvedRuntimeSettings(game,{runtime:second},root)).rejects.toThrow('Explicit separate prefix');
+ Object.assign(game,await approvedRuntimeSettings(game,{runtime:second,runtimeSeparatePrefix:true},root));const other=await context();await bindRuntimePrefix(other);await fs.writeFile(path.join(other.compatibilityDataPath,'save'),'family2');
+ Object.assign(game,await approvedRuntimeSettings(game,{runtime:family,runtimeSeparatePrefix:true},root));expect((await context()).compatibilityDataPath).toBe(first.compatibilityDataPath);expect(Object.keys(game.runtimePrefixes!)).toHaveLength(2);expect(await fs.readFile(path.join(first.compatibilityDataPath,'save'),'utf8')).toBe('family1');expect(await fs.readFile(path.join(other.compatibilityDataPath,'save'),'utf8')).toBe('family2');
+});
+it('rejects an old marker conflicting with its persisted origin without rewriting it or its save',async()=>{
+ await fixture();const origin=await approval(),options={runtimeRoot:root,dataRoot:root,gameId:'old',selection:family,separatePrefix:true,approvedBuild:origin,defaultWine:'/default/wine',arch:'x64'};
+ const a=await resolveGameRuntime(options);await bindRuntimePrefix(a);const marker=path.join(a.compatibilityDataPath,'.nexus-runtime-family.json');const invalid=JSON.stringify({...JSON.parse(await fs.readFile(marker,'utf8')),manifestSha256:'0'.repeat(64)});await fs.writeFile(marker,invalid);await fs.writeFile(path.join(a.compatibilityDataPath,'save'),'preserve');await switchBuild('d'.repeat(64));const b=await resolveGameRuntime(options);await expect(bindRuntimePrefix(b)).rejects.toThrow('mismatch');expect(await fs.readFile(marker,'utf8')).toBe(invalid);expect(await fs.readFile(path.join(a.compatibilityDataPath,'save'),'utf8')).toBe('preserve');
+});
diff --git a/src/main/runtime-families.ts b/src/main/runtime-families.ts
index c2a3a73..40d82a0 100644
--- a/src/main/runtime-families.ts
+++ b/src/main/runtime-families.ts
@@ -152,11 +152,11 @@ async function resolveVerifiedRuntimeFamily(runtimeRoot:string,selection:unknown
inFlight.set(key,work);
try{return await work;}finally{if(inFlight.get(key)===work)inFlight.delete(key);}
}
-/** Current build is for discovery and fresh explicit approval. */
+/** Current build is used by discovery and every new family launch. */
export function resolveRuntimeFamily(runtimeRoot:string,selection:unknown,arch:string=process.arch) {
return resolveVerifiedRuntimeFamily(runtimeRoot,selection,arch);
}
-/** Launch an exact approved retained build, independently of current. */
+/** Exact retained-build lookup for rollback/lifetime tooling, not per-game launch selection. */
export async function resolveRuntimeFamilyBuild(runtimeRoot:string,selection:unknown,approval:unknown,arch:string=process.arch) {
return resolveVerifiedRuntimeFamily(runtimeRoot,selection,arch,runtimeBuildApproval(approval));
}
diff --git a/src/main/runtime-prefix-binding.ts b/src/main/runtime-prefix-binding.ts
index 124cbaa..a89f88d 100644
--- a/src/main/runtime-prefix-binding.ts
+++ b/src/main/runtime-prefix-binding.ts
@@ -1,15 +1,15 @@
import {promises as fs} from 'node:fs';
import path from 'node:path';
-import {gameRuntimeSelection,sameRuntimeBuild,type GameRuntimeSelection} from '../shared/runtime-selection.js';
-import {resolveRuntimeFamilyBuild,type ResolvedRuntimeFamily} from './runtime-families.js';
+import {gameRuntimeSelection,runtimePrefixAnchor,runtimeBuildApproval,type RuntimePrefixAnchor,type GameRuntimeSelection} from '../shared/runtime-selection.js';
+import {resolveRuntimeFamily,type ResolvedRuntimeFamily} from './runtime-families.js';
export interface GameRuntimeContext {
readonly selection:GameRuntimeSelection;readonly family:'default'|'nexus'|'nexus-cachyos';
readonly winePath:string;readonly compatibilityDataPath:string;readonly legacyPrefixRoot:string;readonly dataRoot:string;
- readonly managed?:Readonly<ResolvedRuntimeFamily>;
+ readonly prefixAnchor?:Readonly<RuntimePrefixAnchor>;readonly managed?:Readonly<ResolvedRuntimeFamily>;
}
/** Capture once before prerequisite staging or launch. Later setting/pointer
* changes cannot redirect this session, its prefix or its captured Stop runner. */
-export async function resolveGameRuntime(options:{runtimeRoot:string;dataRoot:string;gameId:string;selection:unknown;separatePrefix:unknown;approvedBuild?:unknown;defaultWine:string|undefined;arch?:string}):Promise<Readonly<GameRuntimeContext>> {
+export async function resolveGameRuntime(options:{runtimeRoot:string;dataRoot:string;gameId:string;selection:unknown;separatePrefix:unknown;approvedBuild?:unknown;prefixAnchor?:unknown;defaultWine:string|undefined;arch?:string}):Promise<Readonly<GameRuntimeContext>> {
const selection=gameRuntimeSelection(options.selection);
if(!/^[A-Za-z0-9_-]{1,128}$/.test(options.gameId))throw Error('Invalid game prefix identity.');
if(selection==='default') {
@@ -22,10 +22,11 @@ export async function resolveGameRuntime(options:{runtimeRoot:string;dataRoot:st
compatibilityDataPath:path.join(options.dataRoot,'compatdata',options.gameId),legacyPrefixRoot:path.join(options.dataRoot,'prefixes',options.gameId)});
}
if(options.separatePrefix!==true)throw Error('Choose a separate runtime prefix before using this family. Existing local saves remain in the old prefix.');
- const managed=await resolveRuntimeFamilyBuild(options.runtimeRoot,selection,options.approvedBuild,options.arch).catch(error=>{throw Error('The selected runtime build changed, has not been approved or failed verification. Explicitly choose an installed build in Game settings. Existing prefix and local saves were preserved.',{cause:error});});
- if(!sameRuntimeBuild(options.approvedBuild,managed))throw Error('The selected runtime build changed or has not been approved. Explicitly choose the installed build in Game settings. Existing prefix and local saves were preserved.');
- const root=path.join(options.dataRoot,'runtime-prefixes',selection,managed.buildId,options.gameId);
- return Object.freeze({selection,family:selection,winePath:managed.winePath,dataRoot:options.dataRoot,managed,
+ const managed=await resolveRuntimeFamily(options.runtimeRoot,selection,options.arch);
+ // Persisted pre-0.5 build metadata identifies an existing prefix, not its next runtime.
+ const anchor=options.prefixAnchor!==undefined?runtimePrefixAnchor(options.prefixAnchor):options.approvedBuild!==undefined?{layout:'build' as const,origin:runtimeBuildApproval(options.approvedBuild)}:{layout:'family' as const};
+ const root=path.join(options.dataRoot,'runtime-prefixes',selection,anchor.layout==='build'?anchor.origin.buildId:'prefixes',options.gameId);
+ return Object.freeze({selection,family:selection,winePath:managed.winePath,dataRoot:options.dataRoot,managed,prefixAnchor:Object.freeze(anchor),
compatibilityDataPath:path.join(root,'compatdata'),legacyPrefixRoot:path.join(root,'wine')});
}
/** No pfx/wineboot, copying, save migration or default pointer mutation. */
@@ -43,7 +44,8 @@ export async function bindRuntimePrefix(context:Readonly<GameRuntimeContext>):Pr
try{if(!(await fs.lstat(marker)).isFile())throw Error('Runtime prefix binding must be a regular file.');}
catch(error){if((error as NodeJS.ErrnoException).code!=='ENOENT')throw error;}
}
- const expected=context.managed?{schema:1,family:context.family,buildId:context.managed.buildId,sourceCommit:context.managed.sourceCommit,manifestSha256:context.managed.manifestSha256,prefixSchema:context.managed.prefixSchema,arch:context.managed.arch}:undefined;
+ const anchor=context.prefixAnchor;
+ const expected=context.managed?(anchor?.layout==='build'?{schema:1,family:context.family,buildId:anchor.origin.buildId,sourceCommit:anchor.origin.sourceCommit,manifestSha256:anchor.origin.manifestSha256,prefixSchema:context.managed.prefixSchema,arch:context.managed.arch}:{schema:2,family:context.family,layout:'family',prefixSchema:context.managed.prefixSchema,arch:context.managed.arch}):undefined;
try {
const current=JSON.parse(await fs.readFile(marker,'utf8'));
if(!expected) {if(current.family!=='default')throw Error('The default prefix belongs to another runtime family.');return;}
diff --git a/src/main/runtime-settings.ts b/src/main/runtime-settings.ts
index 9b4839d..2f2f198 100644
--- a/src/main/runtime-settings.ts
+++ b/src/main/runtime-settings.ts
@@ -1,22 +1,18 @@
import type {Game} from '../shared/types.js';
-import {gameRuntimeSelection,runtimeBuildApproval,sameRuntimeBuild,type RuntimeBuildApproval} from '../shared/runtime-selection.js';
+import {gameRuntimeSelection,runtimePrefixAnchors,runtimeBuildApproval} from '../shared/runtime-selection.js';
import {resolveRuntimeFamily} from './runtime-families.js';
-export type RuntimeSettingsRequest=Partial<Pick<Game,'runtime'|'runtimeSeparatePrefix'>> & {runtimeApproveBuild?:boolean;runtimeExpectedBuild?:RuntimeBuildApproval};
-/** Explicit compare-and-set. Expected hashes are only a stale-form precondition;
- * persist exclusively the once-resolved, verified server descriptor. */
+export type RuntimeSettingsRequest=Partial<Pick<Game,'runtime'|'runtimeSeparatePrefix'>>;
export async function approvedRuntimeSettings(current:Game,request:RuntimeSettingsRequest,runtimeRoot:string,resolve=resolveRuntimeFamily):Promise<Partial<Game>> {
const selection=gameRuntimeSelection('runtime' in request?request.runtime:current.runtime);
const separate='runtimeSeparatePrefix' in request?request.runtimeSeparatePrefix:current.runtimeSeparatePrefix;
if(separate!==undefined&&typeof separate!=='boolean')throw Error('Invalid runtime prefix choice.');
- if(request.runtimeApproveBuild!==undefined&&typeof request.runtimeApproveBuild!=='boolean')throw Error('Invalid explicit runtime build approval.');
- if(selection==='default')return {runtime:selection,runtimeSeparatePrefix:false,runtimeBuild:undefined};
+ const anchors=runtimePrefixAnchors(current.runtimePrefixes);
+ const previous=gameRuntimeSelection(current.runtime);
+ if(previous!=='default'&&!anchors[previous]&&current.runtimeBuild)anchors[previous]={layout:'build',origin:runtimeBuildApproval(current.runtimeBuild)};
+ if(selection==='default')return {runtime:selection,runtimeSeparatePrefix:false,runtimeBuild:undefined,runtimePrefixes:anchors};
+ if(selection!==previous&&!anchors[selection]&&request.runtimeSeparatePrefix!==true)throw Error('Explicit separate prefix choice is required for a new runtime family.');
if(separate!==true)throw Error('Explicit separate prefix choice is required. Existing local saves remain in the old prefix.');
- if(selection===current.runtime&&request.runtimeApproveBuild!==true) {
- // Ordinary title/locale Save never refreshes a prior build's permission.
- return {runtime:selection,runtimeSeparatePrefix:true,runtimeBuild:runtimeBuildApproval(current.runtimeBuild)};
- }
- if(request.runtimeApproveBuild!==true)throw Error('Fresh explicit approval of the installed runtime build is required.');
- const verified=await resolve(runtimeRoot,selection);
- if(!sameRuntimeBuild(request.runtimeExpectedBuild,verified))throw Error('The installed runtime build changed while settings were open. Review it and approve a new separate prefix again.');
- return {runtime:selection,runtimeSeparatePrefix:true,runtimeBuild:runtimeBuildApproval(verified)};
+ if(selection!==previous||current.runtimeSeparatePrefix!==true)await resolve(runtimeRoot,selection);
+ anchors[selection]??={layout:'family'};
+ return {runtime:selection,runtimeSeparatePrefix:true,runtimeBuild:undefined,runtimePrefixes:anchors};
}
diff --git a/src/main/store.ts b/src/main/store.ts
index ed90584..30c2192 100644
--- a/src/main/store.ts
+++ b/src/main/store.ts
@@ -1,4 +1,4 @@
-import {gameRuntimeSelection,runtimeBuildApproval} from '../shared/runtime-selection.js';
+import {gameRuntimeSelection,runtimeBuildApproval,runtimePrefixAnchors} from '../shared/runtime-selection.js';
import { createHash } from 'node:crypto';
import { promises as fs } from 'node:fs';
import os from 'node:os';
@@ -113,6 +113,7 @@ export class StateStore {
if (!game) throw new Error('Game not found.');
if ('runtime' in patch) patch.runtime = gameRuntimeSelection(patch.runtime);
if ('runtimeSeparatePrefix' in patch && typeof patch.runtimeSeparatePrefix !== 'boolean') throw Error('Invalid runtime prefix choice.');
+ if ('runtimePrefixes' in patch) patch.runtimePrefixes=runtimePrefixAnchors(patch.runtimePrefixes);
if ('runtimeBuild' in patch && patch.runtimeBuild !== undefined) patch.runtimeBuild=runtimeBuildApproval(patch.runtimeBuild);
Object.assign(game, patch);
await this.save();
diff --git a/src/renderer/App.tsx b/src/renderer/App.tsx
index 10d257a..e16c095 100644
--- a/src/renderer/App.tsx
+++ b/src/renderer/App.tsx
@@ -1,7 +1,7 @@
import {useGameRuntimeReady} from './useGameRuntimeReady';
import {useStoreAccess} from './store-access';
import {GameRuntimeFields} from './GameRuntimeFields';
-import {sameRuntimeBuild,runtimeBuildApproval,type InstalledRuntimeFamily,type RuntimeBuildApproval,type GameRuntimeSelection} from '../shared/runtime-selection';
+import {type InstalledRuntimeFamily,type GameRuntimeSelection} from '../shared/runtime-selection';
import { CloudSaveWarning } from './CloudSaveWarning';
import { CheckField } from './CheckField';
import { useDialogFocus } from './use-dialog-focus';
@@ -214,7 +214,7 @@ function useGameLaunchOptions(game: Game | undefined, data: AppSnapshot): GameLa
.then((value) => { if (!cancelled) setOptions(value); })
.catch((error) => { if (!cancelled) setOptions({ cloudSaves: false, cloudReason: errorMessage(error), vcInstall: false, vcReason: errorMessage(error) }); });
return () => { cancelled = true; };
- }, [game?.id, game?.runtime, game?.runtimeSeparatePrefix, game?.runtimeBuild?.buildId, game?.runtimeBuild?.manifestSha256, data.runtime.variants?.map(item=>item.id+':'+item.buildId).join(','), data.settings.winePath, data.settings.runtimeRoot, data.runtime.winePath, data.backend.binaryPath, data.backend.commit, data.backend.available]);
+ }, [game?.id, game?.runtime, game?.runtimeSeparatePrefix, game?.runtimeBuild?.buildId, game?.runtimeBuild?.manifestSha256, JSON.stringify(game?.runtimePrefixes), data.runtime.variants?.map(item=>item.id+':'+item.buildId).join(','), data.settings.winePath, data.settings.runtimeRoot, data.runtime.winePath, data.backend.binaryPath, data.backend.commit, data.backend.available]);
return options;
}
@@ -640,22 +640,9 @@ export function LibraryPage({ data, toast, filters, onFiltersChange, selection,
const [editLocale, setEditLocale] = useState('');
const [editRuntime,setEditRuntime]=useState<GameRuntimeSelection>('default');
const [editSeparatePrefix,setEditSeparatePrefix]=useState(false);
- const [editApproveRuntimeBuild,setEditApproveRuntimeBuild]=useState(false);
- const [editExpectedRuntimeBuild,setEditExpectedRuntimeBuild]=useState<Readonly<RuntimeBuildApproval>>();
const [runtimeChoices,setRuntimeChoices]=useState<InstalledRuntimeFamily[]>(data.runtime.variants??[]);
const runtimeChoicesKey=JSON.stringify(data.runtime.variants??[]);
useEffect(()=>setRuntimeChoices(data.runtime.variants??[]),[runtimeChoicesKey]);
- const runtimeChoice=useRef<{gameId:string;key:string}>();
- const installedChoice=runtimeChoices.find(item=>item.id===editRuntime);
- const installedChoiceKey=JSON.stringify([editRuntime,installedChoice?.buildId,installedChoice?.manifestSha256,installedChoice?.sourceCommit]);
- useBrowserLayoutEffect(()=>{
- if(!dialogGame||dialogGame.kind!=='settings'){runtimeChoice.current=undefined;return;}
- if(runtimeChoice.current?.gameId===dialogGame.id&&runtimeChoice.current.key!==installedChoiceKey){
- const game=data.games.find(item=>item.id===dialogGame.id);
- setEditSeparatePrefix(game?.runtime===editRuntime&&game.runtimeSeparatePrefix===true&&sameRuntimeBuild(game.runtimeBuild,game.runtimeBuild));setEditApproveRuntimeBuild(false);setEditExpectedRuntimeBuild(undefined);
- }
- runtimeChoice.current={gameId:dialogGame.id,key:installedChoiceKey};
- },[dialogGame?.id,dialogGame?.kind,installedChoiceKey]);
const [editTools, setEditTools] = useState<GameLaunchTools>({ ...defaultLaunchTools });
const [localeOptions, setLocaleOptions] = useState<string[]>([]);
const localeRequest = useRef(0);
@@ -734,8 +721,7 @@ export function LibraryPage({ data, toast, filters, onFiltersChange, selection,
setEditTitle(game.title);
setEditLocale(game.locale ?? '');
setEditRuntime(game.runtime ?? 'default');
- setEditSeparatePrefix(game.runtimeSeparatePrefix===true&&sameRuntimeBuild(game.runtimeBuild,game.runtimeBuild));
- setEditApproveRuntimeBuild(false);setEditExpectedRuntimeBuild(undefined);
+ setEditSeparatePrefix(game.runtimeSeparatePrefix===true);
setEditTools({ ...defaultLaunchTools, ...game.launchTools });
setLocaleOptions([]);
const request = ++localeRequest.current;
@@ -751,7 +737,7 @@ export function LibraryPage({ data, toast, filters, onFiltersChange, selection,
if (!dialogGame) return;
setDialogBusy(true);
try {
- await window.launcher.updateGame(dialogGame.id, { title: editTitle.trim(), locale: editLocale, launchTools: normalizeLaunchTools(editTools), runtime:editRuntime, runtimeSeparatePrefix:editSeparatePrefix, runtimeApproveBuild:editApproveRuntimeBuild, runtimeExpectedBuild:editExpectedRuntimeBuild });
+ await window.launcher.updateGame(dialogGame.id, { title: editTitle.trim(), locale: editLocale, launchTools: normalizeLaunchTools(editTools), runtime:editRuntime, runtimeSeparatePrefix:editSeparatePrefix });
toast({ kind: 'success', message: ui("ui.game_settings_saved_7f466a5") });
setDialogGame(undefined);
} catch (error) { toast({ kind: 'error', message: errorMessage(error) }); }
@@ -862,7 +848,7 @@ export function LibraryPage({ data, toast, filters, onFiltersChange, selection,
<h2>{ui("ui.game_settings_fece860")}</h2>
<label>{ui("ui.display_name_2b7f6a8")}<input data-gamepad-initial required value={editTitle} onChange={(event) => setEditTitle(event.target.value)} /></label>
<GameLanguage value={editLocale} locales={localeOptions} onChange={setEditLocale} />
- <GameRuntimeFields value={editRuntime} separate={editSeparatePrefix} approved={editRuntime===(modalGame.runtime??'default')?modalGame.runtimeBuild:undefined} installed={runtimeChoices} change={value=>{setEditRuntime(value);setEditSeparatePrefix(false);setEditApproveRuntimeBuild(false);setEditExpectedRuntimeBuild(undefined);}} changeSeparate={value=>{setEditSeparatePrefix(value);setEditApproveRuntimeBuild(value);const installed=runtimeChoices.find(item=>item.id===editRuntime);setEditExpectedRuntimeBuild(value&&installed?runtimeBuildApproval(installed):undefined);}}/>
+ <GameRuntimeFields value={editRuntime} separate={editSeparatePrefix} installed={runtimeChoices} change={value=>{setEditRuntime(value);setEditSeparatePrefix(value===(modalGame.runtime??'default')?modalGame.runtimeSeparatePrefix===true:Boolean(value!=='default'&&modalGame.runtimePrefixes?.[value]));}} changeSeparate={setEditSeparatePrefix}/>
<GameLaunchToolFields value={editTools} change={setEditTools} />
<div className="dialog-actions"><button type="button" className="secondary" disabled={dialogBusy} data-gamepad-cancel onClick={() => setDialogGame(undefined)}>{ui("ui.cancel_19766ed")}</button><button className="primary" disabled={dialogBusy || !editTitle.trim()}><Check />{ui("ui.save_1509f56")}</button></div>
</form>}
diff --git a/src/renderer/GameRuntimeFields.tsx b/src/renderer/GameRuntimeFields.tsx
index 0092e43..db8c896 100644
--- a/src/renderer/GameRuntimeFields.tsx
+++ b/src/renderer/GameRuntimeFields.tsx
@@ -1,11 +1,9 @@
import {CheckField} from './CheckField';
import {ui} from './i18n';
-import {runtimeFamilyLabels,sameRuntimeBuild,type GameRuntimeSelection,type InstalledRuntimeFamily} from '../shared/runtime-selection';
-export function GameRuntimeFields({value,separate,installed,approved,change,changeSeparate}:{value:GameRuntimeSelection;separate:boolean;installed:InstalledRuntimeFamily[];approved?:unknown;change:(value:GameRuntimeSelection)=>void;changeSeparate:(value:boolean)=>void}) {
+import {runtimeFamilyLabels,type GameRuntimeSelection,type InstalledRuntimeFamily} from '../shared/runtime-selection';
+export function GameRuntimeFields({value,separate,installed,change,changeSeparate}:{value:GameRuntimeSelection;separate:boolean;installed:InstalledRuntimeFamily[];change:(value:GameRuntimeSelection)=>void;changeSeparate:(value:boolean)=>void}) {
const current=installed.find(item=>item.id===value);
const missing=value!=='default'&&!current;
- const changed=value!=='default'&&Boolean(current)&&!sameRuntimeBuild(approved,current);
- const retained=changed&&sameRuntimeBuild(approved,approved)&&separate;
return <>
<label>{ui('runtime.game_runtime')}<select value={value} onChange={event=>change(event.target.value as GameRuntimeSelection)}>
<option value="default">{ui('runtime.use_default')}</option>
@@ -13,8 +11,6 @@ export function GameRuntimeFields({value,separate,installed,approved,change,chan
{missing?<option value={value} disabled>{ui('runtime.unavailable',{name:runtimeFamilyLabels[value as keyof typeof runtimeFamilyLabels]??String(value)})}</option>:null}
</select></label>
{value!=='default'?<>
- {changed?<p role="alert">{retained?ui('runtime.new_build_available'):ui('runtime.build_changed')}</p>:null}
- {retained?<button type="button" onClick={()=>changeSeparate(true)}>{ui('runtime.use_installed_build')}</button>:null}
<CheckField required checked={separate} onChange={event=>changeSeparate(event.target.checked)} label={ui('runtime.separate_prefix')} description={ui('runtime.prefix_warning')}/>
</>:null}
</>;
diff --git a/src/renderer/game-runtime-fields.test.tsx b/src/renderer/game-runtime-fields.test.tsx
index 3bdfeb2..87ae54f 100644
--- a/src/renderer/game-runtime-fields.test.tsx
+++ b/src/renderer/game-runtime-fields.test.tsx
@@ -9,7 +9,7 @@ it('offers only default when no verified variants are installed, never an unbuil
});
it('lists verified families with explicit separate-prefix acknowledgment and save warning',()=>{
const html=renderToStaticMarkup(<GameRuntimeFields value="nexus-cachyos" separate={false} installed={[{id:'nexus-cachyos',label:'Nexus Runtime (CachyOS, experimental)',buildId:'a'.repeat(64),sourceCommit:'b'.repeat(40),manifestSha256:'c'.repeat(64)}]} change={change} changeSeparate={change}/>);
- expect(html).toContain('experimental');expect(html).toMatch(/type="checkbox" required/);expect(html).toContain('class="check-input"');const help=html.match(/aria-describedby="([^"]+)"/)?.[1];expect(help).toBeTruthy();expect(html).toContain('<small id="'+help+'">');expect(html).toContain('Existing local saves stay in the old prefix');expect(html).not.toContain('checked=""');
+ expect(html).toContain('experimental');expect(html).toMatch(/type="checkbox" required/);expect(html).toContain('class="check-input"');const help=html.match(/aria-describedby="([^"]+)"/)?.[1];expect(help).toBeTruthy();expect(html).toContain('<small id="'+help+'">');expect(html).toContain('Existing local saves stay in the old prefix');expect(html).toContain('Updates within this family reuse the same prefix and local saves');expect(html).not.toContain('each runtime build');expect(html).not.toContain('this runtime build');expect(html).not.toContain('checked=""');
});
it('shows a missing persisted selection as disabled rather than falling back',()=>{
const html=renderToStaticMarkup(<GameRuntimeFields value="nexus-cachyos" separate installed={[]} change={change} changeSeparate={change}/>);
diff --git a/src/renderer/game-runtime-settings.test.tsx b/src/renderer/game-runtime-settings.test.tsx
index d9c3b0d..a19c73a 100644
--- a/src/renderer/game-runtime-settings.test.tsx
+++ b/src/renderer/game-runtime-settings.test.tsx
@@ -29,43 +29,23 @@ beforeEach(async()=>{
document.body.innerHTML='<div id="root"></div>';root=createRoot(document.getElementById('root')!);await render();
});
afterEach(async()=>{await act(async()=>root.unmount());vi.restoreAllMocks();vi.unstubAllGlobals();document.body.innerHTML='';});
-const chooseInstalled=()=>click([...document.querySelectorAll('[role="dialog"] button')].find(button=>button.textContent==='Use the newly installed build with a separate prefix')!);
-it('preserves approved A while B is current and unrelated settings Save sends no new approval',async()=>{
- await openSettings();expect(consent().checked).toBe(true);
- expect(document.querySelector('[role="alert"]')?.textContent).toContain('approved build');
- await save();expect(window.launcher.updateGame).toHaveBeenCalledWith(data.games[0].id,expect.objectContaining({runtime:family,runtimeSeparatePrefix:true,runtimeApproveBuild:false,runtimeExpectedBuild:undefined}));
+it('retains family consent when a newer installed build is discovered without a new approval action',async()=>{
+ await openSettings();expect(consent().checked).toBe(true);expect(document.querySelector('[role="alert"]')).toBeNull();
+ await save();expect(window.launcher.updateGame).toHaveBeenCalledWith(data.games[0].id,expect.objectContaining({runtime:family,runtimeSeparatePrefix:true}));expect(vi.mocked(window.launcher.updateGame).mock.calls[0][1]).not.toHaveProperty('runtimeApproveBuild');
});
-it('permits same-family A-to-B only after explicit choice of the installed build',async()=>{
- await openSettings();await chooseInstalled();await save();
- expect(window.launcher.updateGame).toHaveBeenCalledWith(data.games[0].id,expect.objectContaining({runtime:family,runtimeSeparatePrefix:true,runtimeApproveBuild:true,runtimeExpectedBuild:b}));
+it('keeps consent during B to C update while the form is open',async()=>{
+ await openSettings();data.runtime.variants=[installed(c)];await render();expect(consent().checked).toBe(true);await save();expect(window.launcher.updateGame).toHaveBeenCalledWith(data.games[0].id,expect.objectContaining({runtimeSeparatePrefix:true}));
});
-it('ordinary Save of an already current approved build sends no fresh build approval',async()=>{
- data.runtime.variants=[installed(a)];await render();await openSettings();expect(consent().checked).toBe(true);
- await save();expect(window.launcher.updateGame).toHaveBeenCalledWith(data.games[0].id,expect.objectContaining({runtimeApproveBuild:false,runtimeExpectedBuild:undefined}));
+it('retains consent after reopening and local family refresh',async()=>{
+ data.runtime.variants=[installed(a)];await render();vi.mocked(window.launcher.getRuntimeFamilies).mockResolvedValue([installed(b)]);await openSettings();expect(consent().checked).toBe(true);await click(document.querySelector('[role="dialog"] [data-gamepad-cancel]')!);await openSettings();expect(consent().checked).toBe(true);
});
-it('invalidates pending B approval when C arrives, retaining A until explicit C choice',async()=>{
- await openSettings();await chooseInstalled();data.runtime.variants=[installed(c)];await render();
- expect(consent().checked).toBe(true);await save();expect(window.launcher.updateGame).toHaveBeenLastCalledWith(data.games[0].id,expect.objectContaining({runtimeApproveBuild:false,runtimeExpectedBuild:undefined}));
- await openSettings();await chooseInstalled();await save();
- expect(window.launcher.updateGame).toHaveBeenLastCalledWith(data.games[0].id,expect.objectContaining({runtimeApproveBuild:true,runtimeExpectedBuild:c}));
+it('requires separate prefix consent when first choosing another family',async()=>{
+ data.games=[{...data.games[0],runtime:'default',runtimeSeparatePrefix:false,runtimeBuild:undefined}];await render();await openSettings();
+ const select=[...document.querySelectorAll<HTMLSelectElement>('[role="dialog"] select')].find(node=>[...node.options].some(option=>option.value===family))!;
+ await act(async()=>{select.value=family;select.dispatchEvent(new Event('change',{bubbles:true}));});expect(consent().checked).toBe(false);await click(consent());await save();expect(window.launcher.updateGame).toHaveBeenCalledWith(data.games[0].id,expect.objectContaining({runtime:family,runtimeSeparatePrefix:true}));
});
-it('preserves A approval when current changes while the form stays open',async()=>{
- data.runtime.variants=[installed(a)];await render();await openSettings();expect(consent().checked).toBe(true);
- data.runtime.variants=[installed(b)];await render();expect(consent().checked).toBe(true);
- await save();expect(window.launcher.updateGame).toHaveBeenCalledWith(data.games[0].id,expect.objectContaining({runtimeSeparatePrefix:true,runtimeApproveBuild:false}));
-});
-it('resets fresh B approval after closing and reopening, preserving A',async()=>{
- await openSettings();await chooseInstalled();await click(document.querySelector('[role="dialog"] [data-gamepad-cancel]')!);
- await openSettings();expect(consent().checked).toBe(true);await save();
- expect(window.launcher.updateGame).toHaveBeenCalledWith(data.games[0].id,expect.objectContaining({runtimeApproveBuild:false}));
-});
-it('refreshes verified current B locally without clearing saved A approval',async()=>{
- data.runtime.variants=[installed(a)];await render();vi.mocked(window.launcher.getRuntimeFamilies).mockResolvedValue([installed(b)]);
- await openSettings();expect(window.launcher.getRuntimeFamilies).toHaveBeenCalledOnce();expect(consent().checked).toBe(true);
- await chooseInstalled();await save();
- expect(window.launcher.updateGame).toHaveBeenCalledWith(data.games[0].id,expect.objectContaining({runtime:family,runtimeApproveBuild:true,runtimeExpectedBuild:b}));
-});
-it('does not fabricate valid approval for a legacy family-wide consent',async()=>{
- data.games=[{...data.games[0],runtimeBuild:undefined}];await render();await openSettings();expect(consent().checked).toBe(false);
- await click(consent());await save();expect(window.launcher.updateGame).toHaveBeenCalledWith(data.games[0].id,expect.objectContaining({runtimeApproveBuild:true,runtimeExpectedBuild:b}));
+it('returning to a previously used family retains its saved prefix choice',async()=>{
+ data.games=[{...data.games[0],runtime:'default',runtimeSeparatePrefix:false,runtimePrefixes:{[family]:{layout:'build',origin:a}}}];await render();await openSettings();
+ const select=[...document.querySelectorAll<HTMLSelectElement>('[role="dialog"] select')].find(node=>[...node.options].some(option=>option.value===family))!;
+ await act(async()=>{select.value=family;select.dispatchEvent(new Event('change',{bubbles:true}));});expect(consent().checked).toBe(true);
});
diff --git a/src/renderer/useGameRuntimeReady.ts b/src/renderer/useGameRuntimeReady.ts
index fe65e44..f6b1e9b 100644
--- a/src/renderer/useGameRuntimeReady.ts
+++ b/src/renderer/useGameRuntimeReady.ts
@@ -1,10 +1,10 @@
import {useEffect,useRef,useState} from 'react';
import type {AppSnapshot,Game} from '../shared/types';
-/** Exact visible-game readiness, separate from current-build discovery. Pending
+/** Visible-game readiness follows the verified installed family current. Pending
* and errors never borrow another build's availability. */
export function useGameRuntimeReady(game:Game|undefined,data:AppSnapshot):boolean {
const managed=Boolean(game?.runtime&&game.runtime!=='default');
- const scope=JSON.stringify([game?.id,game?.runtime,game?.runtimeSeparatePrefix,game?.runtimeBuild?.buildId,game?.runtimeBuild?.manifestSha256,game?.runtimeBuild?.sourceCommit,data.settings.runtimeRoot,data.settings.winePath,data.runtime.winePath,(data.runtime.variants??[]).map(item=>[item.id,item.buildId,item.manifestSha256,item.sourceCommit])]);
+ const scope=JSON.stringify([game?.id,game?.runtime,game?.runtimeSeparatePrefix,game?.runtimeBuild?.buildId,game?.runtimeBuild?.manifestSha256,game?.runtimeBuild?.sourceCommit,game?.runtimePrefixes,data.settings.runtimeRoot,data.settings.winePath,data.runtime.winePath,(data.runtime.variants??[]).map(item=>[item.id,item.buildId,item.manifestSha256,item.sourceCommit])]);
const current=useRef({scope,version:0});
if(current.current.scope!==scope)current.current={scope,version:current.current.version+1};
const version=current.current.version;
diff --git a/src/shared/runtime-selection.ts b/src/shared/runtime-selection.ts
index 279553e..8abc62b 100644
--- a/src/shared/runtime-selection.ts
+++ b/src/shared/runtime-selection.ts
@@ -29,3 +29,24 @@ export function gameRuntimeAvailable(selection:unknown,separatePrefix:unknown,de
if(selection===undefined||selection==='default')return defaultAvailable;
return separatePrefix===true&&runtimeFamilies.includes(selection as RuntimeFamily)&&installed.some(item=>item.id===selection);
}
+
+/** Prefix identity survives family updates and switching away/back. Build origin is compatibility metadata, never a runtime pin. */
+export type RuntimePrefixAnchor = {layout:'family'} | {layout:'build';origin:RuntimeBuildApproval};
+export type RuntimePrefixAnchors = Partial<Record<RuntimeFamily,RuntimePrefixAnchor>>;
+export function runtimePrefixAnchor(value:unknown):RuntimePrefixAnchor {
+ if(!value||typeof value!=='object')throw Error('Invalid runtime prefix identity.');
+ const item=value as RuntimePrefixAnchor;
+ if(item.layout==='family')return {layout:'family'};
+ if(item.layout==='build')return {layout:'build',origin:runtimeBuildApproval(item.origin)};
+ throw Error('Invalid runtime prefix identity.');
+}
+export function runtimePrefixAnchors(value:unknown):RuntimePrefixAnchors {
+ if(value===undefined)return {};
+ if(!value||typeof value!=='object'||Array.isArray(value))throw Error('Invalid runtime prefix identities.');
+ const result:RuntimePrefixAnchors={};
+ for(const [family,anchor] of Object.entries(value)) {
+ if(!runtimeFamilies.includes(family as RuntimeFamily))throw Error('Invalid runtime prefix family.');
+ result[family as RuntimeFamily]=runtimePrefixAnchor(anchor);
+ }
+ return result;
+}
diff --git a/src/shared/types.ts b/src/shared/types.ts
index ef7140d..44323cf 100644
--- a/src/shared/types.ts
+++ b/src/shared/types.ts
@@ -1,4 +1,4 @@
-import type {GameRuntimeSelection,InstalledRuntimeFamily,RuntimeBuildApproval} from './runtime-selection.js';
+import type {GameRuntimeSelection,InstalledRuntimeFamily,RuntimeBuildApproval,RuntimePrefixAnchors} from './runtime-selection.js';
export type Page = 'home' | 'store' | 'library' | 'downloads' | 'settings' | 'social';
export interface BackendCapabilities {
@@ -128,7 +128,8 @@ export interface Game {
winePath?: string; // Legacy saved field; ignored for launch.
runtime?: GameRuntimeSelection;
runtimeSeparatePrefix?: boolean;
- runtimeBuild?: RuntimeBuildApproval;
+ runtimeBuild?: RuntimeBuildApproval; // Old prefix origin only, never a launch pin.
+ runtimePrefixes?: RuntimePrefixAnchors;
launchArgs?: string;
launchTools?: GameLaunchTools;
locale?: string;
@@ -630,7 +631,7 @@ export interface LauncherApi {
removeDownload(id: string): Promise<void>;
clearFinishedDownloads(): Promise<void>;
importGame(path?: string): Promise<Game | null>;
- updateGame(id: string, patch: Partial<Pick<Game, 'title' | 'executable' | 'launchArgs' | 'locale' | 'launchTools' | 'runtime' | 'runtimeSeparatePrefix'>> & {runtimeApproveBuild?:boolean;runtimeExpectedBuild?:RuntimeBuildApproval}): Promise<Game>;
+ updateGame(id: string, patch: Partial<Pick<Game, 'title' | 'executable' | 'launchArgs' | 'locale' | 'launchTools' | 'runtime' | 'runtimeSeparatePrefix'>>): Promise<Game>;
getGameLocales(id: string): Promise<string[]>;
removeGame(id: string, mode: 'library' | 'delete-files'): Promise<void>;
getGameRuntimeReadiness(id: string): Promise<boolean>;