Self-hosted, Self-Improving, Federated Everything App — dev management, agent orchestration, persistent mind, digital twin, second brain, and creative pipeline from a single dashboard over Tailscale to port the user into the OS
JavaScript ai-agentsdashboarddeveloper-toolsdigital-twinquantified-selfsecond-brainself-hostedtailscale
fix: clamp fixed-width dropdown popovers to the viewport (#5686)
Adam Eivyf1e0505bda6c
diff --git a/client/src/AGENTS.md b/client/src/AGENTS.mdindex a64d26fe0f..140e00a38d 100644--- a/client/src/AGENTS.md+++ b/client/src/AGENTS.md@@ -7,6 +7,7 @@ These apply to React/Vite client code. Universal constraints (functional program- **No window.alert/confirm** - use inline confirmations or toast notifications- **Form labels need `htmlFor`/`id` pairing** - when adding a settings/config form field, wire `<label htmlFor="...">` to an `id="..."` on the input — screen readers and click-to-focus both depend on the association. The visual `block`/`mb-1` styling alone doesn't establish it.- **Mobile responsive** - all pages should be mobile responsive friendly. **A `grid-cols-N` with N > 3 and no `…:grid-cols-*` anywhere in the same class string is a bug**, not a style nit: at 360px a four-up stat bar gives each card ~65px of outer width, so its label wraps to five lines and the whole above-the-fold region is unreadable. Give text-bearing cards a narrow phone default and let the viewport opt into the wide layout (`grid-cols-2 gap-3 sm:gap-4 lg:grid-cols-4`); a widened *gap* (`gap-4 sm:gap-6`) is not a column breakpoint. A grid of square thumbnails or heatmap cells may stay four-plus wide on a phone, but it still needs a column breakpoint so the desktop isn't stuck at the phone count. Enforced tree-wide by `client/src/responsiveGridConventions.test.js`, which carries the allowlist for the few grids that really are frozen N-across (a seven-day month grid, the fixed five-trait Big Five bars).+- **A fixed-width popover carries a viewport clamp** - an absolutely-positioned panel with a bare `w-64`/`w-72`/`w-80`/`w-96` must also carry `max-w-[calc(100vw-1rem)]`. `Layout`'s root shell is `overflow-x-hidden`, so anything wider than the viewport is *clipped away*, not made scrollable: a `w-96` filter panel anchored `right-3` on a 360px phone puts its whole left column of controls permanently off-screen with nothing to scroll to. The `calc(100vw-1rem)` form (not `90vw`) is the standard because it holds an 8px gutter at every width instead of a proportional one that collapses on small screens. Enforced tree-wide by `client/src/popoverClampConventions.test.js`.- **Above the fold** - keep actionable content and info above the fold and design pages for maximum information and access without scrolling- **No hardcoded localhost** - use `window.location.hostname` for URLs; app accessed via Tailscale remotely- **Chrome floating over media uses `.port-media-overlay`** - a label, status bar, badge, or control panel sitting on top of an image, a video, or a 3D canvas takes its surface and ink from the theme (`.port-media-overlay`, or `.port-media-overlay-strong` for a small label directly on photography; `.port-media-overlay-item` for its buttons, `.port-media-overlay-divider` for its separators — all defined in `index.css`, which carries the mechanism and the rule for picking between this, `.always-dark`, and the OpenWorld HUD remap). **Don't write `bg-black/NN` + `text-white`/`text-gray-N00` for this** — day mode remaps the text to the theme's dark ink while the black scrim stays black, so the label renders dark-on-black. Older overlays outside the 3D/Three.js pages still carry that idiom (migration tracked in #3796), so match the new convention rather than the nearest neighbor.diff --git a/client/src/components/goals/GoalsTreeView.jsx b/client/src/components/goals/GoalsTreeView.jsxindex d7f79caa67..97c0f520c4 100644--- a/client/src/components/goals/GoalsTreeView.jsx+++ b/client/src/components/goals/GoalsTreeView.jsx@@ -267,7 +267,7 @@ function OrganizePanel({ suggestion, goals, onApply, onClose, applying }) {if (!suggestion) return null;return (- <div className="absolute top-12 right-3 z-20 bg-port-card border border-port-border rounded-lg p-4 w-96 max-h-dvh-cap [--dvh-cap:80dvh] overflow-y-auto shadow-xl">+ <div className="absolute top-12 right-3 z-20 bg-port-card border border-port-border rounded-lg p-4 w-96 max-w-[calc(100vw-1rem)] max-h-dvh-cap [--dvh-cap:80dvh] overflow-y-auto shadow-xl"><div className="flex items-center justify-between mb-3"><div className="flex items-center gap-2"><Wand2 className="w-4 h-4 text-port-accent" />@@ -567,7 +567,7 @@ export default function GoalsTreeView({ data, onRefresh }) {{/* New goal form */}{showNewGoal && (- <div className="absolute top-12 left-3 z-10 bg-port-card border border-port-border rounded-lg p-3 w-72 space-y-2 shadow-lg">+ <div className="absolute top-12 left-3 z-10 bg-port-card border border-port-border rounded-lg p-3 w-72 max-w-[calc(100vw-1rem)] space-y-2 shadow-lg"><inputtype="text"value={newGoal.title}diff --git a/client/src/components/pipeline/LengthProfilePicker.jsx b/client/src/components/pipeline/LengthProfilePicker.jsxindex e34d96b562..6a04c2dc03 100644--- a/client/src/components/pipeline/LengthProfilePicker.jsx+++ b/client/src/components/pipeline/LengthProfilePicker.jsx@@ -99,7 +99,7 @@ export default function LengthProfilePicker({ issue, onChange, disabled = false</button>{open && (- <div className="absolute right-0 mt-1 w-72 bg-port-card border border-port-border rounded-lg shadow-lg z-30 p-1">+ <div className="absolute right-0 mt-1 w-72 max-w-[calc(100vw-1rem)] bg-port-card border border-port-border rounded-lg shadow-lg z-30 p-1">{PRESET_ORDER.map((id) => {const preset = LENGTH_PROFILES[id];const active = profile === id;diff --git a/client/src/pages/Shell.jsx b/client/src/pages/Shell.jsxindex ed43ca7105..e85cb91e5b 100644--- a/client/src/pages/Shell.jsx+++ b/client/src/pages/Shell.jsx@@ -277,7 +277,7 @@ export default function Shell() {<ChevronDown size={12} className={`transition-transform ${folderDropdownOpen ? 'rotate-180' : ''}`} /></button>{folderDropdownOpen && (- <div className="absolute right-0 top-full mt-1 w-64 max-h-80 overflow-y-auto bg-port-card border border-port-border rounded-lg shadow-xl z-50">+ <div className="absolute right-0 top-full mt-1 w-64 max-w-[calc(100vw-1rem)] max-h-80 overflow-y-auto bg-port-card border border-port-border rounded-lg shadow-xl z-50">{appFolders.map(({ name, path }) => (<buttonkey={name}diff --git a/client/src/popoverClampConventions.test.js b/client/src/popoverClampConventions.test.jsnew file mode 100644index 0000000000..f1172f765d--- /dev/null+++ b/client/src/popoverClampConventions.test.js@@ -0,0 +1,103 @@+/**+ * Repo-wide viewport clamp on fixed-width popovers.+ *+ * `Layout`'s root shell is `w-full max-w-full overflow-x-hidden`, so an+ * absolutely-positioned panel wider than the viewport is CLIPPED, not made+ * scrollable — the overflowing edge is simply unreachable. A filter panel+ * declared `w-96` (384px) and anchored `right-3` is therefore wider than a 360px+ * phone screen, and its whole left column of controls sits permanently off the+ * left edge with nothing to scroll to (issue #5686).+ *+ * The rule: a class string that positions an element `absolute` AND fixes its+ * width with a bare `w-<n>` of 64 (16rem / 256px) or more must also carry a+ * `max-w-*` clamp. The tree's canonical form is `max-w-[calc(100vw-1rem)]`+ * (`components/pipeline/arcCanvas/VerifyScopeTooltip.jsx`), which keeps a fixed+ * 8px gutter at every width rather than a proportional one that collapses on+ * small screens — but any `max-w-*` satisfies the guard, because a panel that+ * declares one has demonstrably been through the narrow case.+ *+ * Deliberately NOT flagged:+ * - `min-w-*` / `max-w-*` tokens, which are not a fixed width (`sm:min-w-80` on+ * a `left-3 right-3` media overlay is correct as written).+ * - `fixed` positioning, which escapes the shell's overflow box.+ * - Widths below `w-64`, which fit inside the narrowest viewport the app+ * targets even with a gutter.+ *+ * Scoped to git-tracked non-test sources; comments are masked first so a doc+ * block quoting an example class string is documentation, not markup.+ */++import { describe, it, expect } from 'vitest';+import { readFileSync } from 'fs';+import { join, dirname } from 'path';+import { fileURLToPath } from 'url';+import { trackedSourceFiles } from './test/trackedFiles.js';+import { lineOf, maskComments, stringLiterals } from './test/classNameScan.js';++const CLIENT_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');++/** Tailwind's numeric width scale is in 0.25rem steps: 64 → 16rem → 256px. */+const MIN_CLAMPED_WIDTH = 64;+const VARIANT = String.raw`(?:[\w@[\]().\-/]+:)*`;+// `w-64`, `sm:w-96` — but never `min-w-80` / `max-w-96`, whose token doesn't+// start at `w-` once the variant prefixes are consumed.+const FIXED_WIDTH = new RegExp(String.raw`^${VARIANT}w-(\d+)$`);+const ABSOLUTE = new RegExp(String.raw`^${VARIANT}absolute$`);+const MAX_WIDTH = new RegExp(String.raw`^${VARIANT}max-w-`);++function widestFixedWidth(tokens) {+ return tokens.reduce((widest, token) => {+ const match = FIXED_WIDTH.exec(token);+ return match ? Math.max(widest, Number(match[1])) : widest;+ }, 0);+}++function violationsIn(rawSource, file) {+ const source = maskComments(rawSource);+ return stringLiterals(source)+ .filter(({ value }) => {+ const tokens = value.split(/\s+/).filter(Boolean);+ if (!tokens.some((token) => ABSOLUTE.test(token))) return false;+ if (widestFixedWidth(tokens) < MIN_CLAMPED_WIDTH) return false;+ return !tokens.some((token) => MAX_WIDTH.test(token));+ })+ .map(({ value, index }) => `${file}:${lineOf(source, index)} — "${value.trim()}"`);+}++const findViolations = (file) =>+ violationsIn(readFileSync(join(CLIENT_ROOT, file), 'utf8'), file);++describe('popover viewport-clamp conventions', () => {+ const files = trackedSourceFiles(CLIENT_ROOT);++ it('scans a populated client tree', () => {+ expect(files.length).toBeGreaterThan(100);+ });++ // Without this the suite would still pass if the detector silently stopped+ // matching anything — a green tree-wide guard proves nothing on its own.+ it('flags an unclamped fixed-width popover and clears every safe form', () => {+ const flagged = (markup) => violationsIn(`<div className="${markup}" />`, 'probe.jsx').length;+ expect(flagged('absolute top-12 right-3 z-20 p-4 w-96 shadow-xl')).toBe(1);+ expect(flagged('absolute right-0 mt-1 w-72 rounded-lg')).toBe(1);+ expect(flagged('absolute right-0 top-full w-64 max-h-80 overflow-y-auto')).toBe(1);+ // A max-height is not a width clamp.+ expect(flagged('absolute w-96 max-h-dvh-cap [--dvh-cap:80dvh]')).toBe(1);+ // The clamp, in either of the tree's two forms.+ expect(flagged('absolute right-3 w-96 max-w-[calc(100vw-1rem)] p-4')).toBe(0);+ expect(flagged('absolute w-80 max-w-[90vw] p-3')).toBe(0);+ // `min-w-*` is not a fixed width, at any variant prefix.+ expect(flagged('absolute bottom-3 left-3 right-3 sm:right-auto sm:min-w-80')).toBe(0);+ expect(flagged('absolute min-w-96 w-full')).toBe(0);+ // Narrow panels fit a 360px phone unclamped.+ expect(flagged('absolute right-0 w-56 rounded-lg')).toBe(0);+ // `fixed` escapes the shell's overflow box; it is positioned to the viewport.+ expect(flagged('fixed bottom-4 right-4 w-96 rounded-lg')).toBe(0);+ // A doc comment quoting an example class string is not markup.+ expect(violationsIn('// e.g. "absolute right-0 w-96"', 'probe.jsx')).toEqual([]);+ });++ it('never fixes a popover wider than a phone without a max-width', () => {+ expect(files.flatMap((file) => findViolations(file))).toEqual([]);+ });+});diff --git a/client/src/responsiveGridConventions.test.js b/client/src/responsiveGridConventions.test.jsindex 7ef6b0fe09..282bd5157a 100644--- a/client/src/responsiveGridConventions.test.js+++ b/client/src/responsiveGridConventions.test.js@@ -34,6 +34,7 @@ import { readFileSync } from 'fs';import { join, dirname } from 'path';import { fileURLToPath } from 'url';import { trackedSourceFiles } from './test/trackedFiles.js';+import { lineOf, maskComments, stringLiterals } from './test/classNameScan.js';const CLIENT_ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');@@ -57,51 +58,6 @@ const ALLOWED = new Map([],]);-/** Blank out `//` and block comments so a quoted example class isn't scanned as markup. */-function maskComments(source) {- let out = '';- let i = 0;- while (i < source.length) {- const ch = source[i];- if (ch === '/' && source[i + 1] === '/') {- while (i < source.length && source[i] !== '\n') {- out += ' ';- i += 1;- }- continue;- }- if (ch === '/' && source[i + 1] === '*') {- while (i < source.length && !(source[i] === '*' && source[i + 1] === '/')) {- out += source[i] === '\n' ? '\n' : ' ';- i += 1;- }- out += ' ';- i += 2;- continue;- }- if (ch === '"' || ch === "'" || ch === '`') {- out += ch;- i += 1;- while (i < source.length && source[i] !== ch) {- if (source[i] === '\\') {- out += source.slice(i, i + 2);- i += 2;- continue;- }- out += source[i];- i += 1;- }- out += source[i] ?? '';- i += 1;- continue;- }- out += ch;- i += 1;- }- return out;-}--const STRING_LITERAL = /(['"`])((?:\\.|(?!\1)[\s\S])*?)\1/g;// A column count that is the phone default: no `variant:` in front of it. Global,// because a single class string can hold more than one bare token and the widest// one is the one that decides whether the layout is legible.@@ -118,22 +74,11 @@ function widestBareColumnCount(value) {return widest;}-function lineOf(source, index) {- return source.slice(0, index).split('\n').length;-}-function violationsIn(rawSource, file) {const source = maskComments(rawSource);- const found = [];- let match;- STRING_LITERAL.lastIndex = 0;- while ((match = STRING_LITERAL.exec(source))) {- const value = match[2];- if (widestBareColumnCount(value) < MIN_WIDE_COLUMNS) continue;- if (PREFIXED_GRID.test(value)) continue;- found.push(`${file}:${lineOf(source, match.index)} — "${value.trim()}"`);- }- return found;+ return stringLiterals(source)+ .filter(({ value }) => widestBareColumnCount(value) >= MIN_WIDE_COLUMNS && !PREFIXED_GRID.test(value))+ .map(({ value, index }) => `${file}:${lineOf(source, index)} — "${value.trim()}"`);}const findViolations = (file) =>diff --git a/client/src/test/classNameScan.js b/client/src/test/classNameScan.jsnew file mode 100644index 0000000000..c8827e8410--- /dev/null+++ b/client/src/test/classNameScan.js@@ -0,0 +1,74 @@+/**+ * Shared string-literal scanner for the class-string convention guards.+ *+ * `src/responsiveGridConventions.test.js` and `src/popoverClampConventions.test.js`+ * both enforce a narrow-viewport rule by reading every quoted string in the client+ * tree and inspecting the Tailwind tokens inside it. They need the same two+ * primitives — blank out comments so a doc block quoting an example class isn't+ * scanned as markup, then walk the remaining string literals — so those live here+ * once rather than being copied into each guard.+ *+ * Node-only consumers (test files) exclusively; kept in `src/test/` for the same+ * reason as `trackedFiles.js` — `lib/` carries the enforced barrel + README rule+ * and a test-only helper has no business in the browser barrel.+ */++/** Blank out `//` and block comments so a quoted example class isn't scanned as markup. */+export function maskComments(source) {+ let out = '';+ let i = 0;+ while (i < source.length) {+ const ch = source[i];+ if (ch === '/' && source[i + 1] === '/') {+ while (i < source.length && source[i] !== '\n') {+ out += ' ';+ i += 1;+ }+ continue;+ }+ if (ch === '/' && source[i + 1] === '*') {+ while (i < source.length && !(source[i] === '*' && source[i + 1] === '/')) {+ out += source[i] === '\n' ? '\n' : ' ';+ i += 1;+ }+ out += ' ';+ i += 2;+ continue;+ }+ if (ch === '"' || ch === "'" || ch === '`') {+ out += ch;+ i += 1;+ while (i < source.length && source[i] !== ch) {+ if (source[i] === '\\') {+ out += source.slice(i, i + 2);+ i += 2;+ continue;+ }+ out += source[i];+ i += 1;+ }+ out += source[i] ?? '';+ i += 1;+ continue;+ }+ out += ch;+ i += 1;+ }+ return out;+}++const STRING_LITERAL = /(['"`])((?:\\.|(?!\1)[\s\S])*?)\1/g;++/** Every quoted string in `source`, as `{ value, index }` in source order. */+export function stringLiterals(source) {+ const found = [];+ let match;+ STRING_LITERAL.lastIndex = 0;+ while ((match = STRING_LITERAL.exec(source))) found.push({ value: match[2], index: match.index });+ return found;+}++/** 1-based line number of a character offset. */+export function lineOf(source, index) {+ return source.slice(0, index).split('\n').length;+}