Skip to content

perf: skip blank page on first browser command#710

Merged
jackwener merged 1 commit intomainfrom
perf/skip-blank-page-on-first-nav
Apr 2, 2026
Merged

perf: skip blank page on first browser command#710
jackwener merged 1 commit intomainfrom
perf/skip-blank-page-on-first-nav

Conversation

@jackwener
Copy link
Copy Markdown
Owner

Summary

  • Eliminate the about:blank → target-domain navigation on first command execution, saving ~1-3s
  • Extension's getAutomationWindow() now accepts an optional initialUrl to create the window directly on the target domain
  • CLI removes the isAlreadyOnDomain() exec-based check and always calls page.goto() — the extension's handleNavigate already fast-paths when the tab is at the target URL

How it works

Before:

1. CLI: exec getCurrentUrl() → triggers window creation with about:blank
2. CLI: detects URL mismatch → calls goto(targetDomain)
3. Extension: navigates about:blank → targetDomain (1-3s page load)
4. Command runs

After:

1. CLI: calls goto(targetDomain) directly
2. Extension: creates window with targetDomain as initial URL
3. handleNavigate detects tab already at target → fast-path return
4. Command runs

Changes

  • extension/src/background.ts: getAutomationWindow(workspace, initialUrl?) uses target URL for window creation; resolveTabId and handleNavigate pass URL through
  • src/execution.ts: Remove isAlreadyOnDomain() check, always navigate directly. Extension handles domain-match efficiently

Test plan

  • npx tsc --noEmit passes (both CLI and extension)
  • All 143 unit test files pass (1033 tests)
  • Subsequent commands still skip redundant navigation (extension fast-path)
  • Manual test: verify first command loads directly to target domain without blank page flash

Two changes that eliminate the about:blank → target-domain navigation
on first command execution:

1. Extension: getAutomationWindow() accepts an optional initialUrl.
   When creating a new window, uses the target URL directly instead
   of about:blank. handleNavigate() passes cmd.url through so the
   window starts on the correct domain.

2. CLI: Remove isAlreadyOnDomain() check before pre-nav. Instead,
   always call page.goto(preNavUrl) — the extension's handleNavigate
   already has a fast-path that skips navigation when the tab is
   already at the target URL. This avoids an extra exec round-trip
   (getCurrentUrl eval) on first command.

Net effect: first command saves ~1-3s (one fewer page load),
subsequent commands behave the same (navigate fast-path handles
domain matching efficiently via chrome.tabs.get).
@jackwener jackwener merged commit cd5da59 into main Apr 2, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant