From 1a59082e12db02709b9ed7980c69d86bdd93b08b Mon Sep 17 00:00:00 2001 From: "Tommy D. Rossi" Date: Wed, 4 Feb 2026 17:47:57 +0100 Subject: [PATCH] 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. --- extension/src/background.ts | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/extension/src/background.ts b/extension/src/background.ts index 97c2fe1..7a0ce6e 100644 --- a/extension/src/background.ts +++ b/extension/src/background.ts @@ -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 }