fix(plugin): update verify config check, add debug list tmp

This commit is contained in:
2026-06-28 20:51:47 +08:00
parent 2b53b30be6
commit 7a653198e7
3 changed files with 34 additions and 10 deletions
+28 -8
View File
@@ -273,30 +273,50 @@ benchmark_percentiles=97,AVG,1,0.1
return {"success": False, "error": str(e)} return {"success": False, "error": str(e)}
async def _find_mangohud_log(self) -> str | None: async def _find_mangohud_log(self) -> str | None:
"""Find the most recent MangoHud log file in /tmp/. """Find the most recent MangoHud log file in /tmp/."""
MangoHud creates log files with the game name and timestamp."""
import glob import glob
import time
candidates = [] candidates = []
# MangoHud log files are typically .csv or have MangoHud in the name now = time.time()
for pattern in ["/tmp/*MangoHud*", "/tmp/*.csv", "/tmp/*.log"]: for pattern in ["/tmp/*MangoHud*", "/tmp/*.csv", "/tmp/*.log"]:
for f in glob.glob(pattern): for f in glob.glob(pattern):
# Skip directories
if os.path.isdir(f): if os.path.isdir(f):
continue continue
# Check if it looks like a MangoHud log (has fps/frametime header) # Only consider files modified in the last hour
try:
mtime = os.path.getmtime(f)
if now - mtime > 3600:
continue
except:
pass
# Check if it looks like a MangoHud log
try: try:
with open(f, 'r') as fh: with open(f, 'r') as fh:
first_lines = "".join(fh.readline() for _ in range(5)) first_lines = "".join(fh.readline() for _ in range(5))
if 'fps' in first_lines.lower() or 'MangoHud' in first_lines: if 'fps' in first_lines.lower() or 'MangoHud' in first_lines:
candidates.append(f) candidates.append(f)
except (IOError, UnicodeDecodeError, PermissionError): except:
pass candidates.append(f) # Add anyway if we can't read it
if not candidates: if not candidates:
return None return None
# Return the most recently modified file
candidates.sort(key=lambda f: os.path.getmtime(f), reverse=True) candidates.sort(key=lambda f: os.path.getmtime(f), reverse=True)
return candidates[0] return candidates[0]
async def debug_list_tmp(self) -> dict:
"""RPC: List all files in /tmp/ for debugging."""
import glob
files = []
for f in glob.glob("/tmp/*"):
if os.path.isfile(f):
try:
mtime = os.path.getmtime(f)
size = os.path.getsize(f)
files.append({"name": os.path.basename(f), "size": size, "mtime": mtime})
except:
pass
files.sort(key=lambda x: x["mtime"], reverse=True)
return {"files": files[:30]}
async def read_and_parse_mangohud_log(self, log_path: str | None = None) -> dict: async def read_and_parse_mangohud_log(self, log_path: str | None = None) -> dict:
"""RPC: Read the MangoHud log file and return parsed FPS stats. """RPC: Read the MangoHud log file and return parsed FPS stats.
If no log_path given, searches /tmp/ for the most recent MangoHud log. If no log_path given, searches /tmp/ for the most recent MangoHud log.
@@ -165,9 +165,9 @@ export default function MainPanel({
} }
const content = result.content const content = result.content
const hasOutputFolder = content.includes("output_folder=/tmp") const hasOutputFolder = content.includes("output_folder=/tmp")
const hasOutputFile = content.includes("output_file=deckyvault-mangohud.log")
const hasFps = content.includes("fps") const hasFps = content.includes("fps")
if (hasOutputFolder && hasOutputFile && hasFps) { const hasFrameTiming = content.includes("frame_timing")
if (hasOutputFolder && hasFps) {
setConfigVerified({ checked: true, valid: true, message: "Config looks good" }) setConfigVerified({ checked: true, valid: true, message: "Config looks good" })
} else { } else {
setConfigVerified({ checked: true, valid: false, message: "Config is missing required settings. Write it again." }) setConfigVerified({ checked: true, valid: false, message: "Config is missing required settings. Write it again." })
+4
View File
@@ -86,6 +86,10 @@ export const testApiKey = callable<[apiKey: string, baseUrl?: string], {
error?: string error?: string
}>("test_api_key") }>("test_api_key")
export const debugListTmp = callable<[], {
files: Array<{ name: string; size: number; mtime: number }>
}>("debug_list_tmp")
// ── Config Export/Import ──────────────────────────────────────── // ── Config Export/Import ────────────────────────────────────────
export const exportConfig = callable<[settings: { export const exportConfig = callable<[settings: {
apiKey: string apiKey: string