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

address review: entity-safe telegram truncation, ref-based double-submit guards for resume modal and memory actions

Adam Eivy4182bea68408
diff --git a/client/src/components/cos/tabs/MemoryTab.jsx b/client/src/components/cos/tabs/MemoryTab.jsx
index 8c5e089481..6e6ca0f6e4 100644
--- a/client/src/components/cos/tabs/MemoryTab.jsx
+++ b/client/src/components/cos/tabs/MemoryTab.jsx
@@ -1,4 +1,4 @@
-import { useState, useEffect, useCallback } from 'react';
+import { useState, useEffect, useCallback, useRef } from 'react';
import { useSearchParams } from 'react-router-dom';
import { RefreshCw, Trash2, X, Check, XCircle, Pencil, AlertTriangle, Brain, Bot } from 'lucide-react';
import toast from '../../ui/Toast';
@@ -75,11 +75,14 @@ export default function MemoryTab({ apps = [] }) {
}, [filters, sourceFilter]);
const [actionInFlight, setActionInFlight] = useState(null);
+ const actionRef = useRef(false);
const handleMemoryAction = async (id, action, label, updateStats) => {
- if (actionInFlight) return;
+ if (actionRef.current) return;
+ actionRef.current = true;
setActionInFlight(id);
const result = await action(id).catch(() => null);
+ actionRef.current = false;
setActionInFlight(null);
if (!result) return;
toast.success(`Memory ${label}`);
diff --git a/client/src/components/cos/tabs/ResumeAgentModal.jsx b/client/src/components/cos/tabs/ResumeAgentModal.jsx
index a77a0be529..1e1746587f 100644
--- a/client/src/components/cos/tabs/ResumeAgentModal.jsx
+++ b/client/src/components/cos/tabs/ResumeAgentModal.jsx
@@ -45,9 +45,11 @@ export default function ResumeAgentModal({ agent, taskType = 'user', providers,
const selectedProvider = providers?.find(p => p.id === formData.provider);
const availableModels = selectedProvider?.models || [];
+ const submittingRef = useRef(false);
const handleSubmit = async (e) => {
e.preventDefault();
- if (isSubmitting) return;
+ if (submittingRef.current) return;
+ submittingRef.current = true;
setIsSubmitting(true);
const fullContext = formData.refinedInstructions.trim()
@@ -65,6 +67,7 @@ export default function ResumeAgentModal({ agent, taskType = 'user', providers,
}).catch(err => {
toast.error(err?.message || 'Failed to resume agent');
}).finally(() => {
+ submittingRef.current = false;
setIsSubmitting(false);
});
};
diff --git a/server/services/telegram.js b/server/services/telegram.js
index 84c0a64d73..eb96615593 100644
--- a/server/services/telegram.js
+++ b/server/services/telegram.js
@@ -383,12 +383,16 @@ async function forwardNotification(notification) {
if (isMemoryApproval) {
const memory = await peekMemory(notification.metadata.memoryId).catch(() => null);
const raw = memory?.summary || memory?.content || notification.description || '';
- // Telegram messages are capped at 4096 chars; truncate raw text first to avoid
- // slicing mid-entity after escaping (e.g. & → &am). Use conservative limit
- // since escaping can expand characters (& → &amp;, < → &lt;, etc.)
- const MAX_RAW = 3000;
- const truncated = raw.length > MAX_RAW ? raw.slice(0, MAX_RAW) + '...' : raw;
- if (truncated) lines.push(escapeHtml(truncated));
+ // Telegram messages are capped at 4096 chars; escape then enforce limit
+ const escaped = escapeHtml(raw);
+ const MAX_ESCAPED = 3500;
+ let content = escaped;
+ if (content.length > MAX_ESCAPED) {
+ // Avoid slicing mid-entity (e.g. &amp;) — find last ; or safe char before limit
+ const cut = content.lastIndexOf(';', MAX_ESCAPED);
+ content = (cut > MAX_ESCAPED - 10 ? content.slice(0, cut + 1) : content.slice(0, MAX_ESCAPED)) + '...';
+ }
+ if (content) lines.push(content);
opts.reply_markup = JSON.stringify({
inline_keyboard: [[
{ text: '✅ Approve', callback_data: `${CALLBACK_APPROVE}:${notification.metadata.memoryId}` },