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
feat(ui): universal FolderPicker — Sharing + Backup + Templates
[._.]/ Adam Eivyf0eb95305715
diff --git a/.changelog/NEXT.md b/.changelog/NEXT.mdindex 52f0b24b7c..ae83b7f5be 100644--- a/.changelog/NEXT.md+++ b/.changelog/NEXT.md@@ -2,6 +2,17 @@## Added+- **Universal folder-picker UX — Sharing + Backup + Templates.**+ Three places that ask the user for a server-side folder path now all+ use the same `FolderPicker` component (a folder-icon button that opens+ a modal directory browser backed by `GET /api/scaffold/directories`).+ Wired into the Sharing page's add-bucket form and the Backup settings+ tab so the user no longer has to hand-type a path. Migrated+ `Templates.jsx` off its inline-dropdown `DirectoryPicker` so the+ codebase converges on a single picker primitive; `DirectoryPicker.jsx`+ removed. The picker's existing UX (modal overlay, Windows drive+ selector, Home shortcut, click-outside/Escape) is preserved.+- **Sharing v1.2 — schema versioning + producedBy attribution.**Defensive plumbing so PortOS version drift between peers fails loudlyinstead of silently corrupting shares. Every outgoing artifact (manifestsdiff --git a/client/src/components/DirectoryPicker.jsx b/client/src/components/DirectoryPicker.jsxdeleted file mode 100644index 1f2af06638..0000000000--- a/client/src/components/DirectoryPicker.jsx+++ /dev/null@@ -1,141 +0,0 @@-import { useState, useEffect, useCallback } from 'react';-import { Folder, ChevronRight, Home, ArrowUp, Loader2 } from 'lucide-react';-import * as api from '../services/api';--export default function DirectoryPicker({ value, onChange, label = 'Select Directory' }) {- const [currentPath, setCurrentPath] = useState('');- const [parentPath, setParentPath] = useState(null);- const [directories, setDirectories] = useState([]);- const [loading, setLoading] = useState(false);- const [error, setError] = useState(null);- const [isOpen, setIsOpen] = useState(false);-- const loadDirectories = useCallback(async (path = null, setAsValue = false) => {- setLoading(true);- setError(null);-- const result = await api.getDirectories(path).catch(err => {- setError(err.message);- return null;- });-- if (result) {- setCurrentPath(result.currentPath);- setParentPath(result.parentPath);- setDirectories(result.directories);- // Auto-set the value if requested (e.g., on initial load with no value)- if (setAsValue && result.currentPath) {- onChange(result.currentPath);- }- }-- setLoading(false);- }, [onChange]);-- useEffect(() => {- // Load directories and auto-set value if none provided- loadDirectories(value || null, !value);- }, [loadDirectories, value]);-- const handleSelectDirectory = (dirPath) => {- onChange(dirPath);- setIsOpen(false);- };-- const handleNavigate = (path) => {- loadDirectories(path);- };-- return (- <div className="relative">- <label className="block text-sm text-gray-400 mb-1">{label} *</label>-- {/* Selected Directory Display */}- <button- type="button"- onClick={() => setIsOpen(!isOpen)}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white focus:border-port-accent focus:outline-hidden font-mono text-left flex items-center justify-between"- >- <span className="truncate">{value || currentPath || 'Select a directory...'}</span>- <ChevronRight size={16} className={`shrink-0 transition-transform ${isOpen ? 'rotate-90' : ''}`} />- </button>-- {/* Directory Browser Dropdown */}- {isOpen && (- <div className="absolute z-50 mt-1 w-full bg-port-card border border-port-border rounded-lg shadow-xl max-h-96 overflow-hidden flex flex-col">- {/* Current Path Header */}- <div className="sticky top-0 bg-port-card border-b border-port-border p-3 flex items-center gap-2">- <Folder size={16} className="text-port-accent shrink-0" />- <span className="text-sm text-gray-400 truncate font-mono">{currentPath}</span>- </div>-- {/* Navigation Controls */}- <div className="border-b border-port-border p-2 flex gap-2">- {parentPath && (- <button- type="button"- onClick={() => handleNavigate(parentPath)}- className="flex items-center gap-2 px-3 py-1.5 text-sm text-gray-400 hover:text-white hover:bg-port-border rounded transition-colors"- disabled={loading}- >- <ArrowUp size={14} />- <span>Parent</span>- </button>- )}- <button- type="button"- onClick={() => handleNavigate(null)}- className="flex items-center gap-2 px-3 py-1.5 text-sm text-gray-400 hover:text-white hover:bg-port-border rounded transition-colors"- disabled={loading}- >- <Home size={14} />- <span>Default</span>- </button>- <button- type="button"- onClick={() => handleSelectDirectory(currentPath)}- className="ml-auto px-3 py-1.5 text-sm bg-port-accent hover:bg-port-accent/80 text-white rounded transition-colors"- disabled={loading}- >- Select Current- </button>- </div>-- {/* Directory List */}- <div className="overflow-y-auto flex-1">- {loading ? (- <div className="flex items-center justify-center p-8">- <Loader2 size={24} className="text-gray-500 animate-spin" />- </div>- ) : error ? (- <div className="p-4 text-center text-port-error text-sm">{error}</div>- ) : directories.length === 0 ? (- <div className="p-4 text-center text-gray-500 text-sm">No subdirectories</div>- ) : (- <div className="p-2">- {directories.map(dir => (- <button- key={dir.path}- type="button"- onClick={() => handleNavigate(dir.path)}- onDoubleClick={() => handleSelectDirectory(dir.path)}- className="w-full flex items-center gap-2 px-3 py-2 text-sm text-gray-300 hover:text-white hover:bg-port-border rounded transition-colors group"- >- <Folder size={14} className="text-gray-500 group-hover:text-port-accent shrink-0" />- <span className="truncate">{dir.name}</span>- <ChevronRight size={14} className="ml-auto shrink-0 text-gray-600 group-hover:text-gray-400" />- </button>- ))}- </div>- )}- </div>-- {/* Footer Help */}- <div className="border-t border-port-border p-2 text-xs text-gray-500">- Double-click a folder to select it, or use "Select Current"- </div>- </div>- )}- </div>- );-}diff --git a/client/src/components/settings/BackupTab.jsx b/client/src/components/settings/BackupTab.jsxindex a0a26d260a..62dd5dbb38 100644--- a/client/src/components/settings/BackupTab.jsx+++ b/client/src/components/settings/BackupTab.jsx@@ -3,6 +3,7 @@ import { Save, Plus, X, Play, ShieldOff } from 'lucide-react';import toast from '../ui/Toast';import BrailleSpinner from '../BrailleSpinner';import ToggleSwitch from '../ToggleSwitch';+import FolderPicker from '../FolderPicker';import useAsyncAction from '../../hooks/useAsyncAction';import { getSettings, updateSettings, getBackupStatus, triggerBackup } from '../../services/api';@@ -147,13 +148,16 @@ export function BackupTab() {<div className="bg-port-card border border-port-border rounded-xl p-4 sm:p-6 space-y-5"><div className="space-y-1"><label className="block text-sm text-gray-400">Destination Path</label>- <input- type="text"- value={destPath}- onChange={e => setDestPath(e.target.value)}- className="w-full bg-port-bg border border-port-border rounded-lg px-3 py-2 text-sm text-white focus:outline-none focus:border-port-accent"- placeholder="/path/to/backups"- />+ <div className="flex gap-2 items-stretch">+ <input+ type="text"+ value={destPath}+ onChange={e => setDestPath(e.target.value)}+ className="flex-1 min-w-0 bg-port-bg border border-port-border rounded-lg px-3 py-2 text-sm text-white focus:outline-none focus:border-port-accent"+ placeholder="/path/to/backups"+ />+ <FolderPicker value={destPath} onChange={setDestPath} />+ </div></div><div className="flex items-center gap-3">diff --git a/client/src/pages/Sharing.jsx b/client/src/pages/Sharing.jsxindex e5ae4fd534..dd36ac0d40 100644--- a/client/src/pages/Sharing.jsx+++ b/client/src/pages/Sharing.jsx@@ -12,6 +12,7 @@ import {Share2, Plus, Trash2, Folder, Inbox, History, Save, Loader2, Check, X, Users, AlertCircle,} from 'lucide-react';import toast from '../components/ui/Toast';+import FolderPicker from '../components/FolderPicker';import socket from '../services/socket';import {listShareBuckets, createShareBucket, updateShareBucket, deleteShareBucket,@@ -292,13 +293,19 @@ export default function Sharing() {<label className="block text-xs uppercase tracking-wider text-gray-500 mb-1">Folder path</label>- <input- type="text"- value={form.path}- onChange={(e) => setForm((f) => ({ ...f, path: e.target.value }))}- placeholder="/Users/you/Library/CloudStorage/GoogleDrive-…/PortOS Shares/creative-circle"- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded text-white text-sm font-mono"- />+ <div className="flex gap-2 items-stretch">+ <input+ type="text"+ value={form.path}+ onChange={(e) => setForm((f) => ({ ...f, path: e.target.value }))}+ placeholder="/Users/you/Library/CloudStorage/GoogleDrive-…/PortOS Shares/creative-circle"+ className="flex-1 min-w-0 px-3 py-2 bg-port-bg border border-port-border rounded text-white text-sm font-mono"+ />+ <FolderPicker+ value={form.path}+ onChange={(path) => setForm((f) => ({ ...f, path }))}+ />+ </div><p className="text-[11px] text-gray-500 mt-1">Pick a folder that's synced by your cloud-storage app. PortOS will create <code>manifests/</code>, <code>records/</code>, and <code>assets/</code> inside it.</p>diff --git a/client/src/pages/Templates.jsx b/client/src/pages/Templates.jsxindex ff85a22a7f..844489b06f 100644--- a/client/src/pages/Templates.jsx+++ b/client/src/pages/Templates.jsx@@ -2,7 +2,7 @@ import { useState, useEffect } from 'react';import { useNavigate } from 'react-router-dom';import { Layers, Code, Server, Globe, Smartphone, MonitorSmartphone, Plus } from 'lucide-react';import * as api from '../services/api';-import DirectoryPicker from '../components/DirectoryPicker';+import FolderPicker from '../components/FolderPicker';const ICONS = {layers: Layers,@@ -115,11 +115,18 @@ export default function Templates() {</div><div>- <DirectoryPicker- value={targetPath}- onChange={setTargetPath}- label="Target Directory"- />+ <label className="block text-sm text-gray-400 mb-1">Target Directory *</label>+ <div className="flex gap-2 items-stretch">+ <input+ type="text"+ value={targetPath}+ onChange={(e) => setTargetPath(e.target.value)}+ placeholder="/path/to/parent/directory"+ required+ className="flex-1 min-w-0 px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white font-mono text-sm focus:border-port-accent focus:outline-hidden"+ />+ <FolderPicker value={targetPath} onChange={setTargetPath} />+ </div><p className="text-xs text-gray-500 mt-1">App will be created at: {targetPath ? `${targetPath}/${appName || 'app-name'}` : '...'}</p>