@aiyiran/myclaw 1.1.158 → 1.1.161
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 +32 -37
- package/package.json +1 -1
package/assets/myclaw-inject.js
CHANGED
|
@@ -569,7 +569,15 @@
|
|
|
569
569
|
lines.push("学生描述:" + (state.description || "(未填写)"));
|
|
570
570
|
lines.push("");
|
|
571
571
|
lines.push("请从学生描述里提取:我做了什么、发生了什么、我的预期是什么。");
|
|
572
|
-
lines.push("
|
|
572
|
+
lines.push("");
|
|
573
|
+
lines.push("如何阅读调试记录(不要通读整个 HTML,按下面抓重点):");
|
|
574
|
+
lines.push("1. 调试记录是一个 HTML 文件,完整事件数据在 <script id=\"debug-data\" type=\"application/json\"> 这段 JSON 里——只读这段,别看页面样式。");
|
|
575
|
+
lines.push("2. 先在事件里找 runtime-error / unhandledrejection / 以及 level 为 error 的 console 事件,它们是问题的起点。");
|
|
576
|
+
lines.push("3. 抓住报错事件的 message、stack、filename、lineno——直接定位到源码里出错的那个函数/那几行,只看相关代码段,不要通读整个作品文件。");
|
|
577
|
+
lines.push("4. 再倒着看报错之前的 page-enter / click / keydown / console,还原“做了什么 → 触发了什么”的因果链,确认重现路径。");
|
|
578
|
+
lines.push("5. 如果没有任何报错(属于逻辑 bug),就对比【学生的预期】和事件里 console 输出 / 交互序列反映出的【实际行为】,差异处就是 bug。");
|
|
579
|
+
lines.push("");
|
|
580
|
+
lines.push("定位到根因后只做最小修复。修复后说明:问题原因、改了哪个文件的哪段代码、为什么这样改能解决。");
|
|
573
581
|
|
|
574
582
|
return lines.join("\n");
|
|
575
583
|
}
|
|
@@ -1423,52 +1431,39 @@ btn.addEventListener("click", function () {
|
|
|
1423
1431
|
});
|
|
1424
1432
|
}
|
|
1425
1433
|
|
|
1426
|
-
function hideNativeNewSessionBtn(nativeBtn) {
|
|
1427
|
-
nativeBtn.style.setProperty("display", "none", "important");
|
|
1428
|
-
}
|
|
1429
|
-
|
|
1430
1434
|
function createNewSessionButton() {
|
|
1431
|
-
|
|
1432
|
-
if (!nativeBtn) {
|
|
1433
|
-
setTimeout(createNewSessionButton, 500);
|
|
1434
|
-
return;
|
|
1435
|
-
}
|
|
1436
|
-
|
|
1437
|
-
// 已经替换过,不重复插入
|
|
1438
|
-
if (nativeBtn.parentNode && nativeBtn.parentNode.querySelector("#myclaw-newsession-btn")) return;
|
|
1435
|
+
if (document.querySelector("#myclaw-newsession-btn")) return;
|
|
1439
1436
|
|
|
1440
|
-
|
|
1441
|
-
hideNativeNewSessionBtn(nativeBtn);
|
|
1442
|
-
|
|
1443
|
-
// 复用原生按钮的 class + innerHTML,外观完全一致
|
|
1444
|
-
var btn = document.createElement("button");
|
|
1437
|
+
var btn = document.createElement("div");
|
|
1445
1438
|
btn.id = "myclaw-newsession-btn";
|
|
1446
|
-
btn.
|
|
1447
|
-
|
|
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 = "🆕 新会话";
|
|
1448
1457
|
btn.title = "创建新会话(可中文命名)";
|
|
1449
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)"; };
|
|
1450
1461
|
btn.onclick = function (e) {
|
|
1451
1462
|
e.stopPropagation();
|
|
1452
|
-
e.preventDefault();
|
|
1453
1463
|
if (newSessionOpen) { closeNewSessionModal(); } else { openNewSessionModal(); }
|
|
1454
1464
|
};
|
|
1455
1465
|
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
// 监听 shadow DOM 变化:防止 Lit 重渲染后原生按钮恢复显示或我们的按钮被移除
|
|
1459
|
-
var shadowRoot = nativeBtn.getRootNode();
|
|
1460
|
-
if (shadowRoot && shadowRoot !== document) {
|
|
1461
|
-
new MutationObserver(function () {
|
|
1462
|
-
var ourBtn = shadowRoot.querySelector("#myclaw-newsession-btn");
|
|
1463
|
-
if (!ourBtn) {
|
|
1464
|
-
// 被重渲染移除了,重新插入
|
|
1465
|
-
createNewSessionButton();
|
|
1466
|
-
return;
|
|
1467
|
-
}
|
|
1468
|
-
var native = shadowRoot.querySelector(".sidebar-new-session:not(#myclaw-newsession-btn)");
|
|
1469
|
-
if (native) hideNativeNewSessionBtn(native);
|
|
1470
|
-
}).observe(shadowRoot, { childList: true, subtree: true });
|
|
1471
|
-
}
|
|
1466
|
+
document.body.appendChild(btn);
|
|
1472
1467
|
}
|
|
1473
1468
|
|
|
1474
1469
|
function closeNewSessionModal() {
|