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: fold never-dismissing toasts into a corner pill so they stop eating clicks
[._.]/ Adam Eivy02dbbf59b147
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex d76cb8df7e..3fc98a3df8 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -23,6 +23,7 @@## Fixed+- **The task form's Screenshot and Attach buttons work again — a stuck notification was eating the clicks.** A notice that never goes away (the "Install out of sync" warning, "Update available", "New build available") parks in the bottom-right corner, and on a desktop window it landed on top of the Chief of Staff task form and silently absorbed every click meant for the buttons underneath. They did nothing at all — no file picker, no error, nothing in the browser console — which is why it read as a broken button rather than something covering one, and why the same page still worked on a phone, where the layout puts those buttons elsewhere. On a 1280×720 window the notice covered a 520×86px block starting at the exact pixel the Attach button begins. Notices that never dismiss themselves now fold into a small badge in the corner after 8 seconds (1600px², clear of the page); clicking the badge brings the message back, and it stays open while you hover it or use its buttons. Toasts with a set lifetime — including the manuscript Undo prompt — are untouched.- **CoS agent PRs no longer open with TUI startup noise as their description.** A PR that PortOS opened for a Codex/Antigravity/OpenCode agent led with the session's own lifecycle log — `📟 TUI session started: … (codex …)`, `💡 Open the Shell tab…`, `📟 Prompt pasted…` — before getting to what the agent actually did. The PR description now starts at the agent's completion summary and drops PortOS's status lines, along with the trailing `## Branch` / `## PR` section that only repeats what the PR page already shows.- **Review Hub success-rate alerts now require recent runs.** Low lifetime rates for task types that have been idle no longer appear as current health anomalies; alerts are shown only after enough runs occur in the rolling 30-day performance window.- **Malware scan reports now open inside PortOS.** Scan links from Brain, the Review Hub, and completed CoS agents render the markdown in a mobile-friendly PortOS page instead of navigating a Home Screen install to the raw `.md` API response. Brain Links also has a Scan Reports filter, so clean and caution results are just as discoverable as dangerous findings.diff --git a/client/src/a11yConventions.test.js b/client/src/a11yConventions.test.jsindex e261cbc7b0..c9ba18024d 100644--- a/client/src/a11yConventions.test.js+++ b/client/src/a11yConventions.test.js@@ -20,6 +20,10 @@* picker at all in WebKit-as-installed-PWA — the shape PortOS is opened in* from a second machine over the tailnet. `components/ui/FilePickerButton.jsx`* is the shared widget (sr-only input + native `<label for>` activation).+ * 4. A `duration: Infinity` toast whose content is JSX or a render prop but+ * which passes no `label`. Such a toast collapses to a pill after+ * COLLAPSE_AFTER_MS (so it stops covering the page), and the pill has no+ * text of its own to name itself with.** Scoped to git-tracked `.jsx` under `client/src` so an untracked scratch file* can't fail the suite.@@ -64,6 +68,25 @@ function openingTagAt(src, index, nameLength) {const lineOf = (src, index) => src.slice(0, index).split('\n').length;+/**+ * Slice a call's full argument list, `(` through its matching `)`, starting at+ * the opening paren. Skips over string and template literals so a `)` inside+ * one can't close the call early.+ */+function balancedCallAt(src, openIndex) {+ let depth = 0;+ for (let i = openIndex; i < src.length; i++) {+ const c = src[i];+ if (c === '\'' || c === '"' || c === '`') {+ for (i++; i < src.length && src[i] !== c; i++) if (src[i] === '\\') i++;+ continue;+ }+ if (c === '(') depth++;+ else if (c === ')' && --depth === 0) return src.slice(openIndex, i + 1);+ }+ return null;+}+describe('a11y conventions', () => {// Modal.jsx IS the shared implementation; Drawer and Layout use the same// backdrop treatment for a slide-in panel / mobile nav scrim, both of which@@ -170,6 +193,36 @@ describe('a11y conventions', () => {expect(offenders, `Programmatic .click() on a ref — if it targets a file input the picker never opens in WebKit/PWA; use components/ui/FilePickerButton.jsx. If the ref is genuinely NOT a file input (e.g. a synthesized <a download>), add the file to REF_CLICK_ALLOWLIST above with a comment:\n${offenders.join('\n')}`).toEqual([]);});+ it('names every never-dismissing toast that cannot name itself', () => {+ // A `duration: Infinity` toast folds into an icon-only pill after+ // COLLAPSE_AFTER_MS so it stops covering the page (components/ui/Toast.jsx).+ // The pill takes its accessible name from string content — but JSX and+ // render-prop content have no text to take, so without `label` the whole+ // name is "Show notification" and the notice becomes unidentifiable to a+ // screen reader for the rest of its (unbounded) life. Nothing at runtime+ // complains, so this is the only thing that catches it.+ const offenders = [];+ for (const file of trackedSourceFiles()) {+ const src = readFileSync(join(CLIENT_ROOT, file), 'utf8');+ const re = /\btoast(?:\.\w+)?\s*\(/g;+ let m;+ while ((m = re.exec(src))) {+ const call = balancedCallAt(src, re.lastIndex - 1);+ if (!call || !/\bduration:\s*Infinity\b/.test(call)) continue;+ // Only content that demonstrably isn't a string needs `label`: inline+ // JSX and render props. A literal or a variable is left alone — the+ // pill reads a string straight off `t.content`.+ const firstArg = call.slice(1).trimStart();+ const isJsx = firstArg.startsWith('<');+ const isRenderProp = /^(\([^)]*\)|\w+)\s*=>/.test(firstArg);+ if (!isJsx && !isRenderProp) continue;+ if (/\blabel:/.test(call)) continue;+ offenders.push(`${file}:${lineOf(src, m.index)}`);+ }+ }+ expect(offenders, `A duration: Infinity toast with JSX/render-prop content must pass \`label\` — it collapses to a pill that has no other accessible name (see COLLAPSE_AFTER_MS in components/ui/Toast.jsx):\n${offenders.join('\n')}`).toEqual([]);+ });+it('gives every role="switch" an aria-checked state', () => {const offenders = [];for (const file of trackedJsxFiles()) {diff --git a/client/src/components/ui/Toast.jsx b/client/src/components/ui/Toast.jsxindex 33a3b50d2e..5a45b15389 100644--- a/client/src/components/ui/Toast.jsx+++ b/client/src/components/ui/Toast.jsx@@ -2,6 +2,11 @@* Toast notification system — replaces react-hot-toast* Supports: toast(), toast.success(), toast.error(), toast.loading(), toast.dismiss(), <Toaster />* Render-prop toasts: toast((t) => <Component t={t} />, opts) — t has { id }+ *+ * A `duration: Infinity` toast collapses to a corner pill after+ * COLLAPSE_AFTER_MS so it stops blocking clicks on the page beneath it. Such a+ * toast with render-prop content MUST pass `label` — the pill can't name itself+ * from JSX, and `a11yConventions.test.js` enforces it.*/import { useState, useEffect } from 'react';@@ -17,6 +22,19 @@ function notify() {const DEFAULT_DURATION = 4000;const DEDUP_WINDOW_MS = 1500;+// How long a `duration: Infinity` toast stays at full size before folding into+// a corner pill. The stack is `fixed`, `z-[9999]` and `pointer-events-auto`, so+// a toast that never dismisses is a permanent click sink over the page: an+// install whose `outOfSync` notice parked in the bottom-right corner covered+// the CoS task form's Screenshot and Attach buttons, and clicking them did+// nothing at all — no picker, no error, nothing in the console.+//+// Only unbounded toasts collapse. A finite duration is a bound the caller+// already chose and it clears itself, so folding one early would hide an action+// the caller meant to keep offering for the whole time (the manuscript+// Undo-fix toast runs 10s and its Undo button is the only one there is).+export const COLLAPSE_AFTER_MS = 8000;+// Fingerprint → expiry timestamp. Same content+type within DEDUP_WINDOW_MS is// silently dropped so a single user action that flows through multiple error// channels (API client toast + socket error:occurred + error:notified) doesn't@@ -50,7 +68,9 @@ function add(content, opts = {}, type = 'default') {}}- const entry = { id, type, content, icon: opts.icon, duration, style: opts.style };+ // `label` names the toast once it collapses to a pill — required for+ // render-prop content, whose JSX the pill can't summarise on its own.+ const entry = { id, type, content, icon: opts.icon, duration, style: opts.style, label: opts.label };const idx = toasts.findIndex(t => t.id === id);toasts = idx !== -1@@ -114,23 +134,94 @@ export function Toaster({ position = 'bottom-right', toastOptions = {} }) {role="region"aria-label="Notifications">- {items.map(t => {- const style = { padding: '12px 16px', borderRadius: '8px', ...toastOptions.style, ...t.style };- const iconStr = t.icon ?? (t.type !== 'default' ? TYPE_ICON[t.type] : null);- const iconClass = t.type !== 'default' ? TYPE_CLASS[t.type] : '';- return (- <div- key={t.id}- style={style}- role={t.type === 'error' ? 'alert' : 'status'}- className="pointer-events-auto flex items-start gap-2 shadow-lg text-sm max-w-[calc(100vw-2rem)] sm:max-w-[520px] bg-port-card border border-port-border">- {iconStr && <span className={`shrink-0 ${iconClass}`} aria-hidden="true">{iconStr}</span>}- <div className="flex-1 min-w-0">- {typeof t.content === 'function' ? t.content({ id: t.id }) : <span>{t.content}</span>}- </div>- </div>- );- })}+ {items.map(t => (+ <ToastItem key={t.id} t={t} toastOptions={toastOptions} />+ ))}</div>);}++function ToastItem({ t, toastOptions }) {+ const style = { padding: '12px 16px', borderRadius: '8px', ...toastOptions.style, ...t.style };+ const iconStr = t.icon ?? (t.type !== 'default' ? TYPE_ICON[t.type] : null);+ const iconClass = t.type !== 'default' ? TYPE_CLASS[t.type] : '';+ // Only a toast that never dismisses itself can outstay its welcome and start+ // eating clicks — see COLLAPSE_AFTER_MS.+ const collapsible = t.duration === Infinity;+ const [collapsed, setCollapsed] = useState(false);+ // Held open while the pointer is over the toast or focus is inside it —+ // collapsing out from under a hover would yank the buttons the user is+ // reaching for, and collapsing while focus is inside would drop that focus+ // to <body>.+ const [held, setHeld] = useState(false);++ useEffect(() => {+ if (!collapsible || collapsed || held) return undefined;+ const timer = setTimeout(() => setCollapsed(true), COLLAPSE_AFTER_MS);+ return () => clearTimeout(timer);+ }, [collapsible, collapsed, held]);++ // Re-entering `add()` with the same id replaces the entry in place (a+ // loading→success swap, a coalesced AI-status error picking up another+ // failure). That toast has something new to say, so unfold it — otherwise the+ // update lands inside a pill nobody opens. `content`/`type` only change+ // identity when `add()` actually ran, so this doesn't fire on re-renders.+ useEffect(() => { setCollapsed(false); }, [t.content, t.type]);++ // Collapsing HIDES the body, it does not unmount it: render-prop toasts own+ // their lifecycle (useAgentFeedbackToast's card runs its own auto-dismiss),+ // and unmounting would destroy those timers and strand the pill forever.+ // `display: none` inline beats the `flex` utility class, and takes the body+ // out of the a11y tree and out of hit-testing — which is the whole point.+ //+ // `collapsible` is re-read during render, not just in the effect, so a+ // loading→success swap on the same id (Infinity → 4000) unfolds in the same+ // commit. The reset effect below would get there a paint later, which shows+ // as a frame of pill over the new message.+ const isCollapsed = collapsed && collapsible;+ const bodyStyle = isCollapsed ? { ...style, display: 'none' } : style;++ return (+ <>+ {isCollapsed && (+ // Re-expanding does NOT pin the toast open: the timer restarts, so a tap+ // on a touch device (where no mouseleave ever arrives) re-collapses on+ // its own.+ // No hover handlers here: the timer effect short-circuits on+ // `collapsed` so `held` couldn't change anything, and the pill unmounts+ // on click — browsers fire no `mouseleave` on a removed node, so a+ // mouse click would strand `held` at true and suppress the re-collapse.+ <button+ type="button"+ onClick={() => setCollapsed(false)}+ aria-label={collapsedLabel(t)}+ className="pointer-events-auto flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-port-card border border-port-border shadow-lg text-sm"+ >+ <span className={iconClass} aria-hidden="true">{iconStr ?? '•'}</span>+ </button>+ )}+ <div+ style={bodyStyle}+ role={t.type === 'error' ? 'alert' : 'status'}+ onMouseEnter={() => setHeld(true)}+ onMouseLeave={() => setHeld(false)}+ // onFocus/onBlur bubble in React, so these fire for the toast's buttons too.+ onFocus={() => setHeld(true)}+ onBlur={() => setHeld(false)}+ className="pointer-events-auto flex items-start gap-2 shadow-lg text-sm max-w-[calc(100vw-2rem)] sm:max-w-[520px] bg-port-card border border-port-border">+ {iconStr && <span className={`shrink-0 ${iconClass}`} aria-hidden="true">{iconStr}</span>}+ <div className="flex-1 min-w-0">+ {typeof t.content === 'function' ? t.content({ id: t.id }) : <span>{t.content}</span>}+ </div>+ </div>+ </>+ );+}++// Accessible name for the collapsed pill. String content names itself; a+// render-prop toast has to supply `label` or it collapses to an anonymous badge.+function collapsedLabel(t) {+ if (t.label) return `Show notification: ${t.label}`;+ if (typeof t.content === 'string') return `Show notification: ${t.content}`;+ return 'Show notification';+}diff --git a/client/src/components/ui/Toast.test.jsx b/client/src/components/ui/Toast.test.jsxindex 94f40741dc..f066386e87 100644--- a/client/src/components/ui/Toast.test.jsx+++ b/client/src/components/ui/Toast.test.jsx@@ -1,12 +1,14 @@-import { describe, it, expect, afterEach, vi } from 'vitest';-import { render, screen, cleanup, act } from '@testing-library/react';+import { useEffect } from 'react';+import { describe, it, expect, afterEach, beforeEach, vi } from 'vitest';+import { render, screen, cleanup, act, fireEvent } from '@testing-library/react';-import { toast, Toaster } from './Toast.jsx';+import { toast, Toaster, COLLAPSE_AFTER_MS } from './Toast.jsx';afterEach(() => {act(() => toast.dismiss());cleanup();vi.unstubAllGlobals();+ vi.useRealTimers();});describe('Toast on an insecure origin', () => {@@ -61,3 +63,99 @@ describe('Toaster accessibility', () => {expect(glyph).toHaveTextContent('✓');});});++/** Why a never-dismissing toast has to fold away: see COLLAPSE_AFTER_MS. */+describe('long-lived toasts stop blocking the page', () => {+ const advance = (ms) => act(() => { vi.advanceTimersByTime(ms); });++ // Every test here measures a timeout, so fake timers are mandatory — a test+ // that forgot them would silently no-op every `advance()`.+ beforeEach(() => {+ vi.useFakeTimers();+ render(<Toaster />);+ });++ it('collapses a persistent toast to a pill that no longer covers the page', () => {+ act(() => { toast('Install out of sync', { duration: Infinity, icon: '⚠️' }); });++ // Still a full-size toast for the first COLLAPSE_AFTER_MS.+ expect(screen.getByRole('status')).toBeVisible();+ expect(screen.queryByRole('button', { name: /show notification/i })).toBeNull();++ advance(COLLAPSE_AFTER_MS);++ // The body is hidden (out of hit-testing and out of the a11y tree) and only+ // a corner pill remains.+ expect(screen.queryByRole('status')).toBeNull();+ expect(screen.getByRole('button', { name: 'Show notification: Install out of sync' })).toBeVisible();+ });++ it('leaves transient toasts alone — they never live long enough to block anything', () => {+ act(() => { toast('Saved'); });++ // The default 4s toast is dismissed well before the collapse threshold, so+ // it must never sprout a pill on its way out.+ advance(COLLAPSE_AFTER_MS * 2);+ expect(screen.queryByRole('status')).toBeNull();+ expect(screen.queryByRole('button', { name: /show notification/i })).toBeNull();+ });++ it('re-expands when the pill is clicked, and re-collapses on its own', () => {+ // Distinct text per test: identical content within DEDUP_WINDOW_MS is+ // dropped, and the fingerprint map outlives an individual test.+ act(() => { toast('New build available', { duration: Infinity }); });+ advance(COLLAPSE_AFTER_MS);++ fireEvent.click(screen.getByRole('button', { name: /show notification/i }));+ expect(screen.getByRole('status')).toBeVisible();++ // No pinning on expand — a tap on a touch device (no mouseleave ever+ // arrives) must still fold the toast back away.+ advance(COLLAPSE_AFTER_MS);+ expect(screen.queryByRole('status')).toBeNull();+ });++ it('keeps the toast open while focus is inside it', () => {+ act(() => {+ toast(() => <button type="button">Reconcile</button>, { duration: Infinity, label: 'Install out of sync' });+ });++ fireEvent.focus(screen.getByRole('button', { name: 'Reconcile' }));+ advance(COLLAPSE_AFTER_MS * 2);+ // Collapsing here would `display: none` the focused button and dump focus+ // on <body> mid-interaction.+ expect(screen.getByRole('button', { name: 'Reconcile' })).toBeVisible();++ fireEvent.blur(screen.getByRole('button', { name: 'Reconcile' }));+ advance(COLLAPSE_AFTER_MS);+ expect(screen.getByRole('button', { name: 'Show notification: Install out of sync' })).toBeVisible();+ });++ it('unfolds a collapsed toast when it is updated in place', () => {+ act(() => { toast.loading('Restarting PortOS...', { id: 'restart', duration: Infinity }); });+ advance(COLLAPSE_AFTER_MS);+ expect(screen.getByRole('button', { name: /show notification/i })).toBeVisible();++ // Same id, new content: the swap has something to say, so it must not land+ // inside a pill nobody thinks to open.+ act(() => { toast.success('PortOS restarted', { id: 'restart' }); });+ expect(screen.getByRole('status')).toHaveTextContent('PortOS restarted');+ expect(screen.queryByRole('button', { name: /show notification/i })).toBeNull();+ });++ it('hides rather than unmounts, so a self-dismissing toast keeps its timers', () => {+ const unmounted = vi.fn();+ function SelfManaging() {+ useEffect(() => unmounted, []);+ return <span>Agent finished</span>;+ }+ act(() => { toast(() => <SelfManaging />, { duration: Infinity, label: 'Agent finished' }); });++ advance(COLLAPSE_AFTER_MS);++ // Unmounting the body would destroy the render-prop's own auto-dismiss+ // timer and strand the pill on screen forever.+ expect(unmounted).not.toHaveBeenCalled();+ expect(screen.getByText('Agent finished')).toBeInTheDocument();+ });+});diff --git a/client/src/hooks/useAgentFeedbackToast.jsx b/client/src/hooks/useAgentFeedbackToast.jsxindex aa78866081..412fdf9147 100644--- a/client/src/hooks/useAgentFeedbackToast.jsx+++ b/client/src/hooks/useAgentFeedbackToast.jsx@@ -183,6 +183,7 @@ export function useAgentFeedbackToast() {{id: toastId,duration: Infinity, // Component manages its own auto-dismiss+ label: 'Agent finished — rate the result',style: {background: 'rgb(var(--port-card))',border: '1px solid rgb(var(--port-border))',diff --git a/client/src/hooks/useUpdateChecker.jsx b/client/src/hooks/useUpdateChecker.jsxindex 2a32720b60..55fc0cf003 100644--- a/client/src/hooks/useUpdateChecker.jsx+++ b/client/src/hooks/useUpdateChecker.jsx@@ -51,7 +51,8 @@ export function useUpdateChecker() {{id: TOAST_ID,duration: Infinity,- icon: '🔄'+ icon: '🔄',+ label: `Update available: v${data.latestVersion}`});};@@ -85,7 +86,8 @@ export function useUpdateChecker() {{id: OUT_OF_SYNC_TOAST_ID,duration: Infinity,- icon: '⚠️'+ icon: '⚠️',+ label: 'Install out of sync'});};diff --git a/client/src/services/staleBuildToast.jsx b/client/src/services/staleBuildToast.jsxindex 152daf36b8..05e418e520 100644--- a/client/src/services/staleBuildToast.jsx+++ b/client/src/services/staleBuildToast.jsx@@ -17,6 +17,6 @@ export function showStaleBuildToast() {Reload</button></div>,- { id: 'portos-stale-build', duration: Infinity },+ { id: 'portos-stale-build', duration: Infinity, label: 'New build available' },);}