Skip to content

Feat : Expands the self-heal tooling to support build-scoped self-healing reports and enrich responses#282

Merged
ruturaj-browserstack merged 10 commits into
browserstack:mainfrom
vipin-bs:self-heal-session
May 26, 2026
Merged

Feat : Expands the self-heal tooling to support build-scoped self-healing reports and enrich responses#282
ruturaj-browserstack merged 10 commits into
browserstack:mainfrom
vipin-bs:self-heal-session

Conversation

@vipin-bs
Copy link
Copy Markdown
Collaborator

No description provided.

- Added interfaces for healing logs and reports in selfheal-utils.
- Implemented fetchSelfHealingReportByBuild to retrieve self-healing reports from BrowserStack.
- Introduced flattenHealedSelectors to simplify selector extraction from reports.
- Enhanced getSelfHealSelectors to support fetching test code alongside selectors.
- Created prepareSelfHealingPlanTool to generate structured plans for applying healed selectors.
- Added input validation and error handling for self-healing tools.
- Implemented tests for fetchSelfHealSelectorTool and prepareSelfHealingPlanTool to ensure functionality and error messaging.
- Included handling for various input shapes and credential requirements in the tools.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Expands the self-heal tooling to support build-scoped self-healing reports and enrich responses with per-session test source code, plus adds a new “plan preparation” tool to help the calling LLM apply locator edits safely.

Changes:

  • Add buildUuid mode to fetchSelfHealedSelectors, including fetching the build self-healing report + test-code context and emitting a prominent warning banner when test code is unavailable.
  • Introduce prepareSelfHealingPlan tool to normalize multiple input shapes and generate a structured plan (with optional test-code enrichment) without modifying files.
  • Add new Observability test-code fetch utilities and auth override resolution; update self-heal log parsing to support both Automate and App Automate sessions.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tests/tools/selfheal.test.ts Adds comprehensive unit tests for new validation paths, plan output, banner ordering, and fetch-issues guidance text.
src/tools/selfheal.ts Implements buildUuid/sessionId modes, warning banners, session normalization, and registers the new prepareSelfHealingPlan MCP tool.
src/tools/selfheal-utils/selfheal.ts Adds build-scoped self-healing report fetch + report types; updates session log parsing to capture locator types and support app-automate.
src/tools/selfheal-utils/fetch-test-code.ts New helper module to fetch test code per session, classify outcomes, and format context + LLM guidance notes.
src/lib/get-auth.ts Adds resolveBrowserStackAuth to safely merge arg overrides with server config and avoid hard failures when creds are absent.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/tools/selfheal.ts
Comment thread src/tools/selfheal.ts Outdated
Copy link
Copy Markdown
Collaborator

@ruturaj-browserstack ruturaj-browserstack left a comment

Choose a reason for hiding this comment

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

Check copilot comments as well , they are relevant

Comment thread src/lib/get-auth.ts Outdated
Comment thread src/tools/selfheal.ts Outdated
vipin-bs and others added 5 commits April 27, 2026 19:39
…etchSelfHealSelectorTool

The catch block in fetchSelfHealSelectorTool rethrew the error, breaking
the function's exported `Promise<CallToolResult>` contract. It worked
end-to-end through the server.tool() wrapper (which has its own catch),
but any direct caller — internal callers, tests, alternate transports —
would see a rejected promise instead of the documented shape, and it
violated the project rule that tool handlers must never throw.

The fix returns a structured `{ isError: true }` result using the same
friendlyApiError helper the wrapper used, so user-visible messages stay
identical. Added 3 regression tests that mock the underlying utils to
throw and assert the function resolves with isError: true (would have
failed against the old code).

Also picks up a pure-formatting prettier sweep on
selfheal-utils/fetch-test-code.ts from the build gate (no semantic
change, just bracket placement).

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@ruturaj-browserstack ruturaj-browserstack changed the title Self heal session Feat : Expands the self-heal tooling to support build-scoped self-healing reports and enrich responses May 26, 2026
@ruturaj-browserstack ruturaj-browserstack merged commit 6061950 into browserstack:main May 26, 2026
1 check passed
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