feat(session): support unfocused agent windows (--no-focus) (#87)

`bsk session start --no-focus` opens the Agent Window in the background
without stealing focus. The flag threads focused=false through
CLI -> daemon IPC -> tool.session_start -> chrome.windows.create; an
omitted `focused` keeps the extension default (true) so older clients
are unaffected.

Reworked onto current main so it composes with #52 window sizing:
AgentWindowApi.create / SessionManager.start (extension), start_session
(CLI) and the daemon's session start now take options objects/structs
({ size, focused }) instead of colliding positional params.

Co-authored-by: alectimison-maker <alec.timison@gmail.com>
This commit is contained in:
BB-fat
2026-08-12 19:58:53 +08:00
committed by GitHub
co-authored by alectimison-maker
parent 0ce497f017
commit f443cfae74
17 changed files with 235 additions and 43 deletions
+9 -3
View File
@@ -42,8 +42,8 @@ use tracing::{debug, warn};
use super::abort::AbortRegistry;
use super::queue::{DEFAULT_TOOL_TIMEOUT, DispatchError};
use super::sessions::{
SessionId, StartSessionError, StopSessionError, snapshot_status_entries, start_session,
stop_session,
AgentWindowOptions, SessionId, StartSessionError, StopSessionError, snapshot_status_entries,
start_session, stop_session,
};
use super::state::{DAEMON_VERSION, DaemonState, PROTOCOL_VERSION};
@@ -545,6 +545,8 @@ struct CliSessionStartParams {
pub width: Option<u32>,
#[serde(default)]
pub height: Option<u32>,
#[serde(default)]
pub focused: Option<bool>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -638,6 +640,7 @@ async fn handle_session_start(state: &Arc<DaemonState>, params: Value) -> Result
browser_instance_id: None,
width: None,
height: None,
focused: None,
}
} else {
serde_json::from_value(params).map_err(|err| RpcError {
@@ -664,7 +667,10 @@ async fn handle_session_start(state: &Arc<DaemonState>, params: Value) -> Result
&state.sessions,
&state.tool_queues,
params.browser_instance_id.as_deref(),
window_size,
AgentWindowOptions {
size: window_size,
focused: params.focused,
},
state.config.extension_connect_wait,
DEFAULT_RPC_TIMEOUT,
)