@jackwener/opencli 1.2.3 → 1.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -228,7 +228,7 @@ async function getAutomationWindow(workspace) {
|
|
|
228
228
|
}
|
|
229
229
|
}
|
|
230
230
|
const win = await chrome.windows.create({
|
|
231
|
-
url: "
|
|
231
|
+
url: "data:text/html,<html></html>",
|
|
232
232
|
focused: false,
|
|
233
233
|
width: 1280,
|
|
234
234
|
height: 900,
|
|
@@ -309,6 +309,7 @@ async function resolveTabId(tabId, workspace) {
|
|
|
309
309
|
if (tabId !== void 0) {
|
|
310
310
|
try {
|
|
311
311
|
const tab = await chrome.tabs.get(tabId);
|
|
312
|
+
console.log(`[opencli] resolveTabId: explicit tabId=${tabId}, url=${tab.url}`);
|
|
312
313
|
if (isDebuggableUrl(tab.url)) return tabId;
|
|
313
314
|
console.warn(`[opencli] Tab ${tabId} URL is not debuggable (${tab.url}), re-resolving`);
|
|
314
315
|
} catch {
|
|
@@ -318,10 +319,14 @@ async function resolveTabId(tabId, workspace) {
|
|
|
318
319
|
const windowId = await getAutomationWindow(workspace);
|
|
319
320
|
const tabs = await chrome.tabs.query({ windowId });
|
|
320
321
|
const debuggableTab = tabs.find((t) => t.id && isDebuggableUrl(t.url));
|
|
321
|
-
if (debuggableTab?.id)
|
|
322
|
+
if (debuggableTab?.id) {
|
|
323
|
+
console.log(`[opencli] resolveTabId: found debuggable tab ${debuggableTab.id} (${debuggableTab.url})`);
|
|
324
|
+
return debuggableTab.id;
|
|
325
|
+
}
|
|
326
|
+
console.warn(`[opencli] resolveTabId: no debuggable tabs found, tabs: ${tabs.map((t) => `${t.id}=${t.url}`).join(", ")}`);
|
|
322
327
|
const reuseTab = tabs.find((t) => t.id);
|
|
323
328
|
if (reuseTab?.id) {
|
|
324
|
-
await chrome.tabs.update(reuseTab.id, { url: "
|
|
329
|
+
await chrome.tabs.update(reuseTab.id, { url: "data:text/html,<html></html>" });
|
|
325
330
|
await new Promise((resolve) => setTimeout(resolve, 300));
|
|
326
331
|
try {
|
|
327
332
|
const updated = await chrome.tabs.get(reuseTab.id);
|
|
@@ -335,7 +340,7 @@ async function resolveTabId(tabId, workspace) {
|
|
|
335
340
|
} catch {
|
|
336
341
|
}
|
|
337
342
|
}
|
|
338
|
-
const newTab = await chrome.tabs.create({ windowId, url: "
|
|
343
|
+
const newTab = await chrome.tabs.create({ windowId, url: "data:text/html,<html></html>", active: true });
|
|
339
344
|
if (!newTab.id) throw new Error("Failed to create tab in automation window");
|
|
340
345
|
return newTab.id;
|
|
341
346
|
}
|
|
@@ -423,7 +428,7 @@ async function handleTabs(cmd, workspace) {
|
|
|
423
428
|
}
|
|
424
429
|
case "new": {
|
|
425
430
|
const windowId = await getAutomationWindow(workspace);
|
|
426
|
-
const tab = await chrome.tabs.create({ windowId, url: cmd.url ?? "
|
|
431
|
+
const tab = await chrome.tabs.create({ windowId, url: cmd.url ?? "data:text/html,<html></html>", active: true });
|
|
427
432
|
return { id: cmd.id, ok: true, data: { tabId: tab.id, url: tab.url } };
|
|
428
433
|
}
|
|
429
434
|
case "close": {
|
package/extension/manifest.json
CHANGED
package/extension/package.json
CHANGED
|
@@ -135,9 +135,10 @@ async function getAutomationWindow(workspace: string): Promise<number> {
|
|
|
135
135
|
}
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
// Create a new window with
|
|
138
|
+
// Create a new window with a data: URI that New Tab Override extensions cannot intercept.
|
|
139
|
+
// Using about:blank would be hijacked by extensions like "New Tab Override".
|
|
139
140
|
const win = await chrome.windows.create({
|
|
140
|
-
url: '
|
|
141
|
+
url: 'data:text/html,<html></html>',
|
|
141
142
|
focused: false,
|
|
142
143
|
width: 1280,
|
|
143
144
|
height: 900,
|
|
@@ -244,6 +245,7 @@ async function resolveTabId(tabId: number | undefined, workspace: string): Promi
|
|
|
244
245
|
if (tabId !== undefined) {
|
|
245
246
|
try {
|
|
246
247
|
const tab = await chrome.tabs.get(tabId);
|
|
248
|
+
console.log(`[opencli] resolveTabId: explicit tabId=${tabId}, url=${tab.url}`);
|
|
247
249
|
if (isDebuggableUrl(tab.url)) return tabId;
|
|
248
250
|
// Tab exists but URL is not debuggable — fall through to auto-resolve
|
|
249
251
|
console.warn(`[opencli] Tab ${tabId} URL is not debuggable (${tab.url}), re-resolving`);
|
|
@@ -259,7 +261,11 @@ async function resolveTabId(tabId: number | undefined, workspace: string): Promi
|
|
|
259
261
|
// Prefer an existing debuggable tab (about:blank, http://, https://, etc.)
|
|
260
262
|
const tabs = await chrome.tabs.query({ windowId });
|
|
261
263
|
const debuggableTab = tabs.find(t => t.id && isDebuggableUrl(t.url));
|
|
262
|
-
if (debuggableTab?.id)
|
|
264
|
+
if (debuggableTab?.id) {
|
|
265
|
+
console.log(`[opencli] resolveTabId: found debuggable tab ${debuggableTab.id} (${debuggableTab.url})`);
|
|
266
|
+
return debuggableTab.id;
|
|
267
|
+
}
|
|
268
|
+
console.warn(`[opencli] resolveTabId: no debuggable tabs found, tabs: ${tabs.map(t => `${t.id}=${t.url}`).join(', ')}`);
|
|
263
269
|
|
|
264
270
|
// No debuggable tab found — this typically happens when a "New Tab Override"
|
|
265
271
|
// extension replaces about:blank with a chrome-extension:// page.
|
|
@@ -267,7 +273,7 @@ async function resolveTabId(tabId: number | undefined, workspace: string): Promi
|
|
|
267
273
|
// accumulating orphan tabs if chrome.tabs.create is also intercepted).
|
|
268
274
|
const reuseTab = tabs.find(t => t.id);
|
|
269
275
|
if (reuseTab?.id) {
|
|
270
|
-
await chrome.tabs.update(reuseTab.id, { url: '
|
|
276
|
+
await chrome.tabs.update(reuseTab.id, { url: 'data:text/html,<html></html>' });
|
|
271
277
|
// Wait for the navigation to take effect
|
|
272
278
|
await new Promise(resolve => setTimeout(resolve, 300));
|
|
273
279
|
// Verify the URL is actually debuggable (New Tab Override may have intercepted)
|
|
@@ -288,7 +294,7 @@ async function resolveTabId(tabId: number | undefined, workspace: string): Promi
|
|
|
288
294
|
}
|
|
289
295
|
|
|
290
296
|
// Window has no debuggable tabs — create one
|
|
291
|
-
const newTab = await chrome.tabs.create({ windowId, url: '
|
|
297
|
+
const newTab = await chrome.tabs.create({ windowId, url: 'data:text/html,<html></html>', active: true });
|
|
292
298
|
if (!newTab.id) throw new Error('Failed to create tab in automation window');
|
|
293
299
|
return newTab.id;
|
|
294
300
|
}
|
|
@@ -397,7 +403,7 @@ async function handleTabs(cmd: Command, workspace: string): Promise<Result> {
|
|
|
397
403
|
}
|
|
398
404
|
case 'new': {
|
|
399
405
|
const windowId = await getAutomationWindow(workspace);
|
|
400
|
-
const tab = await chrome.tabs.create({ windowId, url: cmd.url ?? '
|
|
406
|
+
const tab = await chrome.tabs.create({ windowId, url: cmd.url ?? 'data:text/html,<html></html>', active: true });
|
|
401
407
|
return { id: cmd.id, ok: true, data: { tabId: tab.id, url: tab.url } };
|
|
402
408
|
}
|
|
403
409
|
case 'close': {
|