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:
@@ -1263,6 +1263,22 @@ impl BrowserManager {
|
||||
.collect()
|
||||
}
|
||||
|
||||
/// The active tab's stable handle + current location, for `chrome-use
|
||||
/// current` (#26). `targetId` survives cross-process navigation, so it's the
|
||||
/// handle an agent should hold across a multi-step flow.
|
||||
pub fn active_page_info(&self) -> Option<Value> {
|
||||
let i = self.resolved_active_index();
|
||||
self.pages.get(i).map(|p| {
|
||||
json!({
|
||||
"tabId": format_tab_id(p.tab_id),
|
||||
"targetId": p.target_id,
|
||||
"label": p.label,
|
||||
"url": p.url,
|
||||
"title": p.title,
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
/// Stable `tab_id` for a page identified by its CDP `targetId`, if tracked.
|
||||
/// Lets callers adopt a tab by the cross-session-stable target id.
|
||||
pub fn tab_id_for_target(&self, target_id: &str) -> Option<u32> {
|
||||
|
||||
Reference in New Issue
Block a user