Open-source Grok Bot alternative with a virtual machine that bots can use
TypeScript ai-agentsclaude-codecodexcomputer-usedockerelectrongrokgrok-botgrok-bot-alternativeself-hostedtypescript
Point chip label: keep page capitals and visible children of hidden wrappers
AdityaUmaledce951e682d3
diff --git a/shared/app-frame/point.test.ts b/shared/app-frame/point.test.tsindex 23460c1927..4c978f65b6 100644--- a/shared/app-frame/point.test.ts+++ b/shared/app-frame/point.test.ts@@ -94,6 +94,16 @@ describe("the page's point script", () => {expect(posted.at(-1)).toMatchObject({ params: { tag: "div", text: "Cloud Restore finishes More" } });});+ it("keeps the page's capitals, a visible child of a hidden wrapper, and leaves out text the page does not render", () => {+ const { say } = boot();+ document.body.innerHTML = `<div class="card"><span style="text-transform:uppercase">save</span>+ <span style="visibility:hidden">tip <em style="visibility:visible">shown</em></span><details><summary>One</summary><summary>Two</summary>x</details>+ <section style="content-visibility:hidden">skipped</section></div>`;+ say(pointMessage(true));+ click(document.querySelector(".card")!);+ expect(posted.at(-1)).toMatchObject({ params: { tag: "div", text: "SAVE shown One" } });+ });+it("names a keyed part by its key, and Escape ends point mode with word to the parent", () => {const { say } = boot();say(pointMessage(true));diff --git a/shared/app-frame/point.ts b/shared/app-frame/point.tsindex ed79faedfd..8e5cf7eca7 100644--- a/shared/app-frame/point.ts+++ b/shared/app-frame/point.ts@@ -121,17 +121,25 @@ export const APP_POINT_SOURCE = `(function () {}return parts.join(" > ");};+ var cased = function (text, transform) {+ return transform === "uppercase" ? text.toUpperCase() : transform === "lowercase" ? text.toLowerCase()+ : transform === "capitalize" ? text.replace(/(^|\\s)(\\S)/g, function (all, gap, letter) { return gap + letter.toUpperCase(); }) : text;+ };// innerText runs a badge (an inline-block span) into the next word ("CloudRestore"): any box that is not plain inline// is a word break on screen, so it is one here too.var wordsOf = function (node) {- if (node.nodeType === 3) return node.data;if (node.nodeType !== 1 || /^(script|style|noscript|template)$/i.test(node.tagName)) return "";var style = window.getComputedStyle(node);var display = style.display;- if (display === "none" || style.visibility === "hidden" || style.visibility === "collapse") return "";- var shown = node.tagName === "DETAILS" && !node.open- ? Array.prototype.filter.call(node.children, function (child) { return child.tagName === "SUMMARY"; }) : node.childNodes;- var words = Array.prototype.map.call(shown, wordsOf).join("");+ if (display === "none") return "";+ // A hidden wrapper's own text stays out, but a descendant set visible again is on screen.+ var hidden = style.visibility === "hidden" || style.visibility === "collapse";+ var closed = node.tagName === "DETAILS" && !node.open;+ var summary = closed && Array.prototype.find.call(node.children, function (child) { return child.tagName === "SUMMARY"; });+ var shown = style.contentVisibility === "hidden" ? [] : closed ? (summary ? [summary] : []) : node.childNodes;+ var words = Array.prototype.map.call(shown, function (child) {+ return child.nodeType === 3 ? (hidden ? "" : cased(child.data, style.textTransform)) : wordsOf(child);+ }).join("");return /^(inline|contents)?$/.test(display) && node.tagName !== "BR" ? words : " " + words + " ";};var describe = function (element) {