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
test: catch arbitrary-value widths and non-bounding clamps (#5686)
Adam Eivy147f60103827
diff --git a/client/src/AGENTS.md b/client/src/AGENTS.mdindex 140e00a38d..6867e98bed 100644--- a/client/src/AGENTS.md+++ b/client/src/AGENTS.md@@ -7,7 +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`.+- **A fixed-width popover carries a viewport clamp** - an absolutely-positioned panel whose width is fixed at 256px or more (`w-64` and up, or the same size as an arbitrary `w-[19rem]`) 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/openworld/OpenWorldFocusPanel.jsx b/client/src/components/openworld/OpenWorldFocusPanel.jsxindex 7042d30f91..e0e11582f6 100644--- a/client/src/components/openworld/OpenWorldFocusPanel.jsx+++ b/client/src/components/openworld/OpenWorldFocusPanel.jsx@@ -38,7 +38,7 @@ function StatBlock({ label, value, tone = 'text-cyan-300' }) {export default function OpenWorldFocusPanel({ app, notFound = false, agents = [], onClose, onFocusInWorld, isDesktop = true }) {// Desktop: occupy the Intel-pane slot. Compact: a bottom sheet above the dock.const containerClass = isDesktop- ? 'absolute top-20 right-4 bottom-24 w-[19rem] pointer-events-auto'+ ? 'absolute top-20 right-4 bottom-24 w-[19rem] max-w-[calc(100vw-1rem)] pointer-events-auto': 'absolute inset-x-2 bottom-16 pointer-events-auto';// Live per-process PM2 telemetry (roadmap 1.1) — same aggregation the buildingdiff --git a/client/src/components/openworld/OpenWorldIntelPane.jsx b/client/src/components/openworld/OpenWorldIntelPane.jsxindex 3204c8eb77..48ffb0239c 100644--- a/client/src/components/openworld/OpenWorldIntelPane.jsx+++ b/client/src/components/openworld/OpenWorldIntelPane.jsx@@ -391,7 +391,7 @@ export default function OpenWorldIntelPane({ apps, cosAgents, reviewCounts, inst};return (- <div className={`absolute top-20 right-4 ${collapsed ? '' : 'bottom-24'} w-[19rem] pointer-events-auto`}>+ <div className={`absolute top-20 right-4 ${collapsed ? '' : 'bottom-24'} w-[19rem] max-w-[calc(100vw-1rem)] pointer-events-auto`}><div className={`${collapsed ? '' : 'h-full'} openworld-intel-surface overflow-hidden flex flex-col`}><div className="flex items-stretch border-b border-cyan-500/20">{/* Deliberately NOT `ui/TabPills`: this bar wears the immersive OpenWorlddiff --git a/client/src/popoverClampConventions.test.js b/client/src/popoverClampConventions.test.jsindex 87e358d74c..38d33967a9 100644--- a/client/src/popoverClampConventions.test.js+++ b/client/src/popoverClampConventions.test.js@@ -9,9 +9,10 @@* 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- * clamp that is *relative to the available width* and applies at the BASE- * viewport. The tree's canonical form is `max-w-[calc(100vw-1rem)]`+ * width at 256px or more — `w-64` and up on the numeric scale, or the same size+ * written as an arbitrary `w-[19rem]` / `w-[384px]` — must also carry a clamp+ * that is *relative to the available width* and applies at the BASE viewport.+ * 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; `max-w-[90vw]`, `max-w-full`, and `max-w-screen` also qualify.@@ -31,8 +32,8 @@* - `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.+ * - Widths below 256px, which fit inside the narrowest viewport the app+ * targets even with an anchor offset and 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.@@ -47,22 +48,51 @@ 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;// Every token below is matched UNPREFIXED, because the base variant is the phone-// and the phone is the viewport that clips. `w-64` is a fixed width; `min-w-80`-// and `max-w-96` are not (the token doesn't start at `w-`).-const FIXED_WIDTH = /^w-(\d+)$/;+// and the phone is the viewport that clips.const ABSOLUTE = /^absolute$/;-// The clamp's value has to track the available width: an arbitrary value in-// viewport or percentage units, or the two keywords that mean exactly that.-const VIEWPORT_CLAMP = /^max-w-(?:full|screen|\[[^\]]*(?:[dsl]?vw|%)[^\]]*\])$/;-function widestFixedWidth(tokens) {- return tokens.reduce((widest, token) => {- const match = FIXED_WIDTH.exec(token);- return match ? Math.max(widest, Number(match[1])) : widest;- }, 0);+/**+ * The narrowest viewport the app targets is 360px; a panel at or above 256px+ * (`w-64`) is close enough to it that an anchor offset plus a gutter can push it+ * over. Widths are compared in px so the numeric scale and an arbitrary value+ * answer to one threshold.+ */+const MIN_CLAMPED_PX = 256;+// `w-64` — the numeric scale, in 0.25rem steps at a 16px root. `min-w-80` and+// `max-w-96` are not fixed widths: the token doesn't start at `w-`.+const NUMERIC_WIDTH = /^w-(\d+(?:\.\d+)?)$/;+// `w-[19rem]`, `w-[384px]` — the same bug written as an arbitrary value.+const ARBITRARY_WIDTH = /^w-\[(\d+(?:\.\d+)?)(rem|px)\]$/;+const ARBITRARY_CLAMP = /^max-w-\[(.+)\]$/;+const RELATIVE_UNIT = /[dsl]?vw|%/;+const BARE_RELATIVE = /^(\d+(?:\.\d+)?)(?:[dsl]?vw|%)$/;++/** Fixed width in px, or 0 when the token doesn't declare one. */+function fixedWidthPx(token) {+ const numeric = NUMERIC_WIDTH.exec(token);+ if (numeric) return Number(numeric[1]) * 4;+ const arbitrary = ARBITRARY_WIDTH.exec(token);+ if (!arbitrary) return 0;+ return arbitrary[2] === 'rem' ? Number(arbitrary[1]) * 16 : Number(arbitrary[1]);+}++/**+ * Whether the token caps the element against the width actually available.+ * `max-w-96` / `max-w-lg` / `max-w-none` are absolute ceilings and do not — they+ * leave the panel overflowing a phone exactly as before.+ */+function isViewportClamp(token) {+ if (token === 'max-w-full' || token === 'max-w-screen') return true;+ const arbitrary = ARBITRARY_CLAMP.exec(token);+ if (!arbitrary) return false;+ const value = arbitrary[1];+ if (!RELATIVE_UNIT.test(value)) return false;+ // `calc(100vw+10rem)` is relative, but it widens rather than clamps.+ if (value.includes('+')) return false;+ // A bare `200vw` / `200%` is over the available width, not a bound on it.+ const bare = BARE_RELATIVE.exec(value);+ return !bare || Number(bare[1]) <= 100;}function violationsIn(rawSource, file) {@@ -71,8 +101,8 @@ function violationsIn(rawSource, file) {.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) => VIEWPORT_CLAMP.test(token));+ if (Math.max(0, ...tokens.map(fixedWidthPx)) < MIN_CLAMPED_PX) return false;+ return !tokens.some(isViewportClamp);}).map(({ value, index }) => `${file}:${lineOf(source, index)} — "${value.trim()}"`);}@@ -116,6 +146,14 @@ describe('popover viewport-clamp conventions', () => {expect(flagged('absolute md:static inset-y-0 left-0 w-[80vw] max-w-xs md:w-64')).toBe(0);// Narrow panels fit a 360px phone unclamped.expect(flagged('absolute right-0 w-56 rounded-lg')).toBe(0);+ // The same bug written as an arbitrary value.+ expect(flagged('absolute top-20 right-4 bottom-24 w-[19rem]')).toBe(1);+ expect(flagged('absolute w-[384px] rounded-lg')).toBe(1);+ expect(flagged('absolute w-[19rem] max-w-[calc(100vw-1rem)]')).toBe(0);+ expect(flagged('absolute w-[12rem] rounded-lg')).toBe(0);+ // Relative units that are not actually a bound.+ expect(flagged('absolute w-96 max-w-[200%]')).toBe(1);+ expect(flagged('absolute w-96 max-w-[calc(100vw+10rem)]')).toBe(1);// `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.