Skip to content

The cross-harness, self-improving memory layer for AI agents. Join our community: https://discord.com/invite/zdNChS2fBu

fix(lenses): lint's viewport warning ignores line-, min- and max-height

Claudebc1eb9a70098
diff --git a/cli/beacon/internal/endpoint/lensstore/lint.go b/cli/beacon/internal/endpoint/lensstore/lint.go
index 6e1d8723..3d44e2b7 100644
--- a/cli/beacon/internal/endpoint/lensstore/lint.go
+++ b/cli/beacon/internal/endpoint/lensstore/lint.go
@@ -42,7 +42,7 @@ var lintChecks = []struct {
"uses browser storage, which an opaque-origin lens frame does not have; keep state in memory"},
{regexp.MustCompile(`\b(window\.)?(parent|top|opener)\.(postMessage|document|location)\b|\blocation\.(href|assign|replace)\b`),
"talks to or navigates a window; the host ignores window messages and closes a lens that navigates"},
- {regexp.MustCompile(`\b100vh\b|\bheight\s*:\s*100%`),
+ {regexp.MustCompile(`\b100vh\b|(^|[^-\w])height\s*:\s*100%`),
"sizes to the viewport; the frame grows to fit the document, so a viewport-height root never settles"},
{regexp.MustCompile(`new\s+Worker\s*\(|new\s+SharedWorker\s*\(|serviceWorker`),
"starts a worker, which the lens CSP blocks"},
diff --git a/cli/beacon/internal/endpoint/lensstore/lint_test.go b/cli/beacon/internal/endpoint/lensstore/lint_test.go
index 3d1deaac..65d47b8e 100644
--- a/cli/beacon/internal/endpoint/lensstore/lint_test.go
+++ b/cli/beacon/internal/endpoint/lensstore/lint_test.go
@@ -44,6 +44,22 @@ func TestLintFlagsWhatTheSandboxBlocks(t *testing.T) {
}
}
+// Only height itself sizes an element to its container; the hyphenated properties do not.
+func TestLintViewportHeightIgnoresOtherHeightProperties(t *testing.T) {
+ for _, css := range []string{"p { line-height: 100% }", "img { max-height: 100% }", "td { min-height: 100% }"} {
+ html := "<!doctype html>\n" + lintManifest + "\n<script>window.beacon.getTrace()</script>\n<style>" + css + "</style>\n"
+ if findings := Lint([]byte(html)); len(findings) != 0 {
+ t.Errorf("Lint(%q) = %+v, want no findings", css, findings)
+ }
+ }
+ for _, css := range []string{"html { height: 100% }", "body{height:100%}"} {
+ html := "<!doctype html>\n" + lintManifest + "\n<script>window.beacon.getTrace()</script>\n<style>" + css + "</style>\n"
+ if findings := Lint([]byte(html)); len(findings) != 1 {
+ t.Errorf("Lint(%q) = %+v, want the viewport warning", css, findings)
+ }
+ }
+}
+
func TestLintClean(t *testing.T) {
html := "<!doctype html>\r\n" + lintManifest + "\r\n<p id=out></p>\r\n<script>\r\nwindow.beacon.getTrace().then(function (d) { out.textContent = d.trace.id; });\r\n</script>\r\n"
if findings := Lint([]byte(html)); len(findings) != 0 {