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 Add App folder picker mobile rendering via shared Modal + portal
Adam Eivye552ef9f7e67
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 1fd1c83eda..211ef65a6b 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -70,6 +70,7 @@- The Creative Director "Runs" tab now shows why a run failed (e.g. "interrupted by restart") instead of leaving failed runs blank with no explanation.- Creative Director agents are no longer told to run `/do:push` (or open a pull request) when they finish. A CD agent's job is to write its plan or update a scene over the API, not to change code — so the end-of-task "commit and push" instruction was wrong and just made the agent load that command for nothing. They now get a completion step that matches what they actually do.- [issue-2738] **Deleting an image or video now drops your media asset count right away, instead of waiting for a restart.** The media index kept a row for every deleted asset until the next boot swept it up, so the Character sheet's Auteur skill and Media Assets tile — both of which count that index — kept counting media you'd already thrown away. Deletes now retire the row with the file, including for downloaded videos. The boot sweep stays as the backstop for anything removed outside PortOS (a file deleted straight off disk never runs a delete). A failing index removal can't fail the delete itself: the file is already gone, so the row just waits for the next sweep exactly as it used to.+- **The Add App folder picker is now usable on a phone.** On the "glass" day/night themes the Browse-folders dialog opened translucent and mis-placed — the page's "Add App" heading and the detection panel behind it bled straight through the folder list, the "Select Folder" title was pushed off the top of the screen, and the panel ran edge-to-edge with no margin. The dialog was a bare `position: fixed` overlay rendered inside a card that becomes a positioning boundary on those themes (its `backdrop-filter` traps fixed positioning), so it sized itself to the card instead of the viewport. It now renders through the shared modal — portaled to the page root so it always covers the full screen, dims the page behind it, and keeps a gutter from the edge on narrow displays.## Character Sheetdiff --git a/PLAN.md b/PLAN.mdindex e1c752d1f0..78dbc21c20 100644--- a/PLAN.md+++ b/PLAN.md@@ -221,3 +221,12 @@ by `/do:replan --issues`:- [ ] **Resolve a commission's render projects without pulling the whole CD project list.** `client/src/pages/CreativeCommissionDetail.jsx` fetches `listCreativeDirectorProjects()` (every project, non-slim) on load just to index the ≤50 referenced by `runs[].projectId`. It's a single request and matches how the CD list page already loads, but it scales with the install's *total* project count, not the commission's. Once a by-id/batch resolver exists (see the `useVideoFileSrc` follow-up above — same "no by-id endpoint" root cause), swap this to fetch only the referenced projects. Deferred from the detail-page PR to avoid adding a server endpoint in a client-only change.- [ ] **Live-update a commission's freshly-run render instead of asking the user to reload.** After "Run now" on `CreativeCommissionDetail.jsx`, the new run appears immediately as a "no render yet" card, but the CD project generates asynchronously and nothing on the open page refetches when it completes — the render only materializes on a `location.key` refetch (navigation / notification deep-link), so the toast tells the user to reload. Fix once the CD project exposes a completion signal the page can subscribe to (socket event or a lightweight poll of the referenced projects while any run is `started`), then drop the "reload to refresh" clause from the toast. Deferred from the detail-page PR: it needs a CD-generation-completion subscription the page doesn't have today, and the render still arrives correctly on the next navigation in the meantime.- [ ] **Consider extracting the shared run-now/pause/delete commission actions.** The `handleRunNow` / `toggleEnabled` / `handleDelete` handlers now live in both `CreativeCommissions.jsx` (list state — `setCommissions` map/filter) and `CreativeCommissionDetail.jsx` (single-record state — `setCommission`). Two occurrences with genuinely different state shapes, so the rule of three isn't met and a `useCommissionActions` hook would need to abstract over both shapes awkwardly; left as-is. Revisit if a third surface (e.g. a dashboard widget) needs the same actions.++### Hand-rolled `fixed inset-0` overlays trapped by `backdrop-filter` cards (glass themes)++Root cause: the theme rule at `client/src/index.css` (`html[data-port-theme] :is(.bg-port-card,…):is(.border,.rounded,…) { backdrop-filter: var(--port-backdrop-filter); }`) makes every bordered/rounded `.bg-port-card` a containing block for `position:fixed` descendants on "glass" themes (e.g. `lumen-glass-day`). Any hand-rolled `fixed inset-0` overlay rendered *inside* such a card is then sized to the card, not the viewport — the exact bug fixed for `FolderPicker` (migrated to the shared `Modal` + `usePortal`). Precedent for the fix: `GalleryImagePicker.jsx` and the shared `Modal`'s `usePortal` option. These remaining overlays neither portal nor use `Modal` and would break identically *if* opened from inside a themed card — each needs its own "is it actually nested under a card, and does it want portal vs. z-elevation?" check before fixing.++- [ ] **Make the shared `Drawer` primitive portal-capable (highest value).** `client/src/components/Drawer.jsx` (~line 87) renders its `fixed inset-0` backdrop inline, not portaled. It's the shared config-drawer primitive (CLAUDE.md convention) used by many pages, so any instantiation nested under a bordered `.bg-port-card` is trappable on glass themes. Audit its call sites or make the primitive portal its overlay.+- [ ] **`MediaLightbox` — portal its `fixed inset-0 z-50 bg-black/90` overlay** (`client/src/components/media/MediaLightbox.jsx` ~line 229). Trappable when opened from inside a themed gallery card.+- [ ] **`ProcessesTab` fullscreen log modal** (`client/src/components/apps/tabs/ProcessesTab.jsx` ~line 288). `fixed inset-0`, not portaled; rendered inside the app-detail tab tree — trappable if that content sits in a `.bg-port-card`.+- [ ] **Lower priority:** `IconPicker.jsx` (~line 35) transparent click-away catcher (only the catcher shrinks to the card; popover itself is `absolute`), and `Review.jsx` (~line 431) briefing-fullscreen `<section>` toggle (element is itself `.bg-port-card`; depends on ancestors). Confirmed already-safe (no action): `CmdKSearch.jsx` (portaled), `Layout.jsx` mobile backdrop (shell-root sibling), `Ambient.jsx` / `Shell.jsx` (page-root fullscreen). Deferred from the FolderPicker mobile fix to keep that PR scoped to the picker the bug report named; each of these wants its own nesting check + portal-vs-z-elevation decision.diff --git a/client/src/components/FolderPicker.jsx b/client/src/components/FolderPicker.jsxindex 9e586f33d0..51149b9310 100644--- a/client/src/components/FolderPicker.jsx+++ b/client/src/components/FolderPicker.jsx@@ -1,6 +1,7 @@import { useState, useEffect, useRef, useCallback } from 'react';import { Folder, FolderOpen, ChevronUp, HardDrive, Home, X, Check, AlertCircle } from 'lucide-react';import * as api from '../services/api';+import Modal from './ui/Modal.jsx';export default function FolderPicker({ value, onChange, defaultPath }) {const [isOpen, setIsOpen] = useState(false);@@ -10,7 +11,6 @@ export default function FolderPicker({ value, onChange, defaultPath }) {const [drives, setDrives] = useState(null);const [loading, setLoading] = useState(false);const [error, setError] = useState(null);- const modalRef = useRef(null);// Remember when `defaultPath` has already failed once so re-opens skip the// wasted round trip (and the server-side 400 it logs). Ref-not-state because// changing it must not re-trigger the open effect.@@ -74,32 +74,6 @@ export default function FolderPicker({ value, onChange, defaultPath }) {defaultPathUnavailableRef.current = false;}, [defaultPath]);- // Close on click outside- useEffect(() => {- const handleClickOutside = (e) => {- if (modalRef.current && !modalRef.current.contains(e.target)) {- setIsOpen(false);- }- };-- if (isOpen) {- document.addEventListener('mousedown', handleClickOutside);- return () => document.removeEventListener('mousedown', handleClickOutside);- }- }, [isOpen]);-- // Close on Escape- useEffect(() => {- const handleEscape = (e) => {- if (e.key === 'Escape') setIsOpen(false);- };-- if (isOpen) {- document.addEventListener('keydown', handleEscape);- return () => document.removeEventListener('keydown', handleEscape);- }- }, [isOpen]);-const handleSelect = () => {onChange(currentPath);setIsOpen(false);@@ -110,7 +84,7 @@ export default function FolderPicker({ value, onChange, defaultPath }) {};return (- <div className="relative">+ <div><buttontype="button"onClick={() => setIsOpen(true)}@@ -121,142 +95,146 @@ export default function FolderPicker({ value, onChange, defaultPath }) {<Folder size={20} /></button>+ {/* Only mount the Modal while open so its children (the directory list in+ particular) aren't rebuilt on every parent re-render while closed.+ usePortal renders the overlay at <body> so the fixed positioning+ escapes any backdrop-filter / transform ancestor (e.g. the enclosing+ bg-port-card card, which becomes a containing block on "glass" themes)+ — otherwise the overlay is trapped inside that card and mis-positioned+ on mobile. */}{isOpen && (- <div- className="fixed inset-0 bg-black/50 flex items-center justify-center z-50"- role="dialog"- aria-modal="true"- aria-labelledby="folder-picker-title"+ <Modal+ open+ onClose={() => setIsOpen(false)}+ size="md"+ usePortal+ ariaLabelledBy="folder-picker-title"+ panelClassName="bg-port-card border border-port-border rounded-xl max-h-[80vh] flex flex-col shadow-2xl">- <div- ref={modalRef}- className="bg-port-card border border-port-border rounded-xl w-full max-w-lg max-h-[80vh] flex flex-col shadow-2xl"- >- {/* Header */}- <div className="flex items-center justify-between p-4 border-b border-port-border">- <h3 id="folder-picker-title" className="text-lg font-semibold text-white">Select Folder</h3>- <button- type="button"- onClick={() => setIsOpen(false)}- className="p-1 text-gray-400 hover:text-white"- aria-label="Close folder picker"- >- <X size={20} />- </button>- </div>+ {/* Header */}+ <div className="flex items-center justify-between p-4 border-b border-port-border">+ <h3 id="folder-picker-title" className="text-lg font-semibold text-white">Select Folder</h3>+ <button+ type="button"+ onClick={() => setIsOpen(false)}+ className="p-1 text-gray-400 hover:text-white"+ aria-label="Close folder picker"+ >+ <X size={20} />+ </button>+ </div>- {/* Current Path + Quick Nav */}- <div className="px-4 py-2 bg-port-bg border-b border-port-border flex items-center gap-2">- <p className="flex-1 text-sm font-mono text-gray-400 truncate" title={currentPath}>- {currentPath}- </p>- {/* Home directory button */}- <button- type="button"- onClick={() => handleNavigate('~')}- className="p-1 text-gray-500 hover:text-white shrink-0"- title="Home directory"- >- <Home size={16} />- </button>+ {/* Current Path + Quick Nav */}+ <div className="px-4 py-2 bg-port-bg border-b border-port-border flex items-center gap-2">+ <p className="flex-1 text-sm font-mono text-gray-400 truncate" title={currentPath}>+ {currentPath}+ </p>+ {/* Home directory button */}+ <button+ type="button"+ onClick={() => handleNavigate('~')}+ className="p-1 text-gray-500 hover:text-white shrink-0"+ title="Home directory"+ >+ <Home size={16} />+ </button>+ </div>++ {/* Windows Drive Selector */}+ {drives && drives.length > 0 && (+ <div className="px-4 py-2 border-b border-port-border flex items-center gap-1 flex-wrap">+ <HardDrive size={14} className="text-gray-500 shrink-0 mr-1" />+ {drives.map((drive) => (+ <button+ key={drive}+ type="button"+ onClick={() => handleNavigate(drive)}+ className={`px-2 py-0.5 text-xs font-mono rounded transition-colors ${+ currentPath.toUpperCase().startsWith(drive.charAt(0).toUpperCase())+ ? 'bg-port-accent text-white'+ : 'bg-port-border text-gray-400 hover:text-white hover:bg-port-border/80'+ }`}+ >+ {drive.charAt(0)}:+ </button>+ ))}</div>+ )}- {/* Windows Drive Selector */}- {drives && drives.length > 0 && (- <div className="px-4 py-2 border-b border-port-border flex items-center gap-1 flex-wrap">- <HardDrive size={14} className="text-gray-500 shrink-0 mr-1" />- {drives.map((drive) => (+ {/* Directory List */}+ <div className="flex-1 overflow-auto p-2 min-h-[300px]">+ {loading ? (+ <div className="flex items-center justify-center h-full text-gray-500">+ Loading...+ </div>+ ) : error ? (+ <div className="flex flex-col items-center justify-center h-full gap-2 text-gray-500 px-4">+ <AlertCircle size={24} className="text-port-error" />+ <p className="text-sm text-center">{error}</p>+ <button+ type="button"+ onClick={() => loadDirectory(null)}+ className="mt-2 text-xs text-port-accent hover:underline"+ >+ Go to default directory+ </button>+ </div>+ ) : (+ <div className="space-y-1">+ {/* Go Up */}+ {parentPath && (<button- key={drive}type="button"- onClick={() => handleNavigate(drive)}- className={`px-2 py-0.5 text-xs font-mono rounded transition-colors ${- currentPath.toUpperCase().startsWith(drive.charAt(0).toUpperCase())- ? 'bg-port-accent text-white'- : 'bg-port-border text-gray-400 hover:text-white hover:bg-port-border/80'- }`}+ onClick={() => handleNavigate(parentPath)}+ className="w-full flex items-center gap-3 px-3 py-2 text-left rounded-lg hover:bg-port-border/50 text-gray-400 hover:text-white transition-colors">- {drive.charAt(0)}:+ <ChevronUp size={18} />+ <span>..</span></button>- ))}- </div>- )}+ )}- {/* Directory List */}- <div className="flex-1 overflow-auto p-2 min-h-[300px]">- {loading ? (- <div className="flex items-center justify-center h-full text-gray-500">- Loading...- </div>- ) : error ? (- <div className="flex flex-col items-center justify-center h-full gap-2 text-gray-500 px-4">- <AlertCircle size={24} className="text-port-error" />- <p className="text-sm text-center">{error}</p>+ {/* Directories */}+ {directories.map((dir) => (<button+ key={dir.path}type="button"- onClick={() => loadDirectory(null)}- className="mt-2 text-xs text-port-accent hover:underline"+ onClick={() => handleNavigate(dir.path)}+ className="w-full flex items-center gap-3 px-3 py-2 text-left rounded-lg hover:bg-port-border/50 text-white transition-colors">- Go to default directory+ <FolderOpen size={18} className="text-port-accent shrink-0" />+ <span className="truncate">{dir.name}</span></button>- </div>- ) : (- <div className="space-y-1">- {/* Go Up */}- {parentPath && (- <button- type="button"- onClick={() => handleNavigate(parentPath)}- className="w-full flex items-center gap-3 px-3 py-2 text-left rounded-lg hover:bg-port-border/50 text-gray-400 hover:text-white transition-colors"- >- <ChevronUp size={18} />- <span>..</span>- </button>- )}-- {/* Directories */}- {directories.map((dir) => (- <button- key={dir.path}- type="button"- onClick={() => handleNavigate(dir.path)}- className="w-full flex items-center gap-3 px-3 py-2 text-left rounded-lg hover:bg-port-border/50 text-white transition-colors"- >- <FolderOpen size={18} className="text-port-accent shrink-0" />- <span className="truncate">{dir.name}</span>- </button>- ))}+ ))}- {directories.length === 0 && !parentPath && (- <div className="text-center text-gray-500 py-8">- No subdirectories- </div>- )}- </div>- )}- </div>+ {directories.length === 0 && !parentPath && (+ <div className="text-center text-gray-500 py-8">+ No subdirectories+ </div>+ )}+ </div>+ )}+ </div>- {/* Footer */}- <div className="flex items-center justify-between gap-3 p-4 border-t border-port-border">- <button- type="button"- onClick={() => setIsOpen(false)}- className="px-4 py-2 text-gray-400 hover:text-white transition-colors"- >- Cancel- </button>- <button- type="button"- onClick={handleSelect}- disabled={!currentPath || loading || !!error}- className="flex items-center gap-2 px-4 py-2 bg-port-accent hover:bg-port-accent/80 text-white rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed"- >- <Check size={18} />- Select This Folder- </button>- </div>+ {/* Footer */}+ <div className="flex items-center justify-between gap-3 p-4 border-t border-port-border">+ <button+ type="button"+ onClick={() => setIsOpen(false)}+ className="px-4 py-2 text-gray-400 hover:text-white transition-colors"+ >+ Cancel+ </button>+ <button+ type="button"+ onClick={handleSelect}+ disabled={!currentPath || loading || !!error}+ className="flex items-center gap-2 px-4 py-2 bg-port-accent hover:bg-port-accent/80 text-white rounded-lg transition-colors disabled:opacity-50 disabled:cursor-not-allowed"+ >+ <Check size={18} />+ Select This Folder+ </button></div>- </div>+ </Modal>)}</div>);diff --git a/client/src/components/FolderPicker.test.jsx b/client/src/components/FolderPicker.test.jsxnew file mode 100644index 0000000000..2bef241371--- /dev/null+++ b/client/src/components/FolderPicker.test.jsx@@ -0,0 +1,45 @@+import { describe, it, expect, vi, beforeEach } from 'vitest';+import { render, screen, fireEvent } from '@testing-library/react';++// FolderPicker imports `* as api` and only calls getDirectories once its+// picker opens.+vi.mock('../services/api', () => ({+ getDirectories: vi.fn(),+}));++import * as api from '../services/api';+import FolderPicker from './FolderPicker';++beforeEach(() => {+ api.getDirectories.mockResolvedValue({+ currentPath: '/Users/example/projects',+ parentPath: '/Users/example',+ directories: [{ name: 'my-app', path: '/Users/example/projects/my-app' }],+ drives: null,+ });+});++describe('FolderPicker responsive overlay', () => {+ it('portals the dialog to <body>, escaping a backdrop-filter containing-block ancestor', async () => {+ // Mirror the Add App layout: the picker lives inside a `bg-port-card` card+ // that gains `backdrop-filter` on "glass" themes. A backdrop-filter ancestor+ // becomes the containing block for position:fixed descendants, so an inline+ // (non-portaled) overlay would be trapped inside the card and mis-sized on+ // mobile instead of covering the viewport. usePortal must move the overlay+ // to <body> to escape that trap.+ const { container } = render(+ <div style={{ backdropFilter: 'blur(22px)' }} data-testid="glass-card">+ <FolderPicker value="" onChange={() => {}} />+ </div>+ );++ fireEvent.click(screen.getByRole('button', { name: 'Browse folders' }));++ const dialog = await screen.findByRole('dialog');+ const glassCard = screen.getByTestId('glass-card');+ expect(glassCard.contains(dialog)).toBe(false);+ expect(document.body.contains(dialog)).toBe(true);+ // The component's own rendered subtree holds only the trigger button.+ expect(container.querySelector('[role="dialog"]')).toBeNull();+ });+});