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

@@ -23,6 +23,8 @@ pub struct Services {
pub missed: conversation::MissedLog,
pub llm: Arc<Llm>,
pub browser: BrowserRun,
/// Game detection while the services run (admin.spec.md, "Game detection").
pub game: crate::game::GameWatch,
}
/// The bot browser of a run (admin.spec.md, "Bot browser").
@@ -59,6 +61,7 @@ impl BrowserRun {
impl Services {
/// Stop everything; an error means the LLM's server may still run.
pub async fn stop(&self) -> Result<(), String> {
self.game.stop();
self.core.close().await;
self.worker.close();
self.worker_process.stop().await;
@@ -109,6 +112,7 @@ async fn start_browser(data_dir: &Path, settings: &crate::settings::Settings) ->
/// before the brain can. A failure stops what already started.
pub async fn start_services(data_dir: &Path, llm: Arc<Llm>) -> Result<Services, Box<dyn std::error::Error + Send + Sync>> {
let settings = load_settings(&data_dir.join("config").join("settings.json"))?;
let game_settings = settings.game.clone();
// The stored token (the setup wizard keeps it encrypted, admin.spec.md), else the environment.
let secrets = crate::secrets::Secrets::new(&data_dir.join("config").join("secrets.dat"));
let stored = secrets.get(crate::secrets::DISCORD_TOKEN)?;
@@ -189,7 +193,8 @@ pub async fn start_services(data_dir: &Path, llm: Arc<Llm>) -> Result<Services,
return Err(after_stop(&llm, &browser, e.to_string()).await.into());
}
crate::info_log!("app", "services started");
Ok(Services { core, events, worker, worker_process, missed, llm, browser })
let game = crate::game::GameWatch::start(game_settings);
Ok(Services { core, events, worker, worker_process, missed, llm, browser, game })
}
/// The secret values the services get: the bot token and the MCP servers' environment values.