Skip to content

fix(cli): default browse get text|html selector to body#2058

Open
ziruihao wants to merge 1 commit intomainfrom
fix/cli-get-text-html-no-selector
Open

fix(cli): default browse get text|html selector to body#2058
ziruihao wants to merge 1 commit intomainfrom
fix/cli-get-text-html-no-selector

Conversation

@ziruihao
Copy link
Copy Markdown
Contributor

Summary

browse get text and browse get html crash with Cannot read properties of null (reading 'startsWith') when called without a selector argument. The crash originates in parseRef, which is called via resolveSelector(undefined).

browse get markdown already handles the no-selector case by defaulting to body. This PR applies the same default to text and html so the whole-page form works for all three.

Reproduction (before)

$ bb browse open https://example.com
$ bb browse get text
Error: Cannot read properties of null (reading 'startsWith')
$ bb browse get html
Error: Cannot read properties of null (reading 'startsWith')
$ bb browse get markdown
{ "markdown": "# Example Domain\n\n..." }   # works

After

$ bb browse get text
{ "text": "Example Domain\n\nThis domain is..." }
$ bb browse get html
{ "html": "<head>...</head><body>..." }

Test plan

  • bb browse get text returns whole-page text on a loaded page
  • bb browse get html returns whole-page HTML on a loaded page
  • bb browse get text <selector> still scopes to the selector
  • bb browse get html <selector> still scopes to the selector

🤖 Generated with Claude Code

Without an explicit selector, `browse get text` and `browse get html`
called `resolveSelector(undefined)`, which crashed in `parseRef`:

    Error: Cannot read properties of null (reading 'startsWith')

`browse get markdown` already handles this by defaulting to `body`. Apply
the same default to `text` and `html` so the no-selector form returns
the whole-page content instead of crashing.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented Apr 27, 2026

⚠️ No Changeset found

Latest commit: 699a3e4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

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

@ziruihao ziruihao marked this pull request as ready for review April 28, 2026 21:38
Copy link
Copy Markdown
Contributor

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

Choose a reason for hiding this comment

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

No issues found across 1 file

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.
Architecture diagram
sequenceDiagram
    participant User as User (Terminal)
    participant CLI as CLI (executeCommand)
    participant Utils as Selector Utils
    participant Browser as Browser Page

    User->>CLI: bb browse get <text|html> [selector]
    
    alt selector provided
        CLI->>Utils: resolveSelector(selector)
        Utils-->>CLI: normalized selector
    else NEW: selector is null/undefined
        CLI->>CLI: Default target to "body"
    end

    Note over CLI,Browser: Execute selection on active page
    
    CLI->>Browser: deepLocator(target)
    
    alt type == "text"
        CLI->>Browser: textContent()
    else type == "html"
        CLI->>Browser: innerHtml()
    end
    
    Browser-->>CLI: content string
    CLI-->>User: { "text" | "html": content }
Loading

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.

1 participant