diff --git a/Cargo.lock b/Cargo.lock index 4d3ae0f14..1b3e8f5f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13347,7 +13347,7 @@ dependencies = [ [[package]] name = "zatex" -version = "0.3.7" +version = "0.3.4" dependencies = [ "tiny-skia", "ttf-parser", @@ -13598,7 +13598,7 @@ dependencies = [ [[package]] name = "zeron" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "clap", @@ -13617,13 +13617,14 @@ dependencies = [ "zeron-mcp", "zeron-notify", "zeron-rpc", + "zeron-sync", "zeron-ui", "zeron-update", ] [[package]] name = "zeron-audio" -version = "0.3.7" +version = "0.3.4" dependencies = [ "base64 0.22.1", "cpal 0.18.2", @@ -13635,7 +13636,7 @@ dependencies = [ [[package]] name = "zeron-cli" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "clap", @@ -13651,7 +13652,7 @@ dependencies = [ [[package]] name = "zeron-client" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "async-trait", @@ -13682,7 +13683,7 @@ dependencies = [ [[package]] name = "zeron-doc" -version = "0.3.7" +version = "0.3.4" dependencies = [ "chrono", "loro", @@ -13697,7 +13698,7 @@ dependencies = [ [[package]] name = "zeron-engine" -version = "0.3.7" +version = "0.3.4" dependencies = [ "alacritty_terminal", "anyhow", @@ -13757,7 +13758,7 @@ dependencies = [ [[package]] name = "zeron-harness" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "async-trait", @@ -13791,7 +13792,7 @@ dependencies = [ [[package]] name = "zeron-launch" -version = "0.3.7" +version = "0.3.4" dependencies = [ "libc", "tempfile", @@ -13800,20 +13801,24 @@ dependencies = [ [[package]] name = "zeron-markdown" -version = "0.3.7" +version = "0.3.4" dependencies = [ "pulldown-cmark", ] [[package]] name = "zeron-mcp" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "async-trait", "base64 0.22.1", + "bytes", "chrono", "futures", + "http-body-util", + "hyper", + "hyper-util", "serde", "serde_json", "tempfile", @@ -13829,7 +13834,7 @@ dependencies = [ [[package]] name = "zeron-mobile" -version = "0.3.7" +version = "0.3.4" dependencies = [ "async-trait", "serde", @@ -13856,14 +13861,14 @@ dependencies = [ [[package]] name = "zeron-mobile-bindgen" -version = "0.3.7" +version = "0.3.4" dependencies = [ "uniffi", ] [[package]] name = "zeron-notify" -version = "0.3.7" +version = "0.3.4" dependencies = [ "objc", "sha2", @@ -13872,11 +13877,11 @@ dependencies = [ [[package]] name = "zeron-orb" -version = "0.3.7" +version = "0.3.4" [[package]] name = "zeron-plugin-guard" -version = "0.3.7" +version = "0.3.4" dependencies = [ "serde_json", "tempfile", @@ -13884,7 +13889,7 @@ dependencies = [ [[package]] name = "zeron-preview" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "async-trait", @@ -13914,11 +13919,11 @@ dependencies = [ [[package]] name = "zeron-preview-label" -version = "0.3.7" +version = "0.3.4" [[package]] name = "zeron-proto" -version = "0.3.7" +version = "0.3.4" dependencies = [ "chrono", "pulldown-cmark", @@ -13929,7 +13934,7 @@ dependencies = [ [[package]] name = "zeron-rpc" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "async-trait", @@ -13950,7 +13955,7 @@ dependencies = [ [[package]] name = "zeron-sync" -version = "0.3.7" +version = "0.3.4" dependencies = [ "base64 0.22.1", "block2 0.6.2", @@ -13976,7 +13981,7 @@ dependencies = [ [[package]] name = "zeron-syntax" -version = "0.3.7" +version = "0.3.4" dependencies = [ "thiserror 2.0.20", "tree-sitter", @@ -14011,14 +14016,14 @@ dependencies = [ [[package]] name = "zeron-term" -version = "0.3.7" +version = "0.3.4" dependencies = [ "alacritty_terminal", ] [[package]] name = "zeron-term-link" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "async-trait", @@ -14035,7 +14040,7 @@ dependencies = [ [[package]] name = "zeron-text" -version = "0.3.7" +version = "0.3.4" dependencies = [ "core-foundation 0.10.1", "core-graphics 0.24.0", @@ -14052,7 +14057,7 @@ dependencies = [ [[package]] name = "zeron-theme" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "clap", @@ -14067,7 +14072,7 @@ dependencies = [ [[package]] name = "zeron-ui" -version = "0.3.7" +version = "0.3.4" dependencies = [ "alacritty_terminal", "anyhow", @@ -14150,7 +14155,7 @@ dependencies = [ [[package]] name = "zeron-update" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "futures", @@ -14167,11 +14172,11 @@ dependencies = [ [[package]] name = "zeron-veil" -version = "0.3.7" +version = "0.3.4" [[package]] name = "zeron-visual" -version = "0.3.7" +version = "0.3.4" dependencies = [ "base64 0.22.1", "gltf", @@ -14183,7 +14188,7 @@ dependencies = [ [[package]] name = "zeron-visual-gpu" -version = "0.3.7" +version = "0.3.4" dependencies = [ "image", "pollster 0.4.0", @@ -14194,7 +14199,7 @@ dependencies = [ [[package]] name = "zeron-voice" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "cpal 0.17.3", @@ -14213,7 +14218,7 @@ dependencies = [ [[package]] name = "zeron-voice-media" -version = "0.3.7" +version = "0.3.4" dependencies = [ "async-trait", "semver", @@ -14228,7 +14233,7 @@ dependencies = [ [[package]] name = "zeron-voice-session" -version = "0.3.7" +version = "0.3.4" dependencies = [ "async-trait", "futures", diff --git a/Cargo.toml b/Cargo.toml index 7865ac29a..a39b93125 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ members = [ ] [workspace.package] -version = "0.3.7" +version = "0.3.4" edition = "2024" license = "MIT" publish = false diff --git a/apps/zeron/Cargo.toml b/apps/zeron/Cargo.toml index 2fda76d93..036c03949 100644 --- a/apps/zeron/Cargo.toml +++ b/apps/zeron/Cargo.toml @@ -27,6 +27,7 @@ zeron-update.workspace = true zeron-cli.workspace = true zeron-mcp.workspace = true zeron-notify.workspace = true +zeron-sync.workspace = true tokio.workspace = true clap.workspace = true anyhow.workspace = true diff --git a/apps/zeron/src/allocator.rs b/apps/zeron/src/allocator.rs index c037522f8..edf11b9b1 100644 --- a/apps/zeron/src/allocator.rs +++ b/apps/zeron/src/allocator.rs @@ -31,6 +31,14 @@ fn tag_heap() { } } +/// mimalloc's forced collect: what its threads freed (exited threads' +/// pages too) goes back to the system. The engine calls it after dropping +/// a large short-lived allocation ([`zeron_engine::heap`]). +pub fn trim() { + // SAFETY: mimalloc's collect frees nothing in use. + unsafe { libmimalloc_sys::mi_collect(true) }; +} + unsafe impl GlobalAlloc for Allocator { #[inline] unsafe fn alloc(&self, layout: Layout) -> *mut u8 { diff --git a/apps/zeron/src/background.rs b/apps/zeron/src/background.rs index b5626acb9..fb4cfb71b 100644 --- a/apps/zeron/src/background.rs +++ b/apps/zeron/src/background.rs @@ -55,6 +55,9 @@ fn run_engine(config: zeron_engine::EngineConfig) -> anyhow::Result<()> { /// are posted on and delivers their clicks. #[cfg(target_os = "macos")] fn run_engine(config: zeron_engine::EngineConfig) -> anyhow::Result<()> { + // Before the engine starts: its sockets then never start the polling + // wake detector (`zeron_sync::wake`). + main_loop::watch_power(); let worker = std::thread::Builder::new() .name("engine".into()) .spawn(move || { @@ -75,9 +78,26 @@ fn run_engine(config: zeron_engine::EngineConfig) -> anyhow::Result<()> { #[cfg(target_os = "macos")] mod main_loop { use std::ffi::c_void; - use std::sync::atomic::{AtomicBool, Ordering}; + use std::sync::atomic::{AtomicBool, AtomicPtr, AtomicU32, Ordering}; static DONE: AtomicBool = AtomicBool::new(false); + /// The source [`finish`] signals; null until [`run`] makes it. + static STOP: AtomicPtr = AtomicPtr::new(std::ptr::null_mut()); + + /// `CFRunLoopSourceContext`, version 0: only `perform` is used. + #[repr(C)] + struct SourceContext { + version: isize, + info: *mut c_void, + retain: *const c_void, + release: *const c_void, + copy_description: *const c_void, + equal: *const c_void, + hash: *const c_void, + schedule: *const c_void, + cancel: *const c_void, + perform: extern "C" fn(*mut c_void), + } #[link(name = "CoreFoundation", kind = "framework")] unsafe extern "C" { @@ -86,39 +106,100 @@ mod main_loop { fn CFRunLoopGetMain() -> *mut c_void; fn CFRunLoopRunInMode(mode: *const c_void, seconds: f64, return_after_source: u8) -> i32; fn CFRunLoopWakeUp(run_loop: *mut c_void); - fn CFAbsoluteTimeGetCurrent() -> f64; - fn CFRunLoopTimerCreate( + fn CFRunLoopSourceCreate( allocator: *const c_void, - fire_date: f64, - interval: f64, - flags: u64, order: isize, - callout: extern "C" fn(*mut c_void, *mut c_void), - context: *mut c_void, + context: *mut SourceContext, ) -> *mut c_void; - fn CFRunLoopAddTimer(run_loop: *mut c_void, timer: *mut c_void, mode: *const c_void); + fn CFRunLoopAddSource(run_loop: *mut c_void, source: *mut c_void, mode: *const c_void); + fn CFRunLoopSourceSignal(source: *mut c_void); } - extern "C" fn tick(_timer: *mut c_void, _info: *mut c_void) {} + #[link(name = "IOKit", kind = "framework")] + unsafe extern "C" { + fn IORegisterForSystemPower( + refcon: *mut c_void, + port: *mut *mut c_void, + callback: extern "C" fn(*mut c_void, u32, u32, *mut c_void), + notifier: *mut u32, + ) -> u32; + fn IONotificationPortGetRunLoopSource(port: *mut c_void) -> *mut c_void; + fn IOAllowPowerChange(kernel_port: u32, notification_id: isize) -> i32; + } - /// Serve the main run loop until [`finish`]. A repeating timer keeps the - /// loop from returning at once for want of sources and bounds how late - /// the exit check runs. + // IOKit's power messages (IOKit/IOMessage.h). + const CAN_SYSTEM_SLEEP: u32 = 0xe000_0270; + const SYSTEM_WILL_SLEEP: u32 = 0xe000_0280; + const SYSTEM_HAS_POWERED_ON: u32 = 0xe000_0300; + + /// The root power domain's connection, for acknowledging sleep. + static ROOT_PORT: AtomicU32 = AtomicU32::new(0); + + extern "C" fn power(_refcon: *mut c_void, _service: u32, message: u32, argument: *mut c_void) { + match message { + // Every registered client must answer these, or the Mac waits + // up to 30 s before it sleeps. + CAN_SYSTEM_SLEEP | SYSTEM_WILL_SLEEP => unsafe { + IOAllowPowerChange(ROOT_PORT.load(Ordering::Acquire), argument as isize); + }, + SYSTEM_HAS_POWERED_ON => zeron_sync::wake::notify_wake(), + _ => {} + } + } + + /// Hear the Mac's sleep and wake from IOKit on the main run loop, so the + /// engine's sockets redial on wake without a detector waking the + /// process every second to compare clocks. Falls back to that detector + /// if registering fails. + pub(super) fn watch_power() { + unsafe { + let mut port = std::ptr::null_mut(); + let mut notifier = 0u32; + let root = + IORegisterForSystemPower(std::ptr::null_mut(), &mut port, power, &mut notifier); + if root == 0 || port.is_null() { + tracing::warn!( + "couldn't register for power notifications; polling for wake instead" + ); + return; + } + ROOT_PORT.store(root, Ordering::Release); + let source = IONotificationPortGetRunLoopSource(port); + CFRunLoopAddSource(CFRunLoopGetMain(), source, kCFRunLoopCommonModes); + } + zeron_sync::wake::use_os_wake_events(); + } + + /// The stop source fired: [`run`]'s wait returns and it reads `DONE`. + extern "C" fn stop(_info: *mut c_void) {} + + /// Serve the main run loop until [`finish`]. It sleeps until something + /// arrives (a banner's click, the stop source) rather than on a timer: + /// an idle engine's main thread never wakes. The stop source both keeps + /// the loop from returning at once for want of sources and makes a + /// `finish` that comes before the wait begins end it at once (a signaled + /// source is served as soon as the loop runs). pub(super) fn run() { unsafe { let main = CFRunLoopGetMain(); - let timer = CFRunLoopTimerCreate( - std::ptr::null(), - CFAbsoluteTimeGetCurrent() + 1.0, - 1.0, - 0, - 0, - tick, - std::ptr::null_mut(), - ); - CFRunLoopAddTimer(main, timer, kCFRunLoopCommonModes); + let mut context = SourceContext { + version: 0, + info: std::ptr::null_mut(), + retain: std::ptr::null(), + release: std::ptr::null(), + copy_description: std::ptr::null(), + equal: std::ptr::null(), + hash: std::ptr::null(), + schedule: std::ptr::null(), + cancel: std::ptr::null(), + perform: stop, + }; + let source = CFRunLoopSourceCreate(std::ptr::null(), 0, &mut context); + CFRunLoopAddSource(main, source, kCFRunLoopCommonModes); + STOP.store(source, Ordering::SeqCst); while !DONE.load(Ordering::SeqCst) { - CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0, 0); + // (Returns after each source served, so `DONE` is read then.) + CFRunLoopRunInMode(kCFRunLoopDefaultMode, 1.0e10, 1); } } } @@ -126,6 +207,12 @@ mod main_loop { /// End [`run`] (any thread). pub(super) fn finish() { DONE.store(true, Ordering::SeqCst); - unsafe { CFRunLoopWakeUp(CFRunLoopGetMain()) }; + let source = STOP.load(Ordering::SeqCst); + unsafe { + if !source.is_null() { + CFRunLoopSourceSignal(source); + } + CFRunLoopWakeUp(CFRunLoopGetMain()); + } } } diff --git a/apps/zeron/src/bin/zeron-engine.rs b/apps/zeron/src/bin/zeron-engine.rs index 76d9bcbc1..0b6648a1d 100644 --- a/apps/zeron/src/bin/zeron-engine.rs +++ b/apps/zeron/src/bin/zeron-engine.rs @@ -2,8 +2,9 @@ //! own ("Zeron Engine" in Activity Monitor): the app starts it and attaches; //! sessions keep running with the app closed. Without the UI linked in. //! -//! It also answers what the engine runs its own executable for: `mcp` (the -//! Zeron MCP server injected into agents) and `--noop-browser` (browser +//! It also answers what the engine runs its own executable for: `mcp-proxy` +//! (an agent's Zeron MCP tools on stdio, served by the engine), `mcp` (the +//! standalone Zeron MCP server) and `--noop-browser` (browser //! suppression for agents' sign-in flows). And it is the engine helper of an //! interface that doesn't link the engine (the zgx app): every `zeron` //! subcommand that runs the engine's code (`headless`, `login`, `status`, @@ -17,6 +18,9 @@ use zeron_cli::{Engines, Launch}; fn main() -> anyhow::Result<()> { match std::env::args().nth(1).as_deref() { Some("--noop-browser") => Ok(()), + // An agent's Zeron MCP tools on stdio, forwarded to the engine's own + // endpoint. First, before any engine setup: it must stay tiny. + Some("mcp-proxy") => zeron_mcp::proxy::run(), Some("--version" | "-V") => { println!("zeron-engine {}", zeron_update::current_version()); Ok(()) diff --git a/apps/zeron/src/lib.rs b/apps/zeron/src/lib.rs index 265c0d7d5..f65d61475 100644 --- a/apps/zeron/src/lib.rs +++ b/apps/zeron/src/lib.rs @@ -12,11 +12,11 @@ pub mod engine_commands; pub mod ipc_cli; pub mod plugin_cli; +pub use engine_commands::run_engine_command; pub use zeron_cli::{ DEFAULT_EDGE_URL, DEFAULT_WORKOS_CLIENT_ID, edge_url_from_env, init_logging, long_running_setup, open_log_file, paths, workos_client_id_from_env, }; -pub use engine_commands::run_engine_command; /// mimalloc, macOS only: libmalloc never returns the streaming churn's /// high-water pages, so transient allocation became permanent RSS @@ -33,6 +33,9 @@ static ALLOC: allocator::Allocator = allocator::Allocator; /// `logout`, and `status` — one resolution so the CLI auth commands always /// operate on the exact session the daemon will load. pub fn engine_config_from_env() -> zeron_engine::EngineConfig { + // (Every way an engine starts here resolves its configuration first.) + #[cfg(target_os = "macos")] + zeron_engine::heap::set_trim(allocator::trim); // Dev-mode bearer (no WorkOS): an explicit token enables sync. let edge_token = std::env::var("ZERON_EDGE_TOKEN").ok(); zeron_engine::EngineConfig { diff --git a/apps/zeron/src/main.rs b/apps/zeron/src/main.rs index 0a3d049b8..30ca2a5f1 100644 --- a/apps/zeron/src/main.rs +++ b/apps/zeron/src/main.rs @@ -12,6 +12,11 @@ use zeron_app::{edge_url_from_env, paths, workos_client_id_from_env}; use zeron_cli::{Engines, Launch}; fn main() -> anyhow::Result<()> { + // The engine runs its own executable as an agent's stdio MCP forwarder + // (`zeron headless`'s agents): first, before any setup, to stay tiny. + if std::env::args().nth(1).as_deref() == Some("mcp-proxy") { + return zeron_mcp::proxy::run(); + } match zeron_cli::run(zeron_update::current_version(), Engines::InProcess) { Launch::Done(result) => result, Launch::Engine(command) => zeron_app::run_engine_command(command), diff --git a/apps/zgx/Cargo.lock b/apps/zgx/Cargo.lock index d096e16e9..106fef9ea 100644 --- a/apps/zgx/Cargo.lock +++ b/apps/zgx/Cargo.lock @@ -30,7 +30,7 @@ dependencies = [ [[package]] name = "accesskit_atspi_common" version = "0.19.1" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "accesskit", "accesskit_consumer", @@ -43,7 +43,7 @@ dependencies = [ [[package]] name = "accesskit_consumer" version = "0.38.0" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "accesskit", "hashbrown 0.16.1", @@ -66,7 +66,7 @@ dependencies = [ [[package]] name = "accesskit_macos" version = "0.26.3" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "accesskit", "accesskit_consumer", @@ -79,7 +79,7 @@ dependencies = [ [[package]] name = "accesskit_unix" version = "0.22.1" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "accesskit", "accesskit_atspi_common", @@ -96,7 +96,7 @@ dependencies = [ [[package]] name = "accesskit_windows" version = "0.34.0" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "accesskit", "accesskit_consumer", @@ -6450,7 +6450,7 @@ dependencies = [ [[package]] name = "wgpu-hal" version = "29.0.4" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "android_system_properties", "arrayvec", @@ -6888,7 +6888,7 @@ checksum = "d6bbff5f0aada427a1e5a6da5f1f98158182f26556f345ac9e04d36d0ebed650" [[package]] name = "winit" version = "0.30.13" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "ahash", "android-activity", @@ -7067,7 +7067,7 @@ dependencies = [ [[package]] name = "zatex" -version = "0.3.7" +version = "0.3.4" dependencies = [ "ttf-parser", ] @@ -7233,7 +7233,7 @@ checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" [[package]] name = "zeron-cli" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "clap", @@ -7248,7 +7248,7 @@ dependencies = [ [[package]] name = "zeron-launch" -version = "0.3.7" +version = "0.3.4" dependencies = [ "libc", "windows-sys 0.61.2", @@ -7256,7 +7256,7 @@ dependencies = [ [[package]] name = "zeron-notify" -version = "0.3.7" +version = "0.3.4" dependencies = [ "objc", "sha2", @@ -7265,18 +7265,18 @@ dependencies = [ [[package]] name = "zeron-plugin-guard" -version = "0.3.7" +version = "0.3.4" dependencies = [ "serde_json", ] [[package]] name = "zeron-preview-label" -version = "0.3.7" +version = "0.3.4" [[package]] name = "zeron-proto" -version = "0.3.7" +version = "0.3.4" dependencies = [ "chrono", "pulldown-cmark 0.12.2", @@ -7287,7 +7287,7 @@ dependencies = [ [[package]] name = "zeron-theme" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "clap", @@ -7301,7 +7301,7 @@ dependencies = [ [[package]] name = "zeron-update" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "futures", @@ -7318,7 +7318,7 @@ dependencies = [ [[package]] name = "zeron-visual" -version = "0.3.7" +version = "0.3.4" dependencies = [ "base64 0.22.1", "gltf", @@ -7330,7 +7330,7 @@ dependencies = [ [[package]] name = "zeron-visual-gpu" -version = "0.3.7" +version = "0.3.4" dependencies = [ "pollster", "tracing", @@ -7340,7 +7340,7 @@ dependencies = [ [[package]] name = "zeron-voice" -version = "0.3.7" +version = "0.3.4" dependencies = [ "anyhow", "cpal", @@ -7456,7 +7456,7 @@ dependencies = [ [[package]] name = "zgx" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "fixed_decimal", "foldhash 0.2.0", @@ -7485,7 +7485,7 @@ dependencies = [ [[package]] name = "zgx-3d" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "bytemuck", "zgx", @@ -7495,7 +7495,7 @@ dependencies = [ [[package]] name = "zgx-alacritty-terminal" version = "0.26.8" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "base64 0.22.1", "bitflags 2.13.2", @@ -7520,7 +7520,7 @@ dependencies = [ [[package]] name = "zgx-components" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "zgx", ] @@ -7528,7 +7528,7 @@ dependencies = [ [[package]] name = "zgx-cosmic-text" version = "0.19.14" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "bitflags 2.13.2", "fontdb", @@ -7552,7 +7552,7 @@ dependencies = [ [[package]] name = "zgx-desktop" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "accesskit", "accesskit_consumer", @@ -7603,12 +7603,12 @@ dependencies = [ [[package]] name = "zgx-ghostty-sys" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" [[package]] name = "zgx-gpu" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "ash", "block2 0.6.2", @@ -7648,7 +7648,7 @@ dependencies = [ [[package]] name = "zgx-harfrust" version = "0.5.4" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "bitflags 2.13.2", "bytemuck", @@ -7660,7 +7660,7 @@ dependencies = [ [[package]] name = "zgx-mlua" version = "0.12.9" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "bstr", "either", @@ -7675,7 +7675,7 @@ dependencies = [ [[package]] name = "zgx-run" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "serde_json", "ureq 3.5.0", @@ -7687,7 +7687,7 @@ dependencies = [ [[package]] name = "zgx-script" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "icu_locale_core", "icu_plurals", @@ -7712,7 +7712,7 @@ dependencies = [ [[package]] name = "zgx-swash" version = "0.2.11" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "skrifa", "yazi", @@ -7722,7 +7722,7 @@ dependencies = [ [[package]] name = "zgx-taffy" version = "0.9.2" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "arrayvec", "grid", @@ -7733,7 +7733,7 @@ dependencies = [ [[package]] name = "zgx-terminal" version = "0.1.10" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "base64 0.22.1", "flate2", @@ -7749,7 +7749,7 @@ dependencies = [ [[package]] name = "zgx-vte" version = "0.15.4" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "arrayvec", "bitflags 2.13.2", @@ -7761,7 +7761,7 @@ dependencies = [ [[package]] name = "zgx-zune-jpeg" version = "0.5.15" -source = "git+https://github.com/zeronsh/zgx?rev=d391ea7276f0de5cb3d65c191bfd66c02a4c358d#d391ea7276f0de5cb3d65c191bfd66c02a4c358d" +source = "git+https://github.com/zeronsh/zgx?rev=5a6a439637fb6a937ac355ff33ef66142357a0ca#5a6a439637fb6a937ac355ff33ef66142357a0ca" dependencies = [ "zune-core", ] diff --git a/apps/zgx/Cargo.toml b/apps/zgx/Cargo.toml index 9a30cbf91..ec04d1975 100644 --- a/apps/zgx/Cargo.toml +++ b/apps/zgx/Cargo.toml @@ -32,7 +32,7 @@ layout_probe = [] [dependencies] lz4_flex = { version = "0.11", default-features = false, features = ["safe-encode", "safe-decode"] } -zgx = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } +zgx = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca" } # `mimalloc`: the program's allocator, in place of the system's. It hands # freed memory back to the system (the system's keeps the most it ever # held), and zgx measures 1-10% less CPU for script, text and layout work. @@ -43,7 +43,7 @@ zgx = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191 # none of it, and without it pages are placeholders ("Web view · "). # zgx-run turns it on by default, but this app takes zgx-run without its # defaults (below). Nothing on macOS or Windows. -zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", features = ["mimalloc", "terminal", "webkitgtk"] } +zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca", features = ["mimalloc", "terminal", "webkitgtk"] } # `inspect`: devtools for `zgx inspect` (and its MCP server), asked for # with `--inspect`. `i18n`: `ui.t`'s plurals and numbers by each locale's # own rules (ICU4X's data, about 90 KB), for ui/locales' translations. @@ -51,18 +51,18 @@ zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb # wgpu this app already links), for plugins that show 3D: the CAD plugin # hands it its own triangles (`geometry = { positions, indices, … }`). It # asks no grant; a scene draws a frame only when something in it changes. -zgx-script = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", features = ["inspect", "i18n", "scene3d"] } +zgx-script = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca", features = ["inspect", "i18n", "scene3d"] } # A picture's pixels for the clipboard (src/images.rs): zgx's own decoder, # the formats `ui.image` shows (no features of its own: the ones zgx-desktop # turns on). -zgx-gpu = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", default-features = false } +zgx-gpu = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca", default-features = false } # Each plugin's own database (`zeron.db`, src/plugins/db.rs): SQLite, # built in; `limits` to keep one from attaching any other file. rusqlite = { version = "0.32", features = ["bundled", "limits", "hooks"] } # `fetch`: zgx's own transport for `ui.fetch` and remote images (HTTP and # HTTPS, rustls), given to every window (src/main.rs): the app's scripts, # and plugins granted "network". Nothing else of the runner. -zgx-run = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", default-features = false, features = ["fetch"] } +zgx-run = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca", default-features = false, features = ["fetch"] } # `webp`: `ui.image` decodes through this crate, by what its features # allow, so turning WebP on here is all it takes (the member cards' art). # `ico`: sites' favicons (the browser tab's: src/favicons.rs), most of @@ -162,7 +162,7 @@ foreign-types = "0.5" # elements, box drawing and Powerline glyphs to the cell; zgx's own renderer # draws them from the font at its text line height, gapped. Builds Ghostty # with Zig 0.16 (cached in ~/Library/Caches/zgx-ghostty). -zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", features = ["ghostty"] } +zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca", features = ["ghostty"] } # Windows' Transparency effects (src/transparency.rs), read and watched in # the registry, until zgx reports them (zgx-asks/windows-transparency); a @@ -172,8 +172,8 @@ zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb # DirectComposition tree of the window's own. The runtime ships with Windows # 11 (and with Edge on Windows 10); without it, pages are placeholders. [target.'cfg(windows)'.dependencies] -windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Graphics_Gdi", "Win32_Media_Audio", "Win32_Storage_FileSystem", "Win32_System_IO", "Win32_System_Console", "Win32_System_Registry", "Win32_System_Threading", "Win32_System_Time", "Win32_UI_WindowsAndMessaging"] } -zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d", features = ["webview2"] } +windows-sys = { version = "0.61", features = ["Win32_Foundation", "Win32_Graphics_Gdi", "Win32_Media_Audio", "Win32_Storage_FileSystem", "Win32_System_IO", "Win32_System_Console", "Win32_System_Registry", "Win32_System_Threading", "Win32_UI_WindowsAndMessaging"] } +zgx-desktop = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca", features = ["webview2"] } # zgx's D-Bus (menus, portals) linked in rather than loaded: `zeron` is also # what a headless Linux server and every Cloud machine runs (`zeron @@ -185,13 +185,13 @@ libdbus-sys = { version = "0.2.7", features = ["vendored"] } # zgx's own patches (its root Cargo.toml): a git dependency does not bring # them, so every consumer repeats them. [patch.crates-io] -wgpu-hal = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -winit = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -accesskit_macos = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -accesskit_consumer = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -accesskit_atspi_common = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -accesskit_unix = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } -accesskit_windows = { git = "https://github.com/zeronsh/zgx", rev = "d391ea7276f0de5cb3d65c191bfd66c02a4c358d" } +wgpu-hal = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca" } +winit = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca" } +accesskit_macos = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca" } +accesskit_consumer = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca" } +accesskit_atspi_common = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca" } +accesskit_unix = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca" } +accesskit_windows = { git = "https://github.com/zeronsh/zgx", rev = "5a6a439637fb6a937ac355ff33ef66142357a0ca" } # zgx is slow unoptimized (its own setting): optimize dependencies, keep # this crate quick to build. diff --git a/apps/zgx/docs/plugins.md b/apps/zgx/docs/plugins.md index 5ac07018a..6ad2dd6bd 100644 --- a/apps/zgx/docs/plugins.md +++ b/apps/zgx/docs/plugins.md @@ -52,8 +52,7 @@ Your own plugins are signed as yours, and re-signed and reloaded each time you s | `navigate` | open chats and pages (`zeron.open`) | | `links.open` | open http(s) links (`zeron.open_url`), where you open links (Settings → Links) | | `notifications` | send you notifications (`zeron.notify`), as Zeron's own: Settings → Notifications decides whether they show, a few a minute at most | -| `compose` | put text in the message box, after what's there or in place of its words (`zeron.compose`), or a review comment on it (`zeron.compose_comment`); you still send it | -| `draft` | read the message box's draft as you type it (`zeron.draft`), or any chat's (`zeron.draft_of`), and take it whole, put it back, swap it or let it go (`zeron.take_draft`, `put_draft`, `swap_draft`, `drop_draft`). See [The composer's draft](#the-composers-draft) | +| `compose` | put text in the message box (`zeron.compose`), or a review comment on it (`zeron.compose_comment`); you still send it | | `github`, `github.write` | read (and write) GitHub through Zeron's engine (older calls; prefer `commands` with `gh`) | | `network` | the internet: `ui.fetch`, and remote images (`ui.image { src = "https://…" }`). See [Reaching the network](#reaching-the-network) | | `clipboard`, `files`, `web`, `windows` | zgx's clipboard, file dialogs, web views, windows | @@ -214,13 +213,9 @@ Zeron draws that row on your settings page: "Use as wallpaper", and while it's o | call | what | needs | |---|---|---| | `zeron.open("home" \| { session = id } \| { settings = page })` | open a page | `navigate` | -| `zeron.compose(text, { replace?, session? })` | text into a chat's draft: after what's there (on a line of its own), or in place of its words (`replace = true`, its chips kept); the chat shown's draft, or `session`'s ([below](#the-composers-draft)) | `compose` | +| `zeron.compose(text)` | text into the message box | `compose` | | `zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? }` | a review comment on a file or a diff, as a chip on a chat's draft (below) | `compose` | | `zeron.composed()` | in a build: your comments still on a draft, by `key`: `{ session, hovered }` | `compose` | -| `zeron.draft()` | in a build: the message box's draft, `{ session?, text, attachments = { { kind, name } } }` (below) | `draft` | -| `zeron.take_draft(key)`, `zeron.put_draft(key)`, `zeron.swap_draft(key)`, `zeron.drop_draft(key)` | the draft taken whole and kept by Zeron under your key; put back; traded with what the key keeps; let go (below) | `draft` | -| `zeron.drafts()` | in a build: what Zeron keeps for you, by key: `{ session?, text, attachments, at }` | `draft` | -| `zeron.draft_of(session)` | a promise of chat `session`'s draft as it is now, as `zeron.draft()` says it (`""`: a new chat's) | `draft` | | `zeron.toast(text)` | a short note at the window's foot | (always) | | `zeron.need("panel").open_tab { kind, title, icon?, data? }` | a tab of yours in the chat's panel; asked again, the one there is brought forward (found by `data.key` when you give one, else by its title) | `panel.tabs` | | `zeron.tab(kind, function(tab) return node end)` | how a kind of your tabs draws (`tab` = `{ kind, title, data }`) | `panel.tabs` | @@ -279,48 +274,6 @@ Comments on the diff (each cites the file and line it belongs to; L = line numbe Give each a `key` of your own: `zeron.composed()` lists yours still on a draft by it (taken off or sent, gone), and says which one's chip is under the pointer (`hovered`), so the lines it was left on can keep a mark and light up as its chip is pointed at. Zeron's Git plugin does all of this in its Changes (`plugins-builtin/git/changes.luau`): the diff's + (or a drag from it over lines) opens `ds/comment`'s composer under them, using `ds/git_changes`'s `on_comment`, `ranges` and `marks`. -### The composer's draft - -With `draft`, a plugin reads what you're typing and can set it aside and bring it back: a stash for a prompt written in the wrong chat, a counter of its length, a bar that says what it carries. - -- **`zeron.draft()`**, read in a build or an effect, is the draft shown as it changes: `session` (the chat it's for; nil on a new chat), `text` (the words as typed) and `attachments`, each chip's `kind` (`"file"`, `"image"`, `"chat"`, `"comment"`, …) and `name`. A file's path is never in it. -- **`zeron.take_draft(key)`** takes the draft shown whole (its words, its chips, the passages quoted in it) and clears the composer. Zeron keeps it, under your `key` (1 to 64 characters), so your plugin never holds a file's path. An empty draft isn't taken; taking under a key that's kept replaces what it kept. Up to 16 at once. -- **`zeron.put_draft(key)`** puts what `key` kept back on the draft shown, in whichever chat is open, and lets it go. Onto an empty composer it's as it was taken; onto words already there, its words follow after a blank line and its chips after theirs. -- **`zeron.swap_draft(key)`** trades the draft shown with what `key` keeps. Either may be empty, so one call sets the draft aside (nothing kept), brings it back (an empty composer), or swaps the two. -- **`zeron.drop_draft(key)`** lets what `key` kept go. -- **`zeron.drafts()`**, read in a build, is what Zeron keeps for you, by key: `{ session?, text, attachments, at }` (`at` as `os.time()`). Drafts are kept while Zeron runs, as chats' own drafts are. -- **`zeron.draft_of(session)`** reads another chat's draft once, shown or not: a promise of `{ session?, text, attachments }`, as `zeron.draft()` says it (`""` for a new chat's, with no session). - -With `compose` too, a plugin can change the words in place: **`zeron.compose(text, { replace = true })`** puts `text` in place of the draft's words, leaving its chips where they are, and `session` names another chat's draft. A rewrite or a snippet that expands is a read and a replace: - -```lua --- ("ui.add", "draft", "compose"): /bug alone in the box becomes the template. -ui.effect(function() - local d = zeron.draft() - if d and d.text == "/bug" then - zeron.compose("## What happened\n\n## What I expected\n\n## Steps\n", { replace = true, session = d.session }) - end -end) -``` - -Nothing is sent: the person sees the new words in the composer, and sends or edits them. `zeron.compose` takes 20,000 characters at most. - -Each is done in the order you ask. A prompt stash is one shortcut and one chip: - -```lua --- ⌘⇧S (Ctrl+Shift+S): set the draft aside, bring it back, or swap the two. -ui.command { id = "stash", title = "Stash prompt", key = "cmd+shift+s", run = function() - zeron.swap_draft("stash") -end } - --- While one is kept, a chip over the composer: click to bring it back. -zeron.place { at = "#chat-composer", before = function(): Node - return ui.show(function(): boolean - return zeron.drafts().stash ~= nil - end, ui.button { "Stashed", on_click = function() zeron.swap_draft("stash") end }) -end } -``` - ## Programs and a database A plugin can do real work of its own: run the command-line tools you already use, and keep what it learns. diff --git a/apps/zgx/plugins-builtin/git/zeron.luau b/apps/zgx/plugins-builtin/git/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-builtin/git/zeron.luau +++ b/apps/zgx/plugins-builtin/git/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-builtin/github/zeron.luau b/apps/zgx/plugins-builtin/github/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-builtin/github/zeron.luau +++ b/apps/zgx/plugins-builtin/github/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-builtin/parallax-scenes/zeron.luau b/apps/zgx/plugins-builtin/parallax-scenes/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-builtin/parallax-scenes/zeron.luau +++ b/apps/zgx/plugins-builtin/parallax-scenes/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/account-pin/zeron.luau b/apps/zgx/plugins-dev/account-pin/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/account-pin/zeron.luau +++ b/apps/zgx/plugins-dev/account-pin/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/account-rotate/zeron.luau b/apps/zgx/plugins-dev/account-rotate/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/account-rotate/zeron.luau +++ b/apps/zgx/plugins-dev/account-rotate/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/checkout-status/zeron.luau b/apps/zgx/plugins-dev/checkout-status/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/checkout-status/zeron.luau +++ b/apps/zgx/plugins-dev/checkout-status/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/compact-sidebar/zeron.luau b/apps/zgx/plugins-dev/compact-sidebar/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/compact-sidebar/zeron.luau +++ b/apps/zgx/plugins-dev/compact-sidebar/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/composer-cat/zeron.luau b/apps/zgx/plugins-dev/composer-cat/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/composer-cat/zeron.luau +++ b/apps/zgx/plugins-dev/composer-cat/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/focus/zeron.luau b/apps/zgx/plugins-dev/focus/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/focus/zeron.luau +++ b/apps/zgx/plugins-dev/focus/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/keep-going/zeron.luau b/apps/zgx/plugins-dev/keep-going/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/keep-going/zeron.luau +++ b/apps/zgx/plugins-dev/keep-going/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/md-hello/zeron.luau b/apps/zgx/plugins-dev/md-hello/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/md-hello/zeron.luau +++ b/apps/zgx/plugins-dev/md-hello/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/notes-tool/zeron.luau b/apps/zgx/plugins-dev/notes-tool/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/notes-tool/zeron.luau +++ b/apps/zgx/plugins-dev/notes-tool/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/ping/zeron.luau b/apps/zgx/plugins-dev/ping/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/ping/zeron.luau +++ b/apps/zgx/plugins-dev/ping/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/session-status/zeron.luau b/apps/zgx/plugins-dev/session-status/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/session-status/zeron.luau +++ b/apps/zgx/plugins-dev/session-status/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/session-words/zeron.luau b/apps/zgx/plugins-dev/session-words/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/session-words/zeron.luau +++ b/apps/zgx/plugins-dev/session-words/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-dev/settings-demo/zeron.luau b/apps/zgx/plugins-dev/settings-demo/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-dev/settings-demo/zeron.luau +++ b/apps/zgx/plugins-dev/settings-demo/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/plugins-sdk/zeron.luau b/apps/zgx/plugins-sdk/zeron.luau index 553b6cc16..c5f896393 100644 --- a/apps/zgx/plugins-sdk/zeron.luau +++ b/apps/zgx/plugins-sdk/zeron.luau @@ -69,31 +69,13 @@ -- zeron.on_message(function(message) end) -- what arrives: { from = { id, name }, data, at } ("devices") -- zeron.open(route) "home", { session = id }, { settings = page } ("navigate") --- zeron.compose(text, { replace?, session? }) --- text into the message box, for you to send: after --- what's there, or in place of its words (`replace = --- true`, its chips kept); the chat shown's draft, or --- `session`'s ("compose") +-- zeron.compose(text) text into the message box, for you to send ("compose") -- zeron.compose_comment { file, line, note, to?, side?, snippet?, key?, session? } -- a review comment chip on a session's draft, sent as -- Zeron's review comments block (file:line, the note, -- the code under it) ("compose") -- zeron.composed() in a build: your comments still on a draft, by key -- ({ [key] = { session, hovered } }), reactive ("compose") --- zeron.draft() the composer's draft as you type it: { session?, --- text, attachments = { { kind, name } } }, reactive --- ("draft") --- zeron.take_draft(key), zeron.put_draft(key), zeron.swap_draft(key), --- zeron.drop_draft(key) --- the draft taken whole (words, chips, quotes) and --- kept by Zeron under your key, the composer --- cleared; put back on the draft shown; the two --- traded; let go ("draft") --- zeron.drafts() what Zeron keeps for you, by key: { session?, text, --- attachments, at }, reactive ("draft") --- zeron.draft_of(session) --- a promise of another chat's draft, as `draft()` --- says it, read once ("" a new chat's) ("draft") -- zeron.toast(text) a short note at the window's foot (always) -- zeron.notify { title, body?, session? } a notification, as Zeron's -- own (Settings → Notifications) ("notifications") @@ -1361,16 +1343,8 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - -- `text` into a chat's draft, for the person to send ("compose"): after - -- what's there, on a line of its own; with `replace = true`, in place of - -- its words (what it carries stays). The chat shown's draft, or - -- `session`'s ("" a new chat's). - function M.compose(text: string, opts: { replace: boolean?, session: string? }?) - if opts and (opts.replace or opts.session) then - ui.invoke("zeron.compose.insert", { text = text, replace = opts.replace == true, session = opts.session or ui.null }) - else - ui.invoke("zeron.compose.insert", text) - end + function M.compose(text: string) + ui.invoke("zeron.compose.insert", text) end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1400,57 +1374,6 @@ return function(id: string): any return composed:get() or {} end - -- The composer's draft as you type it: the chat it's for (nil, a new - -- chat), its words, and what it carries, each chip's kind ("file", - -- "image", "chat", …) and name, never a file's path. Read in a build or - -- an effect: it changes as the draft does. Nil until Zeron says. - -- (Reached on first read: only a plugin allowed "draft" may.) - local draft: any = nil - function M.draft(): { session: string?, text: string, attachments: { { kind: string, name: string } } }? - draft = draft or ui.shared("zeron.draft", nil :: any) - return draft:get() - end - - -- The draft shown, taken whole (its words, its chips, the passages - -- quoted in it) and kept by Zeron under `key`, yours, the composer - -- cleared; what that key kept before is replaced. An empty draft isn't - -- taken. Up to 16 kept at once. - function M.take_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "take", key = key }) - end - - -- What `key` kept, put back on the draft shown as it was taken (after - -- what's there, if the composer isn't empty), and no longer kept. - function M.put_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "put", key = key }) - end - - -- The draft shown and what `key` keeps, traded: either may be empty, so - -- one call sets the draft aside, brings it back, or swaps the two. - function M.swap_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "swap", key = key }) - end - - -- What `key` kept, let go of. - function M.drop_draft(key: string) - ui.invoke(`{prefix}.draft`, { op = "drop", key = key }) - end - - -- What Zeron keeps for you, by key: the chat each was taken from, its - -- words, what it carries (as `draft()` says it) and when (os.time). - -- Read in a build: it changes as you take and put back. - local drafts = ui.shared(`{prefix}.drafts`, {} :: { [string]: any }) - function M.drafts(): { [string]: { session: string?, text: string, attachments: { { kind: string, name: string } }, at: number } } - return drafts:get() or {} - end - - -- Chat `session`'s draft as it is now, unsent: shown or not (`draft()` - -- follows the one shown). A promise of { session?, text, attachments } - -- as `draft()` says it ("" a new chat's draft, with no session). - function M.draft_of(session: string): any - return ui.call(`{prefix}.draft_of`, session) - end - function M.toast(text: string) ui.invoke(`{prefix}.toast`, text) end diff --git a/apps/zgx/src/agents.rs b/apps/zgx/src/agents.rs index 00506865c..af62053ae 100644 --- a/apps/zgx/src/agents.rs +++ b/apps/zgx/src/agents.rs @@ -411,24 +411,6 @@ pub fn install(host: &ScriptHost) { a.add_key(id, provider, key, name).await } }); - // An API key for Cloud's agents (Settings → Providers with Cloud - // shown): kept by the vault, authorized for the account's Cloud device - // (`device`), the key every Cloud machine uses from its next turn. - // Rejects with the engine's words, which never hold the key. - let a = agents.clone(); - host.async_action("agents.cloud_key", move |args| { - let a = a.clone(); - let provider = args.field("provider").map(text).unwrap_or_default(); - let key = args.field("key").map(text).unwrap_or_default().trim().to_string(); - let device = args.field("device").map(text).unwrap_or_default(); - async move { - crate::plugins::preview::refuse("agents.cloud_key")?; - let params = cloud_key_params(&provider, &key, &device)?; - engine::get().call("VaultPutApiKey", params).await.map_err(|error| engine::outcome(&error).to_string())?; - a.load_accounts(true).await; - Ok(Value::Nil) - } - }); // An API key's name (no secret: on whichever device shows it), rejecting // with the engine's words. let a = agents.clone(); @@ -1966,20 +1948,6 @@ fn epoch_secs(s: &str) -> Option { mod tests { use super::*; - /// A Cloud API key goes to the vault for the account's Cloud device: - /// Anthropic's or OpenAI's only, a real key, Cloud on. - #[test] - fn a_cloud_key_is_one_cloud_runs_for_its_device() { - let ok = cloud_key_params("anthropic-key", "sk-ant-123", "cloud-acct").unwrap(); - assert_eq!(ok, json!({ "provider": "anthropic-key", "key": "sk-ant-123", "authorizedDevices": ["cloud-acct"] })); - assert!(cloud_key_params("openai-key", "sk-1", "d").is_ok()); - assert!(cloud_key_params("claude", "sk", "d").is_err(), "a login isn't a key"); - assert!(cloud_key_params("anthropic-key", "", "d").is_err()); - assert!(cloud_key_params("anthropic-key", "a\nb", "d").is_err()); - assert!(cloud_key_params("anthropic-key", &"k".repeat(5000), "d").is_err()); - assert!(cloud_key_params("anthropic-key", "sk", "").is_err(), "Cloud off"); - } - /// Pi signed in to Claude, or another login put in use: Pi's models are /// looked up again. Usage moving, or another agent's, isn't Pi's change. #[test] @@ -2260,22 +2228,6 @@ pub(crate) fn shown_target() -> Option { } /// `params` addressed to the device Providers shows. -/// `VaultPutApiKey`'s params for a Cloud API key: Anthropic's or OpenAI's -/// alone, a key that's there and no longer than any key is, for the -/// account's Cloud device. Else why not. -pub(crate) fn cloud_key_params(provider: &str, key: &str, device: &str) -> Result { - if !matches!(provider, "anthropic-key" | "openai-key") { - return Err("Cloud takes Anthropic and OpenAI keys".into()); - } - if key.is_empty() || key.len() > 4096 || key.chars().any(char::is_control) { - return Err("That isn't an API key".into()); - } - if device.is_empty() { - return Err("Turn Cloud on in Settings → Cloud first".into()); - } - Ok(json!({ "provider": provider, "key": key, "authorizedDevices": [device] })) -} - pub(crate) fn addressed_to_shown(params: Json) -> Json { addressed_to(shown_target().as_deref(), params) } diff --git a/apps/zgx/src/chat.rs b/apps/zgx/src/chat.rs index b8e5734fe..bdf1e9eb2 100644 --- a/apps/zgx/src/chat.rs +++ b/apps/zgx/src/chat.rs @@ -250,7 +250,12 @@ impl zgx_script::Unfold for FoldedEntry { let json = lz4_flex::block::decompress_size_prepended(&self.bytes).ok(); let entry = json.and_then(|bytes| serde_json::from_slice::(&bytes).ok()).unwrap_or(Json::Null); let RowContext { doc, device, model } = &*self.context; - built_entry(&entry, doc, device.as_deref(), model.as_deref()).unwrap_or(Value::Nil) + // (Opened as it comes into view, after Settings' compact transcript + // may have been turned on: laid out compact as well, whichever shows.) + COMPACT_ANYWAY.set(true); + let row = built_entry(&entry, doc, device.as_deref(), model.as_deref()).unwrap_or(Value::Nil); + COMPACT_ANYWAY.set(false); + row } } @@ -275,14 +280,241 @@ struct Built { subagents: Option>, /// Folded, its compressed bytes' length (what a chat kept is weighed by). folded: usize, + /// A long reply's blocks, held here rather than in its row (`set_aside`). + aside: Option>, +} + +/// A long settled reply's blocks and tools, kept out of its row. A script is +/// handed a table for every value of a row it reads, so a reply of a thousand +/// steps cost its 2,000 blocks' and 1,000 tools' tables each time its chat +/// opened (about 3 ms of a long thread's open on an M5 Max, more than all it +/// builds), though its end alone shows. Its row says its runs instead +/// (ds/transcript's windowed runs: each its first block's id, how many +/// blocks, a guess at its height, a sum of what it holds), and the +/// transcript asks for a run's blocks as it builds that run +/// (`chat.reply_run`), the end's alone as it opens. +struct Aside { + /// Each run: its key (its first block's id) and its blocks. + runs: Vec<(Rc, Rc<[Value]>)>, + blocks: Rc<[Value]>, +} + +/// More blocks than this, a settled reply's are set aside (ds/transcript's +/// LONG_REPLY, past which it windows them). +const LONG_REPLY: usize = 48; +/// ds/transcript's runs: a block whose id falls on RUN starts one, and none +/// runs past RUN_MOST. +const RUN: u64 = 32; +const RUN_MOST: usize = 64; + +thread_local! { + /// The long replies set aside, by their entry's id: the latest built of + /// each, while a view's rows (or a chat kept) hold it. + static ASIDE: RefCell, std::rc::Weak