Merge pull request #721 from lfnovo/fix/source-list-auto-refresh-526

fix: source list auto-refresh after adding new source (#526)
This commit is contained in:
Luis Novo 2026-04-06 07:15:46 -03:00 committed by GitHub
commit 2008a6b4d1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 58 additions and 3 deletions

43
dev-init.sh Executable file
View file

@ -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

View file

@ -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,