@ibealec/create-zed-bridge 1.0.5 → 1.0.7
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/templates/@zed-controller/react-bridge/dist/index.cjs +59 -16
- package/templates/@zed-controller/react-bridge/dist/index.cjs.map +1 -1
- package/templates/@zed-controller/react-bridge/dist/index.js +59 -16
- package/templates/@zed-controller/react-bridge/dist/index.js.map +1 -1
|
@@ -165,7 +165,7 @@ function captureContext(element) {
|
|
|
165
165
|
selectedText: getSelectedText(),
|
|
166
166
|
selectedElement: {
|
|
167
167
|
tagName: element.tagName.toLowerCase(),
|
|
168
|
-
className: element
|
|
168
|
+
className: getClassNameString(element),
|
|
169
169
|
id: element.id || void 0,
|
|
170
170
|
innerText: truncateText(element.innerText, 200)
|
|
171
171
|
},
|
|
@@ -187,12 +187,22 @@ function getSelectedText() {
|
|
|
187
187
|
return void 0;
|
|
188
188
|
}
|
|
189
189
|
function truncateText(text, maxLength) {
|
|
190
|
+
if (!text) return "";
|
|
190
191
|
const cleaned = text.replace(/\s+/g, " ").trim();
|
|
191
192
|
if (cleaned.length <= maxLength) {
|
|
192
193
|
return cleaned;
|
|
193
194
|
}
|
|
194
195
|
return cleaned.slice(0, maxLength) + "...";
|
|
195
196
|
}
|
|
197
|
+
function getClassNameString(element) {
|
|
198
|
+
if (typeof element.className === "string") {
|
|
199
|
+
return element.className;
|
|
200
|
+
}
|
|
201
|
+
if (element.className && typeof element.className.baseVal === "string") {
|
|
202
|
+
return element.className.baseVal;
|
|
203
|
+
}
|
|
204
|
+
return "";
|
|
205
|
+
}
|
|
196
206
|
function getSourceFile(element) {
|
|
197
207
|
let current = element;
|
|
198
208
|
while (current) {
|
|
@@ -295,10 +305,13 @@ function getDomPath(element) {
|
|
|
295
305
|
let selector = current.tagName.toLowerCase();
|
|
296
306
|
if (current.id) {
|
|
297
307
|
selector += `#${current.id}`;
|
|
298
|
-
} else
|
|
299
|
-
const
|
|
300
|
-
if (
|
|
301
|
-
|
|
308
|
+
} else {
|
|
309
|
+
const classNameStr = getClassNameString(current);
|
|
310
|
+
if (classNameStr) {
|
|
311
|
+
const classes = classNameStr.split(/\s+/).filter((c) => c && !c.startsWith("__")).slice(0, 2).join(".");
|
|
312
|
+
if (classes) {
|
|
313
|
+
selector += `.${classes}`;
|
|
314
|
+
}
|
|
302
315
|
}
|
|
303
316
|
}
|
|
304
317
|
path.unshift(selector);
|
|
@@ -428,11 +441,34 @@ async function captureElementScreenshot(element, options = {}) {
|
|
|
428
441
|
useCORS: true,
|
|
429
442
|
allowTaint: true,
|
|
430
443
|
backgroundColor: null,
|
|
431
|
-
logging: false
|
|
444
|
+
logging: false,
|
|
445
|
+
// Ignore elements that might cause issues
|
|
446
|
+
ignoreElements: (el) => {
|
|
447
|
+
return el.tagName === "IFRAME" || el.tagName === "VIDEO";
|
|
448
|
+
},
|
|
449
|
+
onclone: (clonedDoc) => {
|
|
450
|
+
try {
|
|
451
|
+
const styleSheets = clonedDoc.styleSheets;
|
|
452
|
+
const fallbackStyle = clonedDoc.createElement("style");
|
|
453
|
+
fallbackStyle.textContent = `
|
|
454
|
+
* {
|
|
455
|
+
/* Fallback for elements using unsupported color functions */
|
|
456
|
+
--html2canvas-fallback: inherit;
|
|
457
|
+
}
|
|
458
|
+
`;
|
|
459
|
+
clonedDoc.head.appendChild(fallbackStyle);
|
|
460
|
+
} catch {
|
|
461
|
+
}
|
|
462
|
+
}
|
|
432
463
|
});
|
|
433
464
|
return canvas.toDataURL("image/png");
|
|
434
465
|
} catch (error) {
|
|
435
|
-
|
|
466
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
467
|
+
if (errorMessage.includes("unsupported color function") || errorMessage.includes("oklch") || errorMessage.includes("lab(") || errorMessage.includes("lch(")) {
|
|
468
|
+
console.debug("[ClaudeBridge] Screenshot skipped: page uses modern CSS colors not supported by html2canvas");
|
|
469
|
+
return void 0;
|
|
470
|
+
}
|
|
471
|
+
console.warn("[ClaudeBridge] Screenshot capture failed:", errorMessage);
|
|
436
472
|
return void 0;
|
|
437
473
|
}
|
|
438
474
|
}
|
|
@@ -475,10 +511,14 @@ function createHighlightOverlay() {
|
|
|
475
511
|
let labelText = element.tagName.toLowerCase();
|
|
476
512
|
if (element.id) {
|
|
477
513
|
labelText += `#${element.id}`;
|
|
478
|
-
} else
|
|
479
|
-
const
|
|
480
|
-
|
|
481
|
-
|
|
514
|
+
} else {
|
|
515
|
+
const className = element.className;
|
|
516
|
+
const classNameStr = typeof className === "string" ? className : className?.baseVal || "";
|
|
517
|
+
if (classNameStr) {
|
|
518
|
+
const firstClass = classNameStr.split(/\s+/)[0];
|
|
519
|
+
if (firstClass && !firstClass.startsWith("__")) {
|
|
520
|
+
labelText += `.${firstClass}`;
|
|
521
|
+
}
|
|
482
522
|
}
|
|
483
523
|
}
|
|
484
524
|
label.textContent = labelText;
|
|
@@ -1705,7 +1745,7 @@ function TaskStatusToast({
|
|
|
1705
1745
|
document.addEventListener("mousemove", handleMouseMove);
|
|
1706
1746
|
document.addEventListener("mouseup", handleMouseUp);
|
|
1707
1747
|
}, [size]);
|
|
1708
|
-
const killSession = useCallback3((sessionId) => {
|
|
1748
|
+
const killSession = useCallback3((sessionId, taskPrompt) => {
|
|
1709
1749
|
return new Promise((resolve) => {
|
|
1710
1750
|
const wsUrl = serverUrl.replace(/^http/, "ws").replace(/\/$/, "");
|
|
1711
1751
|
const ws = new WebSocket(`${wsUrl}/ws/bridge?token=${encodeURIComponent(token)}`);
|
|
@@ -1720,7 +1760,10 @@ function TaskStatusToast({
|
|
|
1720
1760
|
ws.onopen = () => {
|
|
1721
1761
|
ws.send(JSON.stringify({
|
|
1722
1762
|
type: "kill_session",
|
|
1723
|
-
sessionId
|
|
1763
|
+
sessionId,
|
|
1764
|
+
// Include task prompt for auto-commit message
|
|
1765
|
+
taskPrompt,
|
|
1766
|
+
autoCommit: true
|
|
1724
1767
|
}));
|
|
1725
1768
|
};
|
|
1726
1769
|
ws.onmessage = (event) => {
|
|
@@ -1741,17 +1784,17 @@ function TaskStatusToast({
|
|
|
1741
1784
|
resolve();
|
|
1742
1785
|
}
|
|
1743
1786
|
};
|
|
1744
|
-
setTimeout(cleanup,
|
|
1787
|
+
setTimeout(cleanup, 1e4);
|
|
1745
1788
|
});
|
|
1746
1789
|
}, [serverUrl, token]);
|
|
1747
1790
|
const handleDismiss = useCallback3(async () => {
|
|
1748
1791
|
if (killOnClose && task?.sessionId) {
|
|
1749
|
-
await killSession(task.sessionId);
|
|
1792
|
+
await killSession(task.sessionId, task.prompt);
|
|
1750
1793
|
}
|
|
1751
1794
|
setVisible(false);
|
|
1752
1795
|
setExpanded(false);
|
|
1753
1796
|
setTimeout(onDismiss, 300);
|
|
1754
|
-
}, [killOnClose, task?.sessionId, killSession, onDismiss]);
|
|
1797
|
+
}, [killOnClose, task?.sessionId, task?.prompt, killSession, onDismiss]);
|
|
1755
1798
|
const handleToggleExpand = useCallback3(() => {
|
|
1756
1799
|
setExpanded(!expanded);
|
|
1757
1800
|
}, [expanded]);
|