fix(cli): default browse get text|html selector to body#2058
Open
fix(cli): default browse get text|html selector to body#2058
browse get text|html selector to body#2058Conversation
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>
|
Contributor
There was a problem hiding this comment.
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 }
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.
Summary
browse get textandbrowse get htmlcrash withCannot read properties of null (reading 'startsWith')when called without a selector argument. The crash originates inparseRef, which is called viaresolveSelector(undefined).browse get markdownalready handles the no-selector case by defaulting tobody. This PR applies the same default totextandhtmlso the whole-page form works for all three.Reproduction (before)
After
Test plan
bb browse get textreturns whole-page text on a loaded pagebb browse get htmlreturns whole-page HTML on a loaded pagebb browse get text <selector>still scopes to the selectorbb browse get html <selector>still scopes to the selector🤖 Generated with Claude Code