diff --git a/.github/workflows/build-and-deploy-fallback.yml b/.github/workflows/build-and-deploy-fallback.yml index d02224f..eaa92e4 100644 --- a/.github/workflows/build-and-deploy-fallback.yml +++ b/.github/workflows/build-and-deploy-fallback.yml @@ -1,6 +1,6 @@ # .github/workflows/build-and-deploy.yml -name: Build and Deploy +name: Build and Deploy Fallback on: push: diff --git a/rust-engine/src/storage.rs b/rust-engine/src/storage.rs index 08f4ad0..c9e9ea4 100644 --- a/rust-engine/src/storage.rs +++ b/rust-engine/src/storage.rs @@ -32,3 +32,7 @@ pub fn delete_file(path: &Path) -> Result<()> { } Ok(()) } + +pub fn public_url_for(filename: &str) -> String { + format!("/storage/{}", filename) +} diff --git a/rust-engine/src/worker.rs b/rust-engine/src/worker.rs index cdd471b..68b8faa 100644 --- a/rust-engine/src/worker.rs +++ b/rust-engine/src/worker.rs @@ -1,5 +1,6 @@ use crate::gemini_client::{demo_text_embedding, generate_text_with_model, DEMO_EMBED_DIM}; use crate::models::{QueryRecord, QueryStatus}; +use crate::storage; use crate::vector; use crate::vector_db::QdrantClient; use anyhow::Result; @@ -129,7 +130,7 @@ impl Worker { // Stage 4: fetch file metadata for IDs let mut files_json = Vec::new(); for (fid, score) in hits { - if let Some(row) = sqlx::query("SELECT id, filename, path, description FROM files WHERE id = ? AND pending_analysis = FALSE") + if let Some(row) = sqlx::query("SELECT id, filename, path, description, analysis_status FROM files WHERE id = ? AND pending_analysis = FALSE") .bind(&fid) .fetch_optional(&self.pool) .await? { @@ -138,8 +139,16 @@ impl Worker { let filename: String = row.get("filename"); let path: String = row.get("path"); let description: Option = row.get("description"); + let status: Option = row.try_get("analysis_status").ok(); + let storage_url = storage::public_url_for(&filename); files_json.push(serde_json::json!({ - "id": id, "filename": filename, "path": path, "description": description, "score": score + "id": id, + "filename": filename, + "path": path, + "storage_url": storage_url, + "description": description, + "analysis_status": status, + "score": score })); } } diff --git a/web-app/src/components/layouts/chat-layout.jsx b/web-app/src/components/layouts/chat-layout.jsx index 3e142d3..bbbdbdf 100644 --- a/web-app/src/components/layouts/chat-layout.jsx +++ b/web-app/src/components/layouts/chat-layout.jsx @@ -67,7 +67,10 @@ export default function ChatLayout() { .filter((f) => f && typeof f === "object") .map((file) => { const filename = file.filename || file.id || "download"; - const linkTarget = `/storage/${encodeURIComponent(filename)}`; + const storageUrl = file.storage_url || `/storage/${filename}`; + const linkTarget = storageUrl.startsWith("/storage/") + ? `/storage/${encodeURIComponent(storageUrl.replace("/storage/", ""))}` + : storageUrl; const description = file.description?.trim(); const score = typeof file.score === "number"