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 DornanandClaude Opus 5.5 authored and GitHub committed 2026-10-26 10:25:02 -05:00
1 parent 78214a9e77
commit aaf6a4e17a
24 files changed
+108 -5

No files matched your search

@@ -72,6 +72,7 @@ export type GameAction =
| "copy-link" | "copy-link"
| "qr" | "qr"
| "flashpoint" | "flashpoint"
| "steam"
| "favorite" | "favorite"
| "collection" | "collection"
| "status" | "status"
@@ -233,6 +234,16 @@ const preset = computed<Preset>(() => {
active: false, 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") { if (props.action === "favorite") {
return { return {
icon: "mdi-heart-outline", icon: "mdi-heart-outline",
@@ -112,6 +112,13 @@ useGridNav(rootEl, {
:size="btnSize" :size="btnSize"
variant="surface" variant="surface"
/> />
<GameActionBtn
v-if="actions.canOpenInSteam.value"
:rom="rom"
action="steam"
:size="btnSize"
variant="surface"
/>
<GameActionBtn <GameActionBtn
:rom="rom" :rom="rom"
action="favorite" action="favorite"
@@ -10,6 +10,7 @@ type Flags = {
canPlayStream: boolean; canPlayStream: boolean;
canShareQR: boolean; canShareQR: boolean;
canOpenInFlashpoint: boolean; canOpenInFlashpoint: boolean;
canOpenInSteam: boolean;
canManageCollections: boolean; canManageCollections: boolean;
canRemoveFromContinuePlaying: boolean; canRemoveFromContinuePlaying: boolean;
canMatch: boolean; canMatch: boolean;
@@ -33,6 +34,7 @@ const flags: Flags = {
canDownload: true, canDownload: true,
canShareQR: false, canShareQR: false,
canOpenInFlashpoint: false, canOpenInFlashpoint: false,
canOpenInSteam: false,
canManageCollections: true, canManageCollections: true,
canRemoveFromContinuePlaying: false, canRemoveFromContinuePlaying: false,
canMatch: true, 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", () => { describe("GameActionsList: joining someone else's session", () => {
it("renders the join label the composable resolved", () => { it("renders the join label the composable resolved", () => {
const wrapper = mountList({ canJoinStream: true }, "rom.join-session-of"); const wrapper = mountList({ canJoinStream: true }, "rom.join-session-of");
@@ -89,6 +89,12 @@ function run(fn: () => void | Promise<void>) {
icon="mdi-rocket-launch-outline" icon="mdi-rocket-launch-outline"
@click="run(actions.openInFlashpoint)" @click="run(actions.openInFlashpoint)"
/> />
<RMenuItem
v-if="actions.canOpenInSteam.value"
:label="t('rom.open-in-steam')"
icon="mdi-steam"
@click="run(actions.openInSteam)"
/>
<RDivider /> <RDivider />
@@ -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", () => { describe("useGameActions.joinStream", () => {
beforeEach(() => { beforeEach(() => {
streamContainer.value = { host: "http://stream" }; streamContainer.value = { host: "http://stream" };
@@ -55,6 +55,10 @@ const pendingFormatDownloads = new Set<string>();
const FLASHPOINT_ID_RE = 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; /^[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( export function useGameActions(
getRom: () => SimpleRom | null | undefined, getRom: () => SimpleRom | null | undefined,
options: GameActionsOptions = {}, 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` / // Launching a game the user deliberately shelved asks first. `retired` /
// `never_playing` encode an opt-in "don't play" intent; the prompt is // `never_playing` encode an opt-in "don't play" intent; the prompt is
// gated by a per-user preference (on by default). // gated by a per-user preference (on by default).
@@ -517,16 +523,26 @@ export function useGameActions(
emitter?.emit("showQRCodeDialog", rom); 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 // Launch the game in installed Flashpoint
function openInFlashpoint() { function openInFlashpoint() {
const rom = getRom(); const rom = getRom();
if (!rom?.flashpoint_id || !FLASHPOINT_ID_RE.test(rom.flashpoint_id)) if (!rom?.flashpoint_id || !FLASHPOINT_ID_RE.test(rom.flashpoint_id))
return; return;
const a = document.createElement("a"); openAppLink(`flashpoint://${rom.flashpoint_id}`);
a.href = `flashpoint://${rom.flashpoint_id}`; }
document.body.appendChild(a);
a.click(); function openInSteam() {
a.remove(); const steamId = getRom()?.steam_id;
if (!isSteamAppId(steamId)) return;
openAppLink(`steam://run/${steamId}`);
} }
// Copies the API download URL (origin + /api/roms/.../content/...) so // Copies the API download URL (origin + /api/roms/.../content/...) so
@@ -639,6 +655,7 @@ export function useGameActions(
canShareQR, canShareQR,
canInstallOnDevice, canInstallOnDevice,
canOpenInFlashpoint, canOpenInFlashpoint,
canOpenInSteam,
canDownload, canDownload,
downloadFormats, downloadFormats,
canPlay, canPlay,
@@ -671,6 +688,7 @@ export function useGameActions(
shareQR, shareQR,
installOnDevice, installOnDevice,
openInFlashpoint, openInFlashpoint,
openInSteam,
copyDownloadLink, copyDownloadLink,
manageCollections, manageCollections,
refreshMetadata, refreshMetadata,
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Обновена {date}", "notes-updated-at": "Обновена {date}",
"open-game": "Отвори {name}", "open-game": "Отвори {name}",
"open-in-flashpoint": "Отвори във Flashpoint", "open-in-flashpoint": "Отвори във Flashpoint",
"open-in-steam": "Отвори в Steam",
"pdf-toggle-sidebar": "Превключи страничната лента", "pdf-toggle-sidebar": "Превключи страничната лента",
"physical-game-add-failed": "Неуспешно добавяне на физическата игра", "physical-game-add-failed": "Неуспешно добавяне на физическата игра",
"physical-game-added": "Физическата игра е добавена", "physical-game-added": "Физическата игра е добавена",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Aktualizováno {date}", "notes-updated-at": "Aktualizováno {date}",
"open-game": "Otevřít {name}", "open-game": "Otevřít {name}",
"open-in-flashpoint": "Otevřít ve Flashpointu", "open-in-flashpoint": "Otevřít ve Flashpointu",
"open-in-steam": "Otevřít ve Steamu",
"pdf-toggle-sidebar": "Přepnout postranní panel", "pdf-toggle-sidebar": "Přepnout postranní panel",
"physical-game-add-failed": "Fyzickou hru se nepodařilo přidat", "physical-game-add-failed": "Fyzickou hru se nepodařilo přidat",
"physical-game-added": "Fyzická hra byla přidána", "physical-game-added": "Fyzická hra byla přidána",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Aktualisiert {date}", "notes-updated-at": "Aktualisiert {date}",
"open-game": "{name} öffnen", "open-game": "{name} öffnen",
"open-in-flashpoint": "In Flashpoint öffnen", "open-in-flashpoint": "In Flashpoint öffnen",
"open-in-steam": "In Steam öffnen",
"pdf-toggle-sidebar": "Seitenleiste umschalten", "pdf-toggle-sidebar": "Seitenleiste umschalten",
"physical-game-add-failed": "Physisches Spiel konnte nicht hinzugefügt werden", "physical-game-add-failed": "Physisches Spiel konnte nicht hinzugefügt werden",
"physical-game-added": "Physisches Spiel hinzugefügt", "physical-game-added": "Physisches Spiel hinzugefügt",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Updated {date}", "notes-updated-at": "Updated {date}",
"open-game": "Open {name}", "open-game": "Open {name}",
"open-in-flashpoint": "Open in Flashpoint", "open-in-flashpoint": "Open in Flashpoint",
"open-in-steam": "Open in Steam",
"pdf-toggle-sidebar": "Toggle sidebar", "pdf-toggle-sidebar": "Toggle sidebar",
"physical-game-add-failed": "Failed to add physical game", "physical-game-add-failed": "Failed to add physical game",
"physical-game-added": "Physical game added", "physical-game-added": "Physical game added",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Updated {date}", "notes-updated-at": "Updated {date}",
"open-game": "Open {name}", "open-game": "Open {name}",
"open-in-flashpoint": "Open in Flashpoint", "open-in-flashpoint": "Open in Flashpoint",
"open-in-steam": "Open in Steam",
"pdf-toggle-sidebar": "Toggle sidebar", "pdf-toggle-sidebar": "Toggle sidebar",
"physical-game-add-failed": "Failed to add physical game", "physical-game-add-failed": "Failed to add physical game",
"physical-game-added": "Physical game added", "physical-game-added": "Physical game added",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Actualizada {date}", "notes-updated-at": "Actualizada {date}",
"open-game": "Abrir {name}", "open-game": "Abrir {name}",
"open-in-flashpoint": "Abrir en Flashpoint", "open-in-flashpoint": "Abrir en Flashpoint",
"open-in-steam": "Abrir en Steam",
"pdf-toggle-sidebar": "Mostrar/ocultar barra lateral", "pdf-toggle-sidebar": "Mostrar/ocultar barra lateral",
"physical-game-add-failed": "No se pudo añadir el juego físico", "physical-game-add-failed": "No se pudo añadir el juego físico",
"physical-game-added": "Juego físico añadido", "physical-game-added": "Juego físico añadido",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Mise à jour le {date}", "notes-updated-at": "Mise à jour le {date}",
"open-game": "Ouvrir {name}", "open-game": "Ouvrir {name}",
"open-in-flashpoint": "Ouvrir dans Flashpoint", "open-in-flashpoint": "Ouvrir dans Flashpoint",
"open-in-steam": "Ouvrir dans Steam",
"pdf-toggle-sidebar": "Basculer la barre latérale", "pdf-toggle-sidebar": "Basculer la barre latérale",
"physical-game-add-failed": "Échec de l'ajout du jeu physique", "physical-game-add-failed": "Échec de l'ajout du jeu physique",
"physical-game-added": "Jeu physique ajouté", "physical-game-added": "Jeu physique ajouté",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Frissítve: {date}", "notes-updated-at": "Frissítve: {date}",
"open-game": "{name} megnyitása", "open-game": "{name} megnyitása",
"open-in-flashpoint": "Megnyitás Flashpointban", "open-in-flashpoint": "Megnyitás Flashpointban",
"open-in-steam": "Megnyitás Steamben",
"pdf-toggle-sidebar": "Oldalsáv ki/be", "pdf-toggle-sidebar": "Oldalsáv ki/be",
"physical-game-add-failed": "Nem sikerült hozzáadni a fizikai játékot", "physical-game-add-failed": "Nem sikerült hozzáadni a fizikai játékot",
"physical-game-added": "Fizikai játék hozzáadva", "physical-game-added": "Fizikai játék hozzáadva",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Aggiornata il {date}", "notes-updated-at": "Aggiornata il {date}",
"open-game": "Apri {name}", "open-game": "Apri {name}",
"open-in-flashpoint": "Apri in Flashpoint", "open-in-flashpoint": "Apri in Flashpoint",
"open-in-steam": "Apri in Steam",
"pdf-toggle-sidebar": "Mostra/nascondi barra laterale", "pdf-toggle-sidebar": "Mostra/nascondi barra laterale",
"physical-game-add-failed": "Impossibile aggiungere il gioco fisico", "physical-game-add-failed": "Impossibile aggiungere il gioco fisico",
"physical-game-added": "Gioco fisico aggiunto", "physical-game-added": "Gioco fisico aggiunto",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "更新日 {date}", "notes-updated-at": "更新日 {date}",
"open-game": "{name}を開く", "open-game": "{name}を開く",
"open-in-flashpoint": "Flashpointで開く", "open-in-flashpoint": "Flashpointで開く",
"open-in-steam": "Steamで開く",
"pdf-toggle-sidebar": "サイドバーを切り替え", "pdf-toggle-sidebar": "サイドバーを切り替え",
"physical-game-add-failed": "実物のゲームの追加に失敗しました", "physical-game-add-failed": "実物のゲームの追加に失敗しました",
"physical-game-added": "実物のゲームを追加しました", "physical-game-added": "実物のゲームを追加しました",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "업데이트: {date}", "notes-updated-at": "업데이트: {date}",
"open-game": "{name} 열기", "open-game": "{name} 열기",
"open-in-flashpoint": "Flashpoint에서 열기", "open-in-flashpoint": "Flashpoint에서 열기",
"open-in-steam": "Steam에서 열기",
"pdf-toggle-sidebar": "사이드바 전환", "pdf-toggle-sidebar": "사이드바 전환",
"physical-game-add-failed": "실물 게임을 추가하지 못했습니다", "physical-game-add-failed": "실물 게임을 추가하지 못했습니다",
"physical-game-added": "실물 게임이 추가되었습니다", "physical-game-added": "실물 게임이 추가되었습니다",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Zaktualizowano {date}", "notes-updated-at": "Zaktualizowano {date}",
"open-game": "Otwórz {name}", "open-game": "Otwórz {name}",
"open-in-flashpoint": "Otwórz w Flashpoint", "open-in-flashpoint": "Otwórz w Flashpoint",
"open-in-steam": "Otwórz w Steam",
"pdf-toggle-sidebar": "Przełącz pasek boczny", "pdf-toggle-sidebar": "Przełącz pasek boczny",
"physical-game-add-failed": "Nie udało się dodać gry fizycznej", "physical-game-add-failed": "Nie udało się dodać gry fizycznej",
"physical-game-added": "Dodano grę fizyczną", "physical-game-added": "Dodano grę fizyczną",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Atualizada {date}", "notes-updated-at": "Atualizada {date}",
"open-game": "Abrir {name}", "open-game": "Abrir {name}",
"open-in-flashpoint": "Abrir no Flashpoint", "open-in-flashpoint": "Abrir no Flashpoint",
"open-in-steam": "Abrir no Steam",
"pdf-toggle-sidebar": "Alternar barra lateral", "pdf-toggle-sidebar": "Alternar barra lateral",
"physical-game-add-failed": "Falha ao adicionar jogo físico", "physical-game-add-failed": "Falha ao adicionar jogo físico",
"physical-game-added": "Jogo físico adicionado", "physical-game-added": "Jogo físico adicionado",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Actualizată {date}", "notes-updated-at": "Actualizată {date}",
"open-game": "Deschide {name}", "open-game": "Deschide {name}",
"open-in-flashpoint": "Deschide în Flashpoint", "open-in-flashpoint": "Deschide în Flashpoint",
"open-in-steam": "Deschide în Steam",
"pdf-toggle-sidebar": "Comută bara laterală", "pdf-toggle-sidebar": "Comută bara laterală",
"physical-game-add-failed": "Nu s-a putut adăuga jocul fizic", "physical-game-add-failed": "Nu s-a putut adăuga jocul fizic",
"physical-game-added": "Joc fizic adăugat", "physical-game-added": "Joc fizic adăugat",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "Обновлено {date}", "notes-updated-at": "Обновлено {date}",
"open-game": "Открыть {name}", "open-game": "Открыть {name}",
"open-in-flashpoint": "Открыть в Flashpoint", "open-in-flashpoint": "Открыть в Flashpoint",
"open-in-steam": "Открыть в Steam",
"pdf-toggle-sidebar": "Переключить боковую панель", "pdf-toggle-sidebar": "Переключить боковую панель",
"physical-game-add-failed": "Не удалось добавить физическую игру", "physical-game-add-failed": "Не удалось добавить физическую игру",
"physical-game-added": "Физическая игра добавлена", "physical-game-added": "Физическая игра добавлена",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "{date} tarihinde güncellendi", "notes-updated-at": "{date} tarihinde güncellendi",
"open-game": "{name} oyununu aç", "open-game": "{name} oyununu aç",
"open-in-flashpoint": "Flashpoint'te aç", "open-in-flashpoint": "Flashpoint'te aç",
"open-in-steam": "Steam'de aç",
"pdf-toggle-sidebar": "Kenar çubuğunu aç/kapat", "pdf-toggle-sidebar": "Kenar çubuğunu aç/kapat",
"physical-game-add-failed": "Fiziksel oyun eklenemedi", "physical-game-add-failed": "Fiziksel oyun eklenemedi",
"physical-game-added": "Fiziksel oyun eklendi", "physical-game-added": "Fiziksel oyun eklendi",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "更新于 {date}", "notes-updated-at": "更新于 {date}",
"open-game": "打开 {name}", "open-game": "打开 {name}",
"open-in-flashpoint": "在 Flashpoint 中打开", "open-in-flashpoint": "在 Flashpoint 中打开",
"open-in-steam": "在 Steam 中打开",
"pdf-toggle-sidebar": "切换侧边栏", "pdf-toggle-sidebar": "切换侧边栏",
"physical-game-add-failed": "添加实体游戏失败", "physical-game-add-failed": "添加实体游戏失败",
"physical-game-added": "已添加实体游戏", "physical-game-added": "已添加实体游戏",
+1
View File
@@ -289,6 +289,7 @@
"notes-updated-at": "更新於 {date}", "notes-updated-at": "更新於 {date}",
"open-game": "開啟 {name}", "open-game": "開啟 {name}",
"open-in-flashpoint": "在 Flashpoint 中開啟", "open-in-flashpoint": "在 Flashpoint 中開啟",
"open-in-steam": "在 Steam 中開啟",
"pdf-toggle-sidebar": "切換側邊欄", "pdf-toggle-sidebar": "切換側邊欄",
"physical-game-add-failed": "新增實體遊戲失敗", "physical-game-add-failed": "新增實體遊戲失敗",
"physical-game-added": "已新增實體遊戲", "physical-game-added": "已新增實體遊戲",