Skip to content

feat(cli): Discord as help/bug-report fallback - #3451

Merged
shrey150 merged 3 commits into
mainfrom
cursor/discord-help-fallback-621e
Nov 18, 2026
Merged

shrey150 merged 3 commits into
mainfrom
cursor/discord-help-fallback-621e

Conversation

@shrey150

@shrey150 shrey150 commented Nov 13, 2026 •

Copy link
Copy Markdown
Collaborator

why

Help users find the Stagehand and Browse CLI community when they check help or encounter an unexpected error. This PR is stacked on #3450, which adds browse discord and the updated community invitation.

what changed

Adds this footer to root help (browse and browse --help):

COMMUNITY
  Discord: https://discord.gg/stagehand
  Report a bug: https://github.com/browserbase/stagehand/issues

Unexpected runtime errors also print this hint to stderr:

Get help: https://discord.gg/stagehand · Report a bug: https://github.com/browserbase/stagehand/issues

The footer appears only on root help. Usage errors, command-not-found, and expected CommandFailure errors omit the support hint.

For review, packages/cli/src/help.ts adds the footer and packages/cli/src/base.ts handles the error hint. Includes a patch changeset for browse.

test plan

  • CLI TypeScript build and oclif manifest generation.
  • Discord, opener, help, and CLI surface tests: 83 passed.
  • Unexpected-error subprocess case verifies both support links on stderr, the original error, and exit code 1; removing the hint makes the test fail.
  • Changed-file formatting and lint.
  • CI passing at 5c8de796d, including Linux/Windows contracts, Chrome smoke tests, regression tests, and automated review. Windows contracts passed on rerun after the existing daemon-lock fixture EPERM; the isolated test fix is test(cli): fix Windows race in concurrent daemon lock fixture #3456.

@changeset-bot

changeset-bot Bot commented Nov 13, 2026 •

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 000aadb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
browse Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@shrey150 shrey150 mentioned this pull request Nov 13, 2026
9 tasks done
@shrey150
shrey150 added this pull request to stack #3455 November 13, 2026 22:50
@shrey150
shrey150 marked this pull request as ready for review November 13, 2026 23:00

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 6 files

Architecture diagram
sequenceDiagram
    participant User as CLI User
    participant Oclif as Oclif Runtime
    participant BrowseCmd as BrowseCommand (base.ts)
    participant HelpMod as Help Formatter (help.ts)
    participant SupportLinks as Support Links Module
    participant Stderr as STDERR
    participant Stdout as STDOUT

    Note over User,Stdout: Root Help Flow (browse / browse --help)

    User->>Oclif: Execute browse or browse --help
    Oclif->>HelpMod: showRootHelp()
    HelpMod->>SupportLinks: Import DISCORD_INVITE_URL, GITHUB_ISSUES_URL
    HelpMod->>Stdout: Log AGENT_HEADER
    HelpMod->>Stdout: Log auto-generated help sections
    HelpMod->>Stdout: Log COMMUNITY footer with Discord + GitHub links
    Stdout-->>User: Display full help with community footer

    Note over User,Stderr: Subcommand Help Flow (browse open --help)

    User->>Oclif: Execute browse open --help
    Oclif->>HelpMod: showTopicHelp() or showCommandHelp()
    HelpMod->>Stdout: Log help (no community footer)
    Stdout-->>User: Display subcommand help only

    Note over User,Stderr: Error Handling Flow

    User->>Oclif: Execute browse command (e.g., browse open URL)
    Oclif->>BrowseCmd: Run command
    alt Unexpected runtime error (non-oclif error)
        BrowseCmd->>BrowseCmd: isOclifError(err) returns false
        BrowseCmd->>SupportLinks: Access DISCORD_INVITE_URL, GITHUB_ISSUES_URL
        BrowseCmd->>Stderr: Write "Get help: Discord... · Report a bug: GitHub..."
        Stderr-->>User: Display support hint
        BrowseCmd->>Oclif: super.catch(err)
        Oclif-->>User: Display error details
    else Oclif usage/validation error (oclif.exit number)
        BrowseCmd->>BrowseCmd: isOclifError(err) returns true
        BrowseCmd->>Oclif: super.catch(err)
        Oclif-->>User: Display usage error (no support hint)
    else Expected CommandFailure (exitCode in err)
        BrowseCmd->>BrowseCmd: Exit with err.exitCode
        Oclif-->>User: Display command failure (no support hint)
    else Successful execution
        BrowseCmd-->>User: Command output
    end
Loading

Reply with feedback, questions, or to request a fix.

