Skip to content

#1 PDF Application on GitHub that lets you edit PDFs on any device anywhere

Merge remote-tracking branch 'origin/main' into saas-update

James Brunton04d68c650aac
diff --cc engine/src/stirling/documents/pgvector_store.py
index 1599ae047b,bdaf43011d..0942de72e8
--- a/engine/src/stirling/documents/pgvector_store.py
+++ b/engine/src/stirling/documents/pgvector_store.py
@@@ -5,8 -4,8 +5,9 @@@ import jso
from datetime import datetime
import psycopg
+ from pgvector import Vector
from pgvector.psycopg import register_vector_async
+from psycopg_pool import AsyncConnectionPool
from stirling.contracts.documents import Page, PageRange
from stirling.documents.store import Document, DocumentStore, SearchResult, StoredPage
@@@ -41,36 -32,28 +42,39 @@@ class PgVectorStore(DocumentStore)
Writes are owner-scoped; reads are ACL-scoped.
"""
- def __init__(self, dsn: str) -> None:
+ def __init__(self, dsn: str, pool_min_size: int, pool_max_size: int) -> None:
if not dsn:
- raise ValueError("pgvector backend requires a non-empty DSN (STIRLING_RAG_PGVECTOR_DSN)")
+ raise ValueError("pgvector backend requires a non-empty DSN (STIRLING_DOCUMENTS_PGVECTOR_DSN)")
self._dsn = dsn
+ self._pool = AsyncConnectionPool(
+ dsn,
+ min_size=pool_min_size,
+ max_size=pool_max_size,
+ open=False,
+ configure=_register_vector,
+ check=AsyncConnectionPool.check_connection,
+ )
self._initialized = False
+ self._init_lock = asyncio.Lock()
- async def _connect(self) -> psycopg.AsyncConnection:
- conn = await psycopg.AsyncConnection.connect(self._dsn)
- await register_vector_async(conn)
- return conn
-
- async def _ensure_schema(self) -> None:
+ async def _ensure_ready(self) -> None:
+ """Create the schema and open the pool, exactly once across concurrent callers."""
if self._initialized:
return
- # The `vector` type must exist before register_vector_async (called inside
- # _connect) can resolve it. On a fresh database it doesn't yet, so create the
- # extension first on a raw connection that hasn't registered the type.
- async with await psycopg.AsyncConnection.connect(self._dsn) as bootstrap:
- async with bootstrap.cursor() as cur:
- await cur.execute("CREATE EXTENSION IF NOT EXISTS vector")
- await bootstrap.commit()
- async with await self._connect() as conn:
+ async with self._init_lock:
+ if self._initialized:
+ return
+ await self._bootstrap_schema()
+ await self._pool.open()
+ self._initialized = True
+
+ async def _bootstrap_schema(self) -> None:
- # Uses a dedicated non-pool connection: pooled connections register the
- # vector type on checkout, which fails until the extension exists.
++ # The `vector` type must exist before the pool's configure hook
++ # (register_vector_async) can resolve it, and on a fresh database it doesn't
++ # yet. Create the extension + schema on a raw, non-pool connection that hasn't
++ # registered the type; _ensure_ready then opens the pool, whose configure hook
++ # registers the now-existing type per connection.
+ async with await psycopg.AsyncConnection.connect(self._dsn) as conn:
async with conn.cursor() as cur:
await cur.execute("CREATE EXTENSION IF NOT EXISTS vector")
await cur.execute(
diff --cc frontend/editor/vite.config.ts
index 67d796753f,c46c224dfb..a52337e828
--- a/frontend/editor/vite.config.ts
+++ b/frontend/editor/vite.config.ts
@@@ -203,17 -216,9 +216,18 @@@ export default defineConfig(async ({ mo
}),
compressStaticCopyPlugin(),
],
+ resolve: {
+ // Global alias so @shared resolves for ALL importers — including the
+ // shared components' own `@shared/components/X.css` self-imports, which
+ // live outside the editor tsconfig scope and so aren't rewritten by
+ // vite-tsconfig-paths. Required for the editor to consume SUI components.
+ alias: {
+ "@shared": path.resolve(__dirname, "../shared"),
+ },
+ },
server: {
host: true,
+ allowedHosts: allowedHosts.length > 0 ? allowedHosts : undefined,
// make sure this port matches the devUrl port in tauri.conf.json file
port: 5173,
// Tauri expects a fixed port, fail if that port is not available