[STG-1689] fix: improve a11y snapshot efficiency#2050
Open
Conversation
🦋 Changeset detectedLatest commit: 946abb3 The changes in this PR will be included in the next version bump. 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 |
Contributor
There was a problem hiding this comment.
2 issues found across 12 files
Confidence score: 3/5
- There is moderate merge risk because
packages/cli/src/index.tshas a concrete user-facing policy gap: CLI validation throws a genericnew Error()instead of a typed/sanitized error, which can lead to inconsistent handling or unsanitized messaging. packages/core/lib/v3/agent/tools/ariaTree.tshas a cleanup issue where thesetTimeoutused inPromise.raceis not cleared when work finishes early, which can leak timers and create avoidable resource overhead over time.- These issues look fixable without major redesign, but they are specific enough (severity 6/10 and 5/10 with high confidence) to justify addressing before merge for safer behavior.
- Pay close attention to
packages/cli/src/index.ts,packages/core/lib/v3/agent/tools/ariaTree.ts- error sanitization compliance and timeout cleanup are the key risk areas.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="packages/cli/src/index.ts">
<violation number="1" location="packages/cli/src/index.ts:2703">
P2: Custom agent: **Exception and error message sanitization**
User-facing CLI validation throws generic `new Error()` instead of a typed/sanitized error class required by policy.</violation>
</file>
<file name="packages/core/lib/v3/agent/tools/ariaTree.ts">
<violation number="1" location="packages/core/lib/v3/agent/tools/ariaTree.ts:36">
P2: The `setTimeout` in the `Promise.race` is never cleared when the snapshot resolves first, leaking timers. Capture the timer ID and clear it after the race settles.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review, or fix all with cubic.
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
ariaTreetool, withmode: "full"still available for content-heavy reads.snapshot --interactive,--depth, and--selector.<summary>/DisclosureTriangle) after smoke testing found Stagehand was missing them.Linear: https://linear.app/browserbase/issue/STG-1689/improve-a11y-tree-representation-for-browse-cli
Smoke comparison
Synthetic page with 80 repeated static report cards:
Broader matrix after adding disclosure support:
<summary>; browser-use 14/14 but included static prosePrimary source+Subscribe; browser-use preserved article prosecompactis an output-size flag, not a semantic filter. It preserves internal ref maps for follow-up actions:snapshot -c -ion the controls fixture produced a clickableSave settingsref andclick @0-20updated page state tosaved.Compact stdout reductions from the same fixture set:
Validation
pnpm --filter @browserbasehq/stagehand test:core -- packages/core/dist/esm/tests/unit/snapshot-a11y-tree-utils.test.js packages/core/dist/esm/tests/unit/page-snapshot.test.js packages/core/dist/esm/tests/unit/snapshot-tree-format-utils.test.jspnpm --filter @browserbasehq/stagehand lintpnpm exec prettier --check packages/cli && pnpm --filter @browserbasehq/browse-cli eslint && pnpm --filter @browserbasehq/browse-cli typecheckpnpm --filter @browserbasehq/browse-cli testpnpm --filter @browserbasehq/stagehand build && pnpm --filter @browserbasehq/browse-cli build