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
a11y: route the last hand-rolled confirmation modals through shared <Modal>
[._.]/ Adam Eivyf0df1eb78436
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 730db937cf..c0ce06f4bf 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -21,6 +21,8 @@## Changed+- **Accessibility: route the last hand-rolled confirmation modals through the shared `<Modal>`.** The DataDog and JIRA "Delete instance?" dialogs, the GitHub archive/unarchive confirmation, and the PromptManager "Create Stage" / "Delete Stage" dialogs were bespoke `fixed inset-0 bg-black/50` overlays with no `role="dialog"`, no `aria-modal`, no focus trap, and no Esc-to-close. They now render through `client/src/components/ui/Modal.jsx`, gaining the shared dialog semantics — labelled headings (`aria-labelledby`), focus trap with focus restoration, the Esc stack, and backdrop-click dismissal — with the long "Create Stage" form opting out of backdrop-dismiss so an accidental click can't discard typed state. No visual change.+- **[issue-2592] Add an adaptive render budget and visibility-aware frameloop to CyberCity.** City gains an **Auto quality mode** (City Settings → Performance): new installs default to Auto starting at High, while existing saved settings load as **Manual** and keep their preset (adaptation never touches a chosen fixed preset, and never rewrites localStorage). A pure state machine, `client/src/utils/cityRenderBudget.js`, watches p75 frame time over 2s rolling windows — ignoring the startup warm-up and frame gaps above 250ms — and steps the effective detail tier **down** after two windows above 25ms, **up** after five below 18ms, with a 10s cooldown and never more than one tier per decision (the 18–25ms dead band is the anti-oscillation gap); sustained sub-cutoff frames still downshift via a synthetic pressure window. The runtime effective tier is separate from persisted settings and drives reflections, particle density, DPR, interior-window shaders, and set dressing via an explicit `effectiveTier` (replacing the old `particleDensity`-as-quality proxy in `cityShowDetail`/`cityShowInteriorWindows`). The live City frameloop now **pauses while the tab is hidden** (`frameloop="never"`) and resumes with a fresh warm-up when visible again — Photo mode keeps its demand loop and capture behavior untouched. The Performance tab shows the effective tier (`AUTO · HIGH`) plus a local-only diagnostics readout (tier, FPS, p75) that is never persisted or transmitted, and disables the Auto-controlled Reflections/Particle-density fields. New unit tests cover downshift, recovery, cooldown, ignored samples (warm-up/gap), sustained slowness, storage compatibility, Manual mode, and visibility transitions.- **[issue-2534] Unify service errors on `ServerError` and delete the duplicated `mapServiceError` copies.** Routes now speak one error model. A single `createServiceErrorMapper(statusMap, buildContext?)` factory in `server/lib/errorHandler.js` replaces the nine near-identical local `mapServiceError` bodies that had accreted across the pipeline / builder / media routers (`pipeline/shared.js`, `storyBuilder.js`, `universeBuilder.js`, `importer.js`, `dashboardLayouts.js`, `conflictJournal.js`, `mediaSketches.js`, `mediaCollections.js`, `mediaAnnotations.js`) — each now just wires its own domain `code → status` map (and optional diagnostic-context builder) through the shared factory. Separately, the CoS agent service functions that returned result-shaped `{ error }` payloads (`getAgentPrompt`, `deleteAgent`, `submitAgentFeedback`, `sendBtwToAgent`) now throw `ServerError` with an explicit `status`/`code`, so `cosAgentRoutes.js` no longer string-matches `result.error === 'Agent not found'` to guess 404-vs-400 — the errors bubble straight to the centralized middleware and every route returns the same `{ error, code, timestamp, context? }` envelope. No client-visible behavior change (the same statuses/codes are preserved). Pure architecture refactor.- **[issue-2591] Responsive City HUD + City settings on the shared Drawer.** The CyberCity HUD now adapts to the viewport instead of stacking every desktop panel on top of the 3D scene at phone width. A new `useCityViewport` hook brackets the window into desktop (≥1024, unchanged cockpit), compact (640–1023) and phone (<640); below desktop the HUD collapses to a small clock/health chip, a status chip and a bottom dock of 44×44 launchers, keeping ≥70% of the scene unobscured on load. Secondary surfaces (vitals, attention, timeline, activity, map, filter, legend) open as ONE mutually-exclusive disclosure sheet driven by a `cityPane` URL param, so only one shows at a time and the open one is deep-linkable, reload-safe and restored by browser back/forward (the desktop Intel pane's active tab reads the same param). City settings moved off the bespoke bottom-right scroller onto the shared tabbed `Drawer` (`size="sm"`, Performance/Audio/Visual/Explore, active tab deep-linked via `useDrawerTab`'s `cityTab` param, `TabPills` mobile dropdown), preserving the `/city/settings` route.diff --git a/client/src/pages/DataDog.jsx b/client/src/pages/DataDog.jsxindex c14863a813..2118f4ef59 100644--- a/client/src/pages/DataDog.jsx+++ b/client/src/pages/DataDog.jsx@@ -2,6 +2,7 @@ import { useState, useEffect } from 'react';import toast from '../components/ui/Toast';import { FormField } from '../components/ui/FormField';import PageSkeleton from '../components/ui/PageSkeleton';+import Modal from '../components/ui/Modal';import api from '../services/api';const SITE_OPTIONS = [@@ -201,30 +202,34 @@ export default function DataDog() {</div>{/* Delete Confirmation Modal */}- {deleteConfirm && (- <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">- <div className="bg-gray-800 rounded-lg p-4 sm:p-6 max-w-md w-full">- <h3 className="text-lg sm:text-xl font-bold text-white mb-4">Delete DataDog Instance?</h3>- <p className="text-gray-300 mb-6 text-sm sm:text-base break-words">- Are you sure you want to delete "{deleteConfirm}"? This will remove the stored keys.- </p>- <div className="flex flex-col-reverse sm:flex-row gap-2 sm:justify-end">- <button- onClick={handleDeleteCancel}- className="w-full sm:w-auto px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded"- >- Cancel- </button>- <button- onClick={handleDeleteConfirm}- className="w-full sm:w-auto px-4 py-2 bg-port-error hover:bg-port-error/80 text-white rounded"- >- Delete- </button>- </div>+ <Modal+ open={!!deleteConfirm}+ onClose={handleDeleteCancel}+ size="sm"+ backdropClassName="bg-black/50"+ ariaLabelledBy="datadog-delete-title"+ >+ <div className="bg-gray-800 rounded-lg p-4 sm:p-6">+ <h3 id="datadog-delete-title" className="text-lg sm:text-xl font-bold text-white mb-4">Delete DataDog Instance?</h3>+ <p className="text-gray-300 mb-6 text-sm sm:text-base break-words">+ Are you sure you want to delete "{deleteConfirm}"? This will remove the stored keys.+ </p>+ <div className="flex flex-col-reverse sm:flex-row gap-2 sm:justify-end">+ <button+ onClick={handleDeleteCancel}+ className="w-full sm:w-auto px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded"+ >+ Cancel+ </button>+ <button+ onClick={handleDeleteConfirm}+ className="w-full sm:w-auto px-4 py-2 bg-port-error hover:bg-port-error/80 text-white rounded"+ >+ Delete+ </button></div></div>- )}+ </Modal><div className="grid grid-cols-1 lg:grid-cols-[1fr_360px] gap-6 items-start">{editingInstance ? (diff --git a/client/src/pages/GitHub.jsx b/client/src/pages/GitHub.jsxindex c5bf9c6721..0ad403b23a 100644--- a/client/src/pages/GitHub.jsx+++ b/client/src/pages/GitHub.jsx@@ -12,6 +12,7 @@ import {} from '../services/api';import { timeAgo } from '../utils/formatters';import PageSkeleton from '../components/ui/PageSkeleton';+import Modal from '../components/ui/Modal';const FILTERS = ['all', 'npm', 'secrets', 'archived'];@@ -166,39 +167,43 @@ export default function GitHub() {<h1 className="text-xl sm:text-2xl font-bold text-white mb-6">GitHub Repos</h1>{/* Archive Confirmation Modal */}- {archiveConfirm && (- <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">- <div className="bg-gray-800 rounded-lg p-4 sm:p-6 max-w-md w-full">- <h3 className="text-lg font-bold text-white mb-4">- {archiveConfirm.action === 'archive' ? 'Archive' : 'Unarchive'} Repository?- </h3>- <p className="text-gray-300 mb-6 text-sm break-words">- {archiveConfirm.action === 'archive'- ? `Archiving "${archiveConfirm.fullName}" will make it read-only on GitHub.`- : `Unarchiving "${archiveConfirm.fullName}" will restore it to active status on GitHub.`- }- </p>- <div className="flex flex-col-reverse sm:flex-row gap-2 sm:justify-end">- <button- onClick={() => setArchiveConfirm(null)}- className="w-full sm:w-auto px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded"- >- Cancel- </button>- <button- onClick={handleArchiveConfirm}- className={`w-full sm:w-auto px-4 py-2 text-white rounded ${- archiveConfirm.action === 'archive'- ? 'bg-port-warning hover:bg-port-warning/80'- : 'bg-port-success hover:bg-port-success/80'- }`}- >- {archiveConfirm.action === 'archive' ? 'Archive' : 'Unarchive'}- </button>- </div>+ <Modal+ open={!!archiveConfirm}+ onClose={() => setArchiveConfirm(null)}+ size="sm"+ backdropClassName="bg-black/50"+ ariaLabelledBy="github-archive-title"+ >+ <div className="bg-gray-800 rounded-lg p-4 sm:p-6">+ <h3 id="github-archive-title" className="text-lg font-bold text-white mb-4">+ {archiveConfirm?.action === 'archive' ? 'Archive' : 'Unarchive'} Repository?+ </h3>+ <p className="text-gray-300 mb-6 text-sm break-words">+ {archiveConfirm?.action === 'archive'+ ? `Archiving "${archiveConfirm?.fullName}" will make it read-only on GitHub.`+ : `Unarchiving "${archiveConfirm?.fullName}" will restore it to active status on GitHub.`+ }+ </p>+ <div className="flex flex-col-reverse sm:flex-row gap-2 sm:justify-end">+ <button+ onClick={() => setArchiveConfirm(null)}+ className="w-full sm:w-auto px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded"+ >+ Cancel+ </button>+ <button+ onClick={handleArchiveConfirm}+ className={`w-full sm:w-auto px-4 py-2 text-white rounded ${+ archiveConfirm?.action === 'archive'+ ? 'bg-port-warning hover:bg-port-warning/80'+ : 'bg-port-success hover:bg-port-success/80'+ }`}+ >+ {archiveConfirm?.action === 'archive' ? 'Archive' : 'Unarchive'}+ </button></div></div>- )}+ </Modal><div className="grid grid-cols-1 lg:grid-cols-[1fr_360px] gap-6 items-start">{/* Repo List */}diff --git a/client/src/pages/Jira.jsx b/client/src/pages/Jira.jsxindex 763eacd5f1..b0d3f0a3a0 100644--- a/client/src/pages/Jira.jsx+++ b/client/src/pages/Jira.jsx@@ -3,6 +3,7 @@ import { Link } from 'react-router-dom';import toast from '../components/ui/Toast';import PageSkeleton from '../components/ui/PageSkeleton';import { FormField } from '../components/ui/FormField';+import Modal from '../components/ui/Modal';import api from '../services/api';const TOKEN_LIFETIME_DAYS = 30;@@ -204,30 +205,34 @@ export default function Jira() {</div>{/* Delete Confirmation Modal */}- {deleteConfirm && (- <div className="fixed inset-0 bg-black bg-opacity-50 flex items-center justify-center z-50 p-4">- <div className="bg-gray-800 rounded-lg p-4 sm:p-6 max-w-md w-full">- <h3 className="text-lg sm:text-xl font-bold text-white mb-4">Delete JIRA Instance?</h3>- <p className="text-gray-300 mb-6 text-sm sm:text-base break-words">- Are you sure you want to delete "{deleteConfirm}"? This will not affect existing tickets.- </p>- <div className="flex flex-col-reverse sm:flex-row gap-2 sm:justify-end">- <button- onClick={handleDeleteCancel}- className="w-full sm:w-auto px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded"- >- Cancel- </button>- <button- onClick={handleDeleteConfirm}- className="w-full sm:w-auto px-4 py-2 bg-port-error hover:bg-port-error/80 text-white rounded"- >- Delete- </button>- </div>+ <Modal+ open={!!deleteConfirm}+ onClose={handleDeleteCancel}+ size="sm"+ backdropClassName="bg-black/50"+ ariaLabelledBy="jira-delete-title"+ >+ <div className="bg-gray-800 rounded-lg p-4 sm:p-6">+ <h3 id="jira-delete-title" className="text-lg sm:text-xl font-bold text-white mb-4">Delete JIRA Instance?</h3>+ <p className="text-gray-300 mb-6 text-sm sm:text-base break-words">+ Are you sure you want to delete "{deleteConfirm}"? This will not affect existing tickets.+ </p>+ <div className="flex flex-col-reverse sm:flex-row gap-2 sm:justify-end">+ <button+ onClick={handleDeleteCancel}+ className="w-full sm:w-auto px-4 py-2 bg-gray-600 hover:bg-gray-700 text-white rounded"+ >+ Cancel+ </button>+ <button+ onClick={handleDeleteConfirm}+ className="w-full sm:w-auto px-4 py-2 bg-port-error hover:bg-port-error/80 text-white rounded"+ >+ Delete+ </button></div></div>- )}+ </Modal><div className="grid grid-cols-1 lg:grid-cols-[1fr_360px] gap-6 items-start">{editingInstance ? (diff --git a/client/src/pages/PromptManager.jsx b/client/src/pages/PromptManager.jsxindex 2b2bb733be..da82d4cd6a 100644--- a/client/src/pages/PromptManager.jsx+++ b/client/src/pages/PromptManager.jsx@@ -15,6 +15,7 @@ import {import useFieldDraft from '../hooks/useFieldDraft';import SettingsTabsHeader from '../components/settings/SettingsTabsHeader';import { FormField } from '../components/ui/FormField';+import Modal from '../components/ui/Modal';const VALID_PROMPT_TABS = ['stages', 'variables', 'job-skills'];@@ -773,18 +774,25 @@ export default function PromptManager() {)}{/* Create Stage Modal */}- {creatingStage && (- <div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">- <div className="bg-port-card border border-port-border rounded-xl p-6 max-w-2xl w-full max-h-[90vh] overflow-y-auto">- <div className="flex items-center justify-between mb-4">- <h3 className="text-lg font-medium text-white">Create New Stage</h3>- <button- onClick={() => setCreatingStage(false)}- className="text-gray-400 hover:text-white"- >- ✕- </button>- </div>+ <Modal+ open={creatingStage}+ onClose={() => setCreatingStage(false)}+ size="lg"+ backdropClassName="bg-black/50"+ closeOnBackdrop={false}+ ariaLabelledBy="create-stage-title"+ >+ <div className="bg-port-card border border-port-border rounded-xl p-6 max-h-[90vh] overflow-y-auto">+ <div className="flex items-center justify-between mb-4">+ <h3 id="create-stage-title" className="text-lg font-medium text-white">Create New Stage</h3>+ <button+ onClick={() => setCreatingStage(false)}+ aria-label="Close"+ className="text-gray-400 hover:text-white"+ >+ ✕+ </button>+ </div><div className="space-y-4"><div className="grid grid-cols-2 gap-4">@@ -909,48 +917,51 @@ export default function PromptManager() {</div></div></div>- </div>- )}+ </Modal>{/* Delete Stage Confirmation Modal */}- {deleteConfirm && (- <div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50 p-4">- <div className="bg-port-card border border-port-border rounded-xl p-6 max-w-md w-full">- <h3 className="text-lg font-medium text-white mb-3">- {deleteConfirm.isSystemStage ? 'Delete System Stage?' : 'Delete Stage?'}- </h3>- {deleteConfirm.isSystemStage ? (- <div className="space-y-2 mb-6">- <p className="text-port-warning text-sm font-medium">- "{deleteConfirm.stageName}" is a system stage.- </p>- {deleteConfirm.usedBy?.length > 0 && (- <p className="text-gray-400 text-sm">Used by: {deleteConfirm.usedBy.join(', ')}</p>- )}- <p className="text-gray-400 text-sm">Deleting this will break PortOS functionality.</p>- </div>- ) : (- <p className="text-gray-400 text-sm mb-6">- Delete "{deleteConfirm.stageName}"? This cannot be undone.+ <Modal+ open={!!deleteConfirm}+ onClose={() => setDeleteConfirm(null)}+ size="sm"+ backdropClassName="bg-black/50"+ ariaLabelledBy="delete-stage-title"+ >+ <div className="bg-port-card border border-port-border rounded-xl p-6">+ <h3 id="delete-stage-title" className="text-lg font-medium text-white mb-3">+ {deleteConfirm?.isSystemStage ? 'Delete System Stage?' : 'Delete Stage?'}+ </h3>+ {deleteConfirm?.isSystemStage ? (+ <div className="space-y-2 mb-6">+ <p className="text-port-warning text-sm font-medium">+ "{deleteConfirm.stageName}" is a system stage.</p>- )}- <div className="flex gap-2 justify-end">- <button- onClick={() => setDeleteConfirm(null)}- className="px-4 py-2 text-gray-400 hover:text-white"- >- Cancel- </button>- <button- onClick={confirmDeleteStage}- className="px-4 py-2 bg-port-error hover:bg-port-error/80 text-white rounded"- >- Delete- </button>+ {deleteConfirm.usedBy?.length > 0 && (+ <p className="text-gray-400 text-sm">Used by: {deleteConfirm.usedBy.join(', ')}</p>+ )}+ <p className="text-gray-400 text-sm">Deleting this will break PortOS functionality.</p></div>+ ) : (+ <p className="text-gray-400 text-sm mb-6">+ Delete "{deleteConfirm?.stageName}"? This cannot be undone.+ </p>+ )}+ <div className="flex gap-2 justify-end">+ <button+ onClick={() => setDeleteConfirm(null)}+ className="px-4 py-2 text-gray-400 hover:text-white"+ >+ Cancel+ </button>+ <button+ onClick={confirmDeleteStage}+ className="px-4 py-2 bg-port-error hover:bg-port-error/80 text-white rounded"+ >+ Delete+ </button></div></div>- )}+ </Modal></div></div>);