fix(code-mode): wire store/load config through core

This commit is contained in:
Channing Conger
2026-06-05 05:28:13 +00:00
parent 531a79baf3
commit 302840d968
10 changed files with 105 additions and 20 deletions
+4 -2
View File
@@ -1,12 +1,14 @@
use serde::Serialize;
/// Configuration for one durable code-mode session.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize)]
pub struct CodeModeSessionConfig {
/// Controls whether cells can persist JSON values for later cells.
pub store_load: StoreLoadMode,
}
/// Controls whether the `store` and `load` globals are available in a session.
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq)]
#[derive(Clone, Copy, Debug, Default, Eq, PartialEq, Serialize)]
pub enum StoreLoadMode {
/// Expose `store` and `load` and retain their JSON values between cells.
#[default]
+5 -1
View File
@@ -285,12 +285,16 @@ fn run_runtime(
v8::scope!(let scope, isolate);
let context = v8::Context::new(scope, Default::default());
let scope = &mut v8::ContextScope::new(scope, context);
let stored_value_writes = match &config.stored_values {
StoredValues::Enabled(_) => StoredValues::Enabled(HashMap::new()),
StoredValues::Disabled => StoredValues::Disabled,
};
scope.set_slot(RuntimeState {
event_tx: event_tx.clone(),
pending_tool_calls: HashMap::new(),
pending_timeouts: HashMap::new(),
stored_value_writes: config.stored_values.empty_like(),
stored_value_writes,
stored_values: config.stored_values,
enabled_tools: config.enabled_tools,
next_tool_call_id: 1,
-7
View File
@@ -19,13 +19,6 @@ impl StoredValues {
}
}
pub(crate) fn empty_like(&self) -> Self {
match self {
Self::Enabled(_) => Self::Enabled(HashMap::new()),
Self::Disabled => Self::Disabled,
}
}
pub(crate) fn is_enabled(&self) -> bool {
matches!(self, Self::Enabled(_))
}