View guided diff | Turn on auto-fix | Re-trigger cubic

Comment thread packages/cli/src/base.ts Resolved
@cursor
cursor Bot force-pushed the cursor/discord-help-fallback-621e branch 5 times, most recently from 97b2273 to afb8e6c Compare November 17, 2026 00:48
Base automatically changed from cursor/browse-discord-621e to main November 18, 2026 20:24
shrey150 added a commit that referenced this pull request Nov 18, 2026
# why

Make it easy to join the Stagehand and Browse CLI community from the
terminal to contribute, request features, and share feedback.

# what changed

Adds `browse discord`, visible in root help, with this invitation:

```console
$ browse discord --no-open
https://discord.gg/stagehand
Join our Discord community to contribute to Stagehand and the Browse CLI, request features, and share feedback!
```

- In an interactive terminal outside CI, opens the invite using the
maintained [`open`](https://github.com/sindresorhus/open) package and
prints the URL and invitation.
- `--no-open` or noninteractive stdout skips the opener. A nonempty `CI`
value (including `true` or `1`) also skips it; literal `CI=false`
disables that guard, matching the `ci-info` convention.
- If the opener cannot start, the command still prints the invitation
and exits successfully.
- Adds a Discord link to the CLI README and shared support URLs.
- Includes a **patch changeset for `browse`**: a small support command
that preserves existing behavior.

For review, the command and copy are in
`packages/cli/src/commands/discord.ts`; terminal/CI guards and opener
error handling are in `packages/cli/src/lib/open-url.ts`.
Platform-specific launching is delegated to `open`, with its dependency
recorded in the CLI manifest and lockfile. The stacked follow-up, #3451,
adds community links to help and error messages.

# test plan

- [x] CLI TypeScript build and oclif manifest generation.
- [x] Discord, CLI surface, and opener regression tests: **73 passed**.
- [x] Seven compiled CLI smoke checks using the real `open` package:
interactive launch, `CI=false`, `--no-open`, `CI=true`, `CI=0`, piped
stdout, and missing-launcher fallback.
- [x] Changed-file formatting and lint checks, plus changeset
validation.
- [x] CI passing at `7e1f854bd`, including Linux/Windows builds, CLI
contracts, Chrome smoke tests, regression tests, and automated review.

<!-- CURSOR_AGENT_PR_BODY_BEGIN -->
# why

Make it easy to join the Stagehand and Browse CLI community from the
terminal to contribute, request features, and share feedback.

# what changed

Adds `browse discord`, visible in root help, with this invitation:

```console
$ browse discord --no-open
https://discord.gg/stagehand
Join our Discord community to contribute to Stagehand and the Browse CLI, request features, and share feedback!
```

- In an interactive terminal outside CI, opens the invite using a
hand-rolled browser opener and prints the URL and invitation.
- `--no-open` or noninteractive stdout skips the opener. A nonempty `CI`
value (including `true` or `1`) also skips it; literal `CI=false`
disables that guard, matching the `ci-info` convention.
- If the opener cannot start, the command still prints the invitation
and exits successfully.
- Adds a Discord link to the CLI README and shared support URLs.
- Includes a **patch changeset for `browse`**: a small support command
that preserves existing behavior.

## Browser opener implementation

Uses a hand-rolled default-browser opener instead of the `open` npm
package (no new dependencies):

| Platform | Command | Notes |
|----------|---------|-------|
| macOS | `open <url>` | |
| Windows | `rundll32 url.dll,FileProtocolHandler <url>` | Avoids URL
mangling |
| Linux/Unix | `$BROWSER <url>` | If `$BROWSER` is set |
| WSL (non-SSH) | `rundll32.exe url.dll,FileProtocolHandler <url>` |
Falls back to `xdg-open` on ENOENT |
| Linux/Unix/WSL-SSH | `xdg-open <url>` | Default fallback |

Key properties:
- **No shell**: spawns without `shell: true`, so URLs with `&`, `?`,
`#`, spaces, etc. are passed untouched as a single argv element.
- **Detached + unref**: the opener process continues after the CLI
exits.
- **Error-safe**: registers an `'error'` listener to swallow async
ENOENT/EACCES (opener not found) without crashing.
- **`$BROWSER` support**: respects the standard `$BROWSER` environment
variable on Linux/Unix.
- **WSL-aware**: detects WSL via `WSL_DISTRO_NAME` or `/proc/version`
containing "microsoft", uses Windows opener via interop (unless over
SSH).
- **WSL fallback**: if `rundll32.exe` fails (e.g. interop disabled),
falls back to `xdg-open`.

For review, the command and copy are in
`packages/cli/src/commands/discord.ts`; terminal/CI guards and opener
error handling are in `packages/cli/src/lib/open-url.ts`. The stacked
follow-up, #3451, adds community links to help and error messages.

# test plan

- [x] CLI TypeScript build and oclif manifest generation.
- [x] Discord, CLI surface, and opener regression tests: **643 passed**.
- [x] Comprehensive unit tests for the browser opener:
  - Platform-specific command verification (darwin, linux, win32)
  - `$BROWSER` override tests
  - WSL detection via env and `/proc/version`
  - WSL over SSH uses `xdg-open`
  - `rundll32.exe` ENOENT falls back to `xdg-open`
- URLs with special characters (`&`, `?`, `#`, encoded spaces) passed
untouched
  - `shell: false`, `detached: true`, `stdio: 'ignore'` options verified
  - `unref()` called on child process
  - Async `'error'` event (ENOENT) swallowed without crash
  - TTY/CI/`--no-open` gating verified
- [x] Changed-file formatting and lint checks, plus changeset
validation.
<!-- CURSOR_AGENT_PR_BODY_END -->

<div><a
href="https://cursor.com/agents/bc-1a17422b-39e8-50b7-99b6-8f734c5335c8?cursor_ref=pr_footer&cursor_cta=open_in_web"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-web-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-web-light.png"><img
alt="Open in Web" width="114" height="28"
src="https://cursor.com/assets/images/open-in-web-dark.png"></picture></a>&nbsp;<a
href="https://cursor.com/background-agent?bcId=bc-1a17422b-39e8-50b7-99b6-8f734c5335c8&cursor_ref=pr_footer&cursor_cta=open_in_cursor"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://cursor.com/assets/images/open-in-cursor-dark.png"><source
media="(prefers-color-scheme: light)"
srcset="https://cursor.com/assets/images/open-in-cursor-light.png"><img
alt="Open in Cursor" width="131" height="28"
src="https://cursor.com/assets/images/open-in-cursor-dark.png"></picture></a>&nbsp;</div>

---------

Co-authored-by: Cursor Agent <[email protected]>
cursoragent and others added 3 commits November 18, 2026 12:24
Add support links as help/bug-report fallback:
- Root help footer with Discord and GitHub Issues links
- One-line support hint on unexpected runtime errors only

The support hint is NOT shown for:
- Usage/validation errors (oclif errors)
- Command-not-found (handled by hook)
- Expected CommandFailure errors (with resultCode)

Tests verify footer presence on root help, absence on subcommand help,
and hint only on unexpected errors.

Co-authored-by: Shrey Pandya <[email protected]>
@shrey150
shrey150 force-pushed the cursor/discord-help-fallback-621e branch from afb8e6c to 000aadb Compare November 18, 2026 20:24
@shrey150
shrey150 merged commit 902e91b into main Nov 18, 2026
6 checks passed
@shrey150
shrey150 deleted the cursor/discord-help-fallback-621e branch November 18, 2026 20:24
shrey150 pushed a commit that referenced this pull request Nov 19, 2026
Release Browse independently of the Stagehand SDKs. Merging this PR
publishes the CLI from the merged commit.

## 0.12.0

### Minor Changes

- [#3482](#3482)
[`8901460`](8901460)
Thanks [@suyashguptasg](https://github.com/suyashguptasg)! - Add `--size
regular|large|xlarge` to `browse cloud sessions create` to select the
browser size.

- [#3499](#3499)
[`a5a19ea`](a5a19ea)
Thanks [@shrey150](https://github.com/shrey150)! - Remove deprecated
`browse cloud contexts update`; context uploads are no longer supported.

### Patch Changes

- [#3450](#3450)
[`c118e9c`](c118e9c)
Thanks [@shrey150](https://github.com/shrey150)! - Add `browse discord`
command to open the Stagehand Discord in your system browser

- [#3473](#3473)
[`0f9a64c`](0f9a64c)
Thanks [@github-actions](https://github.com/apps/github-actions)! - fix
the CLI printing replacement characters when a daemon reply splits a
multi-byte character across socket chunks

- [#3451](#3451)
[`902e91b`](902e91b)
Thanks [@shrey150](https://github.com/shrey150)! - Add Discord and
GitHub links to root help footer and support hints on unexpected errors

- [#3481](#3481)
[`ebf15c8`](ebf15c8)
Thanks [@shrey150](https://github.com/shrey150)! - Add search filtering
options and migrate cloud commands to the Browserbase SDK.

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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.

3 participants