feat: auto-connect tabs created via ghostPublicAPI.openTab

Tabs created via Ghost Browser's openTab API now automatically
attach to Playwriter's debugger, making them immediately available
in context.pages() without requiring manual extension icon click.
This commit is contained in:
Tommy D. Rossi
2026-02-04 17:47:57 +01:00
parent 6f2aae0006
commit 1a59082e12
+12 -4
View File
@@ -360,13 +360,21 @@ class ConnectionManager {
// This allows calling chrome.ghostPublicAPI, chrome.ghostProxies, chrome.projects
// from the playwriter executor sandbox when running in Ghost Browser
if (message.method === 'ghost-browser') {
const result = await handleGhostBrowserCommand(
message.params as GhostBrowserCommandParams,
chrome
)
const params = message.params as GhostBrowserCommandParams
const result = await handleGhostBrowserCommand(params, chrome)
if (!result.success) {
logger.error('Ghost Browser API error:', result.error)
}
// Auto-connect tabs created via ghostPublicAPI.openTab so they appear in context.pages()
if (result.success && params.namespace === 'ghostPublicAPI' && params.method === 'openTab') {
const tabId = result.result as number
if (tabId) {
logger.debug('Auto-connecting Ghost Browser tab:', tabId)
setTabConnecting(tabId)
await sleep(100)
await attachTab(tabId)
}
}
sendMessage({ id: message.id, result })
return
}