Skip to content

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

fix(memory): use correct backend for telegram approval and improve mobile UX

Adam Eivy06b1f78ce8f5
diff --git a/client/src/components/cos/tabs/MemoryTab.jsx b/client/src/components/cos/tabs/MemoryTab.jsx
index f7529cd93d..705f565fff 100644
--- a/client/src/components/cos/tabs/MemoryTab.jsx
+++ b/client/src/components/cos/tabs/MemoryTab.jsx
@@ -74,18 +74,22 @@ export default function MemoryTab({ apps = [] }) {
setLoading(false);
}, [filters, sourceFilter]);
- const handleApprove = async (id) => {
- await api.approveMemory(id);
- toast.success('Memory approved');
- fetchData();
- };
+ const [actionInFlight, setActionInFlight] = useState(null);
- const handleReject = async (id) => {
- await api.rejectMemory(id);
- toast.success('Memory rejected');
- fetchData();
+ const handleMemoryAction = async (id, action, label, updateStats) => {
+ if (actionInFlight) return;
+ setActionInFlight(id);
+ const result = await action(id).catch(() => null);
+ setActionInFlight(null);
+ if (!result) return;
+ toast.success(`Memory ${label}`);
+ setPendingMemories(prev => prev.filter(m => m.id !== id));
+ setStats(prev => prev ? { ...prev, pendingApproval: Math.max(0, (prev.pendingApproval || 0) - 1), ...updateStats } : prev);
};
+ const handleApprove = (id) => handleMemoryAction(id, api.approveMemory, 'approved', { active: (stats?.active || 0) + 1 });
+ const handleReject = (id) => handleMemoryAction(id, api.rejectMemory, 'rejected', {});
+
useEffect(() => {
fetchData();
}, [fetchData]);
@@ -272,24 +276,27 @@ export default function MemoryTab({ apps = [] }) {
<div className="flex gap-2 sm:flex-col md:flex-row">
<button
onClick={() => setEditingMemory(memory)}
- className="flex-1 sm:flex-none p-3 min-h-[44px] min-w-[44px] flex items-center justify-center bg-port-accent/20 text-port-accent hover:bg-port-accent/30 rounded-lg transition-colors"
+ disabled={actionInFlight === memory.id}
+ className="flex-1 sm:flex-none p-3 min-h-[44px] min-w-[44px] flex items-center justify-center bg-port-accent/20 text-port-accent hover:bg-port-accent/30 active:bg-port-accent/40 rounded-lg transition-colors disabled:opacity-50"
title="Edit before approving"
>
<Pencil size={20} />
</button>
<button
onClick={() => handleApprove(memory.id)}
- className="flex-1 sm:flex-none p-3 min-h-[44px] min-w-[44px] flex items-center justify-center bg-green-500/20 text-green-400 hover:bg-green-500/30 rounded-lg transition-colors"
+ disabled={!!actionInFlight}
+ className="flex-1 sm:flex-none p-3 min-h-[44px] min-w-[44px] flex items-center justify-center bg-green-500/20 text-green-400 hover:bg-green-500/30 active:bg-green-500/40 rounded-lg transition-colors disabled:opacity-50"
title="Approve"
>
- <Check size={20} />
+ {actionInFlight === memory.id ? <RefreshCw className="animate-spin" size={20} /> : <Check size={20} />}
</button>
<button
onClick={() => handleReject(memory.id)}
- className="flex-1 sm:flex-none p-3 min-h-[44px] min-w-[44px] flex items-center justify-center bg-red-500/20 text-red-400 hover:bg-red-500/30 rounded-lg transition-colors"
+ disabled={!!actionInFlight}
+ className="flex-1 sm:flex-none p-3 min-h-[44px] min-w-[44px] flex items-center justify-center bg-red-500/20 text-red-400 hover:bg-red-500/30 active:bg-red-500/40 rounded-lg transition-colors disabled:opacity-50"
title="Reject"
>
- <XCircle size={20} />
+ {actionInFlight === memory.id ? <RefreshCw className="animate-spin" size={20} /> : <XCircle size={20} />}
</button>
</div>
</div>
diff --git a/server/services/memoryBackend.js b/server/services/memoryBackend.js
index f05686e019..3e1a5da391 100644
--- a/server/services/memoryBackend.js
+++ b/server/services/memoryBackend.js
@@ -81,6 +81,11 @@ export async function createMemory(data, embedding) {
return b.createMemory(data, embedding);
}
+export async function peekMemory(id) {
+ const b = await getBackend();
+ return b.peekMemory(id);
+}
+
export async function getMemory(id) {
const b = await getBackend();
return b.getMemory(id);
diff --git a/server/services/memoryDB.js b/server/services/memoryDB.js
index 3a41be4944..9812faad3f 100644
--- a/server/services/memoryDB.js
+++ b/server/services/memoryDB.js
@@ -122,6 +122,12 @@ export async function createMemory(data, embedding = null) {
/**
* Get a memory by ID
*/
+export async function peekMemory(id) {
+ const result = await query('SELECT * FROM memories WHERE id = $1', [id]);
+ if (result.rows.length === 0) return null;
+ return rowToMemory(result.rows[0]);
+}
+
export async function getMemory(id) {
const result = await query('SELECT * FROM memories WHERE id = $1', [id]);
if (result.rows.length === 0) return null;
diff --git a/server/services/telegram.js b/server/services/telegram.js
index 35c9638d71..90d40ad257 100644
--- a/server/services/telegram.js
+++ b/server/services/telegram.js
@@ -11,7 +11,7 @@ import { join } from 'path';
import { v4 as uuidv4 } from '../lib/uuid.js';
import { getSettings } from './settings.js';
import { notificationEvents, NOTIFICATION_TYPES, getNotifications } from './notifications.js';
-import { approveMemory, rejectMemory, peekMemory } from './memory.js';
+import { approveMemory, rejectMemory, peekMemory } from './memoryBackend.js';
import { ensureDir, PATHS, readJSONFile, formatDuration } from '../lib/fileUtils.js';
import { getActiveAgents } from './subAgentSpawner.js';
import { getGoals } from './identity.js';