Repository navigation
fix(auth): keep the browser open for interactive sign-in - #24
Merged
Merged
Conversation
`revcli auth` closed the window as soon as Google Maps rendered whenever
the profile already held a Google session — "already signed in, no action
needed" — which made the one command whose job is credential entry
useless for signing in or switching accounts. The only way through was
`revcli auth logout` first.
The window now stays open either way: for credential entry when signed
out, and for account switching when signed in. It closes when sign-in is
detected or when the user closes it.
`waitForSignIn()` returns `SignInOutcome` ("signed-in" | "browser-closed")
instead of `void`, so each caller can treat a closed window differently:
fatal for a scrape, which cannot continue without a session, but a normal
end for `auth`. `waitForBrowserClose()` covers the signed-in case, polling
`pages()` as well as the context `close` event because closing the last
window on macOS leaves the process alive.
Also fixed while in the flow: the 5-minute timeout threw out of an async
Commander action, which `program.parse()` does not await, so it surfaced
as an unhandled rejection with a raw stack trace. It now reports the
timeout and exits 1.
Verified on the real command: the window stayed open past 12s where it
previously closed after ~4s, and the CLI exited cleanly ~2s after the
window was closed. 10 new tests in tests/auth.test.ts (287 -> 297) pin
both end states of each waiter; AGENTS.md, README and CHANGELOG updated.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
revcli authclosed the browser window as soon as Google Maps rendered, so it could never be used to sign in. The cause was an early return inauthLoginCommand:Whenever the profile already held a session, the command declared "no action needed" about 4s after the map painted and shut the window — leaving
revcli auth logoutfollowed byrevcli authas the only way to sign in or switch accounts. That is backwards for the one command whose job is credential entry.Changes
src/commands/auth.ts— the early return is gone. The window now stays open either way: for credential entry when signed out, and for account switching when signed in. It closes when sign-in is detected, or when the user closes it.src/scraper/auth.ts—waitForSignIn()returnsSignInOutcome("signed-in" | "browser-closed") instead ofvoid, so each caller states its closed-window policy: fatal forwaitForUserAuth(), because a scrape cannot continue without a session, but a normal end forauth. NewwaitForBrowserClose()covers the signed-in case, pollingpages()as well as the contextcloseevent — closing the last window on macOS leaves the process, and therefore the context, alive.tests/auth.test.ts— 10 new cases (287 → 297) pinning both end states of each waiter.waitForBrowserClose()takes the narrow structuralClosableBrowserrather than aBrowserContext, so it is testable against a fake with no browser.AGENTS.md,README.md,CHANGELOG.md— the test count, the auth-flow description, and the documentedauthbehaviour.Also fixed
The 5-minute timeout threw out of an async Commander action.
program.parse()does not await action handlers, so it surfaced as an unhandled rejection with a raw stack trace. It now reports the timeout and exits 1 cleanly.Verified
revcli authprinted "Already signed in to Google Maps. No action needed." and closed 4s after the map loaded.✔ Browser closed. Google session saved for later runs.with exit code 0 and no stack trace.npm run typecheck,npm test(297 passed),npm run build,npm run check:pack,npm run test:package— all green locally.Note
This machine's profile already holds a valid session (cookies good to 2027-10-22), so
revcli authnow opens the window and waits to be closed; switching accounts means signing out inside that window first.