mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
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:
co-authored by
alectimison-maker
parent
0ce497f017
commit
f443cfae74
@@ -16,6 +16,10 @@ pub struct SessionStartParams {
|
||||
/// Optional Agent Window outer height in CSS pixels (100..=7680).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub height: Option<u32>,
|
||||
/// Whether the new Agent Window should take focus. Omitted means the
|
||||
/// extension's default (`true`) for compatibility with older clients.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub focused: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||
@@ -49,6 +53,23 @@ mod tests {
|
||||
use super::*;
|
||||
use serde_json::json;
|
||||
|
||||
#[test]
|
||||
fn session_start_focus_is_optional_and_round_trips_false() {
|
||||
let defaulted: SessionStartParams = serde_json::from_value(json!({
|
||||
"session_id": "aa11"
|
||||
}))
|
||||
.unwrap();
|
||||
assert_eq!(defaulted.focused, None);
|
||||
|
||||
let background: SessionStartParams = serde_json::from_value(json!({
|
||||
"session_id": "aa11",
|
||||
"focused": false
|
||||
}))
|
||||
.unwrap();
|
||||
assert_eq!(background.focused, Some(false));
|
||||
assert_eq!(serde_json::to_value(background).unwrap()["focused"], false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn session_stop_result_round_trips_auto_return_payload() {
|
||||
let result: SessionStopResult = serde_json::from_value(json!({
|
||||
|
||||
Reference in New Issue
Block a user