feat(foreign): raw stdin, per-cell inputs and interrupt

Persistent Python/Node kernels receive raw program stdin per eval; foreign.session accepts an inputs table and view exposes per-cell stdin. Add session interrupt host API and view control.
This commit is contained in:
cflmy committed 2026-10-18 14:37:45 +08:00
1 parent c85f1a2829
commit 064522a338
9 files changed
+86 -2

No files matched your search

+14
View File
@@ -807,6 +807,20 @@ impl DocumentSession {
]))
}
pub fn interrupt(&mut self) -> Result<Value, String> {
let ids: Vec<String> = self.kernel_sessions.keys().cloned().collect();
let mut out = Vec::new();
for name in ids {
if let Some(id) = self.kernel_sessions.get(&name) {
match foreign_session::interrupt(&mut self.host, &Value::Text(id.clone())) {
Ok(_) => out.push(Value::Text(name)),
Err(e) => out.push(Value::Text(format!("{name}: {e}"))),
}
}
}
Ok(Value::List(out))
}
pub fn restart_kernel(&mut self, name: &str) -> Result<Value, String> {
if let Some(id) = self.kernel_sessions.remove(name) {
let _ = foreign_session::close(&mut self.host, &Value::Text(id));