fix(fill/tabs): dispatch real input/change/blur (#25); close <tab> wording + chrome-use current (#26)
#25 — fill() didn't fire the events framework inputs / site autocomplete need: it set value directly (bypassing React's value-tracker) and typed via Input.insertText, so controlled components and input/change/blur listeners (e.g. Mercari's postal-code → 都道府県 lookup) never ran though the value showed. fill now emulates a real edit: focus, set through the element's prototype value setter (React _valueTracker registers), then dispatch input → input → change → blur/ focusout. SELECT and contenteditable handled too. type <sel> <text> remains for per-keystroke sites. Verified live: an input wired with input/change/blur fired 'IICB' from one fill. #26 (ergonomics): - 'close <tab>' now closes just that tab and prints 'Tab [tN] closed'; bare 'close' still closes the browser. Previously 'close t12' ran a browser close and alarmingly printed 'Browser closed'. - new 'chrome-use current': prints the active tab's stable handle (tabId + CDP targetId + url/title), refreshed live — so an agent holds the targetId (which survives cross-process nav) instead of re-deriving 'which tab is live' from 'tabs' every step. The deeper tab-id churn is the #21/#23 stable-targetId story. Tests cover fill events (live), close tab-vs-browser parse, and current.
This commit is contained in:
@@ -209,6 +209,21 @@ pub fn print_response_with_opts(resp: &Response, action: Option<&str>, opts: &Ou
|
||||
);
|
||||
}
|
||||
|
||||
// `current`: the active tab's stable handle (#26).
|
||||
if data
|
||||
.get("current")
|
||||
.and_then(|v| v.as_bool())
|
||||
.unwrap_or(false)
|
||||
{
|
||||
let tid = data.get("tabId").and_then(|v| v.as_str()).unwrap_or("?");
|
||||
let title = data.get("title").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let url = data.get("url").and_then(|v| v.as_str()).unwrap_or("");
|
||||
let target = data.get("targetId").and_then(|v| v.as_str()).unwrap_or("");
|
||||
println!("{} [{}] {} - {}", color::cyan("→"), tid, title, url);
|
||||
println!(" {}", color::dim(&format!("target: {}", target)));
|
||||
return;
|
||||
}
|
||||
|
||||
// Dialog status response
|
||||
if action == Some("dialog") {
|
||||
if let Some(has_dialog) = data.get("hasDialog").and_then(|v| v.as_bool()) {
|
||||
|
||||
Reference in New Issue
Block a user