feat(frontend): add an Open in Steam action for Steam-matched games (#5358)

* feat(frontend): add an Open in Steam action for Steam-matched games

Games with a Steam app ID now get an "Open in Steam" button and menu item
that hand steam://run/<appid> to the local Steam client, the same way the
Flashpoint action hands off flashpoint:// links. The anchor-click handoff
is shared between the two.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh

* test(frontend): drop the em dash from the Open in Steam test title

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XGA3D2oZ1hq3QUdnubMNXh

---------

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Sam Dornan
2026-10-26 10:25:02 -05:00
committed by GitHub
parent 78214a9e77
commit aaf6a4e17a
24 changed files with 108 additions and 5 deletions

View File

@@ -72,6 +72,7 @@ export type GameAction =
| "copy-link"
| "qr"
| "flashpoint"
| "steam"
| "favorite"
| "collection"
| "status"
@@ -233,6 +234,16 @@ const preset = computed<Preset>(() => {
active: false,
};
}
if (props.action === "steam") {
return {
icon: "mdi-steam",
image: "/assets/scrappers/steam.png",
label: t("rom.open-in-steam"),
activeIcon: null,
onClick: actions.openInSteam,
active: false,
};
}
if (props.action === "favorite") {
return {
icon: "mdi-heart-outline",

View File

@@ -112,6 +112,13 @@ useGridNav(rootEl, {
:size="btnSize"
variant="surface"
/>
<GameActionBtn
v-if="actions.canOpenInSteam.value"
:rom="rom"
action="steam"
:size="btnSize"
variant="surface"
/>
<GameActionBtn
:rom="rom"
action="favorite"

View File

@@ -10,6 +10,7 @@ type Flags = {
canPlayStream: boolean;
canShareQR: boolean;
canOpenInFlashpoint: boolean;
canOpenInSteam: boolean;
canManageCollections: boolean;
canRemoveFromContinuePlaying: boolean;
canMatch: boolean;
@@ -33,6 +34,7 @@ const flags: Flags = {
canDownload: true,
canShareQR: false,
canOpenInFlashpoint: false,
canOpenInSteam: false,
canManageCollections: true,
canRemoveFromContinuePlaying: false,
canMatch: true,
@@ -188,6 +190,18 @@ describe("GameActionsList: installing on a device", () => {
});
});
describe("GameActionsList: opening in Steam", () => {
it("offers it for a rom matched to a Steam app", () => {
const shown = labels(mountList({ canOpenInSteam: true }));
expect(shown).toContain("rom.open-in-steam");
});
it("hides it otherwise", () => {
const shown = labels(mountList({ canOpenInSteam: false }));
expect(shown).not.toContain("rom.open-in-steam");
});
});
describe("GameActionsList: joining someone else's session", () => {
it("renders the join label the composable resolved", () => {
const wrapper = mountList({ canJoinStream: true }, "rom.join-session-of");

View File

@@ -89,6 +89,12 @@ function run(fn: () => void | Promise<void>) {
icon="mdi-rocket-launch-outline"
@click="run(actions.openInFlashpoint)"
/>
<RMenuItem
v-if="actions.canOpenInSteam.value"
:label="t('rom.open-in-steam')"
icon="mdi-steam"
@click="run(actions.openInSteam)"
/>
<RDivider />

View File

@@ -238,6 +238,35 @@ describe("useGameActions.canInstallOnDevice", () => {
});
});
describe("useGameActions: Open in Steam", () => {
let opened: string[];
beforeEach(() => {
opened = [];
vi.spyOn(HTMLAnchorElement.prototype, "click").mockImplementation(function (
this: HTMLAnchorElement,
) {
opened.push(this.href);
});
});
it("launches the matched app through the Steam client", () => {
const actions = useGameActions(() => romFixture({ steam_id: 220 }));
expect(actions.canOpenInSteam.value).toBe(true);
actions.openInSteam();
expect(opened).toEqual(["steam://run/220"]);
});
it.each([null, 0, -5, 1.5])("offers nothing for steam_id %s", (steamId) => {
const actions = useGameActions(() => romFixture({ steam_id: steamId }));
expect(actions.canOpenInSteam.value).toBe(false);
actions.openInSteam();
expect(opened).toEqual([]);
});
});
describe("useGameActions.joinStream", () => {
beforeEach(() => {
streamContainer.value = { host: "http://stream" };

View File

@@ -55,6 +55,10 @@ const pendingFormatDownloads = new Set<string>();
const FLASHPOINT_ID_RE =
/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
function isSteamAppId(id: number | null | undefined): id is number {
return Number.isSafeInteger(id) && (id as number) > 0;
}
export function useGameActions(
getRom: () => SimpleRom | null | undefined,
options: GameActionsOptions = {},
@@ -322,6 +326,8 @@ export function useGameActions(
);
});
const canOpenInSteam = computed(() => isSteamAppId(getRom()?.steam_id));
// Launching a game the user deliberately shelved asks first. `retired` /
// `never_playing` encode an opt-in "don't play" intent; the prompt is
// gated by a per-user preference (on by default).
@@ -517,16 +523,26 @@ export function useGameActions(
emitter?.emit("showQRCodeDialog", rom);
}
function openAppLink(href: string) {
const a = document.createElement("a");
a.href = href;
document.body.appendChild(a);
a.click();
a.remove();
}
// Launch the game in installed Flashpoint
function openInFlashpoint() {
const rom = getRom();
if (!rom?.flashpoint_id || !FLASHPOINT_ID_RE.test(rom.flashpoint_id))
return;
const a = document.createElement("a");
a.href = `flashpoint://${rom.flashpoint_id}`;
document.body.appendChild(a);
a.click();
a.remove();
openAppLink(`flashpoint://${rom.flashpoint_id}`);
}
function openInSteam() {
const steamId = getRom()?.steam_id;
if (!isSteamAppId(steamId)) return;
openAppLink(`steam://run/${steamId}`);
}
// Copies the API download URL (origin + /api/roms/.../content/...) so
@@ -639,6 +655,7 @@ export function useGameActions(
canShareQR,
canInstallOnDevice,
canOpenInFlashpoint,
canOpenInSteam,
canDownload,
downloadFormats,
canPlay,
@@ -671,6 +688,7 @@ export function useGameActions(
shareQR,
installOnDevice,
openInFlashpoint,
openInSteam,
copyDownloadLink,
manageCollections,
refreshMetadata,

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Обновена {date}",
"open-game": "Отвори {name}",
"open-in-flashpoint": "Отвори във Flashpoint",
"open-in-steam": "Отвори в Steam",
"pdf-toggle-sidebar": "Превключи страничната лента",
"physical-game-add-failed": "Неуспешно добавяне на физическата игра",
"physical-game-added": "Физическата игра е добавена",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Aktualizováno {date}",
"open-game": "Otevřít {name}",
"open-in-flashpoint": "Otevřít ve Flashpointu",
"open-in-steam": "Otevřít ve Steamu",
"pdf-toggle-sidebar": "Přepnout postranní panel",
"physical-game-add-failed": "Fyzickou hru se nepodařilo přidat",
"physical-game-added": "Fyzická hra byla přidána",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Aktualisiert {date}",
"open-game": "{name} öffnen",
"open-in-flashpoint": "In Flashpoint öffnen",
"open-in-steam": "In Steam öffnen",
"pdf-toggle-sidebar": "Seitenleiste umschalten",
"physical-game-add-failed": "Physisches Spiel konnte nicht hinzugefügt werden",
"physical-game-added": "Physisches Spiel hinzugefügt",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Updated {date}",
"open-game": "Open {name}",
"open-in-flashpoint": "Open in Flashpoint",
"open-in-steam": "Open in Steam",
"pdf-toggle-sidebar": "Toggle sidebar",
"physical-game-add-failed": "Failed to add physical game",
"physical-game-added": "Physical game added",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Updated {date}",
"open-game": "Open {name}",
"open-in-flashpoint": "Open in Flashpoint",
"open-in-steam": "Open in Steam",
"pdf-toggle-sidebar": "Toggle sidebar",
"physical-game-add-failed": "Failed to add physical game",
"physical-game-added": "Physical game added",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Actualizada {date}",
"open-game": "Abrir {name}",
"open-in-flashpoint": "Abrir en Flashpoint",
"open-in-steam": "Abrir en Steam",
"pdf-toggle-sidebar": "Mostrar/ocultar barra lateral",
"physical-game-add-failed": "No se pudo añadir el juego físico",
"physical-game-added": "Juego físico añadido",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Mise à jour le {date}",
"open-game": "Ouvrir {name}",
"open-in-flashpoint": "Ouvrir dans Flashpoint",
"open-in-steam": "Ouvrir dans Steam",
"pdf-toggle-sidebar": "Basculer la barre latérale",
"physical-game-add-failed": "Échec de l'ajout du jeu physique",
"physical-game-added": "Jeu physique ajouté",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Frissítve: {date}",
"open-game": "{name} megnyitása",
"open-in-flashpoint": "Megnyitás Flashpointban",
"open-in-steam": "Megnyitás Steamben",
"pdf-toggle-sidebar": "Oldalsáv ki/be",
"physical-game-add-failed": "Nem sikerült hozzáadni a fizikai játékot",
"physical-game-added": "Fizikai játék hozzáadva",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Aggiornata il {date}",
"open-game": "Apri {name}",
"open-in-flashpoint": "Apri in Flashpoint",
"open-in-steam": "Apri in Steam",
"pdf-toggle-sidebar": "Mostra/nascondi barra laterale",
"physical-game-add-failed": "Impossibile aggiungere il gioco fisico",
"physical-game-added": "Gioco fisico aggiunto",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "更新日 {date}",
"open-game": "{name}を開く",
"open-in-flashpoint": "Flashpointで開く",
"open-in-steam": "Steamで開く",
"pdf-toggle-sidebar": "サイドバーを切り替え",
"physical-game-add-failed": "実物のゲームの追加に失敗しました",
"physical-game-added": "実物のゲームを追加しました",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "업데이트: {date}",
"open-game": "{name} 열기",
"open-in-flashpoint": "Flashpoint에서 열기",
"open-in-steam": "Steam에서 열기",
"pdf-toggle-sidebar": "사이드바 전환",
"physical-game-add-failed": "실물 게임을 추가하지 못했습니다",
"physical-game-added": "실물 게임이 추가되었습니다",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Zaktualizowano {date}",
"open-game": "Otwórz {name}",
"open-in-flashpoint": "Otwórz w Flashpoint",
"open-in-steam": "Otwórz w Steam",
"pdf-toggle-sidebar": "Przełącz pasek boczny",
"physical-game-add-failed": "Nie udało się dodać gry fizycznej",
"physical-game-added": "Dodano grę fizyczną",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Atualizada {date}",
"open-game": "Abrir {name}",
"open-in-flashpoint": "Abrir no Flashpoint",
"open-in-steam": "Abrir no Steam",
"pdf-toggle-sidebar": "Alternar barra lateral",
"physical-game-add-failed": "Falha ao adicionar jogo físico",
"physical-game-added": "Jogo físico adicionado",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Actualizată {date}",
"open-game": "Deschide {name}",
"open-in-flashpoint": "Deschide în Flashpoint",
"open-in-steam": "Deschide în Steam",
"pdf-toggle-sidebar": "Comută bara laterală",
"physical-game-add-failed": "Nu s-a putut adăuga jocul fizic",
"physical-game-added": "Joc fizic adăugat",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "Обновлено {date}",
"open-game": "Открыть {name}",
"open-in-flashpoint": "Открыть в Flashpoint",
"open-in-steam": "Открыть в Steam",
"pdf-toggle-sidebar": "Переключить боковую панель",
"physical-game-add-failed": "Не удалось добавить физическую игру",
"physical-game-added": "Физическая игра добавлена",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "{date} tarihinde güncellendi",
"open-game": "{name} oyununu aç",
"open-in-flashpoint": "Flashpoint'te aç",
"open-in-steam": "Steam'de aç",
"pdf-toggle-sidebar": "Kenar çubuğunu aç/kapat",
"physical-game-add-failed": "Fiziksel oyun eklenemedi",
"physical-game-added": "Fiziksel oyun eklendi",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "更新于 {date}",
"open-game": "打开 {name}",
"open-in-flashpoint": "在 Flashpoint 中打开",
"open-in-steam": "在 Steam 中打开",
"pdf-toggle-sidebar": "切换侧边栏",
"physical-game-add-failed": "添加实体游戏失败",
"physical-game-added": "已添加实体游戏",

View File

@@ -289,6 +289,7 @@
"notes-updated-at": "更新於 {date}",
"open-game": "開啟 {name}",
"open-in-flashpoint": "在 Flashpoint 中開啟",
"open-in-steam": "在 Steam 中開啟",
"pdf-toggle-sidebar": "切換側邊欄",
"physical-game-add-failed": "新增實體遊戲失敗",
"physical-game-added": "已新增實體遊戲",