Fix browser goto snapshot-after parsing

This commit is contained in:
Lawrence Chen 2026-03-05 17:57:05 -08:00
parent 0fb2b414b0
commit 61792c3caf
2 changed files with 15 additions and 2 deletions

View file

@ -2755,12 +2755,17 @@ struct CMUXCLI {
if subcommand == "goto" || subcommand == "navigate" {
let sid = try requireSurface()
let url = subArgs.joined(separator: " ").trimmingCharacters(in: .whitespacesAndNewlines)
var urlArgs = subArgs
let snapshotAfter = urlArgs.last == "--snapshot-after"
if snapshotAfter {
urlArgs.removeLast()
}
let url = urlArgs.joined(separator: " ").trimmingCharacters(in: .whitespacesAndNewlines)
guard !url.isEmpty else {
throw CLIError(message: "browser \(subcommand) requires a URL")
}
var params: [String: Any] = ["surface_id": sid, "url": url]
if hasFlag(subArgs, name: "--snapshot-after") {
if snapshotAfter {
params["snapshot_after"] = true
}
let payload = try client.sendV2(method: "browser.navigate", params: params)

View file

@ -173,6 +173,14 @@ def main() -> int:
_must(routed_url.startswith(page_url), f"Expected routed URL to start with page URL, got: {routed_url_payload}")
_must("--workspace" not in routed_url and "--window" not in routed_url, f"Routing flags leaked into URL: {routed_url_payload}")
goto_url = f"{page_url}?goto=1"
goto_payload = _run_cli_json(cli, ["browser", surface, "goto", goto_url, "--snapshot-after"])
_must(bool(goto_payload.get("post_action_snapshot")), f"Expected goto --snapshot-after to include post_action_snapshot: {goto_payload}")
goto_url_payload = _run_cli_json(cli, ["browser", surface, "url"])
current_goto_url = str(goto_url_payload.get("url") or "")
_must(current_goto_url.startswith(goto_url), f"Expected goto --snapshot-after current URL to match target URL: {goto_url_payload}")
_must("--snapshot-after" not in current_goto_url, f"Expected goto URL to exclude trailing flag text: {goto_url_payload}")
find_text = _run_cli_json(cli, ["browser", surface, "find", "text", "row-b"])
_must(str(find_text.get("element_ref") or "").startswith("@e"), f"Expected element_ref from find text: {find_text}")