feat(app): game detection for the performance stages

- while the services run the app looks at the foreground window every 2 s (Windows): the
  person's notGames and games lists first, never a browser, video player, the desktop, Discord,
  a launcher's own window or this app; a program under a Steam, Epic, Riot or Battle.net game
  folder, exclusive full screen, or a window covering a monitor without title bar or border whose
  process uses at least 10% of the GPU's 3D engine (the M0 rule) is a game
- game mode stays until that game's process ends, also behind other windows; the dashboard shows
  "게임 모드: 켜짐 (name, reason)" and the game log tab its changes
- a 게임 모드 settings screen (detection on/off, the two lists)
- checked on the win-ci VM: a program in a Steam game folder turned it on after 1.4 s and off
  2.0 s after it ended

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
javis-bot
2026-11-14 09:08:50 +09:00
parent 9b53af169d
commit c9101e0d6a
12 changed files with 588 additions and 9 deletions

View File

@@ -410,6 +410,9 @@ async function displayDriverCard() {
// ---- dashboard ----------------------------------------------------------------------------------
const GAME_REASON = { fullscreen: () => "전체화면", borderless: () => "테두리 없는 창", registered: () => "직접 등록한 게임",
launcher: (r) => `${r.launcher} 게임 폴더` };
/** The header with the start/stop buttons; rebuilt only when the state changes, so a click is not
* lost to the once-a-second refresh of the cards. */
function dashboardHeader(d) {
@@ -466,6 +469,8 @@ function dashboardBody(d) {
h("span", { class: "k" }, "RAM"), h("span", {}, d.system?.ramTotalMb ? `${(d.system.ramUsedMb / 1024).toFixed(1)} / ${(d.system.ramTotalMb / 1024).toFixed(1)} GB` : "–"),
(d.system?.gpus || []).flatMap((g) => [h("span", { class: "k" }, g.name.replace("NVIDIA GeForce ", "")),
h("span", {}, `${g.usePercent}% · VRAM ${(g.vramUsedMb / 1024).toFixed(1)} / ${(g.vramTotalMb / 1024).toFixed(1)} GB`)]),
h("span", { class: "k" }, "게임 모드"), h("span", { class: d.game ? "" : "muted" },
d.game ? `켜짐 (${d.game.name}, ${GAME_REASON[d.game.reason.kind]?.(d.game.reason) ?? d.game.reason.kind})` : "꺼짐"),
h("span", { class: "k" }, "성능 단계"), h("span", { class: "muted" }, d.performance ?? "평소")))),
h("div", { class: "grid" },
h("div", { class: "card" }, h("h2", {}, "실시간 자막"), h("div", { class: "captions" },
@@ -565,7 +570,7 @@ async function show(name) {
if (name === "dashboard") { screen.replaceChildren(); await refresh(); ticker = setInterval(refresh, 1000); return; }
if (name === "logs") { const l = logsScreen(); screen.replaceChildren(l.view); ticker = setInterval(l.tick, 1000); return; }
const titles = { bot: "봇", channels: "채널·호출", chat: "채팅 채널", memory: "대화 기억", model: "모델", features: "기능",
collect: "백그라운드 수집" };
collect: "백그라운드 수집", game: "게임 모드" };
const extra = name === "bot" ? await tokenCard() : name === "features" ? await displayDriverCard() : null;
const view = await settingsScreen(name, titles[name], extra);
if (name === "collect") view.append(await collectResults());

View File

@@ -19,6 +19,7 @@
<button data-screen="model" class="nav">모델</button>
<button data-screen="features" class="nav">기능</button>
<button data-screen="collect" class="nav">백그라운드 수집</button>
<button data-screen="game" class="nav">게임 모드</button>
<button data-screen="logs" class="nav">로그</button>
<div class="side-foot" id="version"></div>
</nav>