diff --git a/crates/ide-host/src/notebook.rs b/crates/ide-host/src/notebook.rs index fb5d65cb..413bb3c9 100644 --- a/crates/ide-host/src/notebook.rs +++ b/crates/ide-host/src/notebook.rs @@ -1,7 +1,7 @@ //! Project-incarnation notebook ownership and whole-batch execution admission. use crate::ops::Channel; use ide_core::error::ErrorKind; -use ide_core::{CancellationToken, IdeError, IdeEvent, IdeResult, SharedSink}; +use ide_core::{CancellationToken, IdeError, IdeEvent, IdeResult, IpcPath, SharedSink}; use ide_notebook::kernel::{KernelManager, KernelOutput}; use ide_notebook::{NotebookDocument, NotebookEdit, NotebookSnapshot}; use parking_lot::Mutex; @@ -17,7 +17,7 @@ use tokio::sync::{Mutex as AsyncMutex, watch}; #[serde(rename_all = "camelCase")] pub struct NotebookOutputEvent { pub id: String, - pub path: String, + pub path: IpcPath, pub cell: String, pub msg_id: String, pub kind: String, @@ -536,7 +536,7 @@ fn commit_output( }; Ok(Some(NotebookOutputEvent { id: document.id.clone(), - path: document.path.to_string_lossy().into_owned(), + path: document.path.clone().into(), cell: cell.to_owned(), msg_id: output.msg_id, kind: output.kind, @@ -592,6 +592,16 @@ mod tests { other.shutdown().await; } + #[tokio::test] + async fn the_notebook_path_reaches_the_ui_as_the_project_tree_names_it() { + let (dir, service, _) = fixture(); + let ui_path = + format!("{}/session.ipynb", ide_core::ipc_path::to_ipc(&dunce::canonicalize(dir.path()).unwrap())); + let snapshot = service.open(Path::new(&ui_path)).unwrap(); + assert_eq!(serde_json::to_value(&snapshot).unwrap()["path"], ui_path); + service.shutdown().await; + } + #[tokio::test(start_paused = true)] async fn failed_close_keeps_the_incarnation_recoverable_until_a_retry_succeeds() { let (dir, service, initial) = fixture(); diff --git a/crates/ide-notebook/src/document.rs b/crates/ide-notebook/src/document.rs index 9eb32842..85d7661f 100644 --- a/crates/ide-notebook/src/document.rs +++ b/crates/ide-notebook/src/document.rs @@ -9,7 +9,7 @@ use std::{ time::{Duration, Instant}, }; -use ide_core::{IdeError, IdeResult, error::ErrorKind}; +use ide_core::{IdeError, IdeResult, IpcPath, error::ErrorKind}; use serde::{Deserialize, Serialize}; use serde_json::{Value, json}; use specta::Type; @@ -22,7 +22,7 @@ use crate::kernel::KernelOutput; #[serde(rename_all = "camelCase")] pub struct NotebookSnapshot { pub id: String, - pub path: String, + pub path: IpcPath, pub version: u32, pub dirty: bool, pub can_undo: bool, @@ -188,7 +188,7 @@ impl NotebookDocument { pub fn snapshot(&self) -> NotebookSnapshot { NotebookSnapshot { id: self.id.clone(), - path: self.path.to_string_lossy().into_owned(), + path: self.path.clone().into(), version: self.version, dirty: self.is_dirty(), can_undo: !self.execution_active && !self.undo.is_empty(), diff --git a/src/bindings.ts b/src/bindings.ts index 1fb74b18..39dfd584 100644 --- a/src/bindings.ts +++ b/src/bindings.ts @@ -5342,7 +5342,7 @@ export type NotebookEdit = { type: "setSource"; cell: string; source: string } | export type NotebookOutputEvent = { id: string, - path: string, + path: IpcPath, cell: string, msgId: string, kind: string, @@ -5354,7 +5354,7 @@ export type NotebookOutputEvent = { export type NotebookSnapshot = { id: string, - path: string, + path: IpcPath, version: number, dirty: boolean, canUndo: boolean,