summaryrefslogtreecommitdiff
path: root/tests/brainstorm-server/server.test.js
AgeCommit message (Collapse)Author
2026-11-03test(brainstorm-server): drain the socket before counting reloadsJesse Vincent
The two "does NOT send reload" tests waited for the barrier file's screen-added line on stdout, then counted reloads on the WebSocket. The server logs and broadcasts in the same tick, but stdout and the socket are separate channels, and on Linux stdout usually won: the socket had 0 reloads when the barrier fired and 1 reload 300ms later, so the tests failed in 8 of 10 runs. They now ping the server after the barrier and wait for the pong. The server writes it on the same socket after the reload, so every reload sent before it has arrived. 30 consecutive clean runs; with the server's .html filter removed, both tests still fail.
2026-10-21test(brainstorm-server): wait for file events instead of sleepingJesse Vincent
On macOS, fs.watch (FSEvents) delivered events anywhere from ~100ms to 2.4s after the write on Node 26.10 / Darwin 27, and sometimes held an event back to deliver it in a batch with a later one. The file-watching tests slept a fixed 500ms, so they failed when an event came late, and a late event from one test could trigger a reload or clear state/events during another. Six tests failed on v7.0.0 and on dev, a different six each run. The tests now poll for the outcome with a 5s timeout, wait until the server logs the exact screen event they caused, and drain in-flight events with a barrier file before asserting that nothing reloaded or that state/events survived. 15 consecutive runs pass; dropping the server's .html/dotfile filter still fails both negative tests.
2026-09-26test(brainstorm-server): stop orphaning the server when a test failsJesse Vincent
process.exit(1) ran inside the try, so the finally that kills the spawned server never ran. The leftover server held port 3334 and the next run died with 'preferred port is in use'. Set process.exitCode instead so teardown runs.
2026-09-26fix(brainstorming): preserve literal content replacement tokens (#2364)落尘
2026-06-16Add visual companion Prime Radiant brandingDrew Ritter
2026-06-16Fix server test fallback cleanupDrew Ritter
2026-06-16Harden root screen containmentDrew Ritter
2026-06-16Harden brainstorm companion auth regressionsDrew Ritter
2026-06-16fix(brainstorm-server): fix auth-integration bugs from full-branch reviewJesse Vincent
A second adversarial review of the merged branch found that combining the session-key auth with the feature work created real bugs the (vacuous) tests missed: - [Critical] GET /files/ (empty name) resolved to CONTENT_DIR and crashed the process with uncaught EISDIR — newly reachable because the query-stripping refactor turns /files/?key=... into /files/. Reject non-regular-file names. - [High] --open opened a KEYLESS url, which the auth gate 403s — the headline feature landed on the error page. Open the keyed url. - [High] Same-port restart regenerated the token (port persisted, token not), so the open tab's old cookie 403'd and never reconnected — contradicting the documented promise. Persist the token (BRAINSTORM_TOKEN_FILE / .last-token) alongside the port. - [Medium] Token sat in world-readable server-info/server.log (0644 in /tmp). umask 077 in start-server.sh + mode 0600 on server-info/.last-token. - [Medium] touchActivity() ran before the auth check, so unauthenticated requests defeated the idle timeout. Count activity only after authorization. - [Low] COOKIE_NAME embedded the pre-fallback port; derive it from the actual bound port (also prevents a cross-server cookie-jar collision on fallback). Tests added/strengthened (previously passed vacuously): /files/ no-crash; the auto-open url carries the key and is reachable (200); restart reuses the same key not just the port; unauthenticated requests don't reset the idle clock. Full suite green (ws-protocol 32, helper 12, auth 13, server 29, lifecycle 8, stop-server 4); restart smoke confirms same port+key and old URL -> 200.
2026-06-16test(brainstorm-server): thread session key through tests after auth mergeJesse Vincent
Integrating the per-session-key auth onto the same branch as the dotfile and lifecycle work: two tests added after the auth commit opened WebSockets without a key (server.test.js dotfile-reload, lifecycle.test.js idle-shutdown), which the auth gate now resets. Pass ?key=/BRAINSTORM_TOKEN in both. Full suite green: ws-protocol 32, helper 12, auth 13, server 28, lifecycle 7, stop-server 4.
2026-06-16feat(brainstorm-server): gate every endpoint behind a per-session keyJesse Vincent
The companion server is reachable by any local browser tab (default loopback bind) and by any host that can route to it (remote --host bind). It served screens, files, and accepted event-injecting WebSocket connections with no authentication, so a malicious browser tab or a direct remote client could read brainstorm content or inject events that the agent reads as the user's input (prompt injection into a live session). Generate a per-session secret token, carry it in the served URL as ?key=, and mirror it into an HttpOnly SameSite=Strict per-port cookie on first load so same-origin subresources and the WebSocket handshake authenticate automatically. Every HTTP request and WebSocket upgrade now requires a valid key (query or cookie, constant-time compared); unauthenticated requests get a friendly 403 explaining they need the full URL. A secret authenticates the client uniformly across loopback, tunnel, and remote binds and defeats DNS rebinding, which a Host/Origin allowlist cannot. Also guard handleMessage against a null JSON payload that crashed the process. Tests: new auth.test.js (13 cases) covering the key on /, /files/*, and WS plus cookie bootstrap and the null-payload guard; server.test.js threads the key; ws-protocol.test.js + auth.test.js wired into npm test. Closes #1014 Refs #1110, #1553, #1504
2026-06-16fix(brainstorm-server): ignore macOS resource-fork dotfilesJesse Vincent
On macOS (and ExFAT/SMB volumes) the OS writes ._<name>.html sidecar files holding binary resource-fork metadata. These end with .html, so they passed the content filter and could be picked as the newest screen — serving binary garbage to the browser instead of the mockup — or fetched via /files/. Skip dotfiles (leading '.') at all four sites that list or serve content: getNewestScreen, the /files/ endpoint, the known-files seed, and the fs.watch handler. Tests cover serving (/ and /files/) and the watch path (a ._ file must not trigger a reload). Refs #950
2026-06-16Phase D: cross-runtime tweaks (visual-companion, executing-plans, test)Jesse Vincent
Misc platform/runtime statements and adjacencies that don't fit the prose, config-ref, README-ordering, or tool-vocabulary buckets: - visual-companion frame template: rename CSS/HTML id #claude-content → #frame-content. The id is purely styling — nothing external references it. The brainstorm-server test that asserted the old string is updated in lockstep. - visual-companion launch instructions: add a Copilot CLI section alongside Claude Code, Codex, and Gemini CLI; combine the Claude Code (macOS / Linux) and (Windows) sections so heading style matches the other (non-OS-qualified) platforms. - visual-companion: "Use Write tool" → "Use your file-creation tool" for the cat/heredoc warning. The prohibition is what's load- bearing, not the tool name. - executing-plans/SKILL.md: list all subagent-capable runtimes (Claude Code, Codex CLI, Codex App, Copilot CLI, Gemini CLI) and point at the per-platform tool refs as the source of truth. - executing-plans/SKILL.md: relative path "using-superpowers/ references/" → "../using-superpowers/references/" to resolve correctly from the executing-plans/ directory. No bundled spec doc here — Phase D was scope-extension work that took place across rounds, with no standalone spec authored.
2026-03-25Separate brainstorm server content and state into peer directoriesJesse Vincent
The session directory now contains two peers: content/ (HTML served to the browser) and state/ (events, server-info, pid, log). Previously all files shared a single directory, making server state and user interaction data accessible over the /files/ HTTP route. Also fixes stale test assertion ("Waiting for Claude" → "Waiting for the agent"). Reported-By: 吉田仁
2026-03-25Revert "Move brainstorm server metadata to .meta/ subdirectory"Jesse Vincent
This reverts commit ab500dade6187cf78b9b263ecf4799ec3420d1ef.
2026-03-25Move brainstorm server metadata to .meta/ subdirectoryJesse Vincent
Metadata files (.server-info, .events, .server.pid, .server.log, .server-stopped) were stored in the same directory served over HTTP, making them accessible via the /files/ route. They now live in a .meta/ subdirectory that is not web-accessible. Also fixes a stale test assertion ("Waiting for Claude" → "Waiting for the agent"). Reported-By: 吉田仁
2026-03-17fix : resolve ESM/CommonJS module confict in brainstorming serversarbojitrana
2026-03-11Add design spec and tests for zero-dep brainstorm serverJesse Vincent
Replace vendored node_modules (714 files) with a single server.js using only Node built-ins. Spec covers WebSocket protocol, HTTP serving, file watching, and static file serving. Tests written before implementation (TDD). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-09Move brainstorm-server into skill directory per agentskills specJesse Vincent
Moves lib/brainstorm-server/ → skills/brainstorming/scripts/ so the brainstorming skill uses relative paths (scripts/start-server.sh) instead of ${CLAUDE_PLUGIN_ROOT}/lib/brainstorm-server/. This follows the agentskills.io specification for portable, cross-platform skills. Updates visual-companion.md references and test paths. All tests pass.
2026-03-06Add brainstorm server with WebSocket support, helpers, and testsJesse Vincent
WebSocket server for real-time browser communication during brainstorming sessions. Includes browser helper library for event capture, shell scripts for server lifecycle management with session isolation and persistent mockup storage, and integration tests. Co-Authored-By: Drew Ritter <drew@ritter.dev>