Skip to content

feat(auth): add --no-browser-open to auth login#376

Merged
scottlovegrove merged 2 commits into
mainfrom
feat/auth-login-no-browser-open
Jun 2, 2026
Merged

feat(auth): add --no-browser-open to auth login#376
scottlovegrove merged 2 commits into
mainfrom
feat/auth-login-no-browser-open

Conversation

@scottlovegrove

Copy link
Copy Markdown
Collaborator

What

Adds a --no-browser-open flag to td auth login. With it, the OAuth flow prints the authorization URL for manual copy-paste instead of automatically opening a browser.

td auth login --no-browser-open

Why

Useful on headless or remote hosts, in SSH sessions, or any time you'd rather not have the desktop browser hijacked. cli-core already auto-skips the spawn on detected headless/WSL environments; this flag forces the skip everywhere.

How

cli-core surfaces the authorize URL before its openBrowser hook fires, so skipping the spawn still leaves a usable login — the printed URL is the path through. cli-core's openBrowser hook isn't handed the parsed flags, so the option is read off the command at call time (commander negatable --no-browser-openbrowserOpen, default true).

Tests

  • Added two tests: opens the browser by default, skips when the flag is set.
  • SKILL content updated and regenerated via sync:skill.
  • type-check, check (oxlint + oxfmt), and the auth login suite all pass.

Let users complete the OAuth flow by copy-pasting the printed
authorize URL instead of having a browser opened automatically —
useful on headless or remote hosts, or when the desktop browser
shouldn't be hijacked.

cli-core surfaces the authorize URL before its `openBrowser` hook
fires, so skipping the spawn still leaves a usable login. The hook
isn't handed the parsed flags, so the option is read off the command
at call time. SKILL content regenerated.
@scottlovegrove scottlovegrove self-assigned this Jun 2, 2026
@doistbot doistbot requested a review from rfgamaral June 2, 2026 09:11

@doistbot doistbot left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks scottlovegrove for your contribution 😎 👊. The implementation for the --no-browser-open flag is clean, and the proactive updates to the SKILL docs are much appreciated.

Few things worth tightening:

  • Reauth flows: Follow-up login hints (e.g., for missing scopes) don't preserve the --no-browser-open flag, which could unexpectedly spawn a browser later in headless environments.
  • Helper reuse: The command bypasses src/lib/browser.ts; consider extending the shared helper with an option like { announce: false } to keep browser-launch logic unified.
  • Test assertions: The test verifies the skipped browser behavior by setting Commander's internal state directly rather than parsing the public flag via createTestProgram.

Share FeedbackReview Logs

Comment thread src/commands/auth/login.ts
Comment thread src/commands/auth/login.ts
Comment thread src/commands/auth/login.test.ts Outdated
Address review feedback:
- Funnel the auth-login browser spawn through `openInBrowser` instead of
  importing `open` directly, adding an `{ announce: false }` option so the
  helper doesn't double-print the URL cli-core already shows.
- Exercise the real `--no-browser-open` flag via `createTestProgram` /
  `parseAsync` rather than poking Commander's internal option store.
@scottlovegrove scottlovegrove merged commit 90ee8ec into main Jun 2, 2026
5 checks passed
@scottlovegrove scottlovegrove deleted the feat/auth-login-no-browser-open branch June 2, 2026 09:23
doist-release-bot Bot added a commit that referenced this pull request Jun 2, 2026
## [1.71.0](v1.70.0...v1.71.0) (2026-06-02)

### Features

* **auth:** add `--no-browser-open` to `auth login` ([#376](#376)) ([90ee8ec](90ee8ec))
@doist-release-bot

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.71.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@rfgamaral rfgamaral left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants