diff --git a/src/grpc/service.rs b/src/grpc/service.rs index 17f3041..f10a40e 100644 --- a/src/grpc/service.rs +++ b/src/grpc/service.rs @@ -159,6 +159,36 @@ async fn run_session( } } } + Some(client_message::Payload::IndexSymbols(idx)) => { + // Index client symbols to OpenSearch code index + if let Some(ref os) = state.opensearch { + let index_name = state.code_index_name(); + let mut indexer = crate::code_index::indexer::CodeIndexer::new( + os.clone(), index_name, String::new(), 100, + ); + let now = chrono::Utc::now().timestamp_millis(); + for sym in &idx.symbols { + indexer.add(crate::code_index::schema::SymbolDocument { + file_path: sym.file_path.clone(), + repo_owner: None, + repo_name: idx.project_name.clone(), + language: sym.language.clone(), + symbol_name: sym.name.clone(), + symbol_kind: sym.kind.clone(), + signature: sym.signature.clone(), + docstring: sym.docstring.clone(), + start_line: sym.start_line as u32, + end_line: sym.end_line as u32, + content: sym.content.clone(), + branch: idx.branch.clone(), + source: "local".into(), + indexed_at: now, + }).await; + } + indexer.flush().await; + info!(count = idx.symbols.len(), project = idx.project_name.as_str(), "Indexed client symbols"); + } + } Some(client_message::Payload::End(_)) => { session.end(); tx.send(Ok(ServerMessage {