fix: session isolation and blocking wait for visual companion

- Each session gets unique temp directory (/tmp/brainstorm-{pid}-{timestamp})
- Server outputs screen_dir and screen_file in startup JSON
- stop-server.sh takes screen_dir arg and cleans up session directory
- Document blocking TaskOutput pattern: 10-min timeouts, retry up to 3x,
  then prompt user "let me know when you want to continue"
This commit is contained in:
Jesse Vincent
2026-01-17 17:25:45 -08:00
parent 2a61167b02
commit b98afbd74f
6 changed files with 77 additions and 40 deletions

View File

@@ -3,15 +3,19 @@
# Usage: start-server.sh
#
# Starts server on a random high port, outputs JSON with URL
# Each session gets its own temp directory to avoid conflicts
# Server runs in background, PID saved for cleanup
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SCREEN_DIR="${BRAINSTORM_SCREEN_DIR:-/tmp/brainstorm}"
# Generate unique session directory
SESSION_ID="$$-$(date +%s)"
SCREEN_DIR="/tmp/brainstorm-${SESSION_ID}"
SCREEN_FILE="${SCREEN_DIR}/screen.html"
PID_FILE="${SCREEN_DIR}/.server.pid"
LOG_FILE="${SCREEN_DIR}/.server.log"
# Ensure screen directory exists
# Create fresh session directory
mkdir -p "$SCREEN_DIR"
# Kill any existing server
@@ -23,7 +27,7 @@ fi
# Start server, capturing output to log file
cd "$SCRIPT_DIR"
node index.js > "$LOG_FILE" 2>&1 &
BRAINSTORM_SCREEN="$SCREEN_FILE" node index.js > "$LOG_FILE" 2>&1 &
SERVER_PID=$!
echo "$SERVER_PID" > "$PID_FILE"