Skip to content

feat(goto): add --ensure-auth flag for automated auth wall handling#65

Merged
avifenesh merged 6 commits intomainfrom
feature/ensure-auth-flag-35
Feb 25, 2026
Merged

feat(goto): add --ensure-auth flag for automated auth wall handling#65
avifenesh merged 6 commits intomainfrom
feature/ensure-auth-flag-35

Conversation

@avifenesh
Copy link
Collaborator

Summary

  • Add --ensure-auth flag to goto action that collapses the 3-round-trip auth pattern into a single command
  • When auth wall detected, automatically opens headed checkpoint with polling-based auth detection (2s interval via checkAuthSuccess)
  • After auth completes, closes headed browser, relaunches headless, re-navigates to original URL, and returns authenticated snapshot
  • --ensure-auth overrides --no-auth-wall-detect when both are set
  • Hardened with page.isClosed() checks, try-catch around polling and browser transitions, proper context nullification on timeout

Test Plan

  • 479/479 tests pass (npm test)
  • npm run validate passes
  • Source-level assertions verify flag registration, guard condition, polling pattern, error handling, and context cleanup
  • Flag parsing tests confirm boolean behavior and flag interaction
  • CLI integration test runs goto with --ensure-auth against example.com
  • Manual: goto https://github.com/settings --ensure-auth on a system with display - verify headed browser opens, auth completes, re-navigation returns settings page

Closes #35

Register --ensure-auth in BOOLEAN_FLAGS and modify the goto auth wall
detection block. When --ensure-auth is set, polls with checkAuthSuccess
at 2s intervals instead of a static setTimeout checkpoint. On success,
closes the headed browser, relaunches headless, and navigates to the
original URL. On timeout or no display, returns ensureAuthCompleted:
false with a descriptive message.

The flag overrides --no-auth-wall-detect so auth detection runs even
when wall detection is disabled.
Source-level assertions verify BOOLEAN_FLAGS registration, help text,
opts.ensureAuth guard, checkAuthSuccess polling, result fields
(ensureAuthCompleted true/false), timeout message, no-display path,
guard condition override, headless relaunch, and poll interval.

Flag parsing tests confirm boolean true parsing, no positional arg
consumption, and compatibility with --timeout and --no-auth-wall-detect.

CLI integration test runs goto with --ensure-auth against example.com.
Update SKILL.md goto section with flag description and return type,
README.md action reference table and common flags table, commands/web-ctl.md
quick reference, and CHANGELOG.md with new feature entry.
- Move sleep before checkAuthSuccess so first poll waits 2s
- Add page.isClosed() check to prevent hung evaluations
- Wrap checkAuthSuccess in try-catch for resilience during navigation
- Remove unnecessary headless browser launch on timeout path
- Guard closeBrowser with context null check on normal exit
- Use url variable directly instead of redundant originalUrl
- Wrap headless relaunch in try-catch on success path to preserve
  auth completion context if reload fails
- Wrap closeBrowser in try-catch on timeout path to ensure consistent
  context/page nullification even if browser already closed
- Add source-level tests for new safety patterns
@avifenesh avifenesh merged commit 3d85752 into main Feb 25, 2026
2 of 3 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.

Add --ensure-auth flag to goto action

1 participant