fix(plugin): use correct SteamClient API, alwaysRender true, wrap stop in try-catch

This commit is contained in:
2026-06-28 18:51:53 +08:00
parent df66e0405d
commit 80caa167cc
2 changed files with 60 additions and 61 deletions
+21 -18
View File
@@ -42,21 +42,15 @@ function Content() {
// ── Register SteamClient game events ────────────────────────── // ── Register SteamClient game events ──────────────────────────
useEffect(() => { useEffect(() => {
try { try {
const startedReg = SteamClient.Apps.RegisterForGameStarted(async (appId: number) => { const startedReg = SteamClient.Apps.RegisterForGameActionStart(
let gameName = `App ${appId}` (_gameActionId: number, appId: string, _action: string, _source: number) => {
try { const appIdNum = parseInt(appId, 10)
const info = await SteamClient.Apps.GetCurrentGameInfo() onGameStart(appIdNum, `App ${appId}`)
if (info.appId === appId) { },
gameName = info.strAppName )
}
} catch {
// GetCurrentGameInfo may not be available in all contexts
}
onGameStart(appId, gameName)
})
gameStartedUnregRef.current = startedReg gameStartedUnregRef.current = startedReg
const stoppedReg = SteamClient.Apps.RegisterForGameStopped((_appId: number) => { const stoppedReg = SteamClient.Apps.RegisterForGameActionEnd((_gameActionId: number) => {
onGameStop() onGameStop()
}) })
gameStoppedUnregRef.current = stoppedReg gameStoppedUnregRef.current = stoppedReg
@@ -83,13 +77,13 @@ function Content() {
// ── Handle stop recording: parse log + read system info ──────── // ── Handle stop recording: parse log + read system info ────────
async function handleStop() { async function handleStop() {
try {
stopRecording() stopRecording()
// Parse the MangoHud log // Parse the MangoHud log
const logResult = await readAndParseMangohudLog() const logResult = await readAndParseMangohudLog()
if (logResult.error) { if (logResult.error) {
setError(logResult.error) setError(logResult.error)
// Still transition to stopped state so user can see the error + manual fields
return return
} }
@@ -102,13 +96,18 @@ function Content() {
// Read Proton version + launch options if we have an app ID // Read Proton version + launch options if we have an app ID
let protonVersion = "" let protonVersion = ""
let launchOptions = "" let launchOptions = ""
if (session.appId) { const currentAppId = session.appId
if (currentAppId) {
try {
const [pv, lo] = await Promise.all([ const [pv, lo] = await Promise.all([
getProtonVersion(session.appId), getProtonVersion(currentAppId),
getLaunchOptions(session.appId), getLaunchOptions(currentAppId),
]) ])
protonVersion = pv protonVersion = pv
launchOptions = lo launchOptions = lo
} catch {
// Non-critical, continue without
}
} }
// Use settings hardware override if set, otherwise auto-detected // Use settings hardware override if set, otherwise auto-detected
@@ -126,6 +125,10 @@ function Content() {
protonVersion, protonVersion,
launchOptions, launchOptions,
}) })
} catch (e) {
console.error("[DeckyVault] Error stopping recording:", e)
setError("Failed to process recording. Check the MangoHud log.")
}
} }
if (!loaded) { if (!loaded) {
@@ -215,7 +218,7 @@ export default definePlugin(() => {
titleView: <div className={staticClasses.Title}>DeckyVault</div>, titleView: <div className={staticClasses.Title}>DeckyVault</div>,
content: <Content />, content: <Content />,
icon: <DeckyVaultIcon />, icon: <DeckyVaultIcon />,
alwaysRender: false, alwaysRender: true,
onDismount() { onDismount() {
console.log("[DeckyVault] Plugin unloading") console.log("[DeckyVault] Plugin unloading")
}, },
+4 -8
View File
@@ -5,16 +5,12 @@
declare global { declare global {
const SteamClient: { const SteamClient: {
Apps: { Apps: {
RegisterForGameStarted: ( RegisterForGameActionStart: (
callback: (appId: number) => void, callback: (gameActionId: number, appId: string, action: string, source: number) => void,
) => { unregister: () => void } ) => { unregister: () => void }
RegisterForGameStopped: ( RegisterForGameActionEnd: (
callback: (appId: number) => void, callback: (gameActionId: number) => void,
) => { unregister: () => void } ) => { unregister: () => void }
GetCurrentGameInfo: () => Promise<{
appId: number
strAppName: string
}>
} }
System: { System: {
GetOSVersion: () => Promise<string> GetOSVersion: () => Promise<string>