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: add memory editing and app display to UI
Adam Eivyf61c80a95777
diff --git a/client/src/components/cos/tabs/MemoryEditModal.jsx b/client/src/components/cos/tabs/MemoryEditModal.jsxnew file mode 100644index 0000000000..1ddd74b660--- /dev/null+++ b/client/src/components/cos/tabs/MemoryEditModal.jsx@@ -0,0 +1,311 @@+import { useState, useEffect } from 'react';+import { X, Save, Plus, Trash2 } from 'lucide-react';+import toast from 'react-hot-toast';+import * as api from '../../../services/api';+import { MEMORY_TYPES, MEMORY_TYPE_COLORS } from '../constants';++export default function MemoryEditModal({ memory, apps, onSave, onClose }) {+ const [formData, setFormData] = useState({+ content: memory.content || '',+ summary: memory.summary || '',+ type: memory.type || 'observation',+ category: memory.category || 'other',+ tags: memory.tags || [],+ sourceAppId: memory.sourceAppId || '',+ importance: memory.importance || 0.5,+ confidence: memory.confidence || 0.8+ });+ const [newTag, setNewTag] = useState('');+ const [saving, setSaving] = useState(false);+ const [fullMemory, setFullMemory] = useState(null);++ // Fetch full memory data if we only have index data+ useEffect(() => {+ const fetchFullMemory = async () => {+ if (!memory.content && memory.id) {+ const full = await api.getMemory(memory.id).catch(() => null);+ if (full) {+ setFullMemory(full);+ setFormData({+ content: full.content || '',+ summary: full.summary || '',+ type: full.type || 'observation',+ category: full.category || 'other',+ tags: full.tags || [],+ sourceAppId: full.sourceAppId || '',+ importance: full.importance || 0.5,+ confidence: full.confidence || 0.8+ });+ }+ }+ };+ fetchFullMemory();+ }, [memory]);++ const handleSubmit = async (e) => {+ e.preventDefault();+ if (!formData.content.trim()) {+ toast.error('Content is required');+ return;+ }++ setSaving(true);+ const result = await api.updateMemory(memory.id, {+ content: formData.content,+ summary: formData.summary || undefined,+ type: formData.type,+ category: formData.category,+ tags: formData.tags,+ sourceAppId: formData.sourceAppId || null,+ importance: formData.importance,+ confidence: formData.confidence+ }).catch(err => {+ toast.error(err.message || 'Failed to update memory');+ return null;+ });+ setSaving(false);++ if (result) {+ toast.success('Memory updated');+ onSave(result);+ }+ };++ const handleAddTag = () => {+ const tag = newTag.trim().toLowerCase();+ if (tag && !formData.tags.includes(tag)) {+ setFormData({ ...formData, tags: [...formData.tags, tag] });+ setNewTag('');+ }+ };++ const handleRemoveTag = (tagToRemove) => {+ setFormData({ ...formData, tags: formData.tags.filter(t => t !== tagToRemove) });+ };++ const handleKeyDown = (e) => {+ if (e.key === 'Enter') {+ e.preventDefault();+ handleAddTag();+ }+ };++ // Get app name for display+ const getAppName = (appId) => {+ if (!appId) return 'None';+ const app = apps?.find(a => a.id === appId);+ return app?.name || appId;+ };++ return (+ <div className="fixed inset-0 bg-black/50 flex items-center justify-center z-50">+ <div className="bg-port-card border border-port-border rounded-xl p-6 w-full max-w-2xl max-h-[90vh] overflow-auto">+ <div className="flex items-center justify-between mb-4">+ <h2 className="text-xl font-bold text-white">Edit Memory</h2>+ <button+ onClick={onClose}+ className="text-gray-500 hover:text-white transition-colors"+ >+ <X size={20} />+ </button>+ </div>++ <form onSubmit={handleSubmit} className="space-y-4">+ {/* Type */}+ <div>+ <label className="block text-sm text-gray-400 mb-1">Type</label>+ <div className="flex flex-wrap gap-2">+ {MEMORY_TYPES.map(type => (+ <button+ key={type}+ type="button"+ onClick={() => setFormData({ ...formData, type })}+ className={`px-3 py-1.5 text-sm rounded-lg border transition-colors ${+ formData.type === type+ ? MEMORY_TYPE_COLORS[type]+ : 'border-port-border text-gray-500 hover:text-gray-300'+ }`}+ >+ {type}+ </button>+ ))}+ </div>+ </div>++ {/* Content */}+ <div>+ <label className="block text-sm text-gray-400 mb-1">+ Content <span className="text-port-accent">*</span>+ </label>+ <textarea+ value={formData.content}+ onChange={e => setFormData({ ...formData, content: e.target.value })}+ placeholder="Memory content..."+ rows={5}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:border-port-accent focus:outline-none resize-none"+ autoFocus+ />+ <p className="text-xs text-gray-500 mt-1">+ Editing content will regenerate the embedding for semantic search.+ </p>+ </div>++ {/* Summary */}+ <div>+ <label className="block text-sm text-gray-400 mb-1">Summary (optional)</label>+ <input+ type="text"+ value={formData.summary}+ onChange={e => setFormData({ ...formData, summary: e.target.value })}+ placeholder="Brief summary..."+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:border-port-accent focus:outline-none"+ />+ </div>++ {/* Category and App */}+ <div className="flex gap-3">+ <div className="flex-1">+ <label className="block text-sm text-gray-400 mb-1">Category</label>+ <select+ value={formData.category}+ onChange={e => setFormData({ ...formData, category: e.target.value })}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:border-port-accent focus:outline-none"+ >+ <option value="other">Other</option>+ <option value="codebase">Codebase</option>+ <option value="workflow">Workflow</option>+ <option value="tools">Tools</option>+ <option value="architecture">Architecture</option>+ <option value="patterns">Patterns</option>+ <option value="conventions">Conventions</option>+ <option value="preferences">Preferences</option>+ <option value="system">System</option>+ <option value="project">Project</option>+ </select>+ </div>+ <div className="flex-1">+ <label className="block text-sm text-gray-400 mb-1">Associated App</label>+ <select+ value={formData.sourceAppId}+ onChange={e => setFormData({ ...formData, sourceAppId: e.target.value })}+ className="w-full px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:border-port-accent focus:outline-none"+ >+ <option value="">None (General)</option>+ {apps?.map(app => (+ <option key={app.id} value={app.id}>{app.name}</option>+ ))}+ </select>+ </div>+ </div>++ {/* Tags */}+ <div>+ <label className="block text-sm text-gray-400 mb-1">Tags</label>+ <div className="flex flex-wrap gap-2 mb-2">+ {formData.tags.map(tag => (+ <span+ key={tag}+ className="flex items-center gap-1 px-2 py-1 bg-port-border rounded text-sm text-gray-300"+ >+ {tag}+ <button+ type="button"+ onClick={() => handleRemoveTag(tag)}+ className="text-gray-500 hover:text-port-error transition-colors"+ >+ <Trash2 size={12} />+ </button>+ </span>+ ))}+ </div>+ <div className="flex gap-2">+ <input+ type="text"+ value={newTag}+ onChange={e => setNewTag(e.target.value)}+ onKeyDown={handleKeyDown}+ placeholder="Add tag..."+ className="flex-1 px-3 py-2 bg-port-bg border border-port-border rounded-lg text-white text-sm focus:border-port-accent focus:outline-none"+ />+ <button+ type="button"+ onClick={handleAddTag}+ disabled={!newTag.trim()}+ className="px-3 py-2 bg-port-border hover:bg-port-border/70 text-gray-300 rounded-lg text-sm transition-colors disabled:opacity-50 disabled:cursor-not-allowed"+ >+ <Plus size={16} />+ </button>+ </div>+ </div>++ {/* Importance and Confidence */}+ <div className="flex gap-3">+ <div className="flex-1">+ <label className="block text-sm text-gray-400 mb-1">+ Importance: {(formData.importance * 100).toFixed(0)}%+ </label>+ <input+ type="range"+ min="0"+ max="1"+ step="0.05"+ value={formData.importance}+ onChange={e => setFormData({ ...formData, importance: parseFloat(e.target.value) })}+ className="w-full accent-port-accent"+ />+ </div>+ <div className="flex-1">+ <label className="block text-sm text-gray-400 mb-1">+ Confidence: {(formData.confidence * 100).toFixed(0)}%+ </label>+ <input+ type="range"+ min="0"+ max="1"+ step="0.05"+ value={formData.confidence}+ onChange={e => setFormData({ ...formData, confidence: parseFloat(e.target.value) })}+ className="w-full accent-port-accent"+ />+ </div>+ </div>++ {/* Source Info (read-only) */}+ {(memory.sourceTaskId || memory.sourceAgentId || (fullMemory?.sourceTaskId) || (fullMemory?.sourceAgentId)) && (+ <div className="text-xs text-gray-500 p-3 bg-port-bg rounded-lg">+ <div className="font-medium mb-1">Source Information</div>+ {(memory.sourceTaskId || fullMemory?.sourceTaskId) && (+ <div>Task: {memory.sourceTaskId || fullMemory?.sourceTaskId}</div>+ )}+ {(memory.sourceAgentId || fullMemory?.sourceAgentId) && (+ <div>Agent: {memory.sourceAgentId || fullMemory?.sourceAgentId}</div>+ )}+ {formData.sourceAppId && (+ <div>App: {getAppName(formData.sourceAppId)}</div>+ )}+ </div>+ )}++ {/* Actions */}+ <div className="flex justify-end gap-2 pt-2">+ <button+ type="button"+ onClick={onClose}+ className="px-4 py-2 text-sm text-gray-400 hover:text-white transition-colors"+ >+ Cancel+ </button>+ <button+ type="submit"+ disabled={saving || !formData.content.trim()}+ className="flex items-center gap-2 px-4 py-2 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"+ >+ <Save size={14} />+ {saving ? 'Saving...' : 'Save Changes'}+ </button>+ </div>+ </form>+ </div>+ </div>+ );+}diff --git a/client/src/components/cos/tabs/MemoryTab.jsx b/client/src/components/cos/tabs/MemoryTab.jsxindex e6384d3cf6..87d860f7d7 100644--- a/client/src/components/cos/tabs/MemoryTab.jsx+++ b/client/src/components/cos/tabs/MemoryTab.jsx@@ -1,12 +1,13 @@import { useState, useEffect, useCallback } from 'react';-import { RefreshCw, Trash2, X, Check, XCircle } from 'lucide-react';+import { RefreshCw, Trash2, X, Check, XCircle, Pencil } from 'lucide-react';import toast from 'react-hot-toast';import * as api from '../../../services/api';import { MEMORY_TYPES, MEMORY_TYPE_COLORS } from '../constants';import MemoryTimeline from './MemoryTimeline';import MemoryGraph from './MemoryGraph';+import MemoryEditModal from './MemoryEditModal';-export default function MemoryTab() {+export default function MemoryTab({ apps = [] }) {const [memories, setMemories] = useState([]);const [pendingMemories, setPendingMemories] = useState([]);const [stats, setStats] = useState(null);@@ -16,6 +17,7 @@ export default function MemoryTab() {const [view, setView] = useState('list'); // list, timeline, graphconst [filters, setFilters] = useState({ types: [] });const [embeddingStatus, setEmbeddingStatus] = useState(null);+ const [editingMemory, setEditingMemory] = useState(null);const fetchData = useCallback(async () => {setLoading(true);@@ -67,6 +69,13 @@ export default function MemoryTab() {const displayMemories = searchResults || memories;+ // Get app name for display+ const getAppName = (appId) => {+ if (!appId) return null;+ const app = apps?.find(a => a.id === appId);+ return app?.name || null;+ };+return (<div className="space-y-6">{/* Header */}@@ -179,11 +188,24 @@ export default function MemoryTab() {))}</div>)}- <div className="text-xs text-gray-500 mt-2">- {new Date(memory.createdAt).toLocaleDateString()}+ <div className="text-xs text-gray-500 mt-2 flex flex-wrap gap-2">+ <span>{new Date(memory.createdAt).toLocaleDateString()}</span>+ {getAppName(memory.sourceAppId) && (+ <>+ <span>*</span>+ <span className="text-port-accent">{getAppName(memory.sourceAppId)}</span>+ </>+ )}</div></div><div className="flex gap-2">+ <button+ onClick={() => setEditingMemory(memory)}+ className="p-2 bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded-lg transition-colors"+ title="Edit before approving"+ >+ <Pencil size={16} />+ </button><buttononClick={() => handleApprove(memory.id)}className="p-2 bg-green-500/20 text-green-400 hover:bg-green-500/30 rounded-lg transition-colors"@@ -264,16 +286,34 @@ export default function MemoryTab() {))}</div>)}- <div className="text-xs text-gray-500 mt-2">- {new Date(memory.createdAt).toLocaleDateString()} * importance: {((memory.importance || 0.5) * 100).toFixed(0)}%+ <div className="text-xs text-gray-500 mt-2 flex flex-wrap gap-2">+ <span>{new Date(memory.createdAt).toLocaleDateString()}</span>+ <span>*</span>+ <span>importance: {((memory.importance || 0.5) * 100).toFixed(0)}%</span>+ {getAppName(memory.sourceAppId) && (+ <>+ <span>*</span>+ <span className="text-port-accent">{getAppName(memory.sourceAppId)}</span>+ </>+ )}</div></div>- <button- onClick={() => handleDelete(memory.id)}- className="p-2 text-gray-500 hover:text-port-error transition-colors"- >- <Trash2 size={14} />- </button>+ <div className="flex gap-1">+ <button+ onClick={() => setEditingMemory(memory)}+ className="p-2 text-gray-500 hover:text-port-accent transition-colors"+ title="Edit memory"+ >+ <Pencil size={14} />+ </button>+ <button+ onClick={() => handleDelete(memory.id)}+ className="p-2 text-gray-500 hover:text-port-error transition-colors"+ title="Archive memory"+ >+ <Trash2 size={14} />+ </button>+ </div></div></div>))@@ -284,6 +324,19 @@ export default function MemoryTab() {) : (<MemoryGraph />)}++ {/* Edit Modal */}+ {editingMemory && (+ <MemoryEditModal+ memory={editingMemory}+ apps={apps}+ onSave={() => {+ setEditingMemory(null);+ fetchData();+ }}+ onClose={() => setEditingMemory(null)}+ />+ )}</div>);}diff --git a/client/src/pages/ChiefOfStaff.jsx b/client/src/pages/ChiefOfStaff.jsxindex 6af8f0c952..6766881d35 100644--- a/client/src/pages/ChiefOfStaff.jsx+++ b/client/src/pages/ChiefOfStaff.jsx@@ -509,7 +509,7 @@ export default function ChiefOfStaff() {)}{activeTab === 'memory' && (<div role="tabpanel" id="tabpanel-memory" aria-labelledby="tab-memory">- <MemoryTab />+ <MemoryTab apps={apps} /></div>)}{activeTab === 'health' && (