Skip to content

Commit 7f57e76

Browse files
authored
fix: treat empty tab URL as debuggable (fixes first-run doctor --live failure) (#259)
When a new automation window is created, the initial tab URL may be empty briefly while Chrome loads the data: URI. isDebuggableUrl('') was returning false, causing ensureAttached to reject the tab. Fix: only reject known non-debuggable URLs (chrome://, chrome-extension://). Empty/undefined URLs are now treated as debuggable since they represent tabs still loading. Also adds 200ms delay after window creation to let Chrome populate the tab URL.
1 parent e9818c1 commit 7f57e76

7 files changed

Lines changed: 12 additions & 9 deletions

File tree

extension/dist/background.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const WS_RECONNECT_MAX_DELAY = 6e4;
66

77
const attached = /* @__PURE__ */ new Set();
88
function isDebuggableUrl$1(url) {
9-
if (!url) return false;
9+
if (!url) return true;
1010
return !url.startsWith("chrome://") && !url.startsWith("chrome-extension://");
1111
}
1212
async function ensureAttached(tabId) {
@@ -242,6 +242,7 @@ async function getAutomationWindow(workspace) {
242242
automationSessions.set(workspace, session);
243243
console.log(`[opencli] Created automation window ${session.windowId} (${workspace})`);
244244
resetWindowIdleTimer(workspace);
245+
await new Promise((resolve) => setTimeout(resolve, 200));
245246
return session.windowId;
246247
}
247248
chrome.windows.onRemoved.addListener((windowId) => {
@@ -302,7 +303,7 @@ async function handleCommand(cmd) {
302303
}
303304
}
304305
function isDebuggableUrl(url) {
305-
if (!url) return false;
306+
if (!url) return true;
306307
return !url.startsWith("chrome://") && !url.startsWith("chrome-extension://");
307308
}
308309
async function resolveTabId(tabId, workspace) {

extension/manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"manifest_version": 3,
33
"name": "OpenCLI",
4-
"version": "1.2.4",
4+
"version": "1.2.5",
55
"description": "Bridge between opencli CLI and your browser — execute commands, read cookies, manage tabs.",
66
"permissions": [
77
"debugger",

extension/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "opencli-extension",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"private": true,
55
"type": "module",
66
"scripts": {

extension/src/background.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,8 @@ async function getAutomationWindow(workspace: string): Promise<number> {
152152
automationSessions.set(workspace, session);
153153
console.log(`[opencli] Created automation window ${session.windowId} (${workspace})`);
154154
resetWindowIdleTimer(workspace);
155+
// Brief delay to let Chrome load the initial data: URI tab
156+
await new Promise(resolve => setTimeout(resolve, 200));
155157
return session.windowId;
156158
}
157159

@@ -229,7 +231,7 @@ async function handleCommand(cmd: Command): Promise<Result> {
229231

230232
/** Check if a URL can be attached via CDP (not chrome:// or chrome-extension://) */
231233
function isDebuggableUrl(url?: string): boolean {
232-
if (!url) return false;
234+
if (!url) return true; // empty/undefined = tab still loading, allow it
233235
return !url.startsWith('chrome://') && !url.startsWith('chrome-extension://');
234236
}
235237

extension/src/cdp.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const attached = new Set<number>();
1010

1111
/** Check if a URL can be attached via CDP */
1212
function isDebuggableUrl(url?: string): boolean {
13-
if (!url) return false;
13+
if (!url) return true; // empty/undefined = tab still loading, allow it
1414
return !url.startsWith('chrome://') && !url.startsWith('chrome-extension://');
1515
}
1616

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@jackwener/opencli",
3-
"version": "1.2.4",
3+
"version": "1.2.5",
44
"publishConfig": {
55
"access": "public"
66
},

0 commit comments

Comments
 (0)