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

Commit 6e2b2ef

Browse files
committed
Complete walkthrough system with VSCode IPC integration
- Add base_uri field to ResolvedWalkthrough structure - Implement present_walkthrough IPC method for VSCode communication - Add Debug derives to all resolved types for proper logging - Full end-to-end walkthrough processing: MCP tool → Dialect execution → VSCode - AI assistants can now send walkthroughs with embedded Dialect programs - System processes all sections and sends resolved structure to VSCode extension
1 parent d0b6d6a commit 6e2b2ef

File tree

3 files changed

+49
-9
lines changed

3 files changed

+49
-9
lines changed

server/src/ide.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ pub enum ResolvedLocation {
297297
}
298298

299299
/// The fully normalized struct that we send over IPC.
300-
#[derive(Serialize, Deserialize)]
300+
#[derive(Serialize, Deserialize, Debug)]
301301
pub struct ResolvedComment {
302302
pub locations: Vec<FileRange>,
303303
pub icon: Option<String>,
@@ -403,7 +403,7 @@ pub struct Action {
403403
pub tell_agent: Option<String>,
404404
}
405405

406-
#[derive(Serialize, Deserialize)]
406+
#[derive(Serialize, Deserialize, Debug)]
407407
pub struct ResolvedAction {
408408
pub button: String,
409409
pub tell_agent: Option<String>,
@@ -428,15 +428,16 @@ impl<U: IpcClient> DialectFunction<U> for Action {
428428

429429
/// Resolved walkthrough types for IPC communication with VSCode extension
430430
431-
#[derive(Serialize)]
431+
#[derive(Serialize, Debug)]
432432
pub struct ResolvedWalkthrough {
433433
pub introduction: Option<Vec<ResolvedWalkthroughElement>>,
434434
pub highlights: Option<Vec<ResolvedWalkthroughElement>>,
435435
pub changes: Option<Vec<ResolvedWalkthroughElement>>,
436436
pub actions: Option<Vec<ResolvedWalkthroughElement>>,
437+
pub base_uri: String,
437438
}
438439

439-
#[derive(Serialize, Deserialize)]
440+
#[derive(Serialize, Deserialize, Debug)]
440441
#[serde(untagged)]
441442
pub enum ResolvedWalkthroughElement {
442443
/// Plain markdown text

server/src/ipc.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,40 @@ impl IPCCommunicator {
180180
Ok(())
181181
}
182182

183+
pub async fn present_walkthrough(&self, walkthrough: crate::ide::ResolvedWalkthrough) -> Result<()> {
184+
if self.test_mode {
185+
info!("Present walkthrough called (test mode): {:?}", walkthrough);
186+
return Ok(());
187+
}
188+
189+
let payload = serde_json::to_value(&walkthrough)?;
190+
191+
let shell_pid = {
192+
let inner = self.inner.lock().await;
193+
inner.terminal_shell_pid
194+
};
195+
196+
let message = IPCMessage {
197+
shell_pid,
198+
message_type: IPCMessageType::PresentWalkthrough,
199+
payload,
200+
id: Uuid::new_v4().to_string(),
201+
};
202+
203+
debug!("Sending present_walkthrough message: {:?}", message);
204+
trace!("About to call send_message_with_reply for present_walkthrough");
205+
206+
let response: () = self.send_message_with_reply(message).await?;
207+
208+
trace!(
209+
"Received response from send_message_with_reply: {:?}",
210+
response
211+
);
212+
info!("Successfully presented walkthrough to VSCode");
213+
214+
Ok(())
215+
}
216+
183217
pub async fn get_selection(&self) -> Result<GetSelectionResult> {
184218
if self.test_mode {
185219
info!("Get selection called (test mode)");

server/src/server.rs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -282,20 +282,25 @@ impl DialecticServer {
282282
highlights: self.process_walkthrough_elements(params.highlights.as_ref()).await?,
283283
changes: self.process_walkthrough_elements(params.changes.as_ref()).await?,
284284
actions: self.process_walkthrough_elements(params.actions.as_ref()).await?,
285+
base_uri: params.base_uri.clone(),
285286
};
286287

287-
// Log the processing result
288+
// Send resolved walkthrough to VSCode extension
289+
self.ipc
290+
.present_walkthrough(resolved)
291+
.await
292+
.map_err(|e| McpError::internal_error("Failed to present walkthrough", Some(serde_json::json!({"error": e.to_string()}))))?;
293+
294+
// Log success
288295
self.ipc
289296
.send_log(
290297
LogLevel::Info,
291-
format!("Processed walkthrough with {} sections",
292-
[&resolved.introduction, &resolved.highlights, &resolved.changes, &resolved.actions]
293-
.iter().filter(|s| s.is_some()).count()),
298+
"Walkthrough successfully sent to VSCode".to_string(),
294299
)
295300
.await;
296301

297302
Ok(CallToolResult::success(vec![Content::text(
298-
"Walkthrough successfully processed",
303+
"Walkthrough successfully processed and presented in VSCode",
299304
)]))
300305
}
301306

0 commit comments

Comments
 (0)