Skip to content

YC (S26) | Open Computer History | Continuously record your company computer work, map your workflows, help you find work worth automating, and power your agents' context

fix: add POST /fts/index endpoint for onboarding search to work immediately

Louis Beaumonte5fa02bb9811
diff --git a/apps/screenpipe-app-tauri/components/onboarding/read-content.tsx b/apps/screenpipe-app-tauri/components/onboarding/read-content.tsx
index a8ce1495d..7c37e82a1 100644
--- a/apps/screenpipe-app-tauri/components/onboarding/read-content.tsx
+++ b/apps/screenpipe-app-tauri/components/onboarding/read-content.tsx
@@ -125,6 +125,8 @@ export default function ReadContent({ handleNextSlide }: ReadContentProps) {
time_spent_ms: Date.now() - mountTimeRef.current,
frames_detected: framesDetected,
});
+ // trigger FTS indexing so the welcome page content is searchable immediately
+ fetch("http://localhost:3030/fts/index", { method: "POST" }).catch(() => {});
handleNextSlide();
}, [handleNextSlide, framesDetected]);
diff --git a/crates/screenpipe-db/src/fts_indexer.rs b/crates/screenpipe-db/src/fts_indexer.rs
index 351e5d363..fe266b52e 100644
--- a/crates/screenpipe-db/src/fts_indexer.rs
+++ b/crates/screenpipe-db/src/fts_indexer.rs
@@ -25,8 +25,8 @@ const FTS_INTER_TABLE_DELAY: Duration = Duration::from_secs(1);
/// Interval between FTS indexing cycles. Search uses FTS5 MATCH so
/// unindexed rows won't appear in results until the next cycle.
-/// 30 min is fine — onboarding doesn't use search, and users rarely
-/// search for content they just captured seconds ago.
+/// 30 min is fine — onboarding triggers POST /fts/index explicitly,
+/// and users rarely search for content captured seconds ago.
/// This eliminates the FTS indexer as a source of write contention
/// (was 555 slow batches in 3 hours at the old 30s interval).
const FTS_INDEX_INTERVAL: Duration = Duration::from_secs(30 * 60);
diff --git a/crates/screenpipe-server/src/server.rs b/crates/screenpipe-server/src/server.rs
index 015e0404c..9efb46977 100644
--- a/crates/screenpipe-server/src/server.rs
+++ b/crates/screenpipe-server/src/server.rs
@@ -394,6 +394,15 @@ impl SCServer {
"/sync/download",
axum::routing::post(sync_api::sync_download),
)
+ // Trigger immediate FTS indexing (used by onboarding so search works right away)
+ .route("/fts/index", axum::routing::post({
+ use axum::extract::State;
+ use axum::Json;
+ |State(state): State<Arc<AppState>>| async move {
+ let count = screenpipe_db::fts_indexer::index_all_tables(&state.db).await;
+ Json(json!({ "indexed": count }))
+ }
+ }))
// Vision status endpoint (not in OpenAPI spec to avoid oasgen registration issues)
.route("/vision/status", get(api_vision_status))
// Vision pipeline metrics (not in OpenAPI spec)