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: SSE backpressure drain, consistent MIME allowlist, Accept header for stream

[._.]/ Adam Eivy54e251136776
diff --git a/client/src/pages/OpenClaw.jsx b/client/src/pages/OpenClaw.jsx
index 9bffb046ae..15b02252ca 100644
--- a/client/src/pages/OpenClaw.jsx
+++ b/client/src/pages/OpenClaw.jsx
@@ -98,6 +98,22 @@ function getAttachmentKind(file) {
return file.type.startsWith('image/') ? 'image' : 'file';
}
+const ALLOWED_ATTACHMENT_MIME_PREFIXES = ['image/'];
+const ALLOWED_ATTACHMENT_MIME_TYPES = new Set([
+ 'text/plain', 'text/markdown', 'text/x-markdown',
+ 'application/json', 'text/csv', 'application/csv', 'text/x-csv',
+ 'application/pdf'
+]);
+const ALLOWED_ATTACHMENT_EXTENSIONS = new Set(['.txt', '.md', '.json', '.csv', '.pdf']);
+
+function isAllowedAttachmentType(file) {
+ if (ALLOWED_ATTACHMENT_MIME_PREFIXES.some(p => file.type?.startsWith(p))) return true;
+ const mimeBase = file.type ? file.type.split(';')[0].trim().toLowerCase() : '';
+ if (mimeBase && ALLOWED_ATTACHMENT_MIME_TYPES.has(mimeBase)) return true;
+ const ext = file.name ? `.${file.name.split('.').pop().toLowerCase()}` : '';
+ return ALLOWED_ATTACHMENT_EXTENSIONS.has(ext);
+}
+
function normalizeContent(content) {
if (typeof content === 'string') return content;
if (!content) return '';
@@ -319,6 +335,12 @@ export default function OpenClaw() {
return;
}
+ const disallowedFile = limitedFiles.find(file => !isAllowedAttachmentType(file));
+ if (disallowedFile) {
+ setMessagesError(`"${disallowedFile.name}" is not a supported file type. Allowed: images, .txt, .md, .json, .csv, .pdf`);
+ return;
+ }
+
try {
const next = await filesToAttachments(limitedFiles);
diff --git a/client/src/services/apiOpenClaw.js b/client/src/services/apiOpenClaw.js
index 083cadf5e1..502764cdd3 100644
--- a/client/src/services/apiOpenClaw.js
+++ b/client/src/services/apiOpenClaw.js
@@ -19,7 +19,8 @@ export async function streamOpenClawMessage(sessionId, { message, context, attac
const response = await fetch(`${API_BASE}/openclaw/sessions/${encodeURIComponent(sessionId)}/messages/stream`, {
method: 'POST',
headers: {
- 'Content-Type': 'application/json'
+ 'Content-Type': 'application/json',
+ Accept: 'text/event-stream'
},
body: JSON.stringify({ message, context, attachments }),
signal
diff --git a/server/routes/openclaw.js b/server/routes/openclaw.js
index 138c62b44b..3cace29747 100644
--- a/server/routes/openclaw.js
+++ b/server/routes/openclaw.js
@@ -176,7 +176,10 @@ router.post('/sessions/:id/messages/stream', asyncHandler(async (req, res) => {
while (true) {
const { done, value } = await reader.read();
if (done || clientDisconnected || res.writableEnded || res.destroyed) break;
- if (value) res.write(decoder.decode(value, { stream: true }));
+ if (value) {
+ const canContinue = res.write(decoder.decode(value, { stream: true }));
+ if (!canContinue) await new Promise(resolve => res.once('drain', resolve));
+ }
}
const tail = decoder.decode();
if (tail && !res.writableEnded && !res.destroyed) res.write(tail);