feat: support Agent Window sizing (session start --width/--height, window resize) (#52)

- `bsk session start --width <px> --height <px>` opens the Agent Window
  with the given outer size (chrome.windows.create)
- new `bsk window resize --session <id> --width <px> --height <px>`
  resizes the Agent Window at runtime (chrome.windows.update)
- both validated on CLI, daemon and extension sides (100..=7680 CSS px)
- protocol: new tool.window_resize method (BrowserMutation) and
  optional width/height on tool.session_start params; schemas regenerated
This commit is contained in:
BB-fat
2026-08-05 11:19:10 +08:00
committed by GitHub
parent d7f0f1e78c
commit 49378d70de
25 changed files with 725 additions and 10 deletions
+96
View File
@@ -227,3 +227,99 @@ fn parses_record_start_without_url() {
assert_eq!(args.browser.as_deref(), Some("022ca8ac"));
assert!(args.url.is_none());
}
#[test]
fn parses_session_start_with_window_size() {
use bsk::cli::session::{SessionCmd, SessionSub};
let cli = parse(&[
"bsk", "session", "start", "--width", "1280", "--height", "800",
]);
let Command::Session(SessionCmd {
sub: SessionSub::Start(args),
}) = cli.command
else {
panic!("expected session start subcommand");
};
assert_eq!(args.width, Some(1280));
assert_eq!(args.height, Some(800));
}
#[test]
fn session_start_window_size_defaults_to_none() {
use bsk::cli::session::{SessionCmd, SessionSub};
let cli = parse(&["bsk", "session", "start"]);
let Command::Session(SessionCmd {
sub: SessionSub::Start(args),
}) = cli.command
else {
panic!("expected session start subcommand");
};
assert!(args.width.is_none());
assert!(args.height.is_none());
}
#[test]
fn rejects_out_of_range_session_start_window_size() {
assert!(Cli::try_parse_from(["bsk", "session", "start", "--width", "99"]).is_err());
assert!(Cli::try_parse_from(["bsk", "session", "start", "--height", "7681"]).is_err());
assert!(Cli::try_parse_from(["bsk", "session", "start", "--width", "abc"]).is_err());
}
#[test]
fn parses_window_resize() {
use bsk::cli::window::{WindowCmd, WindowSub};
let cli = parse(&[
"bsk",
"window",
"resize",
"--session",
"s1",
"--width",
"1280",
"--height",
"800",
]);
let Command::Window(WindowCmd {
sub: WindowSub::Resize(args),
}) = cli.command
else {
panic!("expected window resize subcommand");
};
assert_eq!(args.session, "s1");
assert_eq!(args.width, 1280);
assert_eq!(args.height, 800);
}
#[test]
fn rejects_invalid_window_resize_dimensions() {
assert!(
Cli::try_parse_from([
"bsk",
"window",
"resize",
"--session",
"s1",
"--width",
"99",
"--height",
"800"
])
.is_err()
);
assert!(
Cli::try_parse_from([
"bsk",
"window",
"resize",
"--session",
"s1",
"--width",
"1280",
"--height",
"7681"
])
.is_err()
);
// width/height are required for resize.
assert!(Cli::try_parse_from(["bsk", "window", "resize", "--session", "s1"]).is_err());
}