Scope code mode cell IDs to the host process

This commit is contained in:
Channing Conger
2026-06-10 17:22:19 -07:00
parent 72d48f9df9
commit 945eb18f37
3 changed files with 51 additions and 7 deletions
+6 -1
View File
@@ -49,6 +49,7 @@ async fn run() -> Result<(), String> {
sessions: Mutex::new(HashMap::new()),
next_session_id: AtomicU64::new(1),
peer,
host_id: std::process::id().to_string(),
});
let writer = tokio::spawn(async move {
@@ -110,8 +111,12 @@ impl HostState {
});
self.sessions.lock().await.insert(
session_id,
Arc::new(CodeModeService::with_delegate(delegate)),
Arc::new(CodeModeService::with_delegate_and_cell_id_prefix(
delegate,
self.host_id.clone(),
)),
);
host_id: String,
self.respond(request_id, Ok(HostResponse::SessionCreated { session_id }))
.await;
}
+2
View File
@@ -25,6 +25,7 @@ async fn serves_code_mode_sessions_over_stdio() {
.kill_on_drop(true)
.spawn()
.expect("spawn codex-code-mode-host");
let host_id = child.id().expect("host process id");
let mut stdin = child.stdin.take().expect("host stdin");
let mut stdout = child.stdout.take().expect("host stdout");
@@ -70,6 +71,7 @@ async fn serves_code_mode_sessions_over_stdio() {
}) => cell_id,
message => panic!("unexpected execute response: {message:?}"),
};
assert_eq!(cell_id.as_str(), format!("{host_id}_1"));
let response = match read_frame(&mut stdout)
.await
.expect("initial response frame")