Skip to content

feat(goto): add --wait-loaded flag for async-rendered content#69

Merged
avifenesh merged 4 commits intomainfrom
feature/wait-loaded-68
Feb 25, 2026
Merged

feat(goto): add --wait-loaded flag for async-rendered content#69
avifenesh merged 4 commits intomainfrom
feature/wait-loaded-68

Conversation

@avifenesh
Copy link
Collaborator

Summary

  • Add --wait-loaded flag to goto command that waits for async-rendered content to finish loading before taking a snapshot
  • Three-phase detection: network idle + DOM stability (via waitForStable), loading indicator absence (spinners, skeletons, progress bars, aria-busy), and a final DOM quiet period
  • Default timeout 15000ms, overridable with --timeout <ms>
  • Wired into all 4 goto code paths (normal, ensureAuth, checkpoint, no-display)

Changes

  • scripts/browser-launcher.js - New waitForLoaded function with null-body guard, querySelectorAll optimization, TreeWalker node limit, MutationObserver cleanup
  • scripts/web-ctl.js - Flag registration, import, goto handler integration, help text, macro helpers
  • tests/web-ctl-actions.test.js - 21 new tests (export, source introspection, flag parsing, implementation, CLI integration)
  • README.md - Action reference and common flags tables
  • skills/web-browse/SKILL.md - Goto section docs
  • CHANGELOG.md - Feature entry

Test Plan

  • 500/500 tests pass (21 new)
  • npm run validate passes
  • goto https://example.com --wait-loaded returns waitLoaded: true
  • Flag does not consume next positional arg
  • Works alongside --timeout, --ensure-auth, snapshot flags

Closes #68

Add waitForLoaded function to browser-launcher that combines three
phases: network idle + DOM stability (via existing waitForStable),
loading indicator absence detection (spinners, skeletons, progress
bars, aria-busy elements), and a final 300ms DOM quiet period.

Wire --wait-loaded into all four goto snapshot paths, register as
boolean flag, expose in macro helpers, and update help text.

Closes #68
- Guard against null document.body in indicator check and MutationObserver
- Limit TreeWalker to 5000 nodes to prevent DoS on huge DOMs
- Use querySelectorAll with combined selectors for efficient polling
- Ensure MutationObserver disconnect in all resolve paths
- Parse loadedTimeout once at top of goto case (DRY)
- Add tests for null guard, node limit, querySelectorAll, DRY timeout
@avifenesh avifenesh merged commit a5839f8 into main Feb 25, 2026
2 of 3 checks passed
@avifenesh avifenesh deleted the feature/wait-loaded-68 branch February 25, 2026 12:57
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.

Add --wait-loaded flag for pages with async-rendered content

1 participant