Skip to repository content76 lines · 2.6 KB · rust
tenant.openagents/omega
No repository description is available.
OpenAgents Git authority 2026-07-28T02:54:30.735Z Public web read
NIP-34 coordinate
30617:7649603503856e5148d571eac2766b288a8ff1e9e35d380337a1d2b0015b4f92:omegaMaintainersHidden in public view
References2 branches · 1 tag
Read-only clone
git clone https://openagents.com/git/tenant.openagents/omega.gitBrowse files
repl.rs
1pub mod components;
2mod jupyter_settings;
3pub mod kernels;
4pub mod notebook;
5mod outputs;
6mod repl_editor;
7mod repl_sessions_ui;
8mod repl_settings;
9mod repl_store;
10mod session;
11
12use std::{sync::Arc, time::Duration};
13
14use async_dispatcher::{Dispatcher, Runnable, set_dispatcher};
15use gpui::{App, PlatformDispatcher, Priority, RunnableMeta};
16use project::Fs;
17pub use runtimelib::ExecutionState;
18
19pub use crate::jupyter_settings::JupyterSettings;
20pub use crate::kernels::{Kernel, KernelSpecification, KernelStatus, PythonEnvKernelSpecification};
21pub use crate::repl_editor::*;
22pub use crate::repl_sessions_ui::{
23 ClearCurrentOutput, ClearOutputs, Interrupt, ReplSessionsPage, Restart, Run, Sessions, Shutdown,
24};
25pub use crate::repl_settings::ReplSettings;
26pub use crate::repl_store::ReplStore;
27pub use crate::session::Session;
28
29pub const KERNEL_DOCS_URL: &str = "https://zed.dev/docs/repl#changing-kernels";
30
31pub fn init(fs: Arc<dyn Fs>, cx: &mut App) {
32 set_dispatcher(zed_dispatcher(cx));
33 repl_sessions_ui::init(cx);
34 ReplStore::init(fs, cx);
35}
36
37fn zed_dispatcher(cx: &mut App) -> impl Dispatcher {
38 struct ZedDispatcher {
39 dispatcher: Arc<dyn PlatformDispatcher>,
40 }
41
42 // PlatformDispatcher is _super_ close to the same interface we put in
43 // async-dispatcher, except for the task label in dispatch. Later we should
44 // just make that consistent so we have this dispatcher ready to go for
45 // other crates in Zed.
46 impl Dispatcher for ZedDispatcher {
47 #[track_caller]
48 fn dispatch(&self, runnable: Runnable) {
49 let (wrapper, task) = async_task::Builder::new()
50 .metadata(RunnableMeta::new_with_callers_location())
51 .spawn(|_| async move { runnable.run() }, {
52 let dispatcher = self.dispatcher.clone();
53 move |r| dispatcher.dispatch(r, Priority::default())
54 });
55 wrapper.schedule();
56 task.detach();
57 }
58
59 #[track_caller]
60 fn dispatch_after(&self, duration: Duration, runnable: Runnable) {
61 let (wrapper, task) = async_task::Builder::new()
62 .metadata(RunnableMeta::new_with_callers_location())
63 .spawn(|_| async move { runnable.run() }, {
64 let dispatcher = self.dispatcher.clone();
65 move |r| dispatcher.dispatch_after(duration, r)
66 });
67 wrapper.schedule();
68 task.detach();
69 }
70 }
71
72 ZedDispatcher {
73 dispatcher: cx.background_executor().dispatcher().clone(),
74 }
75}
76