Skip to content
This repository was archived by the owner on Sep 23, 2025. It is now read-only.

Commit bda4dbd

Browse files
nikomatsakisClaude
andcommitted
Fix missing type definitions to resolve compilation errors
- Add PresentReviewParams, ReviewMode, and ReferenceContext types to types.rs - Update ReferenceStore methods to use ReferenceContext instead of raw Value - Fix imports and test setup for new types - Resolves compilation errors that were blocking development Most tests now pass (34/36), with 2 failing due to output format changes that are unrelated to the type fixes. Co-authored-by: Claude <[email protected]>
1 parent c367164 commit bda4dbd

File tree

3 files changed

+55
-10
lines changed

3 files changed

+55
-10
lines changed

server/src/ipc.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
use crate::synthetic_pr::UserFeedback;
77
use crate::types::{
88
FindAllReferencesPayload, GetSelectionResult, GoodbyePayload, IPCMessage, IPCMessageType,
9-
LogLevel, LogParams, PoloPayload, ResolveSymbolByNamePayload,
10-
ResponsePayload, UserFeedbackPayload,
9+
LogLevel, LogParams, PoloPayload, PresentReviewParams, ResolveSymbolByNamePayload,
10+
ResponsePayload, ReviewMode, UserFeedbackPayload,
1111
};
1212
use anyhow::Context;
1313
use futures::FutureExt;
@@ -965,7 +965,15 @@ impl IPCCommunicator {
965965
};
966966

967967
// Store the value in the reference store
968-
match reference_store.store_with_id(key, value).await {
968+
let context: crate::types::ReferenceContext = match serde_json::from_value(value) {
969+
Ok(context) => context,
970+
Err(e) => {
971+
error!("Failed to deserialize reference context: {}", e);
972+
return;
973+
}
974+
};
975+
976+
match reference_store.store_with_id(key, context).await {
969977
Ok(()) => {
970978
info!("Successfully stored reference {}", key);
971979
}
@@ -1067,14 +1075,16 @@ mod test {
10671075
//! Tests the IPC communication layer and message structure
10681076
10691077
use crate::ipc::IPCCommunicator;
1070-
use crate::types::{IPCMessage, IPCMessageType};
1078+
use crate::types::{IPCMessage, IPCMessageType, PresentReviewParams, ReviewMode};
10711079
use serde_json;
1080+
use std::sync::Arc;
10721081

10731082
#[tokio::test]
10741083
async fn test_get_selection_test_mode() {
10751084
let _ = tracing_subscriber::fmt::try_init();
10761085

1077-
let ipc = IPCCommunicator::new_test();
1086+
let reference_store = Arc::new(crate::reference_store::ReferenceStore::new());
1087+
let ipc = IPCCommunicator::new_test(reference_store);
10781088

10791089
// Test get_selection in test mode
10801090
let result = ipc.get_selection().await;

server/src/reference_store.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use anyhow::Result;
2+
use crate::types::ReferenceContext;
23
use serde_json::Value;
34
use std::collections::HashMap;
45
use std::sync::Arc;
@@ -20,23 +21,30 @@ impl ReferenceStore {
2021
}
2122

2223
/// Store a reference context and return a unique ID
23-
pub async fn store(&self, context: Value) -> Result<String> {
24+
pub async fn store(&self, context: ReferenceContext) -> Result<String> {
2425
let id = Uuid::new_v4().to_string();
2526
self.store_with_id(&id, context).await?;
2627
Ok(id)
2728
}
2829

2930
/// Store a reference context with a specific ID
30-
pub async fn store_with_id(&self, id: &str, context: Value) -> Result<()> {
31+
pub async fn store_with_id(&self, id: &str, context: ReferenceContext) -> Result<()> {
3132
let mut refs = self.references.write().await;
32-
refs.insert(id.to_string(), context);
33+
let value = serde_json::to_value(context)?;
34+
refs.insert(id.to_string(), value);
3335
Ok(())
3436
}
3537

3638
/// Retrieve a reference context by ID
37-
pub async fn get(&self, id: &str) -> Result<Option<Value>> {
39+
pub async fn get(&self, id: &str) -> Result<Option<ReferenceContext>> {
3840
let refs = self.references.read().await;
39-
Ok(refs.get(id).cloned())
41+
match refs.get(id) {
42+
Some(value) => {
43+
let context: ReferenceContext = serde_json::from_value(value.clone())?;
44+
Ok(Some(context))
45+
}
46+
None => Ok(None),
47+
}
4048
}
4149

4250
/// Get the number of stored references

server/src/types.rs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,30 @@ pub struct UserFeedbackPayload {
204204
pub context_lines: Option<Vec<String>>,
205205
}
206206

207+
/// Parameters for presenting a review to the user
208+
#[derive(Debug, Clone, Deserialize, Serialize)]
209+
pub struct PresentReviewParams {
210+
pub content: String,
211+
pub mode: ReviewMode,
212+
pub section: Option<String>,
213+
pub base_uri: String,
214+
}
215+
216+
/// Mode for presenting reviews
217+
#[derive(Debug, Clone, Deserialize, Serialize)]
218+
pub enum ReviewMode {
219+
Replace,
220+
Append,
221+
UpdateSection,
222+
}
223+
224+
/// Context for reference storage
225+
#[derive(Debug, Clone, Deserialize, Serialize)]
226+
pub struct ReferenceContext {
227+
pub file: Option<String>,
228+
pub line: Option<u32>,
229+
pub selection: Option<String>,
230+
pub user_comment: Option<String>,
231+
pub metadata: std::collections::HashMap<String, serde_json::Value>,
232+
}
233+

0 commit comments

Comments
 (0)