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: dashboard grid layout with quick-entry widgets
Adam Eivybcabd5f068f2
diff --git a/.changelog/v0.25.x.md b/.changelog/v0.25.x.mdindex 74c43379cf..920a6d613b 100644--- a/.changelog/v0.25.x.md+++ b/.changelog/v0.25.x.md@@ -14,6 +14,13 @@ Peer apps display and remote agent streaming on the Instances page — see what'- **Socket.IO peer relay** — local server connects as a Socket.IO client to each online peer, subscribes to agent events, and forwards them to the Instances page- **AgentCard remote mode** — `remote` prop disables local-only features (process stats polling, full output fetch, feedback, kill/delete buttons) and shows a peer name badge+### Dashboard grid layout redesign+- **Responsive grid layout** — Dashboard sections now use a CSS grid instead of vertically stacked full-width cards: System Health + Quick Stats side-by-side at lg, CoS/Goals/Tasks in a 3-column row, Activity Streak + Heatmap side-by-side; everything stacks single-column on mobile+- **Quick Brain Capture widget** — capture thoughts or paste URLs directly from the dashboard; auto-detects URLs vs. text and routes to the appropriate Brain API+- **Quick Task widget** — add CoS tasks from the dashboard via a compact form with expandable "More options" for provider, model, worktree, screenshots, etc.+- **Extracted TaskAddForm component** — the task add form is now a shared component (`TaskAddForm.jsx`) used by both the CoS Tasks page (full mode) and the dashboard widget (compact mode)+- **Replaced `window.prompt()`** — template save now uses an inline text input instead of `window.prompt()`, complying with the no-browser-dialogs rule+## Improvements### Event-driven CoS evaluation architecturediff --git a/client/src/components/QuickBrainCapture.jsx b/client/src/components/QuickBrainCapture.jsxnew file mode 100644index 0000000000..33ea6b2a84--- /dev/null+++ b/client/src/components/QuickBrainCapture.jsx@@ -0,0 +1,91 @@+import { useState, useMemo } from 'react';+import { Link } from 'react-router-dom';+import { Send, Loader2 } from 'lucide-react';+import toast from 'react-hot-toast';+import * as api from '../services/api';++const URL_PATTERN = /^(https?:\/\/|git@)/i;+const DOMAIN_PATTERN = /^\S+\.\S+$/;++export default function QuickBrainCapture() {+ const [input, setInput] = useState('');+ const [sending, setSending] = useState(false);++ const isUrl = useMemo(() => {+ const trimmed = input.trim();+ if (!trimmed) return false;+ return URL_PATTERN.test(trimmed) || DOMAIN_PATTERN.test(trimmed);+ }, [input]);++ const handleSubmit = async (e) => {+ e?.preventDefault();+ const text = input.trim();+ if (!text || sending) return;++ setSending(true);++ if (isUrl) {+ let url = text;+ if (!url.startsWith('http://') && !url.startsWith('https://') && !url.startsWith('git@')) {+ url = 'https://' + url;+ }+ const result = await api.createBrainLink({ url }).catch(err => {+ if (err.message?.includes('already exists')) {+ toast.error('This URL is already saved');+ } else {+ toast.error(err.message || 'Failed to save link');+ }+ return null;+ });+ if (result) {+ toast.success(result.isGitHubRepo ? 'GitHub repo added' : 'Link saved');+ setInput('');+ }+ } else {+ const result = await api.captureBrainThought(text).catch(err => {+ toast.error(err.message || 'Failed to capture thought');+ return null;+ });+ if (result) {+ toast.success(result.message || 'Thought captured');+ setInput('');+ }+ }++ setSending(false);+ };++ return (+ <div className="bg-port-card border border-port-border rounded-xl p-4">+ <div className="flex items-center justify-between mb-3">+ <h3 className="text-sm font-semibold text-white">Quick Capture</h3>+ <Link to="/brain/inbox" className="text-xs text-gray-500 hover:text-port-accent transition-colors">+ Brain →+ </Link>+ </div>+ <form onSubmit={handleSubmit} className="flex gap-2">+ <label htmlFor="quick-brain-input" className="sr-only">Capture a thought or URL</label>+ <input+ id="quick-brain-input"+ type="text"+ placeholder="Thought, URL, or link..."+ value={input}+ onChange={e => setInput(e.target.value)}+ className="flex-1 px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"+ />+ <button+ type="submit"+ disabled={!input.trim() || sending}+ className="flex items-center gap-1 px-3 py-2 bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded-lg text-sm transition-colors disabled:opacity-50 min-h-[40px]"+ >+ {sending ? <Loader2 size={14} className="animate-spin" /> : <Send size={14} />}+ </button>+ </form>+ {input.trim() && (+ <p className="mt-2 text-xs text-gray-500">+ {isUrl ? 'Will save as link' : 'Will capture as thought'}+ </p>+ )}+ </div>+ );+}diff --git a/client/src/components/QuickTaskWidget.jsx b/client/src/components/QuickTaskWidget.jsxnew file mode 100644index 0000000000..25b2a8df75--- /dev/null+++ b/client/src/components/QuickTaskWidget.jsx@@ -0,0 +1,26 @@+import { useState, useEffect } from 'react';+import { Link } from 'react-router-dom';+import * as api from '../services/api';+import TaskAddForm from './cos/TaskAddForm';++export default function QuickTaskWidget() {+ const [providers, setProviders] = useState([]);+ const [apps, setApps] = useState([]);++ useEffect(() => {+ api.getProviders().then(data => setProviders(data.providers || [])).catch(() => setProviders([]));+ api.getApps().then(setApps).catch(() => setApps([]));+ }, []);++ return (+ <div className="bg-port-card border border-port-border rounded-xl p-4">+ <div className="flex items-center justify-between mb-3">+ <h3 className="text-sm font-semibold text-white">Quick Task</h3>+ <Link to="/cos/tasks" className="text-xs text-gray-500 hover:text-port-accent transition-colors">+ Tasks →+ </Link>+ </div>+ <TaskAddForm providers={providers} apps={apps} onTaskAdded={() => {}} compact />+ </div>+ );+}diff --git a/client/src/components/cos/TaskAddForm.jsx b/client/src/components/cos/TaskAddForm.jsxnew file mode 100644index 0000000000..07c3817905--- /dev/null+++ b/client/src/components/cos/TaskAddForm.jsx@@ -0,0 +1,607 @@+import { useState, useEffect, useRef, useMemo, useCallback } from 'react';+import { Plus, Image, X, ChevronDown, ChevronRight, Sparkles, Loader2, Paperclip, FileText, Zap, Bookmark, Ticket, GitBranch } from 'lucide-react';+import toast from 'react-hot-toast';+import * as api from '../../services/api';+import { processScreenshotUploads, processAttachmentUploads, formatFileSize } from '../../utils/fileUpload';++export default function TaskAddForm({ providers, apps, onTaskAdded, compact = false }) {+ const [newTask, setNewTask] = useState({ description: '', context: '', model: '', provider: '', app: '' });+ const [addToTop, setAddToTop] = useState(false);+ const [enhancePrompt, setEnhancePrompt] = useState(false);+ const [isEnhancing, setIsEnhancing] = useState(false);+ const [useWorktree, setUseWorktree] = useState(false);+ const [createJiraTicket, setCreateJiraTicket] = useState(false);+ const [screenshots, setScreenshots] = useState([]);+ const [attachments, setAttachments] = useState([]);+ const [templates, setTemplates] = useState([]);+ const [showTemplates, setShowTemplates] = useState(false);+ const [expanded, setExpanded] = useState(false);+ const [templateNameInput, setTemplateNameInput] = useState('');+ const [showTemplateSave, setShowTemplateSave] = useState(false);+ const fileInputRef = useRef(null);+ const attachmentInputRef = useRef(null);++ // Fetch templates+ useEffect(() => {+ api.getCosPopularTemplates(8)+ .then(data => setTemplates(data.templates || []))+ .catch(() => setTemplates([]));+ }, []);++ // Memoize enabled providers for dropdown+ const enabledProviders = useMemo(() =>+ providers?.filter(p => p.enabled) || [],+ [providers]+ );++ // Check if selected app has JIRA configured+ const selectedApp = useMemo(() =>+ apps?.find(a => a.id === newTask.app),+ [apps, newTask.app]+ );+ const appHasJira = selectedApp?.jira?.enabled;++ // Auto-toggle JIRA and worktree checkboxes when app selection changes+ useEffect(() => {+ const app = apps?.find(a => a.id === newTask.app);+ setCreateJiraTicket(!!app?.jira?.enabled);+ setUseWorktree(!!app?.defaultUseWorktree);+ }, [newTask.app, apps]);++ // Get models for selected provider+ const selectedProvider = providers?.find(p => p.id === newTask.provider);+ const availableModels = selectedProvider?.models || [];++ // Apply template to form+ const applyTemplate = useCallback(async (template) => {+ setNewTask({+ description: template.description,+ context: template.context || '',+ model: template.model || '',+ provider: template.provider || '',+ app: template.app || ''+ });+ await api.useCosTaskTemplate(template.id).catch(() => {});+ toast.success(`Template applied: ${template.name}`);+ }, []);++ // Save current form as template (inline input instead of window.prompt)+ const saveAsTemplate = useCallback(async () => {+ if (!newTask.description.trim()) {+ toast.error('Enter a task description first');+ return;+ }++ if (!showTemplateSave) {+ setTemplateNameInput(newTask.description.substring(0, 40));+ setShowTemplateSave(true);+ return;+ }++ if (!templateNameInput.trim()) {+ toast.error('Template name is required');+ return;+ }++ const result = await api.createCosTaskTemplate({+ name: templateNameInput.trim(),+ description: newTask.description,+ context: newTask.context,+ provider: newTask.provider,+ model: newTask.model,+ app: newTask.app+ }).catch(err => {+ toast.error(err.message);+ return null;+ });++ if (result?.success) {+ toast.success('Template saved');+ setShowTemplateSave(false);+ setTemplateNameInput('');+ api.getCosPopularTemplates(8)+ .then(data => setTemplates(data.templates || []))+ .catch(() => {});+ }+ }, [newTask, templateNameInput, showTemplateSave]);++ // Delete a user template+ const deleteTemplate = useCallback(async (templateId, e) => {+ e.stopPropagation();+ const result = await api.deleteCosTaskTemplate(templateId).catch(err => {+ toast.error(err.message);+ return null;+ });+ if (result?.success) {+ toast.success('Template deleted');+ setTemplates(prev => prev.filter(t => t.id !== templateId));+ }+ }, []);++ // Screenshot handling+ const handleFileSelect = async (e) => {+ await processScreenshotUploads(e.target.files, {+ onSuccess: (fileInfo) => setScreenshots(prev => [...prev, fileInfo]),+ onError: (msg) => toast.error(msg)+ });+ e.target.value = '';+ };++ const removeScreenshot = (id) => {+ setScreenshots(prev => prev.filter(s => s.id !== id));+ };++ // Attachment handling+ const handleAttachmentSelect = async (e) => {+ await processAttachmentUploads(e.target.files, {+ onSuccess: (fileInfo) => setAttachments(prev => [...prev, fileInfo]),+ onError: (msg) => toast.error(msg)+ });+ e.target.value = '';+ };++ const removeAttachment = (id) => {+ setAttachments(prev => prev.filter(a => a.id !== id));+ };++ const handleAddTask = async () => {+ if (!newTask.description.trim()) {+ toast.error('Description is required');+ return;+ }++ let finalDescription = newTask.description;++ if (enhancePrompt) {+ setIsEnhancing(true);+ const enhanceResult = await api.enhanceCosTaskPrompt({+ description: newTask.description,+ context: newTask.context+ }).catch(err => {+ toast('Enhancement failed, using original description', { icon: '\u26a0\ufe0f' });+ console.warn('Task enhancement failed:', err.message);+ return null;+ });++ if (enhanceResult?.enhancedDescription?.trim()) {+ finalDescription = enhanceResult.enhancedDescription;+ toast.success('Prompt enhanced');+ } else if (enhanceResult) {+ toast('Enhancement returned empty result, using original', { icon: '\u26a0\ufe0f' });+ }++ setIsEnhancing(false);+ }++ await api.addCosTask({+ description: finalDescription,+ context: newTask.context,+ model: newTask.model || undefined,+ provider: newTask.provider || undefined,+ app: newTask.app || undefined,+ createJiraTicket: createJiraTicket || undefined,+ useWorktree: useWorktree || undefined,+ screenshots: screenshots.length > 0 ? screenshots.map(s => s.path) : undefined,+ attachments: attachments.length > 0 ? attachments.map(a => ({+ filename: a.filename,+ originalName: a.originalName,+ path: a.path,+ size: a.size,+ mimeType: a.mimeType+ })) : undefined,+ position: addToTop ? 'top' : 'bottom'+ }).catch(err => {+ toast.error(err.message);+ return;+ });++ toast.success('Task added');+ setNewTask({ description: '', context: '', model: '', provider: '', app: '' });+ setScreenshots([]);+ setAttachments([]);+ setAddToTop(false);+ setEnhancePrompt(false);+ setCreateJiraTicket(false);+ setUseWorktree(false);+ setExpanded(false);+ onTaskAdded?.();+ };++ // Compact mode: single row with description + app + add, expandable+ if (compact) {+ return (+ <div className="space-y-3">+ <div className="flex gap-2">+ <label htmlFor="compact-task-desc" className="sr-only">Task description (required)</label>+ <input+ id="compact-task-desc"+ type="text"+ placeholder="Task description *"+ value={newTask.description}+ onChange={e => setNewTask(t => ({ ...t, description: e.target.value }))}+ onKeyDown={e => e.key === 'Enter' && !e.shiftKey && handleAddTask()}+ className="flex-1 px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"+ aria-required="true"+ />+ <label htmlFor="compact-task-app" className="sr-only">Target application</label>+ <select+ id="compact-task-app"+ value={newTask.app}+ onChange={e => setNewTask(t => ({ ...t, app: e.target.value }))}+ className="w-32 px-2 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"+ >+ <option value="">PortOS</option>+ {apps?.map(app => (+ <option key={app.id} value={app.id}>{app.name}</option>+ ))}+ </select>+ <button+ onClick={handleAddTask}+ disabled={isEnhancing}+ className="flex items-center gap-1 px-3 py-2 bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded-lg text-sm transition-colors disabled:opacity-50 min-h-[40px]"+ >+ {isEnhancing ? <Loader2 size={14} className="animate-spin" /> : <Plus size={14} />}+ Add+ </button>+ </div>+ <button+ onClick={() => setExpanded(!expanded)}+ className="flex items-center gap-1 text-xs text-gray-500 hover:text-gray-300 transition-colors"+ aria-expanded={expanded}+ >+ {expanded ? <ChevronDown size={12} /> : <ChevronRight size={12} />}+ More options+ </button>+ {expanded && (+ <div className="space-y-3 pt-1">+ {renderFullFormFields()}+ </div>+ )}+ </div>+ );+ }++ // Full mode: identical to original TasksTab form+ return (+ <div className="bg-port-card border border-port-accent/50 rounded-lg p-4 mb-4" role="form" aria-label="Add new task">+ {/* Quick Templates */}+ {templates.length > 0 && (+ <div className="mb-4">+ <button+ onClick={() => setShowTemplates(!showTemplates)}+ className="flex items-center gap-2 text-sm text-gray-400 hover:text-white transition-colors mb-2"+ aria-expanded={showTemplates}+ >+ {showTemplates ? <ChevronDown size={14} /> : <ChevronRight size={14} />}+ <Zap size={14} className="text-yellow-500" />+ Quick Templates+ <span className="text-xs text-gray-600">({templates.length})</span>+ </button>+ {showTemplates && (+ <div className="flex flex-wrap gap-2">+ {templates.map(template => (+ <div+ key={template.id}+ role="button"+ tabIndex={0}+ onClick={() => applyTemplate(template)}+ onKeyDown={(e) => e.key === 'Enter' && applyTemplate(template)}+ className="group relative flex items-center gap-1.5 px-3 py-1.5 bg-port-card border border-port-border rounded-lg text-sm text-gray-300 hover:text-white hover:border-port-accent/50 transition-colors cursor-pointer"+ title={template.description}+ >+ <span>{template.icon || '\ud83d\udcdd'}</span>+ <span className="max-w-[120px] truncate">{template.name}</span>+ {template.useCount > 0 && (+ <span className="text-xs text-gray-600">({template.useCount})</span>+ )}+ {!template.isBuiltin && (+ <button+ onClick={(e) => deleteTemplate(template.id, e)}+ className="hidden group-hover:flex absolute -top-1 -right-1 w-4 h-4 bg-port-error rounded-full items-center justify-center"+ title="Delete template"+ >+ <X size={10} />+ </button>+ )}+ </div>+ ))}+ </div>+ )}+ </div>+ )}++ <div className="space-y-3">+ <div>+ <label htmlFor="task-description" className="sr-only">Task description (required)</label>+ <input+ id="task-description"+ type="text"+ placeholder="Task description *"+ value={newTask.description}+ onChange={e => setNewTask(t => ({ ...t, description: e.target.value }))}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"+ aria-required="true"+ />+ </div>+ {renderFullFormFields()}+ </div>+ </div>+ );++ function renderFullFormFields() {+ return (+ <>+ <div className="flex items-center gap-6 flex-wrap">+ <div className="flex items-center gap-3">+ <label htmlFor="add-position" className="text-sm text-gray-400">Queue Position:</label>+ <button+ id="add-position"+ type="button"+ onClick={() => setAddToTop(!addToTop)}+ className={`flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors ${+ addToTop+ ? 'bg-port-accent/20 text-port-accent border border-port-accent/50'+ : 'bg-port-bg text-gray-400 border border-port-border'+ }`}+ aria-pressed={addToTop}+ >+ {addToTop ? 'Top of Queue' : 'Bottom of Queue'}+ </button>+ </div>+ <label className="flex items-center gap-2 cursor-pointer select-none">+ <input+ type="checkbox"+ checked={enhancePrompt}+ onChange={(e) => setEnhancePrompt(e.target.checked)}+ className="w-4 h-4 rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent focus:ring-offset-0"+ />+ <span className="flex items-center gap-1.5 text-sm text-gray-400">+ <Sparkles size={14} className="text-yellow-500" />+ Enhance with AI+ </span>+ </label>+ </div>+ <div>+ <label htmlFor="task-context" className="sr-only">Context</label>+ <input+ id="task-context"+ type="text"+ placeholder="Context (optional)"+ value={newTask.context}+ onChange={e => setNewTask(t => ({ ...t, context: e.target.value }))}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"+ />+ </div>+ <div className="flex gap-3 items-center">+ {!compact && (+ <div className="flex-1">+ <label htmlFor="task-app" className="sr-only">Target application</label>+ <select+ id="task-app"+ value={newTask.app}+ onChange={e => setNewTask(t => ({ ...t, app: e.target.value }))}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"+ >+ <option value="">PortOS (default)</option>+ {apps?.map(app => (+ <option key={app.id} value={app.id}>{app.name}</option>+ ))}+ </select>+ </div>+ )}+ <label className="flex items-center gap-2 cursor-pointer select-none whitespace-nowrap">+ <input+ type="checkbox"+ checked={useWorktree}+ onChange={(e) => setUseWorktree(e.target.checked)}+ className="w-4 h-4 rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent focus:ring-offset-0"+ />+ <span className="flex items-center gap-1.5 text-sm text-gray-400">+ <GitBranch size={14} className="text-emerald-400" />+ Branch + PR+ </span>+ </label>+ {appHasJira && (+ <label className="flex items-center gap-2 cursor-pointer select-none whitespace-nowrap">+ <input+ type="checkbox"+ checked={createJiraTicket}+ onChange={(e) => setCreateJiraTicket(e.target.checked)}+ className="w-4 h-4 rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent focus:ring-offset-0"+ />+ <span className="flex items-center gap-1.5 text-sm text-gray-400">+ <Ticket size={14} className="text-blue-400" />+ Create JIRA ticket+ </span>+ </label>+ )}+ </div>+ <div className="flex gap-3">+ <div>+ <label htmlFor="task-provider" className="sr-only">AI provider</label>+ <select+ id="task-provider"+ value={newTask.provider}+ onChange={e => setNewTask(t => ({ ...t, provider: e.target.value, model: '' }))}+ className="w-40 px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"+ >+ <option value="">Auto (default)</option>+ {enabledProviders.map(p => (+ <option key={p.id} value={p.id}>{p.name}</option>+ ))}+ </select>+ </div>+ {availableModels.length > 0 && (+ <div className="flex-1">+ <label htmlFor="task-model" className="sr-only">AI model</label>+ <select+ id="task-model"+ value={newTask.model}+ onChange={e => setNewTask(t => ({ ...t, model: e.target.value }))}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"+ >+ <option value="">Select model...</option>+ {availableModels.map(m => (+ <option key={m} value={m}>{m.replace('claude-', '').replace(/-\d+$/, '')}</option>+ ))}+ </select>+ </div>+ )}+ </div>+ {/* Screenshot and Attachment Upload */}+ <div className="flex items-center gap-3 flex-wrap">+ <button+ type="button"+ onClick={() => fileInputRef.current?.click()}+ className="flex items-center gap-2 px-3 py-2 bg-port-bg border border-port-border rounded-lg text-gray-400 hover:text-white text-sm transition-colors"+ >+ <Image size={16} aria-hidden="true" />+ Add Screenshot+ </button>+ <input+ ref={fileInputRef}+ type="file"+ accept="image/*"+ multiple+ onChange={handleFileSelect}+ className="hidden"+ aria-label="Upload screenshot files"+ />+ <button+ type="button"+ onClick={() => attachmentInputRef.current?.click()}+ className="flex items-center gap-2 px-3 py-2 bg-port-bg border border-port-border rounded-lg text-gray-400 hover:text-white text-sm transition-colors"+ >+ <Paperclip size={16} aria-hidden="true" />+ Attach File+ </button>+ <input+ ref={attachmentInputRef}+ type="file"+ accept=".txt,.md,.json,.csv,.xml,.yaml,.yml,.png,.jpg,.jpeg,.gif,.webp,.svg,.pdf,.js,.ts,.jsx,.tsx,.py,.sh,.sql,.html,.css,.zip,.tar,.gz"+ multiple+ onChange={handleAttachmentSelect}+ className="hidden"+ aria-label="Upload attachment files"+ />+ {screenshots.length > 0 && (+ <span className="text-xs text-gray-500">{screenshots.length} screenshot{screenshots.length > 1 ? 's' : ''}</span>+ )}+ {attachments.length > 0 && (+ <span className="text-xs text-gray-500">{attachments.length} file{attachments.length > 1 ? 's' : ''}</span>+ )}+ </div>+ {/* Screenshot Previews */}+ {screenshots.length > 0 && (+ <div className="flex gap-2 flex-wrap">+ {screenshots.map(s => (+ <div key={s.id} className="relative group">+ <img+ src={s.preview}+ alt={s.filename}+ className="w-20 h-20 object-cover rounded-lg border border-port-border"+ />+ <button+ type="button"+ onClick={() => removeScreenshot(s.id)}+ className="absolute -top-2 -right-2 w-5 h-5 bg-port-error rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity"+ aria-label={`Remove screenshot ${s.filename}`}+ >+ <X size={12} aria-hidden="true" />+ </button>+ </div>+ ))}+ </div>+ )}+ {/* Attachment Previews */}+ {attachments.length > 0 && (+ <div className="flex gap-2 flex-wrap">+ {attachments.map(a => (+ <div key={a.id} className="relative group flex items-center gap-2 px-3 py-2 bg-port-bg border border-port-border rounded-lg">+ {a.isImage && a.preview ? (+ <img+ src={a.preview}+ alt={a.originalName}+ className="w-8 h-8 object-cover rounded"+ />+ ) : (+ <FileText size={20} className="text-gray-400" aria-hidden="true" />+ )}+ <div className="flex flex-col">+ <span className="text-xs text-white truncate max-w-[120px]" title={a.originalName}>+ {a.originalName}+ </span>+ <span className="text-xs text-gray-500">{formatFileSize(a.size)}</span>+ </div>+ <button+ type="button"+ onClick={() => removeAttachment(a.id)}+ className="ml-1 p-0.5 text-gray-500 hover:text-port-error transition-colors"+ aria-label={`Remove attachment ${a.originalName}`}+ >+ <X size={14} aria-hidden="true" />+ </button>+ </div>+ ))}+ </div>+ )}+ {/* Template Save Inline Input */}+ {showTemplateSave && (+ <div className="flex gap-2 items-center">+ <input+ type="text"+ value={templateNameInput}+ onChange={e => setTemplateNameInput(e.target.value)}+ onKeyDown={e => e.key === 'Enter' && saveAsTemplate()}+ placeholder="Template name..."+ className="flex-1 px-3 py-1.5 bg-port-bg border border-port-border rounded-lg text-white text-sm"+ autoFocus+ />+ <button+ onClick={saveAsTemplate}+ className="px-3 py-1.5 bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded-lg text-sm transition-colors"+ >+ Save+ </button>+ <button+ onClick={() => { setShowTemplateSave(false); setTemplateNameInput(''); }}+ className="px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-gray-400 rounded-lg text-sm transition-colors"+ >+ Cancel+ </button>+ </div>+ )}+ {!compact && (+ <div className="flex justify-end gap-2">+ <button+ onClick={saveAsTemplate}+ type="button"+ className="flex items-center gap-1 px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-gray-400 hover:text-white rounded-lg text-sm transition-colors min-h-[40px]"+ title="Save current form as a reusable template"+ >+ <Bookmark size={14} aria-hidden="true" />+ <span className="hidden sm:inline">Save Template</span>+ </button>+ <button+ onClick={handleAddTask}+ disabled={isEnhancing}+ className="flex items-center gap-1 px-3 py-1.5 bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded-lg text-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed min-h-[40px]"+ >+ {isEnhancing ? (+ <>+ <Loader2 size={14} className="animate-spin" aria-hidden="true" />+ Enhancing...+ </>+ ) : (+ <>+ <Plus size={14} aria-hidden="true" />+ {enhancePrompt ? 'Enhance & Add' : 'Add'}+ </>+ )}+ </button>+ </div>+ )}+ </>+ );+ }+}diff --git a/client/src/components/cos/tabs/TasksTab.jsx b/client/src/components/cos/tabs/TasksTab.jsxindex cf0d128256..17ee8ad196 100644--- a/client/src/components/cos/tabs/TasksTab.jsx+++ b/client/src/components/cos/tabs/TasksTab.jsx@@ -1,5 +1,5 @@-import { useState, useEffect, useRef, useMemo, useCallback } from 'react';-import { Plus, Play, Image, X, ChevronDown, ChevronRight, Sparkles, Loader2, Paperclip, FileText, Zap, Bookmark, Ticket, GitBranch } from 'lucide-react';+import { useState, useEffect, useMemo } from 'react';+import { Play, ChevronDown, ChevronRight } from 'lucide-react';import toast from 'react-hot-toast';import {DndContext,@@ -16,100 +16,21 @@ import {verticalListSortingStrategy,} from '@dnd-kit/sortable';import * as api from '../../../services/api';-import { processScreenshotUploads, processAttachmentUploads, formatFileSize } from '../../../utils/fileUpload';import TaskItem from './TaskItem';import SortableTaskItem from './SortableTaskItem';+import TaskAddForm from '../TaskAddForm';export default function TasksTab({ tasks, onRefresh, providers, apps }) {- const [showAddTask] = useState(true);- const [newTask, setNewTask] = useState({ description: '', context: '', model: '', provider: '', app: '' });- const [addToTop, setAddToTop] = useState(false);const [userTasksLocal, setUserTasksLocal] = useState([]);- const [screenshots, setScreenshots] = useState([]);- const [attachments, setAttachments] = useState([]);const [durations, setDurations] = useState(null);const [showCompletedUserTasks, setShowCompletedUserTasks] = useState(false);const [showCompletedSystemTasks, setShowCompletedSystemTasks] = useState(false);- const [enhancePrompt, setEnhancePrompt] = useState(false);- const [isEnhancing, setIsEnhancing] = useState(false);- const [templates, setTemplates] = useState([]);- const [showTemplates, setShowTemplates] = useState(false);- const [createJiraTicket, setCreateJiraTicket] = useState(false);- const [useWorktree, setUseWorktree] = useState(false);- const fileInputRef = useRef(null);- const attachmentInputRef = useRef(null);- // Fetch task duration estimates and templates+ // Fetch task duration estimatesuseEffect(() => {api.getCosLearningDurations().then(setDurations).catch(() => setDurations(null));-- api.getCosPopularTemplates(8)- .then(data => setTemplates(data.templates || []))- .catch(() => setTemplates([]));- }, []);-- // Apply template to form- const applyTemplate = useCallback(async (template) => {- setNewTask({- description: template.description,- context: template.context || '',- model: template.model || '',- provider: template.provider || '',- app: template.app || ''- });-- // Record usage for popularity tracking- await api.useCosTaskTemplate(template.id).catch(() => {});-- toast.success(`Template applied: ${template.name}`);- }, []);-- // Save current form as template- const saveAsTemplate = useCallback(async () => {- if (!newTask.description.trim()) {- toast.error('Enter a task description first');- return;- }-- const name = prompt('Template name:', newTask.description.substring(0, 40));- if (!name) return;-- const result = await api.createCosTaskTemplate({- name,- description: newTask.description,- context: newTask.context,- provider: newTask.provider,- model: newTask.model,- app: newTask.app- }).catch(err => {- toast.error(err.message);- return null;- });-- if (result?.success) {- toast.success('Template saved');- // Refresh templates- api.getCosPopularTemplates(8)- .then(data => setTemplates(data.templates || []))- .catch(() => {});- }- }, [newTask]);-- // Delete a user template- const deleteTemplate = useCallback(async (templateId, e) => {- e.stopPropagation();-- const result = await api.deleteCosTaskTemplate(templateId).catch(err => {- toast.error(err.message);- return null;- });-- if (result?.success) {- toast.success('Template deleted');- setTemplates(prev => prev.filter(t => t.id !== templateId));- }}, []);// Memoize task arrays to prevent unnecessary re-renders@@ -135,26 +56,6 @@ export default function TasksTab({ tasks, onRefresh, providers, apps }) {[cosTasks]);- // Memoize enabled providers for dropdown- const enabledProviders = useMemo(() =>- providers?.filter(p => p.enabled) || [],- [providers]- );-- // Check if selected app has JIRA configured- const selectedApp = useMemo(() =>- apps?.find(a => a.id === newTask.app),- [apps, newTask.app]- );- const appHasJira = selectedApp?.jira?.enabled;-- // Auto-toggle JIRA and worktree checkboxes when app selection changes- useEffect(() => {- const app = apps?.find(a => a.id === newTask.app);- setCreateJiraTicket(!!app?.jira?.enabled);- setUseWorktree(!!app?.defaultUseWorktree);- }, [newTask.app, apps]);-// Split user tasks by status (only pending tasks are sortable)const pendingUserTasksLocal = useMemo(() =>userTasksLocal.filter(t => t.status === 'pending'),@@ -218,102 +119,6 @@ export default function TasksTab({ tasks, onRefresh, providers, apps }) {}};- // Screenshot handling using shared utility- const handleFileSelect = async (e) => {- await processScreenshotUploads(e.target.files, {- onSuccess: (fileInfo) => setScreenshots(prev => [...prev, fileInfo]),- onError: (msg) => toast.error(msg)- });- e.target.value = '';- };-- const removeScreenshot = (id) => {- setScreenshots(prev => prev.filter(s => s.id !== id));- };-- // Attachment handling using shared utility- const handleAttachmentSelect = async (e) => {- await processAttachmentUploads(e.target.files, {- onSuccess: (fileInfo) => setAttachments(prev => [...prev, fileInfo]),- onError: (msg) => toast.error(msg)- });- e.target.value = '';- };-- const removeAttachment = (id) => {- setAttachments(prev => prev.filter(a => a.id !== id));- };-- // Get models for selected provider- const selectedProvider = providers?.find(p => p.id === newTask.provider);- const availableModels = selectedProvider?.models || [];-- const handleAddTask = async () => {- if (!newTask.description.trim()) {- toast.error('Description is required');- return;- }-- let finalDescription = newTask.description;-- // If enhance checkbox is checked, call the enhance API first- if (enhancePrompt) {- setIsEnhancing(true);- const enhanceResult = await api.enhanceCosTaskPrompt({- description: newTask.description,- context: newTask.context- }).catch(err => {- // Enhancement failed - fall back to original description- toast('Enhancement failed, using original description', { icon: '⚠️' });- console.warn('Task enhancement failed:', err.message);- return null;- });-- if (enhanceResult?.enhancedDescription?.trim()) {- finalDescription = enhanceResult.enhancedDescription;- toast.success('Prompt enhanced');- } else if (enhanceResult) {- // Enhancement returned empty result - fall back to original- toast('Enhancement returned empty result, using original', { icon: '⚠️' });- }- // If enhanceResult is null (error), we already showed warning and fall back to original-- setIsEnhancing(false);- }-- await api.addCosTask({- description: finalDescription,- context: newTask.context,- model: newTask.model || undefined,- provider: newTask.provider || undefined,- app: newTask.app || undefined,- createJiraTicket: createJiraTicket || undefined,- useWorktree: useWorktree || undefined,- screenshots: screenshots.length > 0 ? screenshots.map(s => s.path) : undefined,- attachments: attachments.length > 0 ? attachments.map(a => ({- filename: a.filename,- originalName: a.originalName,- path: a.path,- size: a.size,- mimeType: a.mimeType- })) : undefined,- position: addToTop ? 'top' : 'bottom'- }).catch(err => {- toast.error(err.message);- return;- });-- toast.success('Task added');- setNewTask({ description: '', context: '', model: '', provider: '', app: '' });- setScreenshots([]);- setAttachments([]);- setAddToTop(false);- setEnhancePrompt(false);- setCreateJiraTicket(false);- setUseWorktree(false);- onRefresh();- };-return (<div className="space-y-6">{/* User Tasks */}@@ -333,311 +138,8 @@ export default function TasksTab({ tasks, onRefresh, providers, apps }) {</button></div>- {/* Quick Templates */}- {templates.length > 0 && (- <div className="mb-4">- <button- onClick={() => setShowTemplates(!showTemplates)}- className="flex items-center gap-2 text-sm text-gray-400 hover:text-white transition-colors mb-2"- aria-expanded={showTemplates}- >- {showTemplates ? <ChevronDown size={14} /> : <ChevronRight size={14} />}- <Zap size={14} className="text-yellow-500" />- Quick Templates- <span className="text-xs text-gray-600">({templates.length})</span>- </button>- {showTemplates && (- <div className="flex flex-wrap gap-2">- {templates.map(template => (- <div- key={template.id}- role="button"- tabIndex={0}- onClick={() => applyTemplate(template)}- onKeyDown={(e) => e.key === 'Enter' && applyTemplate(template)}- className="group relative flex items-center gap-1.5 px-3 py-1.5 bg-port-card border border-port-border rounded-lg text-sm text-gray-300 hover:text-white hover:border-port-accent/50 transition-colors cursor-pointer"- title={template.description}- >- <span>{template.icon || '📝'}</span>- <span className="max-w-[120px] truncate">{template.name}</span>- {template.useCount > 0 && (- <span className="text-xs text-gray-600">({template.useCount})</span>- )}- {!template.isBuiltin && (- <button- onClick={(e) => deleteTemplate(template.id, e)}- className="hidden group-hover:flex absolute -top-1 -right-1 w-4 h-4 bg-port-error rounded-full items-center justify-center"- title="Delete template"- >- <X size={10} />- </button>- )}- </div>- ))}- </div>- )}- </div>- )}-{/* Add Task Form */}- {showAddTask && (- <div className="bg-port-card border border-port-accent/50 rounded-lg p-4 mb-4" role="form" aria-label="Add new task">- <div className="space-y-3">- <div>- <label htmlFor="task-description" className="sr-only">Task description (required)</label>- <input- id="task-description"- type="text"- placeholder="Task description *"- value={newTask.description}- onChange={e => setNewTask(t => ({ ...t, description: e.target.value }))}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"- aria-required="true"- />- </div>- <div className="flex items-center gap-6 flex-wrap">- <div className="flex items-center gap-3">- <label htmlFor="add-position" className="text-sm text-gray-400">Queue Position:</label>- <button- id="add-position"- type="button"- onClick={() => setAddToTop(!addToTop)}- className={`flex items-center gap-2 px-3 py-1.5 rounded-lg text-sm transition-colors ${- addToTop- ? 'bg-port-accent/20 text-port-accent border border-port-accent/50'- : 'bg-port-bg text-gray-400 border border-port-border'- }`}- aria-pressed={addToTop}- >- {addToTop ? 'Top of Queue' : 'Bottom of Queue'}- </button>- </div>- <label className="flex items-center gap-2 cursor-pointer select-none">- <input- type="checkbox"- checked={enhancePrompt}- onChange={(e) => setEnhancePrompt(e.target.checked)}- className="w-4 h-4 rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent focus:ring-offset-0"- />- <span className="flex items-center gap-1.5 text-sm text-gray-400">- <Sparkles size={14} className="text-yellow-500" />- Enhance with AI- </span>- </label>- </div>- <div>- <label htmlFor="task-context" className="sr-only">Context</label>- <input- id="task-context"- type="text"- placeholder="Context (optional)"- value={newTask.context}- onChange={e => setNewTask(t => ({ ...t, context: e.target.value }))}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"- />- </div>- <div className="flex gap-3 items-center">- <div className="flex-1">- <label htmlFor="task-app" className="sr-only">Target application</label>- <select- id="task-app"- value={newTask.app}- onChange={e => setNewTask(t => ({ ...t, app: e.target.value }))}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"- >- <option value="">PortOS (default)</option>- {apps?.map(app => (- <option key={app.id} value={app.id}>{app.name}</option>- ))}- </select>- </div>- <label className="flex items-center gap-2 cursor-pointer select-none whitespace-nowrap">- <input- type="checkbox"- checked={useWorktree}- onChange={(e) => setUseWorktree(e.target.checked)}- className="w-4 h-4 rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent focus:ring-offset-0"- />- <span className="flex items-center gap-1.5 text-sm text-gray-400">- <GitBranch size={14} className="text-emerald-400" />- Branch + PR- </span>- </label>- {appHasJira && (- <label className="flex items-center gap-2 cursor-pointer select-none whitespace-nowrap">- <input- type="checkbox"- checked={createJiraTicket}- onChange={(e) => setCreateJiraTicket(e.target.checked)}- className="w-4 h-4 rounded border-port-border bg-port-bg text-port-accent focus:ring-port-accent focus:ring-offset-0"- />- <span className="flex items-center gap-1.5 text-sm text-gray-400">- <Ticket size={14} className="text-blue-400" />- Create JIRA ticket- </span>- </label>- )}- </div>- <div className="flex gap-3">- <div>- <label htmlFor="task-provider" className="sr-only">AI provider</label>- <select- id="task-provider"- value={newTask.provider}- onChange={e => setNewTask(t => ({ ...t, provider: e.target.value, model: '' }))}- className="w-40 px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"- >- <option value="">Auto (default)</option>- {enabledProviders.map(p => (- <option key={p.id} value={p.id}>{p.name}</option>- ))}- </select>- </div>- {availableModels.length > 0 && (- <div className="flex-1">- <label htmlFor="task-model" className="sr-only">AI model</label>- <select- id="task-model"- value={newTask.model}- onChange={e => setNewTask(t => ({ ...t, model: e.target.value }))}- className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm"- >- <option value="">Select model...</option>- {availableModels.map(m => (- <option key={m} value={m}>{m.replace('claude-', '').replace(/-\d+$/, '')}</option>- ))}- </select>- </div>- )}- </div>- {/* Screenshot and Attachment Upload */}- <div className="flex items-center gap-3 flex-wrap">- <button- type="button"- onClick={() => fileInputRef.current?.click()}- className="flex items-center gap-2 px-3 py-2 bg-port-bg border border-port-border rounded-lg text-gray-400 hover:text-white text-sm transition-colors"- >- <Image size={16} aria-hidden="true" />- Add Screenshot- </button>- <input- ref={fileInputRef}- type="file"- accept="image/*"- multiple- onChange={handleFileSelect}- className="hidden"- aria-label="Upload screenshot files"- />- <button- type="button"- onClick={() => attachmentInputRef.current?.click()}- className="flex items-center gap-2 px-3 py-2 bg-port-bg border border-port-border rounded-lg text-gray-400 hover:text-white text-sm transition-colors"- >- <Paperclip size={16} aria-hidden="true" />- Attach File- </button>- <input- ref={attachmentInputRef}- type="file"- accept=".txt,.md,.json,.csv,.xml,.yaml,.yml,.png,.jpg,.jpeg,.gif,.webp,.svg,.pdf,.js,.ts,.jsx,.tsx,.py,.sh,.sql,.html,.css,.zip,.tar,.gz"- multiple- onChange={handleAttachmentSelect}- className="hidden"- aria-label="Upload attachment files"- />- {screenshots.length > 0 && (- <span className="text-xs text-gray-500">{screenshots.length} screenshot{screenshots.length > 1 ? 's' : ''}</span>- )}- {attachments.length > 0 && (- <span className="text-xs text-gray-500">{attachments.length} file{attachments.length > 1 ? 's' : ''}</span>- )}- </div>- {/* Screenshot Previews */}- {screenshots.length > 0 && (- <div className="flex gap-2 flex-wrap">- {screenshots.map(s => (- <div key={s.id} className="relative group">- <img- src={s.preview}- alt={s.filename}- className="w-20 h-20 object-cover rounded-lg border border-port-border"- />- <button- type="button"- onClick={() => removeScreenshot(s.id)}- className="absolute -top-2 -right-2 w-5 h-5 bg-port-error rounded-full flex items-center justify-center opacity-0 group-hover:opacity-100 transition-opacity"- aria-label={`Remove screenshot ${s.filename}`}- >- <X size={12} aria-hidden="true" />- </button>- </div>- ))}- </div>- )}- {/* Attachment Previews */}- {attachments.length > 0 && (- <div className="flex gap-2 flex-wrap">- {attachments.map(a => (- <div key={a.id} className="relative group flex items-center gap-2 px-3 py-2 bg-port-bg border border-port-border rounded-lg">- {a.isImage && a.preview ? (- <img- src={a.preview}- alt={a.originalName}- className="w-8 h-8 object-cover rounded"- />- ) : (- <FileText size={20} className="text-gray-400" aria-hidden="true" />- )}- <div className="flex flex-col">- <span className="text-xs text-white truncate max-w-[120px]" title={a.originalName}>- {a.originalName}- </span>- <span className="text-xs text-gray-500">{formatFileSize(a.size)}</span>- </div>- <button- type="button"- onClick={() => removeAttachment(a.id)}- className="ml-1 p-0.5 text-gray-500 hover:text-port-error transition-colors"- aria-label={`Remove attachment ${a.originalName}`}- >- <X size={14} aria-hidden="true" />- </button>- </div>- ))}- </div>- )}- <div className="flex justify-end gap-2">- <button- onClick={saveAsTemplate}- type="button"- className="flex items-center gap-1 px-3 py-1.5 bg-port-border hover:bg-port-border/80 text-gray-400 hover:text-white rounded-lg text-sm transition-colors min-h-[40px]"- title="Save current form as a reusable template"- >- <Bookmark size={14} aria-hidden="true" />- <span className="hidden sm:inline">Save Template</span>- </button>- <button- onClick={handleAddTask}- disabled={isEnhancing}- className="flex items-center gap-1 px-3 py-1.5 bg-port-accent/20 hover:bg-port-accent/30 text-port-accent rounded-lg text-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed min-h-[40px]"- >- {isEnhancing ? (- <>- <Loader2 size={14} className="animate-spin" aria-hidden="true" />- Enhancing...- </>- ) : (- <>- <Plus size={14} aria-hidden="true" />- {enhancePrompt ? 'Enhance & Add' : 'Add'}- </>- )}- </button>- </div>- </div>- </div>- )}+ <TaskAddForm providers={providers} apps={apps} onTaskAdded={onRefresh} />{/* User Tasks Sections */}{pendingUserTasksLocal.length === 0 && activeUserTasksLocal.length === 0 && blockedUserTasksLocal.length === 0 && completedUserTasksLocal.length === 0 ? (diff --git a/client/src/pages/Dashboard.jsx b/client/src/pages/Dashboard.jsxindex 0ec10b870d..98720d4e4f 100644--- a/client/src/pages/Dashboard.jsx+++ b/client/src/pages/Dashboard.jsx@@ -7,6 +7,8 @@ import CosDashboardWidget from '../components/CosDashboardWidget';import GoalProgressWidget from '../components/GoalProgressWidget';import UpcomingTasksWidget from '../components/UpcomingTasksWidget';import DecisionLogWidget from '../components/DecisionLogWidget';+import QuickBrainCapture from '../components/QuickBrainCapture';+import QuickTaskWidget from '../components/QuickTaskWidget';import * as api from '../services/api';import socket from '../services/socket';@@ -33,7 +35,6 @@ export default function Dashboard() {useEffect(() => {fetchData();- // Listen for apps changes via WebSocket instead of pollingconst handleAppsChanged = () => {fetchData();};@@ -50,7 +51,7 @@ export default function Dashboard() {[apps]);- // Memoize derived stats to prevent recalculation on every render (exclude archived)+ // Memoize derived stats (exclude archived)const activeApps = useMemo(() => apps.filter(a => !a.archived), [apps]);const appStats = useMemo(() => ({total: activeApps.length,@@ -68,9 +69,9 @@ export default function Dashboard() {}return (- <div>+ <div className="space-y-6">{/* Header */}- <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-2 sm:gap-4 mb-6">+ <div className="flex flex-col sm:flex-row sm:items-center justify-between gap-2 sm:gap-4"><div><h2 className="text-2xl font-bold text-white">Dashboard</h2><p className="text-gray-500 text-sm sm:text-base">@@ -86,37 +87,48 @@ export default function Dashboard() {{/* Error */}{error && (- <div className="mb-6 p-4 bg-port-error/20 border border-port-error rounded-lg text-port-error">+ <div className="p-4 bg-port-error/20 border border-port-error rounded-lg text-port-error">{error}</div>)}- {/* System Health Widget */}- <div className="mb-6">- <SystemHealthWidget />+ {/* Row 1 — Quick entry */}+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">+ <QuickBrainCapture />+ <QuickTaskWidget /></div>- {/* CoS Status Widget */}- <div className="mb-6">- <CosDashboardWidget />+ {/* Row 2 — Status at a glance */}+ <div className="grid grid-cols-1 lg:grid-cols-12 gap-4">+ <div className="lg:col-span-8">+ <SystemHealthWidget />+ </div>+ {apps.length > 0 && (+ <div className="lg:col-span-4">+ <div className="bg-port-card border border-port-border rounded-xl p-4 h-full">+ <h3 className="text-sm font-semibold text-white mb-3">Quick Stats</h3>+ <div className="grid grid-cols-2 gap-2">+ <StatCard label="Total Apps" value={appStats.total} icon="📦" />+ <StatCard label="Online" value={appStats.online} icon="🟢" />+ <StatCard label="Stopped" value={appStats.stopped} icon="🟡" />+ <StatCard label="Not Started" value={appStats.notStarted} icon="⚪" />+ </div>+ </div>+ </div>+ )}</div>- {/* Goal Progress Widget */}- <div className="mb-6">+ {/* Row 3 — AI/CoS intelligence */}+ <div className="grid grid-cols-1 lg:grid-cols-3 gap-4">+ <CosDashboardWidget /><GoalProgressWidget />- </div>-- {/* Upcoming Tasks Widget */}- <div className="mb-6"><UpcomingTasksWidget /></div>- {/* Decision Log Widget */}- <div className="mb-6">- <DecisionLogWidget />- </div>+ {/* Row 4 — Decision log */}+ <DecisionLogWidget />- {/* App Grid */}+ {/* Row 5 — Apps */}{apps.length === 0 ? (<div className="bg-port-card border border-port-border rounded-xl p-8 sm:p-12 text-center"><div className="text-4xl mb-4">📦</div>@@ -139,96 +151,75 @@ export default function Dashboard() {</div>)}- {/* Activity Streak */}- {usage && (usage.currentStreak > 0 || usage.longestStreak > 0) && (- <div className="mt-6 sm:mt-8 bg-port-card border border-port-border rounded-xl p-4 sm:p-6">- <div className="flex flex-col sm:flex-row sm:items-center gap-3 sm:gap-4">- <div className="flex items-center gap-3">- <div className="text-3xl sm:text-4xl" aria-hidden="true">- {usage.currentStreak >= 7 ? '🔥' : usage.currentStreak >= 3 ? '⚡' : '✨'}- </div>- <div>- <div className="text-xl sm:text-2xl font-bold text-white">- {usage.currentStreak} day{usage.currentStreak !== 1 ? 's' : ''}+ {/* Row 6 — Activity data */}+ {(usage?.currentStreak > 0 || usage?.longestStreak > 0 || usage?.hourlyActivity) && (+ <div className="grid grid-cols-1 md:grid-cols-2 gap-4">+ {/* Activity Streak */}+ {usage && (usage.currentStreak > 0 || usage.longestStreak > 0) && (+ <div className="bg-port-card border border-port-border rounded-xl p-4 sm:p-6">+ <div className="flex flex-col sm:flex-row sm:items-center gap-3 sm:gap-4">+ <div className="flex items-center gap-3">+ <div className="text-3xl sm:text-4xl" aria-hidden="true">+ {usage.currentStreak >= 7 ? '🔥' : usage.currentStreak >= 3 ? '⚡' : '✨'}+ </div>+ <div>+ <div className="text-xl sm:text-2xl font-bold text-white">+ {usage.currentStreak} day{usage.currentStreak !== 1 ? 's' : ''}+ </div>+ <div className="text-xs sm:text-sm text-gray-500">Current streak</div>+ </div></div>- <div className="text-xs sm:text-sm text-gray-500">Current streak</div>+ {usage.longestStreak > usage.currentStreak && (+ <div className="sm:ml-auto text-left sm:text-right">+ <div className="text-base sm:text-lg font-semibold text-port-accent">+ {usage.longestStreak} days+ </div>+ <div className="text-xs text-gray-500">Longest streak</div>+ </div>+ )}+ {usage.currentStreak === usage.longestStreak && usage.currentStreak > 0 && (+ <div className="sm:ml-auto px-3 py-1.5 bg-port-success/20 text-port-success text-xs sm:text-sm rounded-full w-fit">+ Personal best!+ </div>+ )}</div>- </div>- {usage.longestStreak > usage.currentStreak && (- <div className="sm:ml-auto text-left sm:text-right">- <div className="text-base sm:text-lg font-semibold text-port-accent">- {usage.longestStreak} days- </div>- <div className="text-xs text-gray-500">Longest streak</div>+ {/* Mini streak visualization */}+ <div className="mt-4 flex gap-1.5 sm:gap-1">+ {usage.last7Days?.map((day) => (+ <div+ key={day.date}+ className={`flex-1 h-3 sm:h-2 rounded-full ${+ day.sessions > 0 ? 'bg-port-success' : 'bg-port-border'+ }`}+ title={`${day.label}: ${day.sessions} sessions`}+ />+ ))}</div>- )}- {usage.currentStreak === usage.longestStreak && usage.currentStreak > 0 && (- <div className="sm:ml-auto px-3 py-1.5 bg-port-success/20 text-port-success text-xs sm:text-sm rounded-full w-fit">- Personal best!+ <div className="mt-1 flex justify-between text-xs text-gray-500">+ <span>7 days ago</span>+ <span>Today</span></div>- )}- </div>- {/* Mini streak visualization */}- <div className="mt-4 flex gap-1.5 sm:gap-1">- {usage.last7Days?.map((day) => (- <div- key={day.date}- className={`flex-1 h-3 sm:h-2 rounded-full ${- day.sessions > 0 ? 'bg-port-success' : 'bg-port-border'- }`}- title={`${day.label}: ${day.sessions} sessions`}- />- ))}- </div>- <div className="mt-1 flex justify-between text-xs text-gray-500">- <span>7 days ago</span>- <span>Today</span>- </div>- </div>- )}+ </div>+ )}- {/* Quick Stats */}- {apps.length > 0 && (- <div className="mt-6 sm:mt-8 grid grid-cols-2 md:grid-cols-4 gap-2 sm:gap-4">- <StatCard- label="Total Apps"- value={appStats.total}- icon="📦"- />- <StatCard- label="Online"- value={appStats.online}- icon="🟢"- />- <StatCard- label="Stopped"- value={appStats.stopped}- icon="🟡"- />- <StatCard- label="Not Started"- value={appStats.notStarted}- icon="⚪"- />+ {/* Hourly Activity Heatmap */}+ {usage?.hourlyActivity && (+ <HourlyActivityHeatmap hourlyActivity={usage.hourlyActivity} />+ )}</div>)}-- {/* Hourly Activity Heatmap */}- {usage?.hourlyActivity && (- <HourlyActivityHeatmap hourlyActivity={usage.hourlyActivity} />- )}</div>);}function StatCard({ label, value, icon }) {return (- <div className="bg-port-card border border-port-border rounded-lg p-3 sm:p-4" role="group" aria-label={`${label}: ${value}`}>+ <div className="bg-port-bg border border-port-border rounded-lg p-3" role="group" aria-label={`${label}: ${value}`}><div className="flex items-center gap-2 mb-1">- <span aria-hidden="true" className="text-base sm:text-lg">{icon}</span>- <span className="text-xs sm:text-sm text-gray-500">{label}</span>+ <span aria-hidden="true" className="text-base">{icon}</span>+ <span className="text-xs text-gray-500">{label}</span></div>- <div className="text-xl sm:text-2xl font-bold text-white">{value}</div>+ <div className="text-xl font-bold text-white">{value}</div></div>);}@@ -236,23 +227,19 @@ function StatCard({ label, value, icon }) {function HourlyActivityHeatmap({ hourlyActivity }) {const maxActivity = Math.max(...hourlyActivity, 1);- // Find peak hour(s)const peakValue = Math.max(...hourlyActivity);const peakHours = hourlyActivity.map((val, idx) => ({ hour: idx, count: val })).filter(h => h.count === peakValue && h.count > 0);- // Calculate total sessionsconst totalSessions = hourlyActivity.reduce((sum, val) => sum + val, 0);- // Format hour label (12-hour format)const formatHour = (hour) => {if (hour === 0) return '12a';if (hour === 12) return '12p';return hour < 12 ? `${hour}a` : `${hour - 12}p`;};- // Get intensity class based on activity levelconst getIntensityClass = (count) => {if (count === 0) return 'bg-port-border/30';const intensity = count / maxActivity;@@ -262,7 +249,6 @@ function HourlyActivityHeatmap({ hourlyActivity }) {return 'bg-port-success/20';};- // Determine peak time descriptionconst getPeakTimeDescription = () => {if (peakHours.length === 0 || peakValue === 0) return null;if (peakHours.length === 1) {@@ -276,7 +262,7 @@ function HourlyActivityHeatmap({ hourlyActivity }) {if (totalSessions === 0) return null;return (- <div className="mt-8 bg-port-card border border-port-border rounded-xl p-4 sm:p-6">+ <div className="bg-port-card border border-port-border rounded-xl p-4 sm:p-6"><div className="flex flex-col sm:flex-row sm:items-center justify-between gap-2 mb-4"><div className="flex items-center gap-3"><div className="text-2xl" aria-hidden="true">⏰</div>@@ -292,7 +278,6 @@ function HourlyActivityHeatmap({ hourlyActivity }) {)}</div>- {/* Heatmap grid - 12 cols on sm+, 6 cols (2 rows) on mobile for larger touch targets */}<div className="grid grid-cols-6 sm:grid-cols-12 gap-1.5 sm:gap-1" role="img" aria-label="Hourly activity heatmap">{hourlyActivity.map((count, hour) => (<div@@ -304,21 +289,15 @@ function HourlyActivityHeatmap({ hourlyActivity }) {))}</div>- {/* Hour labels - simplified for mobile */}<div className="mt-2 grid grid-cols-6 sm:grid-cols-12 gap-1.5 sm:gap-1 text-xs text-gray-500">{hourlyActivity.map((_, hour) => (- <div- key={hour}- className="text-center"- >- {/* Mobile: show every 4th hour, Desktop: every 3rd hour */}+ <div key={hour} className="text-center"><span className="hidden sm:inline">{hour % 3 === 0 ? formatHour(hour) : ''}</span><span className="sm:hidden">{hour % 4 === 0 ? formatHour(hour) : ''}</span></div>))}</div>- {/* Legend */}<div className="mt-4 flex items-center justify-end gap-2 text-xs text-gray-500"><span>Less</span><div className="flex gap-1">diff --git a/package-lock.json b/package-lock.jsonindex c6c0992672..2be3eeecce 100644--- a/package-lock.json+++ b/package-lock.json@@ -1,12 +1,12 @@{"name": "portos",- "version": "0.25.7",+ "version": "0.26.0","lockfileVersion": 3,"requires": true,"packages": {"": {"name": "portos",- "version": "0.25.7",+ "version": "0.26.0","license": "MIT","workspaces": ["packages/*",diff --git a/package.json b/package.jsonindex ca582c2c70..45778fa1b6 100644--- a/package.json+++ b/package.json@@ -1,6 +1,6 @@{"name": "portos",- "version": "0.25.7",+ "version": "0.26.0","private": true,"description": "Local dev machine App OS portal","author": "Adam Eivy (@antic|@atomantic)",