feat(app): the bot browser's window on a virtual monitor to share in Discord
- features.browserShare (봇용 크롬창 화면공유 선택 표시, off by default) and a driver card on the features screen: the Virtual Display Driver 25.7.23 (MIT, SignPath-signed) ships in display-driver/ (hash-checked by package.sh); install and uninstall run jarvis.exe elevated once (--display-driver), settings in %ProgramData%\JarvisBot\display-driver, another program's copy of the driver is left alone - the monitor is on the desktop only while the bot browser uses it, at the rightmost real monitor's bottom-right corner; the stop closes Chrome first, then takes the monitor off - Chrome starts with no window and the app opens it over CDP in the background, so it never takes the focus; the window is a tool window (no Alt+Tab, no taskbar button), fills the monitor's work area and keeps drawing when covered; without a monitor it runs headless with the reason on the dashboard - Chrome runs with --do-not-de-elevate on Windows: started by an app running as administrator it restarted itself as the user and the app lost hold of it - checked on the win-ci Windows VM from install to uninstall (focus kept while typing, no taskbar button, no Chrome left, nothing left after uninstall) and on Linux with a real Chrome Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,8 @@ pub enum BrowserRun {
|
||||
/// Not started: the feature is off, or (with a note) it is not installed.
|
||||
Off(Option<String>),
|
||||
Failed(String),
|
||||
Running(Arc<crate::browser::BotBrowser>),
|
||||
/// Running; the note says why it runs without the virtual monitor that was asked for.
|
||||
Running(Arc<crate::browser::BotBrowser>, Option<String>),
|
||||
}
|
||||
|
||||
impl BrowserRun {
|
||||
@@ -39,15 +40,18 @@ impl BrowserRun {
|
||||
let (state, note) = match self {
|
||||
BrowserRun::Off(note) => ("off", note.clone()),
|
||||
BrowserRun::Failed(e) => ("failed", Some(e.clone())),
|
||||
BrowserRun::Running(b) if b.running() => ("ready", None),
|
||||
BrowserRun::Running(_) => ("exited", None),
|
||||
BrowserRun::Running(b, note) if b.running() => ("ready", note.clone()),
|
||||
BrowserRun::Running(_, note) => ("exited", note.clone()),
|
||||
};
|
||||
serde_json::json!({"state": state, "note": note})
|
||||
}
|
||||
|
||||
/// Stop the browser, then take the virtual monitor off the desktop (its window first, so
|
||||
/// Windows never moves it onto a real monitor).
|
||||
pub async fn stop(&self) {
|
||||
if let BrowserRun::Running(b) = self {
|
||||
if let BrowserRun::Running(b, _) = self {
|
||||
b.stop().await;
|
||||
crate::vdisplay::detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -63,9 +67,11 @@ impl Services {
|
||||
}
|
||||
}
|
||||
|
||||
/// Start the bot browser when its feature is on and it is installed; a failure leaves the services
|
||||
/// running without it.
|
||||
/// Start the bot browser when its feature is on and it is installed, on the virtual monitor when
|
||||
/// sharing is on; a failure leaves the services running without it (or without the monitor).
|
||||
async fn start_browser(data_dir: &Path, settings: &crate::settings::Settings) -> BrowserRun {
|
||||
// A monitor an earlier run left on goes off first.
|
||||
crate::vdisplay::detach();
|
||||
if !settings.features.browser {
|
||||
return BrowserRun::Off(None);
|
||||
}
|
||||
@@ -74,8 +80,24 @@ async fn start_browser(data_dir: &Path, settings: &crate::settings::Settings) ->
|
||||
crate::warn_log!("browser", "the bot browser is not installed");
|
||||
return BrowserRun::Off(Some("설치되지 않음".into()));
|
||||
}
|
||||
match crate::browser::BotBrowser::start(&layout.chrome_exe(), &crate::browser::profile_dir(data_dir)).await {
|
||||
Ok(b) => BrowserRun::Running(Arc::new(b)),
|
||||
let (exe, profile) = (layout.chrome_exe(), crate::browser::profile_dir(data_dir));
|
||||
let mut note = None;
|
||||
if settings.features.browser_share {
|
||||
let started = match crate::vdisplay::attach() {
|
||||
Ok(r) => crate::browser::BotBrowser::start(&exe, &profile, Some(r)).await,
|
||||
Err(e) => Err(e),
|
||||
};
|
||||
match started {
|
||||
Ok(b) => return BrowserRun::Running(Arc::new(b), None),
|
||||
Err(e) => {
|
||||
crate::vdisplay::detach();
|
||||
crate::warn_log!("browser", "Warning: no virtual monitor for the bot browser: {e}");
|
||||
note = Some(format!("가상 모니터 없이 실행: {e}"));
|
||||
}
|
||||
}
|
||||
}
|
||||
match crate::browser::BotBrowser::start(&exe, &profile, None).await {
|
||||
Ok(b) => BrowserRun::Running(Arc::new(b), note),
|
||||
Err(e) => {
|
||||
crate::warn_log!("browser", "Warning: the bot browser did not start: {e}");
|
||||
BrowserRun::Failed(e)
|
||||
@@ -120,7 +142,7 @@ pub async fn start_services(data_dir: &Path, llm: Arc<Llm>) -> Result<Services,
|
||||
}
|
||||
wopts.env.insert("JARVIS_CONFIG_PATH".into(), brain_config.to_string_lossy().into_owned());
|
||||
wopts.env.insert(crate::features::MCP_ENV_VAR.into(), mcp_env.to_string());
|
||||
if let BrowserRun::Running(b) = &browser {
|
||||
if let BrowserRun::Running(b, _) = &browser {
|
||||
wopts.env.insert("JARVIS_BROWSER_CDP".into(), b.cdp_url());
|
||||
}
|
||||
// Background collection (admin.spec.md): the enabled targets, and the keep days in any case.
|
||||
|
||||
Reference in New Issue
Block a user