Files
SuperCharged-Claude-Code-Up…/patch_simple.sh
uroma 55aafbae9a Fix project isolation: Make loadChatHistory respect active project sessions
- Modified loadChatHistory() to check for active project before fetching all sessions
- When active project exists, use project.sessions instead of fetching from API
- Added detailed console logging to debug session filtering
- This prevents ALL sessions from appearing in every project's sidebar

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-22 14:43:05 +00:00

49 lines
3.4 KiB
Bash

#!/bin/bash
# Simple and reliable cache-busting implementation
SERVER_FILE="/home/uroma/obsidian-web-interface/server.js"
echo "[CACHE-BUSTING] Creating backup..."
cp "$SERVER_FILE" "${SERVER_FILE}.backup"
# Step 1: Add cache-busting constants after SESSION_SECRET line
echo "[CACHE-BUSTING] Adding configuration..."
sed -i "/const SESSION_SECRET = 'obsidian-web-secret-'*/a\\\\
// ============================================================\\\\
// CACHE-BUSTING CONFIGURATION\\\\
// ============================================================\\\\
// Build timestamp forces browser to reload all assets on server restart\\\\
const BUILD_TIMESTAMP = Date.now();\\\\
const ASSET_VERSION = \\\\`v=\${BUILD_TIMESTAMP}\\\\`;\\\\
\\\\
console.log(\\\\\`[CACHE-BUSTING] Build timestamp initialized: \${BUILD_TIMESTAMP}\\\\\`);\\\\
console.log(\\\\\`[CACHE-BUSTING] All JavaScript files will be served with ?\${ASSET_VERSION}\\\\\`);
" "$SERVER_FILE"
# Step 2: Add middleware import after database import
echo "[CACHE-BUSTING] Adding middleware import..."
sed -i "/const { db } = require('.\\/services\\/database');/a\\\\
\\\\
// Cache-busting middleware\\\\
const { createCacheBustingMiddleware } = require('.\\/cache-bust-middleware');
" "$SERVER_FILE"
# Step 3: Add middleware application after session middleware
echo "[CACHE-BUSTING] Applying middleware..."
# Find the session middleware closing and add our middleware
perl -i -0pe 's/(name: '"'"'connect\.sid'"'"'\n }\)\)\n/\1\n\n\/\/ Apply cache-busting middleware to HTML responses\napp.use(createCacheBustingMiddleware(ASSET_VERSION));\n/' "$SERVER_FILE"
# Step 4: Update static file configuration
echo "[CACHE-BUSTING] Updating static file headers..."
perl -i -0pe 's/\/\/ Serve static files \(must come after specific routes\)\n\/\/ Disable caching for JS files to prevent browser from serving stale code\napp\.use\('"'"'\/claude'"'"', express\.static\(path\.join\(__dirname, '"'"'public'"'"'\), \{\n etag: false,\n lastModified: false,\n setHeaders: \(res, filePath\) => \{\n if \(filePath\.endsWith\('"'"'\.js'"'"'\)\)\) \{\n res\.setHeader\('"'"'Cache-Control'"'"', '"'"'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'"'"'\);\n res\.setHeader\('"'"'Pragma'"'"', '"'"'no-cache'"'"'\);\n res\.setHeader\('"'"'Expires'"'"', '"'"'0'"'"'\);\n \}\n \}\n\}\);/\/\/ Serve static files (must come after specific routes)\n\/\/ Disable caching for JS files to prevent browser from serving stale code\n\/\/ CRITICAL: Cache-busting via query parameters (ASSET_VERSION) ensures fresh content\napp.use('\''\/claude'\'', express.static(path.join(__dirname, '\''public'\''), {\n etag: false,\n lastModified: false,\n setHeaders: (res, filePath) => {\n if (filePath.endsWith('\''\.js'\'') || filePath.endsWith('\''\.css'\'')) {\n res.setHeader('\''Cache-Control'\'', '\''no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0'\'');\n res.setHeader('\''Pragma'\'', '\''no-cache'\'');\n res.setHeader('\''Expires'\'', '\''0'\'');\n res.removeHeader('\''ETag'\'');\n }\n }\n});/' "$SERVER_FILE"
echo "[CACHE-BUSTING] Verifying syntax..."
if node -c "$SERVER_FILE" 2>&1 | grep -q "SyntaxError"; then
echo "[CACHE-BUSTING] ✗ Syntax error detected!"
echo "[CACHE-BUSTING] Restoring backup..."
cp "${SERVER_FILE}.backup" "$SERVER_FILE"
exit 1
else
echo "[CACHE-BUSTING] ✓ All modifications applied successfully!"
fi