mirror of
https://github.com/Tencent/BrowserSkill.git
synced 2026-09-10 13:01:23 +08:00
feat(record): add popup quick-actions launcher and make record --url optional
Add a popup launcher + action-recording panel that builds a copyable `bsk record start` prompt, add `--browser` targeting, and default `--url` to https://example.com/ when omitted. Drop the popup browser-alias field.
This commit is contained in:
@@ -211,8 +211,8 @@ which refs/selectors matched a live element.
|
||||
Capture the user's own actions in the Agent Window to a `trace.json`, for later LLM-driven automation:
|
||||
|
||||
```bash
|
||||
bsk record start --url https://… [--purpose "publish a wiki doc"] [--output trace.json]
|
||||
# `--url` is required on a fresh session (about:blank cannot host the content script).
|
||||
bsk record start --browser <instance-id-or-label> [--url https://…] [--purpose "publish a wiki doc"] [--output trace.json]
|
||||
# `--url` is optional; default https://www.baidu.com/ when omitted (must be http(s)).
|
||||
# Blocks until the user clicks Finish in the recording panel, then writes ./trace.json and closes the window.
|
||||
|
||||
bsk record stop [--output trace.json] # terminal fallback if the browser panel is unavailable
|
||||
|
||||
@@ -41,12 +41,16 @@ pub enum RecordSub {
|
||||
|
||||
#[derive(Debug, Clone, Args)]
|
||||
pub struct RecordStartArgs {
|
||||
/// Target browser instance id or label. Required when multiple browsers
|
||||
/// are connected; omit when only one is online.
|
||||
#[arg(long)]
|
||||
pub browser: Option<String>,
|
||||
|
||||
#[arg(long = "tab-id")]
|
||||
pub tab_id: Option<i64>,
|
||||
|
||||
/// Navigate to this http(s) URL before recording (required for a fresh
|
||||
/// session — Agent Window starts on about:blank, which cannot host the
|
||||
/// content script).
|
||||
/// Navigate to this http(s) URL before recording. When omitted, defaults
|
||||
/// to `https://www.baidu.com/`.
|
||||
#[arg(long)]
|
||||
pub url: Option<String>,
|
||||
|
||||
@@ -81,7 +85,7 @@ fn dispatch_start(args: RecordStartArgs, format: Format) -> Result<(), CliError>
|
||||
}
|
||||
|
||||
let info = ensure_daemon().context("ensure daemon is running")?;
|
||||
let session = start_session(info.sock_path.clone(), None)?;
|
||||
let session = start_session(info.sock_path.clone(), args.browser)?;
|
||||
|
||||
let start_params = RecordStartParams {
|
||||
session_id: session.session_id.clone(),
|
||||
@@ -240,6 +244,7 @@ mod tests {
|
||||
#[test]
|
||||
fn start_args_default_output_is_trace_json() {
|
||||
let args = RecordStartArgs {
|
||||
browser: None,
|
||||
tab_id: None,
|
||||
url: None,
|
||||
purpose: None,
|
||||
|
||||
@@ -4,6 +4,7 @@ use std::time::Duration;
|
||||
|
||||
use bsk::cli::daemon::{DaemonCmd, parse_duration};
|
||||
use bsk::cli::navigate::NavigateCmd;
|
||||
use bsk::cli::record::{RecordCmd, RecordSub};
|
||||
use bsk::{Cli, Command};
|
||||
use clap::Parser;
|
||||
|
||||
@@ -192,3 +193,37 @@ fn rejects_zero_click_count() {
|
||||
Cli::try_parse_from(["bsk", "click", "@e1", "--session", "s1", "--count", "0"]).is_err()
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_record_start_with_browser_and_url() {
|
||||
let cli = parse(&[
|
||||
"bsk",
|
||||
"record",
|
||||
"start",
|
||||
"--browser",
|
||||
"022ca8ac",
|
||||
"--url",
|
||||
"https://x",
|
||||
]);
|
||||
let Command::Record(RecordCmd {
|
||||
sub: RecordSub::Start(args),
|
||||
}) = cli.command
|
||||
else {
|
||||
panic!("expected record start subcommand");
|
||||
};
|
||||
assert_eq!(args.browser.as_deref(), Some("022ca8ac"));
|
||||
assert_eq!(args.url.as_deref(), Some("https://x"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_record_start_without_url() {
|
||||
let cli = parse(&["bsk", "record", "start", "--browser", "022ca8ac"]);
|
||||
let Command::Record(RecordCmd {
|
||||
sub: RecordSub::Start(args),
|
||||
}) = cli.command
|
||||
else {
|
||||
panic!("expected record start subcommand");
|
||||
};
|
||||
assert_eq!(args.browser.as_deref(), Some("022ca8ac"));
|
||||
assert!(args.url.is_none());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user