diff --git a/dev-init.sh b/dev-init.sh new file mode 100755 index 0000000..4bd5c67 --- /dev/null +++ b/dev-init.sh @@ -0,0 +1,43 @@ +#!/bin/bash +# Development environment startup for Open Notebook +# Assumes SurrealDB is already running externally (per .env config) + +set -e + +echo "=== Open Notebook Dev Startup ===" + +# Check SurrealDB connectivity +SURREAL_PORT=${SURREAL_PORT:-8018} +echo "Checking SurrealDB on port $SURREAL_PORT..." +if ! nc -z localhost "$SURREAL_PORT" 2>/dev/null; then + echo "❌ SurrealDB not reachable on port $SURREAL_PORT. Please start it first." + exit 1 +fi +echo "✅ SurrealDB is running" + +# Install dependencies if needed +echo "Syncing Python dependencies..." +uv sync + +echo "Syncing frontend dependencies..." +cd frontend && npm install && cd .. + +# Start API backend in background +echo "Starting API backend (port 5055)..." +uv run --env-file .env run_api.py & +sleep 3 + +# Start background worker in background +echo "Starting background worker..." +uv run --env-file .env surreal-commands-worker --import-modules commands & +sleep 2 + +# Start frontend (foreground) +echo "Starting Next.js frontend (port 3000)..." +echo "" +echo "✅ All services starting!" +echo " Frontend: http://localhost:3000" +echo " API: http://localhost:5055" +echo " API Docs: http://localhost:5055/docs" +echo "" +cd frontend && npm run dev diff --git a/frontend/src/lib/hooks/use-sources.ts b/frontend/src/lib/hooks/use-sources.ts index 97f1324..9770298 100644 --- a/frontend/src/lib/hooks/use-sources.ts +++ b/frontend/src/lib/hooks/use-sources.ts @@ -99,7 +99,11 @@ export function useCreateSource() { variables.notebooks.forEach(notebookId => { queryClient.invalidateQueries({ queryKey: QUERY_KEYS.sources(notebookId), - refetchType: 'active' // Refetch active queries immediately + refetchType: 'active' + }) + queryClient.invalidateQueries({ + queryKey: QUERY_KEYS.sourcesInfinite(notebookId), + refetchType: 'active' }) }) } else if (variables.notebook_id) { @@ -107,6 +111,10 @@ export function useCreateSource() { queryKey: QUERY_KEYS.sources(variables.notebook_id), refetchType: 'active' }) + queryClient.invalidateQueries({ + queryKey: QUERY_KEYS.sourcesInfinite(variables.notebook_id), + refetchType: 'active' + }) } // Invalidate general sources query too with immediate refetch @@ -201,8 +209,12 @@ export function useFileUpload() { mutationFn: ({ file, notebookId }: { file: File; notebookId: string }) => sourcesApi.upload(file, notebookId), onSuccess: (_, variables) => { - queryClient.invalidateQueries({ - queryKey: QUERY_KEYS.sources(variables.notebookId) + queryClient.invalidateQueries({ + queryKey: QUERY_KEYS.sources(variables.notebookId) + }) + queryClient.invalidateQueries({ + queryKey: QUERY_KEYS.sourcesInfinite(variables.notebookId), + refetchType: 'active' }) toast({ title: t.common.success,