Skip to content

Conversation

@monadoid
Copy link
Contributor

@monadoid monadoid commented Nov 18, 2025

why

currently, stagehand just logs the BB session URL and debug URL inline without storing this info on the stagehand object but we want getters for these.

If env = browserbase, we return the urls, if it's local we return an empty string currently as per the ticket. It seemed to me like returning undefined if env = local might be better DX, but i'll double check w/ sean.

what changed

Added getters and a small resetBrowserbaseSessionMetadata() helper.

test plan

Adde vitest tests that show that this works when running with env: "BROWSERBASE" and returns an empty string when env: "LOCAL".

@changeset-bot
Copy link

changeset-bot bot commented Nov 18, 2025

🦋 Changeset detected

Latest commit: 7482e95

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

This PR includes changesets to release 2 packages
Name Type
@browserbasehq/stagehand Patch
@browserbasehq/stagehand-evals 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

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Nov 18, 2025

Greptile Summary

  • Added public getter methods browserbaseSessionURL and browserbaseDebugURL to expose Browserbase session metadata that was previously only logged
  • Introduced resetBrowserbaseSessionMetadata() helper to centralize cleanup of session URLs and ID across local browser initialization and close operations

Confidence Score: 3/5

  • Safe to merge after fixing the indentation issue
  • The feature implementation is straightforward with good test coverage, but there's a syntax error with incorrect indentation in the local browser connection block that will likely fail linting/formatting checks
  • packages/core/lib/v3/v3.ts requires attention for the indentation fix at lines 681-693

Important Files Changed

Filename Overview
packages/core/lib/v3/v3.ts Added public getters for Browserbase session URL and debug URL, plus helper method to reset metadata; includes indentation fix in local browser connection block

Sequence Diagram

sequenceDiagram
    participant User
    participant V3
    participant Browserbase
    
    User->>V3: init() with env="BROWSERBASE"
    V3->>Browserbase: createBrowserbaseSession()
    Browserbase-->>V3: sessionId, ws, bb
    V3->>V3: store sessionId
    V3->>Browserbase: bb.sessions.debug(sessionId)
    Browserbase-->>V3: debuggerUrl
    V3->>V3: set browserbaseSessionUrl & browserbaseDebugUrl
    V3-->>User: initialization complete
    User->>V3: browserbaseSessionURL
    V3-->>User: return stored URL
    User->>V3: browserbaseDebugURL
    V3-->>User: return stored debug URL
Loading

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

2 files reviewed, 1 comment

Edit Code Review Agent Settings | Greptile
React with 👍 or 👎 to share your feedback on this new summary format

Comment on lines 681 to 693
this.ctx.conn.onTransportClosed(this._onCdpClosed);
this.state = {
kind: "LOCAL",
// no LaunchedChrome when attaching externally; create a stub kill
chrome: {
kill: async () => {},
} as unknown as import("chrome-launcher").LaunchedChrome,
ws: lbo.cdpUrl,
};
this.resetBrowserbaseSessionMetadata();
// Post-connect settings (downloads and viewport) if provided
await this._applyPostConnectLocalOptions(lbo);
return;
Copy link
Contributor

Choose a reason for hiding this comment

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

syntax: indentation lost here - should be indented to match the surrounding if block (12 spaces)

Prompt To Fix With AI
This is a comment left during a code review.
Path: packages/core/lib/v3/v3.ts
Line: 681:693

Comment:
**syntax:** indentation lost here - should be indented to match the surrounding if block (12 spaces)

How can I resolve this? If you propose a fix, please make it concise.

@monadoid monadoid merged commit fa18cfd into main Nov 18, 2025
32 of 34 checks 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