From 39554876255fbe50a835ee2a544b4606c05840d3 Mon Sep 17 00:00:00 2001 From: slyjain Date: Wed, 29 Apr 2026 20:25:31 +0530 Subject: [PATCH] Add reload command Reloads the current page and waits for networkidle0 so SPAs fully render. Prints the current URL to stdout. Note: package-lock.json was not present in the repo and is being avoided. --- src/commands/reload.ts | 9 +++++++++ src/index.ts | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) create mode 100644 src/commands/reload.ts diff --git a/src/commands/reload.ts b/src/commands/reload.ts new file mode 100644 index 0000000..a8fc8bd --- /dev/null +++ b/src/commands/reload.ts @@ -0,0 +1,9 @@ +import { connect } from "../lib/browser" +import type { Flags } from "../lib/flags" + +export const reload = async (args: string[], flags: Flags) => { + const { page, close } = await connect(flags.tab) + await page.reload({ waitUntil: "networkidle0", timeout: flags.timeout }) + console.log(page.url()) + await close() +} diff --git a/src/index.ts b/src/index.ts index a77b617..e26a170 100755 --- a/src/index.ts +++ b/src/index.ts @@ -19,8 +19,9 @@ import { audit } from "./commands/audit" import { tab } from "./commands/tab" import { logs } from "./commands/logs" import { record } from "./commands/record" +import { reload } from "./commands/reload" -const commands = { go, url, back, forward, shot, snap, text, click, type, fill, key, move, drag, scroll, js, wait, audit, tab, logs, record } +const commands = { go, url, back, forward, reload, shot, snap, text, click, type, fill, key, move, drag, scroll, js, wait, audit, tab, logs, record } const help = `mb — Browser CLI for Agents @@ -32,6 +33,7 @@ Navigation: url Print current URL back Go back forward Go forward + reload Reload page Observe: shot [file] Screenshot (default: ./shot.png)