@aiyiran/myclaw 1.1.160 → 1.1.162
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/assets/myclaw-inject.js +23 -36
- package/package.json +1 -1
- package/server/debug_record.py +12 -0
package/assets/myclaw-inject.js
CHANGED
|
@@ -1431,52 +1431,39 @@ btn.addEventListener("click", function () {
|
|
|
1431
1431
|
});
|
|
1432
1432
|
}
|
|
1433
1433
|
|
|
1434
|
-
function hideNativeNewSessionBtn(nativeBtn) {
|
|
1435
|
-
nativeBtn.style.setProperty("display", "none", "important");
|
|
1436
|
-
}
|
|
1437
|
-
|
|
1438
1434
|
function createNewSessionButton() {
|
|
1439
|
-
|
|
1440
|
-
if (!nativeBtn) {
|
|
1441
|
-
setTimeout(createNewSessionButton, 500);
|
|
1442
|
-
return;
|
|
1443
|
-
}
|
|
1444
|
-
|
|
1445
|
-
// 已经替换过,不重复插入
|
|
1446
|
-
if (nativeBtn.parentNode && nativeBtn.parentNode.querySelector("#myclaw-newsession-btn")) return;
|
|
1435
|
+
if (document.querySelector("#myclaw-newsession-btn")) return;
|
|
1447
1436
|
|
|
1448
|
-
|
|
1449
|
-
hideNativeNewSessionBtn(nativeBtn);
|
|
1450
|
-
|
|
1451
|
-
// 复用原生按钮的 class + innerHTML,外观完全一致
|
|
1452
|
-
var btn = document.createElement("button");
|
|
1437
|
+
var btn = document.createElement("div");
|
|
1453
1438
|
btn.id = "myclaw-newsession-btn";
|
|
1454
|
-
btn.
|
|
1455
|
-
|
|
1439
|
+
btn.style.cssText = [
|
|
1440
|
+
"position: fixed",
|
|
1441
|
+
"bottom: 8px",
|
|
1442
|
+
"right: 335px",
|
|
1443
|
+
"padding: 3px 10px",
|
|
1444
|
+
"background: rgba(139, 92, 246, 0.85)",
|
|
1445
|
+
"color: #fff",
|
|
1446
|
+
"font-size: 11px",
|
|
1447
|
+
"font-weight: bold",
|
|
1448
|
+
"font-family: monospace",
|
|
1449
|
+
"border-radius: 4px",
|
|
1450
|
+
"z-index: 99999",
|
|
1451
|
+
"user-select: none",
|
|
1452
|
+
"cursor: pointer",
|
|
1453
|
+
"transition: all 0.2s",
|
|
1454
|
+
"letter-spacing: 0.5px",
|
|
1455
|
+
].join(";");
|
|
1456
|
+
btn.textContent = "🆕 新会话";
|
|
1456
1457
|
btn.title = "创建新会话(可中文命名)";
|
|
1457
1458
|
|
|
1459
|
+
btn.onmouseenter = function () { btn.style.background = "rgba(124, 58, 237, 1)"; btn.style.transform = "scale(1.05)"; };
|
|
1460
|
+
btn.onmouseleave = function () { btn.style.background = "rgba(139, 92, 246, 0.85)"; btn.style.transform = "scale(1)"; };
|
|
1458
1461
|
btn.onclick = function (e) {
|
|
1459
1462
|
e.stopPropagation();
|
|
1460
|
-
e.preventDefault();
|
|
1461
1463
|
if (newSessionOpen) { closeNewSessionModal(); } else { openNewSessionModal(); }
|
|
1462
1464
|
};
|
|
1463
1465
|
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
// 监听 shadow DOM 变化:防止 Lit 重渲染后原生按钮恢复显示或我们的按钮被移除
|
|
1467
|
-
var shadowRoot = nativeBtn.getRootNode();
|
|
1468
|
-
if (shadowRoot && shadowRoot !== document) {
|
|
1469
|
-
new MutationObserver(function () {
|
|
1470
|
-
var ourBtn = shadowRoot.querySelector("#myclaw-newsession-btn");
|
|
1471
|
-
if (!ourBtn) {
|
|
1472
|
-
// 被重渲染移除了,重新插入
|
|
1473
|
-
createNewSessionButton();
|
|
1474
|
-
return;
|
|
1475
|
-
}
|
|
1476
|
-
var native = shadowRoot.querySelector(".sidebar-new-session:not(#myclaw-newsession-btn)");
|
|
1477
|
-
if (native) hideNativeNewSessionBtn(native);
|
|
1478
|
-
}).observe(shadowRoot, { childList: true, subtree: true });
|
|
1479
|
-
}
|
|
1466
|
+
document.body.appendChild(btn);
|
|
1480
1467
|
}
|
|
1481
1468
|
|
|
1482
1469
|
function closeNewSessionModal() {
|
package/package.json
CHANGED
package/server/debug_record.py
CHANGED
|
@@ -45,6 +45,7 @@ from urllib.parse import urlparse, unquote
|
|
|
45
45
|
|
|
46
46
|
|
|
47
47
|
class EventType:
|
|
48
|
+
PROBE_READY = "probe-ready"
|
|
48
49
|
PAGE_ENTER = "page-enter"
|
|
49
50
|
CLICK = "click"
|
|
50
51
|
KEYDOWN = "keydown"
|
|
@@ -533,6 +534,17 @@ def format_replay_event(event: Dict[str, Any]) -> Dict[str, str]:
|
|
|
533
534
|
event_type = event.get("type")
|
|
534
535
|
payload = event.get("payload") or {}
|
|
535
536
|
|
|
537
|
+
if event_type == EventType.PROBE_READY:
|
|
538
|
+
version = (
|
|
539
|
+
to_safe_string(payload.get("probeVersion"))
|
|
540
|
+
or to_safe_string(event.get("probeVersion"))
|
|
541
|
+
)
|
|
542
|
+
return {
|
|
543
|
+
"icon": "🔌",
|
|
544
|
+
"title": f"调试探针已就位(版本 {version})" if version else "调试探针已就位",
|
|
545
|
+
"detail": "",
|
|
546
|
+
}
|
|
547
|
+
|
|
536
548
|
if event_type == EventType.PAGE_ENTER:
|
|
537
549
|
title = (
|
|
538
550
|
event.get("pageTitle")
|