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
address review: attachment validation, stream errors, timeout zero, sample config, formatDateTime, attachment bounds, session switching guard, aria-label
[._.]/ Adam Eivy07f6ac6a8790
diff --git a/client/src/components/AppContextPicker.jsx b/client/src/components/AppContextPicker.jsxindex 44abf91047..eff0d0fe4b 100644--- a/client/src/components/AppContextPicker.jsx+++ b/client/src/components/AppContextPicker.jsx@@ -20,6 +20,7 @@ export default function AppContextPicker({value={value}onChange={(event) => onChange?.(event.target.value)}className={selectClassName}+ aria-label={label || placeholder}>{includeDefaultOption && <option value="">{placeholder}</option>}{apps.map(app => (diff --git a/client/src/pages/OpenClaw.jsx b/client/src/pages/OpenClaw.jsxindex 45d9b12ec6..4006c8b76a 100644--- a/client/src/pages/OpenClaw.jsx+++ b/client/src/pages/OpenClaw.jsx@@ -246,17 +246,40 @@ export default function OpenClaw() {useEffect(() => () => abortControllerRef.current?.abort(), []);+ const MAX_ATTACHMENTS = 8;+ const MAX_ATTACHMENT_FILE_SIZE = 10 * 1024 * 1024; // 10MB per file+const appendFiles = useCallback(async (files) => {if (!files || files.length === 0) return;+ const currentCount = Array.isArray(attachments) ? attachments.length : 0;+ const remainingSlots = MAX_ATTACHMENTS - currentCount;++ if (remainingSlots <= 0) {+ setMessagesError(`You can attach up to ${MAX_ATTACHMENTS} files per message.`);+ return;+ }++ const limitedFiles = files.slice(0, remainingSlots);+ const tooLargeFile = limitedFiles.find(+ (file) => typeof file.size === 'number' && file.size > MAX_ATTACHMENT_FILE_SIZE+ );++ if (tooLargeFile) {+ setMessagesError(+ `"${tooLargeFile.name}" is too large. Maximum attachment size is ${Math.round(MAX_ATTACHMENT_FILE_SIZE / (1024 * 1024))}MB.`+ );+ return;+ }+try {- const next = await filesToAttachments(files);+ const next = await filesToAttachments(limitedFiles);setAttachments(current => [...current, ...next]);setMessagesError('');} catch (err) {setMessagesError(err.message || 'Failed to prepare attachment');}- }, []);+ }, [attachments]);const handleAttachmentSelect = async (event) => {const files = Array.from(event.target.files || []);@@ -532,10 +555,14 @@ export default function OpenClaw() {<buttonkey={session.id}type="button"- onClick={() => setSelectedSessionId(session.id)}+ disabled={sending}+ onClick={() => {+ if (sending || isActive) return;+ setSelectedSessionId(session.id);+ }}className={`block w-full border-b border-port-border px-4 py-3 text-left transition-colors last:border-b-0 ${isActive ? 'bg-port-accent/10 text-white' : 'text-gray-300 hover:bg-port-border/20 hover:text-white'- }`}+ } ${sending ? 'cursor-not-allowed opacity-60' : ''}`}><div className="truncate text-sm font-medium">{session.title || session.label || session.id}</div><div className="mt-1 flex items-center justify-between gap-3 text-xs text-gray-500">@@ -563,10 +590,14 @@ export default function OpenClaw() {<buttonkey={session.id}type="button"- onClick={() => setSelectedSessionId(session.id)}+ disabled={sending}+ onClick={() => {+ if (sending || isActive) return;+ setSelectedSessionId(session.id);+ }}className={`block w-full border-t border-port-border/60 px-4 py-3 text-left transition-colors ${isActive ? 'bg-port-accent/10 text-white' : 'text-gray-400 hover:bg-port-border/20 hover:text-white'- }`}+ } ${sending ? 'cursor-not-allowed opacity-60' : ''}`}><div className="truncate text-sm font-medium">{session.title || session.label || session.id}</div><div className="mt-1 flex items-center justify-between gap-3 text-xs text-gray-500">diff --git a/client/src/utils/formatters.js b/client/src/utils/formatters.jsindex 37bbf689eb..23b65b34e5 100644--- a/client/src/utils/formatters.js+++ b/client/src/utils/formatters.js@@ -117,7 +117,7 @@ export function formatBytes(bytes, decimals = 1) {export function formatDateTime(value) {if (!value) return 'Unknown time';const date = new Date(value);- if (Number.isNaN(date.getTime())) return String(value);+ if (Number.isNaN(date.getTime())) return 'Unknown time';return new Intl.DateTimeFormat(undefined, { dateStyle: 'medium', timeStyle: 'short' }).format(date);}diff --git a/data.sample/openclaw/config.json b/data.sample/openclaw/config.jsonindex cf7ef82ef7..fb5f62b306 100644--- a/data.sample/openclaw/config.json+++ b/data.sample/openclaw/config.json@@ -5,9 +5,7 @@"defaultSession": "main","label": "Local Operator Runtime","paths": {- "status": "/status",- "sessions": "/sessions",- "sessionMessages": "/sessions/:sessionId/messages",- "sendMessage": "/sessions/:sessionId/messages"+ "toolsInvoke": "/tools/invoke",+ "responses": "/v1/responses"}}diff --git a/server/integrations/openclaw/api.js b/server/integrations/openclaw/api.jsindex 1e047a0f8b..7a33ab7ad3 100644--- a/server/integrations/openclaw/api.js+++ b/server/integrations/openclaw/api.js@@ -133,7 +133,7 @@ async function loadConfig() {label: pickFirst(process.env.OPENCLAW_LABEL, fileConfig.label, 'OpenClaw Runtime'),defaultSession: pickFirst(process.env.OPENCLAW_DEFAULT_SESSION, fileConfig.defaultSession, null),defaultAgentId: pickFirst(process.env.OPENCLAW_DEFAULT_AGENT_ID, fileConfig.defaultAgentId, 'main'),- timeoutMs: Number.parseInt(String(pickFirst(process.env.OPENCLAW_TIMEOUT_MS, fileConfig.timeoutMs, DEFAULT_TIMEOUT_MS)), 10) || DEFAULT_TIMEOUT_MS,+ timeoutMs: (() => { const raw = Number.parseInt(String(pickFirst(process.env.OPENCLAW_TIMEOUT_MS, fileConfig.timeoutMs, DEFAULT_TIMEOUT_MS)), 10); return Number.isFinite(raw) && raw >= 0 ? raw : DEFAULT_TIMEOUT_MS; })(),paths: {...DEFAULT_PATHS,...(fileConfig.paths || {})diff --git a/server/lib/fetchWithTimeout.test.js b/server/lib/fetchWithTimeout.test.jsindex eb16f49a30..4e7d94a4e1 100644--- a/server/lib/fetchWithTimeout.test.js+++ b/server/lib/fetchWithTimeout.test.js@@ -63,6 +63,22 @@ describe('fetchWithTimeout', () => {await expect(promise).rejects.toThrow('aborted');});+ it('does not schedule a timeout when timeoutMs is 0', async () => {+ vi.useFakeTimers();+ try {+ const mockResponse = { ok: true, status: 200 };+ vi.stubGlobal('fetch', vi.fn().mockResolvedValue(mockResponse));+ const setTimeoutSpy = vi.spyOn(global, 'setTimeout');++ const result = await fetchWithTimeout('http://example.com', {}, 0);+ expect(result).toBe(mockResponse);+ // setTimeout should not have been called for the abort timer+ expect(setTimeoutSpy).not.toHaveBeenCalled();+ } finally {+ vi.useRealTimers();+ }+ });+it('aborts immediately when caller signal is already aborted (fallback path)', async () => {// Force fallback path by temporarily removing AbortSignal.anyconst origDescriptor = Object.getOwnPropertyDescriptor(AbortSignal, 'any');diff --git a/server/routes/openclaw.js b/server/routes/openclaw.jsindex 3318e757ce..119582fd72 100644--- a/server/routes/openclaw.js+++ b/server/routes/openclaw.js@@ -21,6 +21,32 @@ const attachmentSchema = z.object({mimeType: z.string().trim().min(1).optional(),data: z.string().trim().min(1).optional(),url: z.string().trim().url().optional()+}).superRefine((value, ctx) => {+ const hasData = typeof value.data === 'string' && value.data.trim().length > 0;+ const hasUrl = typeof value.url === 'string' && value.url.trim().length > 0;++ if (!hasData && !hasUrl) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ message: 'Attachment must include either base64 data or url.'+ });+ }++ if (value.sourceType === 'base64' && !hasData) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ path: ['data'],+ message: 'Attachment with sourceType "base64" must include non-empty data.'+ });+ }++ if (value.sourceType === 'url' && !hasUrl) {+ ctx.addIssue({+ code: z.ZodIssueCode.custom,+ path: ['url'],+ message: 'Attachment with sourceType "url" must include a valid url.'+ });+ }});const contextSchema = z.object({@@ -146,7 +172,12 @@ router.post('/sessions/:id/messages/stream', asyncHandler(async (req, res) => {if (tail) res.write(tail);} catch (err) {if (err?.name !== 'AbortError') {- console.error(`❌ OpenClaw stream error: ${err.message}`);+ const errorPayload = {+ error: 'Upstream stream error',+ message: err instanceof Error ? err.message : String(err)+ };+ res.write(`event: error\ndata: ${JSON.stringify(errorPayload)}\n\n`);+ console.error(`❌ OpenClaw stream error: ${err instanceof Error ? err.message : String(err)}`);}}res.end();