cdpilot 0.4.2 → 0.4.3
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.
- package/package.json +1 -1
- package/src/cdpilot.py +54 -12
package/package.json
CHANGED
package/src/cdpilot.py
CHANGED
|
@@ -14,7 +14,7 @@ Environment:
|
|
|
14
14
|
CDPILOT_PROFILE Isolated browser profile directory
|
|
15
15
|
"""
|
|
16
16
|
|
|
17
|
-
__version__ = "0.4.
|
|
17
|
+
__version__ = "0.4.3"
|
|
18
18
|
|
|
19
19
|
import asyncio
|
|
20
20
|
import json
|
|
@@ -1286,15 +1286,41 @@ def get_browser_preference():
|
|
|
1286
1286
|
|
|
1287
1287
|
|
|
1288
1288
|
def _auto_browser_priority():
|
|
1289
|
-
"""
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1289
|
+
"""Workload-aware browser priority.
|
|
1290
|
+
|
|
1291
|
+
Two axes:
|
|
1292
|
+
1. Extension workload — `cdpilot ext-install` populates dev-extensions.json.
|
|
1293
|
+
If non-empty, the user is doing extension work, so prioritise browsers
|
|
1294
|
+
that honor --load-extension for unpacked extensions:
|
|
1295
|
+
Vivaldi ✅, Brave ✅, Edge ✅, Chrome ❌ (silently drops, 147+),
|
|
1296
|
+
Chromium ✅ (but rarely installed).
|
|
1297
|
+
If the registry is empty, prefer Chrome — most stable, fastest startup,
|
|
1298
|
+
no idiosyncratic background workers.
|
|
1299
|
+
2. Platform stability — macOS 26 (Tahoe) demotes Brave because the
|
|
1300
|
+
current Brave 1.89 build crashes deterministically at ~7min uptime
|
|
1301
|
+
(SIGTRAP in ThreadPoolForegroundWorker, observed across 9+ dumps).
|
|
1302
|
+
|
|
1303
|
+
Returns (priority_list, reason_string) — reason explains *why* this order
|
|
1304
|
+
was picked, surfaced by `cdpilot browser status`.
|
|
1294
1305
|
"""
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1306
|
+
has_extensions = bool(get_dev_extensions())
|
|
1307
|
+
on_tahoe = _macos_major() and _macos_major() >= 26
|
|
1308
|
+
|
|
1309
|
+
if has_extensions:
|
|
1310
|
+
if on_tahoe:
|
|
1311
|
+
order = ['vivaldi', 'brave', 'edge', 'chromium', 'chrome']
|
|
1312
|
+
reason = f"extension mode (registry has dev extensions) + macOS {_macos_major()} (Brave demoted)"
|
|
1313
|
+
else:
|
|
1314
|
+
order = ['brave', 'vivaldi', 'edge', 'chromium', 'chrome']
|
|
1315
|
+
reason = "extension mode (registry has dev extensions)"
|
|
1316
|
+
else:
|
|
1317
|
+
if on_tahoe:
|
|
1318
|
+
order = ['chrome', 'vivaldi', 'edge', 'chromium', 'brave']
|
|
1319
|
+
reason = f"stability mode (no dev extensions) + macOS {_macos_major()} (Brave demoted)"
|
|
1320
|
+
else:
|
|
1321
|
+
order = ['chrome', 'brave', 'vivaldi', 'edge', 'chromium']
|
|
1322
|
+
reason = "stability mode (no dev extensions)"
|
|
1323
|
+
return order, reason
|
|
1298
1324
|
|
|
1299
1325
|
|
|
1300
1326
|
def _find_browser():
|
|
@@ -1323,7 +1349,8 @@ def _find_browser():
|
|
|
1323
1349
|
sys.stderr.write(f"⚠️ Configured browser '{pref}' not found, falling back to auto-detect.\n")
|
|
1324
1350
|
|
|
1325
1351
|
# 3) Auto-detection in priority order
|
|
1326
|
-
|
|
1352
|
+
order, _reason = _auto_browser_priority()
|
|
1353
|
+
for name in order:
|
|
1327
1354
|
resolved = _resolve_browser_name(name)
|
|
1328
1355
|
if resolved:
|
|
1329
1356
|
return resolved
|
|
@@ -2428,6 +2455,18 @@ def cmd_ext_install(source):
|
|
|
2428
2455
|
|
|
2429
2456
|
print(f'✅ Dev extension registered: {name} (v{version})')
|
|
2430
2457
|
print(f' Path: {abs_source}')
|
|
2458
|
+
|
|
2459
|
+
# Warn if the active browser silently drops --load-extension.
|
|
2460
|
+
# Chrome 147+ does this without any console message, easily wasting
|
|
2461
|
+
# hours of "why isn't my extension loading?" debugging.
|
|
2462
|
+
active = os.environ.get('CHROME_BIN') or _find_browser() or ''
|
|
2463
|
+
active_lower = os.path.basename(active).lower()
|
|
2464
|
+
if 'google chrome' in active_lower or active_lower == 'chrome' or 'google-chrome' in active_lower:
|
|
2465
|
+
sys.stderr.write(
|
|
2466
|
+
"⚠️ Active browser is Chrome — Chrome 147+ silently ignores --load-extension\n"
|
|
2467
|
+
" for unpacked extensions. Switch with: cdpilot browser vivaldi\n"
|
|
2468
|
+
)
|
|
2469
|
+
|
|
2431
2470
|
print(' Restarting browser...')
|
|
2432
2471
|
cmd_stop()
|
|
2433
2472
|
import time as _time
|
|
@@ -2729,13 +2768,16 @@ def cmd_browser(name=None):
|
|
|
2729
2768
|
resolved = _resolve_browser_name(pref) if pref != 'auto' else None
|
|
2730
2769
|
auto_resolved = _find_browser()
|
|
2731
2770
|
installed = [n for n in BROWSER_BINARIES if _resolve_browser_name(n)]
|
|
2771
|
+
order, reason = _auto_browser_priority()
|
|
2772
|
+
ext_count = len(get_dev_extensions())
|
|
2732
2773
|
print(f"Preference: {pref}")
|
|
2733
2774
|
if pref != 'auto':
|
|
2734
2775
|
print(f" resolved: {resolved or '(not found — falling back to auto)'}")
|
|
2735
2776
|
print(f"Auto-pick: {auto_resolved or '(none)'}")
|
|
2777
|
+
print(f" reason: {reason}")
|
|
2778
|
+
print(f" order: {' > '.join(order)}")
|
|
2736
2779
|
print(f"Installed: {', '.join(installed) or '(none detected)'}")
|
|
2737
|
-
|
|
2738
|
-
print(f"Note: macOS {_macos_major()} demotes Brave in auto-pick (Brave 1.89 crashes ~7min).")
|
|
2780
|
+
print(f"Dev exts: {ext_count} registered (run `cdpilot extensions` to list)")
|
|
2739
2781
|
return
|
|
2740
2782
|
|
|
2741
2783
|
name = name.lower().strip()
|