Node-based terminal manager for AI coding agents — tmux-backed terminals and parallel agent sessions as draggable nodes on an infinite pan/zoom canvas. macOS, Linux, and a browser Server Edition.
TypeScript adhdagent-orchestrationai-agentscanvasclaude-codecodexcoding-agentsdeveloper-toolselectrongeminilinuxmacosmultiplexeropencodeparallel-agentsterminalterminal-emulatorterminal-multiplexertmuxworkspace-manager
fix(server): warn when index.html CSP rewrite marker is absent
enes1df672a4f751
diff --git a/src/server/http.test.ts b/src/server/http.test.tsindex 84561d157..a2789e289 100644--- a/src/server/http.test.ts+++ b/src/server/http.test.ts@@ -1,4 +1,4 @@-import { describe, it, expect, beforeEach, afterEach } from 'vitest'+import { describe, it, expect, beforeEach, afterEach, vi } from 'vitest'import http from 'http'import fs from 'fs'import os from 'os'@@ -98,6 +98,26 @@ describe('http layer', () => {expect(await evil.text()).not.toContain('salt')})+ it('warns (and still 200s) when index.html lacks the CSP rewrite marker', async () => {+ const cookie = await setupAndLogin()+ fs.writeFileSync(+ path.join(rendererDir, 'index.html'),+ `<meta http-equiv="Content-Security-Policy" content="default-src 'none'" /><div id="root"></div>`+ )+ const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})+ try {+ const res = await fetch(`${base}/`, { headers: { cookie } })+ expect(res.status).toBe(200)+ const html = await res.text()+ expect(html).not.toContain('connect-src')+ expect(warn).toHaveBeenCalledTimes(1)+ expect(warn.mock.calls[0][0]).toContain('CSP')+ expect(warn.mock.calls[0][0]).toContain('WebSocket')+ } finally {+ warn.mockRestore()+ }+ })+it('sessionTokenFromCookie parses the session out of a multi-cookie header', () => {expect(sessionTokenFromCookie(`a=b; ${SESSION_COOKIE}=tok123; c=d`)).toBe('tok123')expect(sessionTokenFromCookie(undefined)).toBeUndefined()diff --git a/src/server/http.ts b/src/server/http.tsindex 8b3c9974b..adadad584 100644--- a/src/server/http.ts+++ b/src/server/http.ts@@ -191,11 +191,18 @@ function serveStatic(let body: Buffer = fs.readFileSync(filePath)// CSP rewrite ONLY on index.html: relax connect-src so the WS client can connect.if (path.basename(filePath) === 'index.html') {- body = Buffer.from(- body- .toString('utf8')- .replace("default-src 'self';", "default-src 'self'; connect-src 'self' ws: wss:;")- )+ const html = body.toString('utf8')+ const marker = "default-src 'self';"+ if (html.includes(marker)) {+ body = Buffer.from(html.replace(marker, "default-src 'self'; connect-src 'self' ws: wss:;"))+ } else {+ // A silent no-op here would leave the desktop CSP intact and the browser+ // would block the ws:/wss: WebSocket with no visible error — make sure an+ // operator sees this in the server logs.+ console.warn(+ "[nodeterm-server] index.html CSP did not contain the expected `default-src 'self';` marker — the ws: connect-src rewrite did not apply; the browser will block the WebSocket. Rebuild the renderer or update the rewrite."+ )+ }}res.writeHead(200, { 'Content-Type': contentType })res.end(body)