Rename V3Context to BrowserContext - #2500
Conversation
|
There was a problem hiding this comment.
1 issue found across 10 files
Confidence score: 3/5
- In
packages/docs/v3/references/context.mdx, theBrowserContextrename currently documentspages(),activePage(), andsetActivePage()as synchronous, which can mislead TypeScript users into incorrect call patterns and cause type/runtime mismatches in real usage—update the declarations and code examples toasync/Promisesignatures to match the SDK.
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/docs/v3/references/context.mdx">
<violation number="1" location="packages/docs/v3/references/context.mdx:777">
P2: The renamed `BrowserContext` reference gives TypeScript users incorrect synchronous signatures: `pages()`, `activePage()`, and `setActivePage()` are async in the SDK. Update this declaration and its examples so callers await these methods; otherwise code following the reference will operate on Promises rather than pages.</violation>
</file>
Architecture diagram
sequenceDiagram
participant SW as Service Worker
participant CtxFactory as BrowserContext.create()
participant BC as BrowserContext
participant CDP as CdpConnection
participant CT as ChromeTabTargetController
participant Clip as Understudy Clipboard
participant Page as Page
Note over SW,Page: Renamed: V3Context → BrowserContext (no behavior change)
SW->>CtxFactory: NEW: call BrowserContext.create(cdpUrl, opts)
CtxFactory->>CDP: connect(wsUrl, websocketFactory, logger)
CDP-->>CtxFactory: CdpConnection instance
CtxFactory->>BC: NEW: new BrowserContext(conn, logger, chromeTabs)
BC-->>CtxFactory: BrowserContext instance
CtxFactory-->>SW: BrowserContext
Note over SW,Clip: Service worker uses BrowserContext for page management
SW->>BC: context.pages()
BC-->>SW: Page[]
SW->>BC: context.newPage(url?)
BC->>CDP: Target.createTarget
CDP-->>BC: targetId
BC->>Page: create & register
BC-->>SW: Page
SW->>BC: context.activePage()
BC->>CT: getActiveTargetId()
CT-->>BC: targetId
BC->>Page: lookup by targetId
BC-->>SW: Page
alt Clipboard operations
SW->>Clip: paste({ context, resolvePage })
Clip->>BC: context.pages()
BC-->>Clip: Page[]
Clip->>Page: evaluate clipboard
Page-->>Clip: result
Clip-->>SW: paste result
end
Note over BC,CT: BrowserContext manages CDP connection lifecycle
BC->>BC: handleTargetCreated / handleTargetDestroyed
BC->>CDP: on(Target.targetCreated)
BC->>CDP: on(Target.targetDestroyed)
BC->>CT: delegate Chrome tab activation
CT-->>BC: active target resolution
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
akeimach
left a comment
There was a problem hiding this comment.
some v3 docs changes in here that shouldn't be. Rest is good
…context # Conflicts: # packages/sdk-go/internal/extensionassets/stagehand-extension.zip
Renames the internal
V3Contextimplementation toBrowserContextacross the service worker, tests, and documentation. This is a naming-only change with no behavior changes.Summary by cubic
Renamed the browser context class from
V3ContexttoBrowserContextacross server code and tests. Restored legacy V3 docs and merged latestv4-spike; fulfills Linear STG-2647 with no behavior changes.packages/server/understudy/context.tstoBrowserContext.BrowserContext.create.BrowserContext.rpc-client-smoke.test.ts.Written for commit bbce9b7. Summary will update on new commits.