From 56e68866256d2c9417e9051fe0e18bc3c282efaf Mon Sep 17 00:00:00 2001 From: Wing <44917547+wingleeio@users.noreply.github.com> Date: Sat, 14 Nov 2026 17:06:34 -0700 Subject: [PATCH 01/10] Transcript: a scroll away from the end stays where it was taken Two ways the view was pulled back to the end after a person scrolled away from it: - A send's glide (the prompt rising to the view's top, or a steer's waiting up to 2 s for its prompt to land) went on to the end over a scroll taken meanwhile. A wheel now stops the glide where it is; the old reply keeps the room it held until it's out of view, so nothing shown moves. - A scroll begun within 300 ms of the view's size changing left the end held, and the next resize, however much later (the sidebar, a panel, the window), went back to it. Resting away from the end now lets it go when a person scrolled since the last resize. ui/tests/transcript_scroll_away.test.luau: both fail on main, pass here. The full UI suite passes (1405). Co-Authored-By: Claude Opus 5.5 --- apps/zgx/ui/ds/transcript.luau | 49 ++++++++++- .../ui/tests/transcript_scroll_away.test.luau | 84 +++++++++++++++++++ 2 files changed, 131 insertions(+), 2 deletions(-) create mode 100644 apps/zgx/ui/tests/transcript_scroll_away.test.luau diff --git a/apps/zgx/ui/ds/transcript.luau b/apps/zgx/ui/ds/transcript.luau index 50071c13c..8606ca686 100644 --- a/apps/zgx/ui/ds/transcript.luau +++ b/apps/zgx/ui/ds/transcript.luau @@ -1146,6 +1146,10 @@ local function Transcript(props: Props): Node -- taken meanwhile stays where it went. local function rise(prompt: Message?) ui.after(16, function() + -- (Scrolled meanwhile: the view is the reader's, see `wheeled`.) + if glides ~= turn then + return + end local row_el = prompt and tops[prompt.id] and tops[prompt.id]:peek() local list_el = list:peek() if not row_el or not list_el or row_el.y == nil or list_el.y == nil then @@ -1158,6 +1162,9 @@ local function Transcript(props: Props): Node duration = motion.ms(GLIDE_MS), ease = "outQuad", onComplete = function() + if glides ~= turn then + return + end -- Landed: the old reply lets go of the room it held -- (above the view, so nothing seen moves), and the -- offset says where the list now rests, a real place @@ -1444,6 +1451,18 @@ local function Transcript(props: Props): Node -- (Taken somewhere of their own: a place still to come back to is -- let go.) waiting = nil + -- A send's glide under way (or its prompt still to land, a steer's): + -- the scroll is theirs, so the glide stops where it is rather than + -- pulling the view back to the end. The old reply keeps the room it + -- held until it's out of view (`rested`), so nothing shown moves. + if gliding:peek() then + glides += 1 + if glide then + glide:pause() + glide = nil + end + gliding:set(false) + end return nil end -- When focus last came to something in the list (Tab, ⇧Tab to a row's @@ -1452,6 +1471,8 @@ local function Transcript(props: Props): Node -- While the width is changing (and a moment after): the reading row -- puts the place back as its lines rewrap, the frame they do. local resizing_until = 0 + -- When the view's size last changed. + local resized_at = -math.huge local function find_reading() reading = nil local el = list:peek() @@ -1533,9 +1554,32 @@ local function Transcript(props: Props): Node local function rested() remember() find_reading() - if not at_end:peek() and ui.now() >= resizing_until then + -- Resting away from the end: let go of it once no change of size is + -- under way, or at once if a person scrolled since the last one (a + -- scroll begun just after a resize is theirs; held, the next resize, + -- however much later, would pull the view back to the end). + if not at_end:peek() and (ui.now() >= resizing_until or wheeled_at >= resized_at) then end_held = false end + -- A send's glide a scroll stopped (`wheeled`): the old reply's held + -- room goes once that reply is out of view, where it moves nothing. + local h = held:peek() + if h.id ~= "" and not gliding:peek() then + local r = rows[h.id] + local row_el = r and r.outer:peek() + local el = list:peek() + local away_from_view = not row_el + or not el + or row_el.y == nil + or row_el.height == nil + or el.y == nil + or el.height == nil + or (row_el.y :: number) + (row_el.height :: number) <= (el.y :: number) + or (row_el.y :: number) >= (el.y :: number) + (el.height :: number) + if away_from_view then + held:set { id = "", h = 0 } + end + end end local rest = ui.debounced(offset, 150, { every = true }) -- (A view just made: its place told once it has stood 150 ms.) @@ -1994,7 +2038,8 @@ local function Transcript(props: Props): Node ui.after(48, settle) end if changed then - resizing_until = ui.now() + 300 + resized_at = ui.now() + resizing_until = resized_at + 300 -- At the end: on it still, every frame of the change. if end_held and not gliding:peek() then -- (Asked of the list itself, which lands it as it lays diff --git a/apps/zgx/ui/tests/transcript_scroll_away.test.luau b/apps/zgx/ui/tests/transcript_scroll_away.test.luau new file mode 100644 index 000000000..a4dddd99a --- /dev/null +++ b/apps/zgx/ui/tests/transcript_scroll_away.test.luau @@ -0,0 +1,84 @@ +-- Scrolled away from the end, the view stays where the person took it: it +-- isn't pulled back to the end. (Nov 14: "scrolling gets stuck to the +-- bottom; scroll away and it scrolls you back down".) Two ways it was: +-- - a scroll during a send's glide (the prompt rising to the view's top, or +-- a steer's waiting to land): the glide went on to the end over it; +-- - a scroll begun within moments of the view's size changing: the end +-- stayed held, and the next resize, however much later (the sidebar, a +-- panel, the window), went back to it. +-- On chat_fixture's `long_chat` (ui/long_chat_fixture.luau). + +local function settle(app: any) + app:wait("#never-shown", { timeout_ms = 250 }) + app:frames(10) +end + +local function offset(app: any): number + return app:state("chat.transcript.offset") +end + +-- How far the view is from its end, measured by going there (which holds +-- the end again: only at the close of a test). +local function from_end(app: any): number + local at = offset(app) + app:scroll("#transcript", 1e6) + app:frames(4) + return offset(app) - at +end + +local function open(): any + local app = mount("chat_fixture.luau") + app:resize(960, 700) + app:frames(20) + app:command("long_chat_sent") + app:command("go_s7") + app:frames(30) + settle(app) + return app +end + +local function send(app: any) + app:type("role:textbox", "three and one sounds like the most optional option") + app:key("Enter") +end + +local function scroll_up(app: any) + for _ = 1, 10 do + app:wheel("#transcript", { dy = -40 }) + app:frames(1) + end +end + +test("scrolled up while a send glides, the view stays where it was taken", function() + local app = open() + send(app) + app:frames(3) + scroll_up(app) + settle(app) + settle(app) + expect(from_end(app) > 100).to_be(true) +end) + +test("scrolled up just after a resize, a later resize leaves the view where it was", function() + local app = open() + send(app) + app:frames(40) + settle(app) + for _ = 1, 60 do + app:command("long_chat_streams") + app:frames(2) + end + app:frames(10) + app:resize(940, 700) + app:frames(2) + scroll_up(app) + -- (It rests inside the resize's moment, then a while.) + settle(app) + app:wait("#never-shown", { timeout_ms = 800 }) + local at = offset(app) + app:resize(900, 700) + app:frames(10) + settle(app) + expect(math.abs(offset(app) - at) < 1).to_be(true) + expect(from_end(app) > 100).to_be(true) +end) From 38f21b51301f3bc6968effb9da8125d34e381854 Mon Sep 17 00:00:00 2001 From: Wing <44917547+wingleeio@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:43:53 -0700 Subject: [PATCH 02/10] zgx: "Task completed" chime rings on a finished turn, not on your send zgx's chimes rang done.wav whenever a chat's sidebar status turned "done", but that status is only unseen activity, and your own message makes it too, so every send played the completion chime (#1437). Chat rows now carry the session's finished-turn mark (`turn`, from lastCompletedTurn) and whether that row was fresh. The chime rings "done" when the mark moves, as the shipping app and the engine's banners decide it: never when the next turn is already running (a steer, a queued message taken), never for an old row a sync brings back or a session row returning, and only once a finish has stood for two seconds, so a send that replaces the runtime (old turn's end, then your turn a moment later) stays quiet. Questions and failures still ring at once. Sends stay silent, as the sound design has it. Fixes #1437 Co-Authored-By: Claude Opus 5.5 --- apps/zgx/src/sessions.rs | 50 +++++++++ apps/zgx/ui/account/sessions.luau | 5 + apps/zgx/ui/chimes_fixture.luau | 7 ++ apps/zgx/ui/screens/settings/chimes.luau | 127 +++++++++++++++++++---- apps/zgx/ui/tests/chimes.test.luau | 114 ++++++++++++++++++++ 5 files changed, 285 insertions(+), 18 deletions(-) create mode 100644 apps/zgx/ui/chimes_fixture.luau create mode 100644 apps/zgx/ui/tests/chimes.test.luau diff --git a/apps/zgx/src/sessions.rs b/apps/zgx/src/sessions.rs index 7e5810e89..f446abc04 100644 --- a/apps/zgx/src/sessions.rs +++ b/apps/zgx/src/sessions.rs @@ -191,6 +191,21 @@ struct RowWith { working_side_chats: u32, known_project: bool, agent_icon: Option, + /// The last turn its agent finished, as its session row marks it + /// (`lastCompletedTurn`): what a "finished" chime rings on moving. + turn: Option, +} + +/// A session row's finished turn, and whether the row is fresh: written in +/// the last `SESSION_STALE_MS`, so a turn's end just published rather than +/// an old row a sync or reconnect brings back (the shipping app's chime +/// rule, crates/engine/src/desktop_notify.rs `SessionNotificationState`). +fn finished_turn(session: Option<&Session>, at: chrono::DateTime) -> (Option, bool) { + let Some(s) = session else { + return (None, false); + }; + let fresh = at.signed_duration_since(s.updated_at).num_milliseconds() <= zeron_proto::view::SESSION_STALE_MS; + (s.last_completed_turn.clone(), fresh) } /// `slot` holds `item` now; whether that's new. @@ -621,6 +636,7 @@ fn child_row(rows: &mut HashMap, c: &Json, id: &str, parent: &str, working_side_chats: 0, known_project: false, agent_icon: harness.and_then(crate::agents::registry_icon), + turn: None, }; if rows.get(id).is_some_and(|row| row.with == with) { return; @@ -681,6 +697,7 @@ fn top_row( working_side_chats, known_project: project.is_some(), agent_icon: harness.and_then(crate::agents::registry_icon), + turn: finished_turn(session, at).0, }; if let Some(row) = rows.get(id).filter(|row| row.with == with) { return row.value.clone(); @@ -721,6 +738,12 @@ fn top_row( // it woke (Unix seconds). ("sleep_until", with.sleep.filter(|s| s.0).map_or(Value::Nil, |s| Value::from(s.1 as f64))), ("woke", with.sleep.filter(|s| !s.0).map_or(Value::Nil, |s| Value::from(s.1 as f64))), + // The last turn its agent finished (an opaque mark), and whether its + // session row was fresh when that was read: the chimes ring + // "finished" on this moving, never on the status alone ("done" is + // only unseen activity, which your own send makes too). + ("turn", with.turn.as_deref().map_or(Value::Nil, Value::from)), + ("turn_fresh", Value::from(finished_turn(session, at).1)), ]); rows.insert(id.to_owned(), Row { moved: moved(c), updated: updated as f64, marks, with, value: value.clone() }); value @@ -2516,6 +2539,33 @@ mod tests { assert!(!s.rows.borrow().contains_key("b")); } + /// A chat's finished turn (what the "done" chime rings on, issue #1437): + /// its session's `lastCompletedTurn`, published as it moves, and whether + /// the row saying so is fresh. + #[test] + fn a_chat_s_finished_turn_is_published_as_it_moves() { + let now = now_seconds(); + let s = with_children("2099-01-01T00:00:00Z"); + s.heard.set(true); + let row = |turn: &str, ago: i64| { + json!([{ "chatId": "p", "deviceId": "d", "status": "idle", "updatedAt": iso(now - ago), "lastCompletedTurn": turn }]) + }; + s.set_live(row("t1", 1)); + s.publish(); + let p = s.value(); + assert_eq!(chat(&p, "p").field("turn").map(crate::auth::text).as_deref(), Some("t1")); + assert!(chat(&p, "p").field("turn_fresh").is_some_and(zgx_script::Value::truthy)); + let before = s.published.get(); + s.heard(Slot::Live, row("t2", 0)); + assert_eq!(s.published.get(), before + 1, "a finish is shown at once"); + assert_eq!(chat(&s.value(), "p").field("turn").map(crate::auth::text).as_deref(), Some("t2")); + // An end published long ago (a sync, a reconnect): not fresh. + s.heard(Slot::Live, row("t3", 600)); + let p = s.value(); + assert_eq!(chat(&p, "p").field("turn").map(crate::auth::text).as_deref(), Some("t3")); + assert!(!chat(&p, "p").field("turn_fresh").is_some_and(zgx_script::Value::truthy)); + } + #[test] fn an_update_that_changes_nothing_publishes_nothing() { let s = with_children("2099-01-01T00:00:00Z"); diff --git a/apps/zgx/ui/account/sessions.luau b/apps/zgx/ui/account/sessions.luau index 22b51e557..7940c4c68 100644 --- a/apps/zgx/ui/account/sessions.luau +++ b/apps/zgx/ui/account/sessions.luau @@ -77,6 +77,11 @@ export type Chat = { -- woke (Unix seconds). sleep_until: number?, woke: number?, + -- The last turn its agent finished (an opaque mark, nil before its + -- first), and whether its session row was fresh as that was read: what + -- the "finished" chime rings on moving (screens/settings/chimes). + turn: string?, + turn_fresh: boolean?, } export type WaitingOn = { id: string, kind: string, label: string } -- A side chat: a chat under another (its `parent`). diff --git a/apps/zgx/ui/chimes_fixture.luau b/apps/zgx/ui/chimes_fixture.luau new file mode 100644 index 000000000..a9788cbae --- /dev/null +++ b/apps/zgx/ui/chimes_fixture.luau @@ -0,0 +1,7 @@ +-- The session chimes (screens/settings/chimes) with no engine: a test sets +-- the `sessions` shared state as the engine would publish it, and reads what +-- played from `settings_stub_calls` ("sound.play:done", …). +require("./settings_stub") +require("@app/screens/settings/chimes") + +return ui.column {} diff --git a/apps/zgx/ui/screens/settings/chimes.luau b/apps/zgx/ui/screens/settings/chimes.luau index 65f5cb1a8..6b8447374 100644 --- a/apps/zgx/ui/screens/settings/chimes.luau +++ b/apps/zgx/ui/screens/settings/chimes.luau @@ -1,9 +1,19 @@ -- The sessions' chimes, as the shipping app plays them (crates/ui --- shell.rs, its one session detector): a chat turning done, waiting on you, --- or failed plays its sound, if Settings → Notifications has it on. A --- chat's first appearance only sets where it stands (a launch, a sync, a --- hot reload never ring), and what it was is kept in state, so a reload --- picks up where it was. +-- shell.rs, its one session detector; crates/engine desktop_notify's +-- `ping_since`): a chat waiting on you, or failed, plays its sound as its +-- status turns so; a turn finished plays "done", if Settings → +-- Notifications has it on. A chat's first appearance only sets where it +-- stands (a launch, a sync, a hot reload never ring), and what it was is +-- kept in state, so a reload picks up where it was. +-- +-- "Finished" is the turn mark moving (`turn`, the session's +-- `lastCompletedTurn`), never the status "done": that's only activity you +-- haven't seen, and your own message makes it too (issue #1437). Nor does +-- every move ring: one published with the next turn already running is +-- your message carrying it on (a steer, a queued message taken), and a +-- send that replaces the agent's runtime marks the old turn's end a moment +-- before your turn starts, so a finish waits `SETTLE` to stand; a turn +-- going on (or asking, or failing) meanwhile takes it with it. -- -- And the window's focus, told to the engine (`SetViewportFocus`), which -- holds its banners while Zeron is the app in front if Notifications says @@ -16,39 +26,120 @@ local prefs = require("@app/screens/settings/prefs") local M = {} --- Each chat's status as last seen, by id ("" for idle). -local seen = ui.state("settings_chimes_seen", {} :: { [string]: string }) +type Seen = { status: string, turn: string? } --- What a status turning on plays. +-- Each chat as last seen, by id: its status ("" for idle) and finished turn. +local seen = ui.state("settings_chimes_seen_turns", {} :: { [string]: Seen }) + +-- Finishes waiting to stand, by chat: the turn, and when it rings +-- (`ui.now()`, ms). +local settling = ui.state("settings_chimes_settling", {} :: { [string]: { turn: string, at: number } }) + +-- How long a finish waits to stand before it rings (the engine's banners' +-- `DONE_SETTLE`). +local SETTLE = 2000 + +-- What a status turning on plays. ("done" isn't one: see above.) local SOUND: { [string]: string } = { - done = "done", input = "request", failed = "attention", } +-- A turn going on, or asking, or failing: nothing has finished. +local function busy(status: string): boolean + return status == "working" or status == "waiting" or status == "input" or status == "failed" +end + +-- One chime for many at once: the most urgent. +local function louder(ring: string?, sound: string): string + if ring == nil or sound == "attention" or (sound == "request" and ring == "done") then + return sound + end + return ring +end + +local function play(ring: string?) + if ring and prefs.chimes(ring) then + host.invoke("sound.play", ring) + end +end + ui.effect(function() local now = sessions.now:get() if now.state ~= "ready" then return end local before = seen:peek() - local after: { [string]: string } = {} + local after: { [string]: Seen } = {} + local waits = table.clone(settling:peek()) + local moved = false local ring: string? = nil for _, c in now.chats do local status = c.status or "" - after[c.id] = status local was = before[c.id] - if was ~= nil and was ~= status and SOUND[status] then - -- (One chime for many at once: the most urgent.) - local sound = SOUND[status] - if ring == nil or sound == "attention" or (sound == "request" and ring == "done") then - ring = sound + -- (A session row gone for a while, a host restarting, keeps the turn + -- last seen: its coming back is no finish.) + after[c.id] = { status = status, turn = c.turn or (was and was.turn) } + if busy(status) and waits[c.id] then + waits[c.id] = nil + moved = true + end + if was ~= nil then + if was.status ~= status and SOUND[status] then + ring = louder(ring, SOUND[status]) + end + if c.turn ~= nil and c.turn ~= was.turn and c.turn_fresh ~= false and not busy(status) then + waits[c.id] = { turn = c.turn, at = ui.now() + SETTLE } + moved = true end end end + -- (A chat gone takes its finish with it.) + for id in waits do + if after[id] == nil then + waits[id] = nil + moved = true + end + end seen:set(after) - if ring and prefs.chimes(ring) then - host.invoke("sound.play", ring) + if moved then + settling:set(waits) + end + play(ring) +end) + +-- The finishes due by `upto` have stood: they ring, once each moment (one +-- chime for many). (The timer that calls this is the deadline: its clock +-- needn't be `ui.now()`'s, so that's never asked again here.) +local function stand(upto: number) + local waits = settling:peek() + local left = {} + local ring: string? = nil + for id, w in waits do + if w.at <= upto then + local now = seen:peek()[id] + if now and now.turn == w.turn and not busy(now.status) then + ring = louder(ring, "done") + end + else + left[id] = w + end + end + settling:set(left) + play(ring) +end +ui.effect(function() + local soonest: number? = nil + for _, w in settling:get() do + soonest = if soonest then math.min(soonest, w.at) else w.at + end + -- (A timer made in an effect belongs to its run: a new finish, or one + -- taken, sets it again.) + if soonest then + local upto: number = soonest + ui.after(math.max(0, upto - ui.now()), function() + stand(upto) + end) end end) diff --git a/apps/zgx/ui/tests/chimes.test.luau b/apps/zgx/ui/tests/chimes.test.luau new file mode 100644 index 000000000..2b4716acb --- /dev/null +++ b/apps/zgx/ui/tests/chimes.test.luau @@ -0,0 +1,114 @@ +-- The session chimes (screens/settings/chimes, issue #1437): "done" rings +-- when a turn finishes (its `turn` mark moving and standing a moment), never +-- for a chat turning "done" alone, which is only activity you haven't seen +-- and your own send makes too. Questions and failures ring at once. + +local function chat(id: string, status: string?, turn: string?, fresh: boolean?): any + return { + id = id, + title = id, + device = "here", + status = status, + updated = 0, + created = 0, + turn = turn, + turn_fresh = if fresh == nil then true else fresh, + } +end + +local function publish(app: any, chats: { any }) + app:set_state("sessions", { + state = "ready", + devices = {}, + projects = {}, + chats = chats, + archived = {}, + places = { pinned = {}, sections = {} }, + places_ready = true, + }) + app:frames(2) +end + +local function played(app: any): { string } + local out = {} + for _, c in (app:state("settings_stub_calls") :: any) or {} do + local sound = string.match(c, "^sound%.play:(.+)$") + if sound then + table.insert(out, sound) + end + end + return out +end + +-- Long enough for a finish to stand (chimes' SETTLE, 2 s). +local function settle(app: any) + app:wait("#never-shown", { timeout_ms = 2400 }) + app:frames(3) +end + +local function open(chats: { any }): any + local app = mount("chimes_fixture.luau") + publish(app, chats) + return app +end + +test("chimes: your own send never rings done", function() + local app = open({ chat("a", nil, "t1") }) + -- The send lands: your message makes the chat unseen ("done") before the + -- live row says it's working; the turn mark hasn't moved. + publish(app, { chat("a", "done", "t1") }) + publish(app, { chat("a", "working", "t1") }) + -- A steer, or a queued message taken, as a turn ends: the end is + -- published with the next turn already running. + publish(app, { chat("a", "working", "t2") }) + -- A send that replaces the runtime: the old turn's end lands idle, then + -- your turn starts a moment later. + publish(app, { chat("a", "done", "t3") }) + publish(app, { chat("a", "working", "t3") }) + settle(app) + expect(#played(app)).to_be(0) + + -- The turn your message started finishing: that rings, once. + publish(app, { chat("a", "done", "t4") }) + expect(#played(app)).to_be(0) + settle(app) + expect(table.concat(played(app), ",")).to_be("done") + settle(app) + expect(#played(app)).to_be(1) +end) + +test("chimes: a chat's first turn finishing rings done", function() + local app = open({ chat("new", "working", nil) }) + publish(app, { chat("new", "done", "t1") }) + settle(app) + expect(table.concat(played(app), ",")).to_be("done") +end) + +test("chimes: an old row coming back, or a session row returning, never rings", function() + local app = open({ chat("a", nil, "t1") }) + -- A sync brings back an end published long ago. + publish(app, { chat("a", "done", "t2", false) }) + -- The row goes away (a host restarting) and comes back as it was. + publish(app, { chat("a", nil, nil) }) + publish(app, { chat("a", nil, "t2") }) + settle(app) + expect(#played(app)).to_be(0) +end) + +test("chimes: questions and failures ring at once", function() + local app = open({ chat("q", "working", "t1"), chat("f", "working", "t1") }) + publish(app, { chat("q", "input", "t1"), chat("f", "working", "t1") }) + expect(table.concat(played(app), ",")).to_be("request") + publish(app, { chat("q", "input", "t1"), chat("f", "failed", "t1") }) + expect(table.concat(played(app), ",")).to_be("request,attention") +end) + +test("chimes: Task completed off keeps done quiet, the rest still ring", function() + local app = open({ chat("a", "working", "t1") }) + app:set_state("settings_sound_done", false) + publish(app, { chat("a", "done", "t2") }) + settle(app) + expect(#played(app)).to_be(0) + publish(app, { chat("a", "input", "t2") }) + expect(table.concat(played(app), ",")).to_be("request") +end) From c10b5ac3f467366ecf4cdc77aa67874a025bdc90 Mon Sep 17 00:00:00 2001 From: Wing <44917547+wingleeio@users.noreply.github.com> Date: Sat, 7 Nov 2026 17:55:48 -0700 Subject: [PATCH 03/10] Banners: no "finished" on your own send, and a click opens the chat MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A finished banner (with its sound) rang as you sent. The engine's notifier rings when a session's completion marker moves, and your own message often moves it: a steer or a queued row taken as a turn ends publishes that end with Working (your message carries the turn on), and a send that replaces the runtime marks the old turn's end (a held wait's included) a moment before your turn starts. The old app's chime kept quiet for a send in flight; the engine, which now rings for the zgx app, never knew. Now a finish published with the next turn running never rings, and the rest wait two seconds to stand: a turn starting meanwhile takes the finish with it. Questions and failures still ring at once. Clicking a banner did nothing. The engine posts Zeron's banners, but macOS hands a click to the app its bundle names (Zeron.app's interface), never to the engine that posted it, so the engine's own route (`open -a … zeron://notification/…`) never runs. Zeron.app's interface has always taken the click itself (`notify::on_click`); the zgx app never did. It does now: Zeron comes forward and opens the banner's chat (agent updates: Settings → Providers), through the same route a link takes. Co-Authored-By: Claude Opus 5.5 --- apps/zgx/src/links.rs | 57 +++++++++ apps/zgx/src/main.rs | 2 + crates/engine/src/desktop_notify.rs | 189 ++++++++++++++++++++++++++-- 3 files changed, 236 insertions(+), 12 deletions(-) diff --git a/apps/zgx/src/links.rs b/apps/zgx/src/links.rs index 8d647e251..a2486dcce 100644 --- a/apps/zgx/src/links.rs +++ b/apps/zgx/src/links.rs @@ -71,6 +71,41 @@ pub fn open(url: &str) { }); } +/// Banner clicks, taken in this process. The engine posts Zeron's banners, +/// but macOS hands a click to the app its bundle names (Zeron.app's +/// interface, this process), never to the engine that posted it, so the +/// engine's own route (`open -a … zeron://notification/…`) never runs. As +/// Zeron.app's interface always has (crates/ui `notify::on_click`), the +/// click is answered here: Zeron comes forward, on the banner's chat. +pub fn take_banner_clicks() { + zeron_notify::on_click(|target| { + activate(); + clicked(&target); + }); +} + +/// A clicked banner's target (a chat, or agent updates), opened as its +/// `zeron://notification/` link is. +fn clicked(target: &str) { + open(&zeron_notify::link(target)); +} + +/// This app to the front: a banner was clicked. (Main thread: the click +/// comes through the AppKit delegate.) +#[cfg(target_os = "macos")] +fn activate() { + use objc::{class, msg_send, sel, sel_impl}; + unsafe { + let app: *mut objc::runtime::Object = msg_send![class!(NSApplication), sharedApplication]; + if !app.is_null() { + let _: () = msg_send![app, activateIgnoringOtherApps: true]; + } + } +} + +#[cfg(not(target_os = "macos"))] +fn activate() {} + fn tell(target: Target) { let seq = SEQ.with(|s| { s.set(s.get() + 1); @@ -94,6 +129,28 @@ fn tell(target: Target) { mod tests { use super::*; + fn last() -> (Option, Option) { + LAST.with(|l| { + let l = l.borrow(); + let text = |k: &str| match l.field(k) { + Some(Value::Str(s)) => Some(s.to_string()), + Some(Value::Text(s)) => Some(s.to_string()), + _ => None, + }; + (text("chat"), text("settings")) + }) + } + + /// A banner clicked in this process (macOS hands the click to the app, + /// not the engine that posted it) opens its chat as its link would. + #[test] + fn a_clicked_banner_opens_its_chat() { + clicked("chat-42"); + assert_eq!(last(), (Some("chat-42".into()), None)); + clicked(zeron_notify::AGENT_UPDATES_TARGET); + assert_eq!(last(), (None, Some("providers".into()))); + } + #[test] fn banners_and_chat_links_open_where_zeron_s_do() { assert_eq!(parse(&zeron_notify::link("chat-1")), Some((Target::Chat("chat-1".into()), None))); diff --git a/apps/zgx/src/main.rs b/apps/zgx/src/main.rs index 11a592697..e3431f7b8 100644 --- a/apps/zgx/src/main.rs +++ b/apps/zgx/src/main.rs @@ -352,6 +352,8 @@ fn main() -> Result<(), Box> { } }); } + // A clicked banner: Zeron forward on its chat (src/links.rs). + links::take_banner_clicks(); let options = match screen { Screen::Intro => intro_window(), Screen::Onboarding => onboarding_window(), diff --git a/crates/engine/src/desktop_notify.rs b/crates/engine/src/desktop_notify.rs index c395531a0..e27315b91 100644 --- a/crates/engine/src/desktop_notify.rs +++ b/crates/engine/src/desktop_notify.rs @@ -31,6 +31,14 @@ use zeron_proto::{Chat, ConnectivityState, HarnessUpdatePhase, HarnessUpdateStat static ENABLED: AtomicBool = AtomicBool::new(false); +/// How long a finish waits to stand before it rings. The person's own +/// message often comes with one: a steer or a queued row taken as a turn +/// ends publishes that end with Working (their message carries the turn on), +/// and a send that replaces the runtime marks the old turn's end a moment +/// before the new one starts. Neither is "finished"; a turn that follows +/// within this window takes the finish with it. +const DONE_SETTLE: chrono::Duration = chrono::Duration::seconds(2); + /// This process shows desktop banners: engines assembled from now on post /// them (and advertise [`zeron_proto::capabilities::DESKTOP_NOTIFICATIONS_V1`]). pub fn enable() { @@ -222,7 +230,12 @@ impl Prefs { /// What a banner asked for by something other than a session (a plugin's, /// through `PostNotification`) came to: shown, or why not. -pub(crate) fn asked_outcome(prefs_enabled: bool, background_only: bool, focused: bool, desktop: bool) -> &'static str { +pub(crate) fn asked_outcome( + prefs_enabled: bool, + background_only: bool, + focused: bool, + desktop: bool, +) -> &'static str { if !desktop { "unavailable" } else if !prefs_enabled { @@ -237,7 +250,13 @@ pub(crate) fn asked_outcome(prefs_enabled: bool, background_only: bool, focused: /// A banner asked for (a plugin's): shown as the engine's own are, under /// the same Settings (`notificationsEnabled`, "only when in the /// background"), clicking it opening `target` (a session). What it came to. -pub(crate) fn post_asked(data_dir: &Path, focus: &ViewportFocus, title: &str, body: &str, target: Option<&str>) -> &'static str { +pub(crate) fn post_asked( + data_dir: &Path, + focus: &ViewportFocus, + title: &str, + body: &str, + target: Option<&str>, +) -> &'static str { let prefs = Prefs::read(data_dir); let outcome = asked_outcome(prefs.enabled, prefs.background_only, focus.any(), enabled()); if outcome == "posted" { @@ -261,7 +280,9 @@ pub(crate) fn post_for( std::sync::LazyLock::new(Default::default); let body: String = body.chars().take(500).collect(); let paced = { - let mut pace = PACE.lock().unwrap_or_else(std::sync::PoisonError::into_inner); + let mut pace = PACE + .lock() + .unwrap_or_else(std::sync::PoisonError::into_inner); !asked_in_time(pace.entry(source.to_owned()).or_default(), Instant::now()) }; if paced { @@ -273,11 +294,19 @@ pub(crate) fn post_for( /// Whether one more banner from a source may show, given when its last /// ones did: at most [`ASKED_PER_MINUTE`] a minute, [`ASKED_APART`] apart. -pub(crate) fn asked_in_time(history: &mut std::collections::VecDeque, now: Instant) -> bool { - while history.front().is_some_and(|at| now.duration_since(*at) >= Duration::from_secs(60)) { +pub(crate) fn asked_in_time( + history: &mut std::collections::VecDeque, + now: Instant, +) -> bool { + while history + .front() + .is_some_and(|at| now.duration_since(*at) >= Duration::from_secs(60)) + { history.pop_front(); } - let apart = history.back().is_none_or(|at| now.duration_since(*at) >= ASKED_APART); + let apart = history + .back() + .is_none_or(|at| now.duration_since(*at) >= ASKED_APART); if apart && history.len() < ASKED_PER_MINUTE { history.push_back(now); return true; @@ -316,6 +345,9 @@ struct Notifier { focus: ViewportFocus, post: Post, baselines: HashMap, + /// Finishes waiting to stand ([`DONE_SETTLE`]): chat → its title and + /// when it rings. + settling: HashMap)>, connectivity: ConnectivityNotificationState, updates_seen: HashSet, } @@ -328,6 +360,7 @@ impl Notifier { focus, post, baselines: HashMap::new(), + settling: HashMap::new(), connectivity: ConnectivityNotificationState::default(), updates_seen: HashSet::new(), } @@ -356,15 +389,56 @@ impl Notifier { if !chat.is_some_and(Chat::is_top_level) { continue; } + // A turn going on (or asking, or failing) takes a waiting + // finish with it. + if status.indicator != Indicator::None { + self.settling.remove(&session.chat_id); + } if let Some(prev) = prev && let Some(ping) = status.ping_since(&prev, false) { let title = chat .and_then(|chat| chat.title.clone()) .unwrap_or_else(|| "New session".into()); - due.push((title, ping, session.chat_id.clone())); + match ping { + // Published with the next turn already running: the + // person's message carried it on, nothing finished. + Ping::Done if status.indicator == Indicator::Working => {} + Ping::Done => { + self.settling + .insert(session.chat_id.clone(), (title, now + DONE_SETTLE)); + } + _ => due.push((title, ping, session.chat_id.clone())), + } } } + self.post_due(due); + } + + /// When the next waiting finish rings. + fn next_settled(&self) -> Option> { + self.settling.values().map(|(_, at)| *at).min() + } + + /// Ring the finishes that have stood for [`DONE_SETTLE`]. + fn flush(&mut self, now: chrono::DateTime) { + let stood: Vec = self + .settling + .iter() + .filter(|(_, (_, at))| *at <= now) + .map(|(chat, _)| chat.clone()) + .collect(); + let due = stood + .into_iter() + .filter_map(|chat| { + let (title, _) = self.settling.remove(&chat)?; + Some((title, Ping::Done, chat)) + }) + .collect(); + self.post_due(due); + } + + fn post_due(&mut self, due: Vec<(String, Ping, String)>) { if due.is_empty() || self.allowed().is_none() { return; } @@ -464,6 +538,7 @@ pub(crate) fn spawn(core: &crate::EngineCore, data_dir: PathBuf) -> tokio::task: let mut updates_due: Option = Some(tokio::time::Instant::now() + UPDATE_DEBOUNCE); loop { + let settles_at = notifier.next_settled(); tokio::select! { changed = sessions.changed() => { if changed.is_err() { break; } @@ -485,6 +560,17 @@ pub(crate) fn spawn(core: &crate::EngineCore, data_dir: PathBuf) -> tokio::task: updates.borrow_and_update(); updates_due.get_or_insert(tokio::time::Instant::now() + UPDATE_DEBOUNCE); } + _ = async { + match settles_at { + Some(at) => { + let wait = (at - chrono::Utc::now()).to_std().unwrap_or_default(); + tokio::time::sleep(wait).await; + } + None => std::future::pending().await, + } + } => { + notifier.flush(chrono::Utc::now()); + } _ = async { match updates_due { Some(at) => tokio::time::sleep_until(at).await, @@ -505,21 +591,38 @@ mod tests { #[test] fn a_plugin_s_banner_keeps_to_the_settings_and_its_pace() { assert_eq!(asked_outcome(true, false, true, true), "posted"); - assert_eq!(asked_outcome(true, true, true, true), "held", "only when in the background, and a window is in front"); + assert_eq!( + asked_outcome(true, true, true, true), + "held", + "only when in the background, and a window is in front" + ); assert_eq!(asked_outcome(true, true, false, true), "posted"); assert_eq!(asked_outcome(false, false, false, true), "off"); - assert_eq!(asked_outcome(true, false, false, false), "unavailable", "a server never shows banners"); + assert_eq!( + asked_outcome(true, false, false, false), + "unavailable", + "a server never shows banners" + ); let mut history = std::collections::VecDeque::new(); let t0 = Instant::now(); assert!(asked_in_time(&mut history, t0)); - assert!(!asked_in_time(&mut history, t0 + Duration::from_secs(1)), "too soon after the last"); + assert!( + !asked_in_time(&mut history, t0 + Duration::from_secs(1)), + "too soon after the last" + ); let mut at = t0; for _ in 1..ASKED_PER_MINUTE { at += ASKED_APART; assert!(asked_in_time(&mut history, at)); } - assert!(!asked_in_time(&mut history, at + ASKED_APART), "a minute's worth"); - assert!(asked_in_time(&mut history, t0 + Duration::from_secs(61)), "a minute on, one more"); + assert!( + !asked_in_time(&mut history, at + ASKED_APART), + "a minute's worth" + ); + assert!( + asked_in_time(&mut history, t0 + Duration::from_secs(61)), + "a minute on, one more" + ); } use super::*; @@ -782,6 +885,8 @@ mod tests { &chats, now, ); + // (Once it has settled: a finish waits a moment for a turn to follow.) + notifier.flush(now + DONE_SETTLE); assert_eq!( *posted.lock().unwrap(), vec![( @@ -793,6 +898,7 @@ mod tests { // A focused window holds it back (background-only is the default). focus.set("window", true); notifier.sessions(&[session("a", Some("t3"), now)], &chats, now); + notifier.flush(now + DONE_SETTLE); assert_eq!(posted.lock().unwrap().len(), 1); // Banners off: nothing, focused or not. focus.set("window", false); @@ -802,9 +908,68 @@ mod tests { ) .unwrap(); notifier.sessions(&[session("a", Some("t4"), now)], &chats, now); + notifier.flush(now + DONE_SETTLE); assert_eq!(posted.lock().unwrap().len(), 1); } + fn working(chat_id: &str, turn: Option<&str>, now: chrono::DateTime) -> Session { + let mut row = session(chat_id, turn, now); + row.status = zeron_proto::SessionStatus::Working; + row.started_at = Some(now); + row + } + + /// Your own message never rings "finished". These are the rows + /// crates/engine/src/sessions.rs publishes at such a send. + #[test] + fn a_send_steer_or_queued_send_never_rings_finished() { + let dir = tempfile::tempdir().unwrap(); + let (mut notifier, posted, _) = notifier(dir.path()); + let chats = [chat("a", "Fix the build", None)]; + let t0 = chrono::Utc::now(); + let at = |ms: i64| t0 + chrono::Duration::milliseconds(ms); + notifier.sessions(&[session("a", Some("t1"), at(0))], &chats, at(0)); + + // A plain send to an idle chat: Working, the marker as it was. + notifier.sessions(&[working("a", Some("t1"), at(10))], &chats, at(10)); + notifier.flush(at(10_000)); + // A steer (or a queued row taken) as the turn ends: the end is + // published with Working, the person's message carrying it on. + notifier.sessions(&[working("a", Some("t2"), at(20))], &chats, at(20)); + notifier.flush(at(10_000)); + // A send that replaces the runtime: the held end lands Idle, then + // the new turn starts a moment later. + notifier.sessions(&[session("a", Some("t3"), at(30))], &chats, at(30)); + notifier.sessions(&[working("a", Some("t3"), at(200))], &chats, at(200)); + notifier.flush(at(10_000)); + assert!( + posted.lock().unwrap().is_empty(), + "rang on a send: {:?}", + posted.lock().unwrap() + ); + + // The turn your message started finishing: that rings, once. + notifier.sessions(&[session("a", Some("t4"), at(20_000))], &chats, at(20_000)); + notifier.flush(at(30_000)); + notifier.flush(at(40_000)); + assert_eq!(posted.lock().unwrap().len(), 1); + } + + /// A question or a failure doesn't wait: it rings at once. + #[test] + fn a_question_or_failure_rings_at_once() { + let dir = tempfile::tempdir().unwrap(); + let (mut notifier, posted, _) = notifier(dir.path()); + let chats = [chat("a", "Fix the build", None)]; + let now = chrono::Utc::now(); + notifier.sessions(&[working("a", Some("t1"), now)], &chats, now); + let mut asking = working("a", Some("t1"), now); + asking.status = zeron_proto::SessionStatus::AwaitingInput; + notifier.sessions(&[asking], &chats, now); + assert_eq!(posted.lock().unwrap().len(), 1); + assert_eq!(posted.lock().unwrap()[0].1, "Waiting on your input"); + } + #[test] fn agent_updates_banner_once_per_release() { let dir = tempfile::tempdir().unwrap(); From e1894e552252e68680708e6958624fd7c5d1822e Mon Sep 17 00:00:00 2001 From: Wing <44917547+wingleeio@users.noreply.github.com> Date: Sat, 14 Nov 2026 19:58:13 -0700 Subject: [PATCH 04/10] Plugins: compose can replace a draft's words or write another chat's; draft_of reads any chat's What #1446 asked for that #1445's draft API didn't cover: - `zeron.compose(text, { replace = true, session? })` ("compose"): the words put in place of the draft's (its chips stay, so a rewrite keeps what it carries), and in another chat's draft (`session`). Words alone are added after what's there, as ever. Nothing is sent. - `zeron.draft_of(session)` ("draft"): a promise of any chat's draft as it is, as `zeron.draft()` says it (text, chat, chips by kind and name, never a path), read once in the host where the app keeps it. The composer's handling of a plugin's words is one path now (words alone come as a string). Consent: "compose" says it may replace what you wrote; "draft" says it sees your words in any chat. Docs, SDK (and its copies). Tests: src/plugins `compose_takes_words_alone_or_with_replace_and_a_chat`, `a_chats_draft_is_read_where_it_is_kept_without_paths`; ui/tests/plugin_compose_replace.test.luau. Full UI suite (1422) and plugins:: (248) pass. Co-Authored-By: Claude Opus 5.5 --- apps/zgx/docs/plugins.md | 22 ++- apps/zgx/plugins-builtin/git/zeron.luau | 28 +++- apps/zgx/plugins-builtin/github/zeron.luau | 28 +++- .../parallax-scenes/zeron.luau | 28 +++- apps/zgx/plugins-dev/account-pin/zeron.luau | 28 +++- .../zgx/plugins-dev/account-rotate/zeron.luau | 28 +++- .../plugins-dev/checkout-status/zeron.luau | 28 +++- .../plugins-dev/compact-sidebar/zeron.luau | 28 +++- apps/zgx/plugins-dev/composer-cat/zeron.luau | 28 +++- apps/zgx/plugins-dev/focus/zeron.luau | 28 +++- apps/zgx/plugins-dev/keep-going/zeron.luau | 28 +++- apps/zgx/plugins-dev/md-hello/zeron.luau | 28 +++- apps/zgx/plugins-dev/notes-tool/zeron.luau | 28 +++- apps/zgx/plugins-dev/ping/zeron.luau | 28 +++- .../zgx/plugins-dev/session-status/zeron.luau | 28 +++- apps/zgx/plugins-dev/session-words/zeron.luau | 28 +++- apps/zgx/plugins-dev/settings-demo/zeron.luau | 28 +++- apps/zgx/plugins-sdk/zeron.luau | 28 +++- apps/zgx/src/plugins/grants.rs | 2 +- apps/zgx/src/plugins/mod.rs | 140 +++++++++++++++++- apps/zgx/ui/locales/en.json | 4 +- apps/zgx/ui/locales/zh-Hans.json | 4 +- apps/zgx/ui/screens/chat/shared.luau | 10 ++ apps/zgx/ui/screens/plugins/init.luau | 23 ++- .../ui/tests/plugin_compose_replace.test.luau | 54 +++++++ 25 files changed, 671 insertions(+), 64 deletions(-) create mode 100644 apps/zgx/ui/tests/plugin_compose_replace.test.luau diff --git a/apps/zgx/docs/plugins.md b/apps/zgx/docs/plugins.md index 361d6383e..5ac07018a 100644 --- a/apps/zgx/docs/plugins.md +++ b/apps/zgx/docs/plugins.md @@ -52,8 +52,8 @@ 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 (`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`), 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, 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) | | `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,12 +214,13 @@ 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)` | text into the message box | `compose` | +| `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_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` | @@ -288,6 +289,21 @@ With `draft`, a plugin reads what you're typing and can set it aside and bring i - **`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: diff --git a/apps/zgx/plugins-builtin/git/zeron.luau b/apps/zgx/plugins-builtin/git/zeron.luau index f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-builtin/git/zeron.luau +++ b/apps/zgx/plugins-builtin/git/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-builtin/github/zeron.luau +++ b/apps/zgx/plugins-builtin/github/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-builtin/parallax-scenes/zeron.luau +++ b/apps/zgx/plugins-builtin/parallax-scenes/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/account-pin/zeron.luau +++ b/apps/zgx/plugins-dev/account-pin/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/account-rotate/zeron.luau +++ b/apps/zgx/plugins-dev/account-rotate/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/checkout-status/zeron.luau +++ b/apps/zgx/plugins-dev/checkout-status/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/compact-sidebar/zeron.luau +++ b/apps/zgx/plugins-dev/compact-sidebar/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/composer-cat/zeron.luau +++ b/apps/zgx/plugins-dev/composer-cat/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/focus/zeron.luau +++ b/apps/zgx/plugins-dev/focus/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/keep-going/zeron.luau +++ b/apps/zgx/plugins-dev/keep-going/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/md-hello/zeron.luau +++ b/apps/zgx/plugins-dev/md-hello/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/notes-tool/zeron.luau +++ b/apps/zgx/plugins-dev/notes-tool/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/ping/zeron.luau +++ b/apps/zgx/plugins-dev/ping/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/session-status/zeron.luau +++ b/apps/zgx/plugins-dev/session-status/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/session-words/zeron.luau +++ b/apps/zgx/plugins-dev/session-words/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-dev/settings-demo/zeron.luau +++ b/apps/zgx/plugins-dev/settings-demo/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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 f512827bc..553b6cc16 100644 --- a/apps/zgx/plugins-sdk/zeron.luau +++ b/apps/zgx/plugins-sdk/zeron.luau @@ -69,7 +69,11 @@ -- 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) text into the message box, for you to send ("compose") +-- 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_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, @@ -87,6 +91,9 @@ -- 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") @@ -1354,8 +1361,16 @@ return function(id: string): any ui.invoke(`{prefix}.open_url`, url) end - function M.compose(text: string) - ui.invoke("zeron.compose.insert", text) + -- `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 end -- A review comment on a file or a diff, as a chip on a session's draft @@ -1429,6 +1444,13 @@ return function(id: string): any 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/plugins/grants.rs b/apps/zgx/src/plugins/grants.rs index ab25070ce..2e731d6e2 100644 --- a/apps/zgx/src/plugins/grants.rs +++ b/apps/zgx/src/plugins/grants.rs @@ -80,7 +80,7 @@ pub const ACTIONS: &[(&str, &str)] = &[ pub const NEVER_REPLACED: &[&str] = &["@app/screens/plugins", "@app/screens/shell/settings"]; /// Each plugin's own actions (`plugin..`). -pub const OWN_ACTIONS: &[&str] = &["result", "ack", "send", "menus", "toast", "problem", "open_tab", "add_page", "github_watch", "github_call", "store_set", "setting_status", "open_url", "notify", "cost", "run", "db", "service_call", "agents", "menu_run", "compose_comment", "draft", "file", "block"]; +pub const OWN_ACTIONS: &[&str] = &["result", "ack", "send", "menus", "toast", "problem", "open_tab", "add_page", "github_watch", "github_call", "store_set", "setting_status", "open_url", "notify", "cost", "run", "db", "service_call", "agents", "menu_run", "compose_comment", "draft", "draft_of", "file", "block"]; /// Each plugin's own shared state, to read (`plugin..`). pub const OWN_SHARED: &[&str] = &["calls", "inbox", "records", "github", "store", "settings", "locales", "menu_items", "composed", "drafts"]; diff --git a/apps/zgx/src/plugins/mod.rs b/apps/zgx/src/plugins/mod.rs index 973f1e646..a557ef1bc 100644 --- a/apps/zgx/src/plugins/mod.rs +++ b/apps/zgx/src/plugins/mod.rs @@ -473,6 +473,71 @@ pub(crate) fn draft_ask(asked: &Value) -> Option { Some(Value::record([("op", Value::from(op.as_str())), ("key", Value::from(key.as_str()))])) } +/// What `zeron.compose` asks of the composer: its words alone (added to +/// the draft shown, as ever), or with `{ text, replace, session }` (the +/// draft's words replaced, or a chat named other than the one shown). +pub(crate) fn compose(asked: &Value) -> Value { + let Some(words) = asked.field("text") else { + return Value::from(text(asked).as_str()); + }; + let words = match words { + Value::Str(_) | Value::Text(_) => words.clone(), + _ => Value::from(""), + }; + let mut fields = vec![ + ("text", words), + ("replace", Value::from(matches!(asked.field("replace"), Some(Value::Bool(true))))), + ]; + if let Some(session) = asked.field("session").map(text).filter(|s| !s.is_empty()) { + fields.push(("session", Value::from(session.as_str()))); + } + Value::record(fields) +} + +/// The app's shared states a chat's draft lives in (screens/chat/shared), +/// each read with the value the app starts it at: read before the app has +/// made one, it's made as the app would. +const DRAFT_HERE: &str = "chat.composer.here"; +const DRAFT_TEXT: &str = "chat.composer.text"; +const DRAFT_CARGO: &str = "chat.composer.cargo"; +const DRAFTS_KEPT: &str = "chat.composer.drafts"; + +/// What a draft carries, as plugins are told it (as `zeron.draft()` says +/// it, screens/plugins): each chip's kind and name, never a file's path. +fn draft_attachments(cargo: &Value) -> Value { + let said = |item: &Value, field: &str, or: &str| match item.field(field) { + Some(v @ Value::Str(_)) => v.clone(), + _ => Value::from(or), + }; + vlist(cargo.items().iter().map(|item| Value::record([("kind", said(item, "kind", "file")), ("name", said(item, "name", ""))])).collect()) +} + +/// Chat `session`'s draft, for `zeron.draft_of` ("draft"): out in the +/// composer (`here` its chat, "" a new chat's; `shown` its words, `cargo` +/// its chips) or kept for it (`kept`, by chat). Its words as typed, what it +/// carries, and its chat (none for a new chat's). A chat with no draft has +/// no words and carries nothing. +pub(crate) fn draft_of(session: &str, here: &Value, shown: &Value, cargo: &Value, kept: &Value) -> Value { + let (words, carried) = if session == text(here) { + (shown.clone(), cargo.clone()) + } else { + let d = kept.field(session); + ( + d.and_then(|d| d.field("text")).cloned().unwrap_or_default(), + d.and_then(|d| d.field("cargo")).cloned().unwrap_or_default(), + ) + }; + let words = match words { + Value::Str(_) | Value::Text(_) => words, + _ => Value::from(""), + }; + let mut fields = vec![("text", words), ("attachments", draft_attachments(&carried))]; + if !session.is_empty() { + fields.push(("session", Value::from(session))); + } + Value::record(fields) +} + /// Plugins for the main window `cx` shows `host` in. pub fn install(cx: &mut WindowContext, host: &ScriptHost) { expose_surface(host); @@ -2433,6 +2498,31 @@ impl Bridge { } } }); + // Another chat's draft, as it is (`zeron.draft_of`, "draft"): read + // where the app keeps it, once, never followed. + host.async_action(format!("plugin.{id}.draft_of"), { + let (me, plugin) = (me.clone(), plugin.clone()); + move |asked| { + let (me, plugin) = (me.clone(), plugin.clone()); + async move { + let b = me.upgrade().ok_or("This plugin isn't on")?; + let item = b.item(&plugin).ok_or("This plugin isn't on")?; + if !item.may("draft") { + return Err("This plugin wasn't allowed to read what you type in the message box".to_string()); + } + let session = text(&asked); + if session.chars().count() > 200 { + return Err("That isn't a chat".to_string()); + } + let read = |name: &str, initial: Value| b.host.shared(name, initial).signal().with_untracked(Value::clone); + let here = read(DRAFT_HERE, Value::from("")); + let shown = read(DRAFT_TEXT, Value::from("")); + let cargo = read(DRAFT_CARGO, vlist(Vec::new())); + let kept = read(DRAFTS_KEPT, Value::record(Vec::<(&str, Value)>::new())); + Ok(draft_of(&session, &here, &shown, &cargo, &kept)) + } + } + }); host.action(format!("plugin.{id}.open_url"), { let (me, plugin) = (me.clone(), plugin.clone()); move |url| { @@ -3333,9 +3423,9 @@ impl Bridge { }); host.action("zeron.compose.insert", { let me = me.clone(); - move |text_| { + move |asked| { if let Some(b) = me.upgrade() { - b.request("compose", "", Value::from(text(&text_).as_str())); + b.request("compose", "", compose(&asked)); } } }); @@ -3477,6 +3567,52 @@ mod tests { assert_eq!(gone, vec!["clock".to_string(), "ping".to_string()]); } + /// `zeron.compose(text)` adds its words as ever; with options, it says + /// whether they replace the draft and which chat's (none: the shown). + #[test] + fn compose_takes_words_alone_or_with_replace_and_a_chat() { + assert_eq!(compose(&Value::from("hello")), Value::from("hello")); + let asked = json_value(&json!({ "text": "clearer", "replace": true, "session": "s2" })); + let out = compose(&asked); + assert_eq!(text(out.field("text").unwrap()), "clearer"); + assert_eq!(out.field("replace"), Some(&Value::from(true))); + assert_eq!(text(out.field("session").unwrap()), "s2"); + // (Only `true` replaces; a blank chat is the one shown; words that + // aren't text are none.) + let loose = json_value(&json!({ "text": 5, "replace": "yes", "session": "" })); + let out = compose(&loose); + assert_eq!(text(out.field("text").unwrap()), ""); + assert_eq!(out.field("replace"), Some(&Value::from(false))); + assert!(out.field("session").is_none()); + } + + /// `zeron.draft_of`: the chat shown's draft (from the composer), or + /// another chat's (kept), with its chat and its chips by kind and name + /// alone; a new chat's has no chat; a chat with none, nothing. + #[test] + fn a_chats_draft_is_read_where_it_is_kept_without_paths() { + let kept = json_value(&json!({ + "s2": { "text": "kept words", "cargo": [{ "kind": "file", "name": "a.rs", "path": "/Users/me/a.rs" }] }, + "": { "text": "new chat words", "cargo": [] }, + })); + let (here, shown) = (Value::from("s1"), Value::from("typing now")); + let cargo = json_value(&json!([{ "kind": "image", "name": "shot.png", "path": "/tmp/shot.png" }])); + let out = draft_of("s1", &here, &shown, &cargo, &kept); + assert_eq!(value_json(&out), json!({ "text": "typing now", "session": "s1", "attachments": [{ "kind": "image", "name": "shot.png" }] })); + let out = draft_of("s2", &here, &shown, &cargo, &kept); + assert_eq!(value_json(&out), json!({ "text": "kept words", "session": "s2", "attachments": [{ "kind": "file", "name": "a.rs" }] })); + assert!(!out.to_json().contains("/Users/me"), "never a path"); + // A chat with no draft: nothing written, nothing carried. + let out = draft_of("s9", &here, &shown, &cargo, &kept); + assert_eq!(value_json(&out), json!({ "text": "", "session": "s9", "attachments": [] })); + // A new chat's draft, kept while a chat shows: no chat. + let out = draft_of("", &here, &shown, &cargo, &kept); + assert_eq!(value_json(&out), json!({ "text": "new chat words", "attachments": [] })); + // Before the app has made its states: nothing, not an error. + let out = draft_of("s1", &Value::Nil, &Value::Nil, &Value::Nil, &Value::Nil); + assert_eq!(text(out.field("text").unwrap()), ""); + } + /// R21: a plugin's review comment goes on the chat shown alone, with /// at most the 40 lines of code that are sent (a 20,000-character /// snippet once rode along unseen, onto any chat's draft). diff --git a/apps/zgx/ui/locales/en.json b/apps/zgx/ui/locales/en.json index 2e7b2e68d..960b2be33 100644 --- a/apps/zgx/ui/locales/en.json +++ b/apps/zgx/ui/locales/en.json @@ -3485,11 +3485,11 @@ }, "compose": { "title": "Put text in the message box", - "detail": "You still send it." + "detail": "It can add to what you've written or replace it. You still send it." }, "draft": { "title": "Read what you type in the message box, and set it aside", - "detail": "It sees your words before you send them, and can take the draft away and put it back later. It never sends it." + "detail": "It sees your words in any chat before you send them, and can take the draft away and put it back later. It never sends it." }, "network": { "title": "Connect to the internet", diff --git a/apps/zgx/ui/locales/zh-Hans.json b/apps/zgx/ui/locales/zh-Hans.json index 021d254da..1a6a00cc0 100644 --- a/apps/zgx/ui/locales/zh-Hans.json +++ b/apps/zgx/ui/locales/zh-Hans.json @@ -3485,11 +3485,11 @@ }, "compose": { "title": "在消息输入框中填写文本", - "detail": "仍由你来发送。" + "detail": "它可以补充或替换你写的内容,仍由你来发送。" }, "draft": { "title": "读取你在消息输入框中输入的内容,并可暂存", - "detail": "它能在你发送前看到你输入的文字,也能把草稿暂时取走、稍后放回。它不会替你发送。" + "detail": "它能在你发送前看到你在任意聊天中输入的文字,也能把草稿暂时取走、稍后放回。它不会替你发送。" }, "network": { "title": "连接互联网", diff --git a/apps/zgx/ui/screens/chat/shared.luau b/apps/zgx/ui/screens/chat/shared.luau index 3f0b8669a..f16052d41 100644 --- a/apps/zgx/ui/screens/chat/shared.luau +++ b/apps/zgx/ui/screens/chat/shared.luau @@ -944,6 +944,16 @@ function M.draft_of(key: string): { text: string, cargo: { any }, chosen: { [str } end +-- Chat `key`'s draft's words as they are, read without following them +-- (`draft_of` follows them): what a plugin's `zeron.compose` adds to. +function M.peek_text_of(key: string): string + if here:peek() == key then + return M.text:peek() + end + local d = kept:peek()[key] + return if d and type(d.text) == "string" then d.text else "" +end + -- Chat `key`'s draft changed where it's shown by its id (`field`: "text" -- or "chosen"): written wherever it is, as `draft_of` reads it. function M.set_draft_of(key: string, field: string, value: any) diff --git a/apps/zgx/ui/screens/plugins/init.luau b/apps/zgx/ui/screens/plugins/init.luau index f67b9acd9..372587175 100644 --- a/apps/zgx/ui/screens/plugins/init.luau +++ b/apps/zgx/ui/screens/plugins/init.luau @@ -45,7 +45,6 @@ local store = require("@app/screens/settings/store") local PrivateText = require("@ds/private_text") local state = require("@app/screens/plugins/state") local page = require("@app/screens/plugins/page") -local chat = require("@app/screens/chat") local ChatShared = require("@app/screens/chat/shared") local Cargo = require("@ds/composer_cargo") @@ -309,8 +308,26 @@ local function run(r: any) elseif type(to) == "table" and type(to.settings) == "string" and to.settings ~= "account" then route.settings(to.settings) end - elseif r.kind == "compose" and type(r.value) == "string" then - chat.store.insert(string.sub(r.value, 1, 20000)) + elseif r.kind == "compose" and (type(r.value) == "string" or (type(r.value) == "table" and type(r.value.text) == "string")) then + -- `zeron.compose(text, { replace, session })` (the host checked + -- "compose"; its words alone come as a string): the words put in a + -- chat's draft, the one shown unless it names another ("" a new + -- chat's), in place of its words (its chips stay) or after them, on + -- a line of their own. Unsent: the person sends it. Shown, the + -- composer takes the keys. + local v = if type(r.value) == "string" then { text = r.value } else r.value + local words = string.sub(v.text, 1, 20000) + local shown = ChatShared.showing() + local key = if type(v.session) == "string" and #v.session <= 200 then v.session else shown + if v.replace ~= true then + local now = ChatShared.peek_text_of(key) + local sep = if now == "" or string.sub(now, -1) == "\n" then "" else "\n" + words = now .. sep .. words + end + ChatShared.set_draft_of(key, "text", words) + if key == shown then + ChatShared.focus:add(1) + end elseif r.kind == "compose_comment" and type(r.value) == "table" and type(r.title) == "string" then -- A plugin's review comment on a file or a diff (the host checked -- "compose"): a comment chip on the session's draft, as the files diff --git a/apps/zgx/ui/tests/plugin_compose_replace.test.luau b/apps/zgx/ui/tests/plugin_compose_replace.test.luau new file mode 100644 index 000000000..e91e12e8a --- /dev/null +++ b/apps/zgx/ui/tests/plugin_compose_replace.test.luau @@ -0,0 +1,54 @@ +-- What a plugin allowed "compose" puts in a chat's draft +-- (`zeron.compose(text, opts)`, handed on by screens/plugins as the host +-- asks it): after what's there, or in place of its words with its chips +-- kept (`replace`), in the chat shown or another (`session`), never sent. +-- On the shell in ui/shell_fixture.luau, the host's asks made here. + +local seq = 0 +local function ask(app: any, value: any) + seq += 1 + app:set_state("plugins.request", { { seq = 1000 + seq, kind = "compose", title = "", value = value } }) + app:frames(10) +end + +local function open(): any + seq = 0 + local app = mount("shell_fixture.luau") + app:resize(1400, 800) + app:set_state("shell_fixture.plugins", true) + app:frames(30) + app:click('#shell-sidebar >> role:button "Fix the build"') + app:frames(30) + return app +end + +local BOX = "#chat-composer >> role:textbox" + +test("a plugin's words replace the draft's, or follow them on a line of their own", function() + local app = open() + app:type(BOX, "fix teh bulid pls") + app:frames(5) + ask(app, { text = "Please fix the build.", replace = true }) + expect(app:text(BOX)).to_be("Please fix the build.") + ask(app, { text = "It fails on main." }) + expect(app:text(BOX)).to_be("Please fix the build.\nIt fails on main.") + -- Words alone, as ever: after what's there. + ask(app, "Thanks.") + expect(app:text(BOX)).to_be("Please fix the build.\nIt fails on main.\nThanks.") + -- Nothing sent. + expect(app:state("calls")).never.to_contain("send:a1") +end) + +test("a plugin's words go in another chat's draft, which shows them when it's opened", function() + local app = open() + app:type(BOX, "here, untouched") + app:frames(5) + ask(app, { text = "for the docs", replace = true, session = "a2" }) + expect(app:text(BOX)).to_be("here, untouched") + app:click('#shell-sidebar >> role:button "Write the docs"') + app:frames(30) + expect(app:text(BOX)).to_be("for the docs") + app:click('#shell-sidebar >> role:button "Fix the build"') + app:frames(30) + expect(app:text(BOX)).to_be("here, untouched") +end) From 7e1d53000aeb5450ab44c1663addaabe7f4f5710 Mon Sep 17 00:00:00 2001 From: Wing <44917547+wingleeio@users.noreply.github.com> Date: Sat, 14 Nov 2026 20:29:07 -0700 Subject: [PATCH 05/10] Cloud: keep zeron-engine, and put it back before each start MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit New Cloud machines never came online: since 0.3.0 the release's `zeron` is the zgx app, whose `zeron headless` runs the `zeron-engine` beside it, and the installer deleted that file (451822be9, when headless linked the engine). The unit exited at once ("no engine beside …/zeron (zeron-engine)"), restarted every second, never enrolled, and the chat said "Starting a Cloud machine…" until the 10-minute limit. 0.3.5's own updater and pre-sleep tidy leave it out on Cloud too, so a machine updating on a wake broke the same way. - The installer keeps zeron-engine, and downloads again a version that's installed without it. - A repair (`~/.zeron/repair-engine`) runs before every start of the unit (`ExecStartPre=-`, never failing it): with `current` missing zeron-engine, it fetches that version's release from the edge and puts the file back. The installer sets it up, and so does every wake's first command, so machines set up before this get it as they wake (reloading systemd once). Tested: the install script's unit tier (keeps it, re-downloads a version without it, the repair restores it and is a no-op once there, a failed download never fails a start, the wake writes the repair once); the real 0.3.5 release on Linux (restored byte for byte; `zeron headless` then starts and enrolls); edge unit (100) and Cloud workerd (77) tests. Co-Authored-By: Claude Opus 5.5 --- edge/src/cloud/install-script.ts | 69 +++++++++++++++++++++++++-- edge/test/unit/install-script.test.ts | 65 +++++++++++++++++++++++-- 2 files changed, 125 insertions(+), 9 deletions(-) diff --git a/edge/src/cloud/install-script.ts b/edge/src/cloud/install-script.ts index eed6fe562..b6c96c15d 100644 --- a/edge/src/cloud/install-script.ts +++ b/edge/src/cloud/install-script.ts @@ -48,6 +48,60 @@ ExecStart=/bin/systemctl start --no-block ${CLOUD_UNIT_NAME} WantedBy=multi-user.target `; +/** + * Puts back the release's `zeron-engine` beside the `zeron` the unit runs, when + * it's missing. Since 0.3.0 the release's `zeron` is the zgx app, whose + * `zeron headless` hands off to that engine: without it the unit exits at + * once, restarts every second and never enrolls. Machines lost it to the + * installer, the engine's own updater and the pre-sleep tidy, which all left + * it out on Cloud (0.3.5's still do), so the unit runs this before every start + * (`ExecStartPre=-`: it never fails a start). Downloads only while it's + * missing, the version `current` names, from the edge's own releases. + */ +export const REPAIR_ENGINE_SCRIPT = `#!/bin/sh +# Zeron Cloud: put back a missing zeron-engine (edge/src/cloud/install-script.ts). +home="\${ZERON_CLOUD_HOME:-$HOME}" +cur="$home/.zeron/app/current" +[ -x "$cur/zeron" ] || exit 0 +[ -f "$cur/zeron-engine" ] && exit 0 +dest="$(readlink -f "$cur")" || exit 0 +ver="$(basename "$dest")" +case "$ver" in + "" | *[!A-Za-z0-9._+-]*) exit 0 ;; +esac +case "$(uname -m)" in + x86_64 | amd64) arch=x86_64 ;; + aarch64 | arm64) arch=aarch64 ;; + *) exit 0 ;; +esac +[ -n "\${ZERON_EDGE_URL:-}" ] || exit 0 +tmp="$(mktemp -d "$home/.zeron/.repair.XXXXXX")" || exit 0 +trap 'rm -rf "$tmp"' EXIT +curl -fsSL --retry 3 --connect-timeout 15 --speed-limit 1048576 --speed-time 15 \\ + -o "$tmp/zeron.tar.gz" "$ZERON_EDGE_URL/releases/zeron-$ver-linux-$arch.tar.gz" || exit 0 +tar -xzf "$tmp/zeron.tar.gz" -C "$tmp" "zeron-$ver-linux-$arch/zeron-engine" || exit 0 +chmod 755 "$tmp/zeron-$ver-linux-$arch/zeron-engine" +mv -f "$tmp/zeron-$ver-linux-$arch/zeron-engine" "$dest/zeron-engine" +echo "zeron cloud: put back zeron-engine for $ver" +`; + +/** + * Writes the repair script (`REPAIR_ENGINE_SCRIPT`) to `~/.zeron/repair-engine` + * and a drop-in running it before the engine's unit starts, each only when it + * differs, reloading systemd only then. Run by the installer and by every + * wake's first command, so machines set up before it get it as they wake. + * Best effort: a failure here never stops what follows. + * `ZERON_CLOUD_HOME` / `ZERON_CLOUD_UNIT_DIR` exist for the unit tier. + */ +export const ENSURE_REPAIR = + `{ h="\${ZERON_CLOUD_HOME:-$HOME}"; r="$h/.zeron/repair-engine"; ` + + `dd="\${ZERON_CLOUD_UNIT_DIR:-/etc/systemd/system}/${CLOUD_UNIT_NAME}.d"; ` + + `t="$(mktemp)" && printf %s '${btoa(REPAIR_ENGINE_SCRIPT)}' | base64 -d >"$t" && ` + + `{ cmp -s "$t" "$r" || install -m 0700 "$t" "$r"; } && ` + + `printf '[Service]\\nExecStartPre=-%s\\n' "$r" >"$t" && ` + + `{ cmp -s "$t" "$dd/repair-engine.conf" || { sudo mkdir -p "$dd" && sudo install -m 0644 "$t" "$dd/repair-engine.conf" && sudo systemctl daemon-reload; }; }; ` + + `rm -f "$t"; } >/dev/null 2>&1 || true`; + export const CLOUD_INSTALL_SCRIPT = `#!/bin/sh # Zeron Cloud engine installer (edge/src/cloud/install-script.ts). # POSIX sh, idempotent, provider-neutral. @@ -85,7 +139,9 @@ esac restart=0 dest="$app/$ver" -if [ -x "$dest/zeron" ]; then +# (Whole, its zeron-engine too: \`zeron headless\` runs it, and installs +# made before 2026-11-15 left it out.) +if [ -x "$dest/zeron" ] && [ -f "$dest/zeron-engine" ]; then echo "zeron $ver already installed" else tmp="$(mktemp -d "$data/.download.XXXXXX")" @@ -99,10 +155,8 @@ else tar -xzf "$tmp/zeron.tar.gz" -C "$tmp/unpacked" --strip-components=1 # Probe before switching: a binary that cannot start must not replace one that can. "$tmp/unpacked/zeron" --version >/dev/null - # The desktop app's background engine (78 MB): never run here (the unit runs - # \`zeron headless\`, which links the engine), and every byte on this disk is - # copied back in on every wake. The engine's updater leaves it out too. - rm -f "$tmp/unpacked/zeron-engine" + # (zeron-engine stays: \`zeron headless\` runs it. Without it the unit + # exits at once and the machine never enrolls.) rm -rf "$dest" mv "$tmp/unpacked" "$dest" fi @@ -172,6 +226,8 @@ else rm -f "$boot_new" fi +# A zeron-engine an update leaves out is put back before each start. +${ENSURE_REPAIR} sudo systemctl daemon-reload sudo systemctl enable ${CLOUD_UNIT_NAME} ${CLOUD_BOOT_UNIT_NAME} >/dev/null sudo systemctl start ${CLOUD_BOOT_UNIT_NAME} @@ -253,6 +309,9 @@ export const RESTART_ENGINE_COMMAND = `sudo systemctl restart ${CLOUD_UNIT_NAME} * systemd hasn't read yet gets one reload. `--no-block` answers at once (the * engine's first token says it's up). Idempotent: a no-op when it's running. */ export const START_ENGINE_COMMAND = + // (First, the repair of a missing zeron-engine before each start, for + // machines set up before it: a no-op once it's there.) + `${ENSURE_REPAIR}; ` + `sudo systemctl start --no-block ${CLOUD_UNIT_NAME} || ` + `{ sudo systemctl daemon-reload; sudo systemctl start --no-block ${CLOUD_UNIT_NAME}; }`; diff --git a/edge/test/unit/install-script.test.ts b/edge/test/unit/install-script.test.ts index b96da8ce3..a4b8420ec 100644 --- a/edge/test/unit/install-script.test.ts +++ b/edge/test/unit/install-script.test.ts @@ -13,6 +13,7 @@ import { afterEach, beforeEach, describe, expect, it } from "vitest"; import { CLOUD_BOOT_UNIT, CLOUD_INSTALL_SCRIPT, + REPAIR_ENGINE_SCRIPT, START_ENGINE_COMMAND, STOP_ENGINE_COMMAND, installCommand, @@ -110,8 +111,15 @@ describe("cloud install script", { timeout: 60_000 }, () => { const data = join(home, ".zeron"); expect(readlinkSync(join(data, "app", "current"))).toBe(join(data, "app", "1.2.3")); expect(existsSync(join(data, "app", "1.2.3", "zeron"))).toBe(true); - // Never run on Cloud, and copied back in on every wake if kept. - expect(existsSync(join(data, "app", "1.2.3", "zeron-engine"))).toBe(false); + // Kept: `zeron headless` runs it (without it the unit exits at once and + // the machine never enrolls). + expect(existsSync(join(data, "app", "1.2.3", "zeron-engine"))).toBe(true); + // And put back before each start, should an update leave it out. + expect(statSync(join(data, "repair-engine")).mode & 0o777).toBe(0o700); + expect(readFileSync(join(data, "repair-engine"), "utf8")).toBe(REPAIR_ENGINE_SCRIPT); + expect(readFileSync(join(units, "zeron-cloud.service.d", "repair-engine.conf"), "utf8")).toBe( + `[Service]\nExecStartPre=-${join(data, "repair-engine")}\n` + ); const envFile = join(data, "env"); expect(statSync(envFile).mode & 0o777).toBe(0o600); expect(readFileSync(envFile, "utf8")).toBe( @@ -159,6 +167,45 @@ describe("cloud install script", { timeout: 60_000 }, () => { expect(calls()).toContain("systemctl restart zeron-cloud.service"); }); + it("downloads again a version installed without its zeron-engine", () => { + const { home, run, calls, clearCalls } = setup(); + run("org.user.cloud-1.codeA"); + const engine = join(home, ".zeron", "app", "1.2.3", "zeron-engine"); + rmSync(engine); + clearCalls(); + run("org.user.cloud-1.codeA"); + expect(existsSync(engine)).toBe(true); + expect(calls().filter((c) => c.includes(".tar.gz"))).toHaveLength(1); + }); + + it("puts back a zeron-engine an update left out, and does nothing once it's there", () => { + const { home, run, calls, clearCalls } = setup(); + run("org.user.cloud-1.codeA"); + const data = join(home, ".zeron"); + const engine = join(data, "app", "1.2.3", "zeron-engine"); + const repair = () => + execFileSync("sh", [join(data, "repair-engine")], { + env: { PATH: `${join(root, "bin")}:/usr/bin:/bin`, ZERON_CLOUD_HOME: home, ZERON_EDGE_URL: "https://edge.test" }, + encoding: "utf8" + }); + rmSync(engine); + clearCalls(); + expect(repair()).toContain("put back zeron-engine for 1.2.3"); + expect(existsSync(engine)).toBe(true); + expect(statSync(engine).mode & 0o111).not.toBe(0); + expect(calls().filter((c) => c.includes("/releases/zeron-1.2.3-linux-x86_64.tar.gz"))).toHaveLength(1); + // There: no download. + clearCalls(); + repair(); + expect(calls().filter((c) => c.startsWith("curl"))).toHaveLength(0); + // A download that fails leaves the start to go on (it never fails it). + rmSync(engine); + writeFileSync(join(root, "bin", "curl"), "#!/bin/sh\nexit 22\n"); + chmodSync(join(root, "bin", "curl"), 0o755); + expect(() => repair()).not.toThrow(); + expect(existsSync(engine)).toBe(false); + }); + it("doesn't wait for the network to start the engine, and starts it on boot without being asked", () => { const { units, run } = setup(); run("org.user.cloud-1.codeA"); @@ -237,9 +284,19 @@ describe("cloud install script", { timeout: 60_000 }, () => { }); it("starts the engine without waiting on it, and reloads once for a unit systemd hasn't read", () => { - const { calls, clearCalls } = setup(); + const { home, units, calls, clearCalls } = setup(); + mkdirSync(join(home, ".zeron"), { recursive: true }); const start = () => - execFileSync("sh", ["-c", START_ENGINE_COMMAND], { env: { PATH: `${join(root, "bin")}:/usr/bin:/bin` }, encoding: "utf8" }); + execFileSync("sh", ["-c", START_ENGINE_COMMAND], { + env: { PATH: `${join(root, "bin")}:/usr/bin:/bin`, ZERON_CLOUD_HOME: home, ZERON_CLOUD_UNIT_DIR: units }, + encoding: "utf8" + }); + // A machine set up before the repair: its first wake writes it, once. + clearCalls(); + start(); + expect(calls()).toEqual(["systemctl daemon-reload", "systemctl start --no-block zeron-cloud.service"]); + expect(readFileSync(join(home, ".zeron", "repair-engine"), "utf8")).toBe(REPAIR_ENGINE_SCRIPT); + expect(readFileSync(join(units, "zeron-cloud.service.d", "repair-engine.conf"), "utf8")).toContain("ExecStartPre=-"); clearCalls(); start(); expect(calls()).toEqual(["systemctl start --no-block zeron-cloud.service"]); From 9f43edfee7c4e078a652a8fba2c19dfe8500f4c0 Mon Sep 17 00:00:00 2001 From: Wing <44917547+wingleeio@users.noreply.github.com> Date: Sat, 14 Nov 2026 20:35:40 -0700 Subject: [PATCH 06/10] Cloud: the updater and the pre-sleep tidy keep zeron-engine Since 0.3.0 the release's `zeron` is the zgx app, whose `zeron headless` runs the `zeron-engine` beside it. The updater (staging a release) and the tidy (pre-sleep, on installed versions) left it out on Cloud (`CLOUD_UNUSED_FILES`, 451822be9), so a machine that updated stopped coming online. Nothing is unused on Cloud now. (#1454's repair, before each start, covers the releases out there until this one is.) Tests: the updater's (74) and transaction tests (30), with the Cloud ones now asserting it's kept. Co-Authored-By: Claude Opus 5.5 --- crates/update/src/lib.rs | 23 +++++++++++++---------- crates/update/tests/update_transaction.rs | 11 ++++------- docs/design/cloud-device.md | 12 ++++++------ 3 files changed, 23 insertions(+), 23 deletions(-) diff --git a/crates/update/src/lib.rs b/crates/update/src/lib.rs index d698dbe58..067653bbd 100644 --- a/crates/update/src/lib.rs +++ b/crates/update/src/lib.rs @@ -1248,10 +1248,11 @@ fn on_cloud() -> bool { on_cloud_platform(std::env::var("ZERON_DEVICE_PLATFORM").ok().as_deref()) } -/// Release files a Cloud machine never runs: the desktop app's background -/// engine (78 MB). A Cloud machine runs `zeron headless`, which links the -/// engine, and its disk is copied back in on every wake. -pub const CLOUD_UNUSED_FILES: &[&str] = &["zeron-engine"]; +/// Release files a Cloud machine never runs: none. (`zeron-engine` was here +/// until 2026-11-15, when `zeron headless` linked the engine. Since 0.3.0 the +/// release's `zeron` is the zgx app, whose `zeron headless` runs the +/// `zeron-engine` beside it: a machine without it never came online.) +pub const CLOUD_UNUSED_FILES: &[&str] = &[]; /// Remove [`CLOUD_UNUSED_FILES`] from the version folder `dir`. pub fn strip_cloud_unused(dir: &Path) { @@ -3692,9 +3693,11 @@ mod tests { assert_eq!(folders(&app_root), ["0.2.10", "0.2.11", "0.2.12", "current"]); } + /// `zeron headless` runs the `zeron-engine` beside it: a Cloud machine + /// keeps it in every version (it once left it out, and never came online). #[cfg(unix)] #[test] - fn a_cloud_machine_keeps_no_desktop_engine() { + fn a_cloud_machine_keeps_the_engine_its_headless_runs() { let tmp = tempfile::tempdir().unwrap(); let app_root = tmp.path().join("app"); versions_installed(&app_root, &["0.2.10", "0.2.11"]); @@ -3708,7 +3711,7 @@ mod tests { strip_unused_from_versions(&app_root); for ver in ["0.2.10", "0.2.11"] { - assert!(!app_root.join(ver).join("zeron-engine").exists(), "{ver}"); + assert!(app_root.join(ver).join("zeron-engine").exists(), "{ver}"); assert!(app_root.join(ver).join("zeron").exists(), "{ver}"); } assert!(app_root.join("notes").join("zeron-engine").exists()); @@ -4169,11 +4172,11 @@ mod tests { assert!(staged.join("zeron").is_file()); } - /// The release carries the desktop's background engine; a Cloud machine - /// stages the release without it, anywhere else keeps it. + /// The release carries `zeron-engine`, which `zeron headless` runs: a + /// Cloud machine stages it as anywhere else does. #[cfg(unix)] #[tokio::test] - async fn a_cloud_machine_stages_a_release_without_the_desktop_engine() { + async fn a_cloud_machine_stages_a_release_with_its_engine() { let tmp = tempfile::tempdir().unwrap(); let pkg = tmp.path().join("pkg"); std::fs::create_dir_all(pkg.join("zeron-pkg")).unwrap(); @@ -4190,7 +4193,7 @@ mod tests { .into(), ..Manifest::default() }; - for (cloud, kept) in [(true, false), (false, true)] { + for (cloud, kept) in [(true, true), (false, true)] { let app_root = tmp.path().join(format!("app-{cloud}")); std::fs::create_dir_all(&app_root).unwrap(); let (base, server) = serve_forever(bytes.clone()).await; diff --git a/crates/update/tests/update_transaction.rs b/crates/update/tests/update_transaction.rs index 3a50d6bb3..882ab5210 100644 --- a/crates/update/tests/update_transaction.rs +++ b/crates/update/tests/update_transaction.rs @@ -489,7 +489,7 @@ mod versioned { let mut rig = Rig::new("ok"); rig.platform = platform; rig.install_old(&["0.8.0", "0.9.0"]); - // The desktop's background engine, as the release ships it. + // The engine `zeron headless` runs, as the release ships it. for version in ["1.0.0", "2.0.0"] { std::fs::write(rig.app.join(version).join("zeron-engine"), "desktop").unwrap(); } @@ -497,12 +497,9 @@ mod versioned { rig.run_until_settled(); rig.assert_updated(&id); rig.app_settles_to(expected); - // A Cloud machine never runs it, and copies it back in on every wake. - assert_eq!( - rig.app.join("2.0.0/zeron-engine").exists(), - platform.is_none(), - "platform {platform:?}" - ); + // Kept everywhere, Cloud too: `zeron headless` runs it (a Cloud + // machine once left it out, and never came online). + assert!(rig.app.join("2.0.0/zeron-engine").exists(), "platform {platform:?}"); } } diff --git a/docs/design/cloud-device.md b/docs/design/cloud-device.md index df22d29af..994867f73 100644 --- a/docs/design/cloud-device.md +++ b/docs/design/cloud-device.md @@ -431,12 +431,12 @@ machine (`ZERON_DEVICE_PLATFORM=cloud`) keeps none of them: going back there is downloads anyway. Other Linux installs keep the newest older one, to go back to by hand. Never `current`, the running executable's folder, or a newer version (an update being staged). -A Cloud machine doesn't keep the release's `zeron-engine` either: it's the desktop app's background -engine (78 MB), and the unit runs `zeron headless`, which links the engine. The installer and the -updater leave it out, and the tidy and the pre-sleep cleanup remove it from versions installed before. -Measured on staging (send to first output, n=8 each), a machine on one version went from a median of -17.5 s to 14.2 s once neither it nor Codex's downloads came back with each wake; its wake downloaded -225 MB, 205 of them the engine it runs. +A Cloud machine keeps the release's `zeron-engine` (78 MB). From 2026-11-07 to 2026-11-15 the +installer, the updater and the tidy left it out, when the unit's `zeron headless` linked the engine; +since 0.3.0 the release's `zeron` is the zgx app, whose `zeron headless` runs that `zeron-engine`, so +a machine without it exited at once and never enrolled. The installer keeps it now, and a repair +(`~/.zeron/repair-engine`, the unit's `ExecStartPre=-`, set up by the installer and every wake) puts +it back before each start if an older updater left it out (edge/src/cloud/install-script.ts). A longer wake reads as updating: the engine says so (`POST /runner/wake-stage`), `CloudSession.stage` is `updating` while it lasts (a stage nobody clears stops showing after 10 minutes), the desktop's From 739ab4187f91f8551610102d6daa7632fca0167f Mon Sep 17 00:00:00 2001 From: Wing <44917547+wingleeio@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:13:25 -0700 Subject: [PATCH 07/10] Providers: Cloud is a choice again, its accounts and API keys managed there MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Zeron 0.3's Settings → Providers listed only computers, so Cloud's providers (the vault's logins and keys every Cloud machine uses) couldn't be managed at all. As 0.2 did, Cloud is one more choice after the computers while Cloud is on (`agents.target("cloud")`, which the engine answers from the vault: crates/engine cloud_accounts). - Its cards: Claude Code and Codex, their accounts (sign in, switch, remove), with no switch, settings or Update (`ProviderCard.fixed`), and nothing to install or add. - Its API keys: Anthropic's and OpenAI's, saved to the vault for the account's Cloud device (`agents.cloud_key` → VaultPutApiKey), the key every Cloud machine uses from its next turn. - devices.picker takes extra choices; the page's body is Cloud's own. Tests: ui/tests/providers_cloud.test.luau (Cloud offered while on, its cards and keys, back to this computer; none without Cloud); agents' `a_cloud_key_is_one_cloud_runs_for_its_device`. Full UI suite (1424) and agents:: (12) pass. Co-Authored-By: Claude Opus 5.5 --- apps/zgx/src/agents.rs | 48 +++++++ apps/zgx/ui/ds/provider_card.luau | 7 +- apps/zgx/ui/locales/en.json | 13 +- apps/zgx/ui/locales/zh-Hans.json | 13 +- apps/zgx/ui/screens/settings/devices.luau | 12 +- apps/zgx/ui/screens/settings/providers.luau | 132 ++++++++++++++++++-- apps/zgx/ui/settings_stub.luau | 15 +++ apps/zgx/ui/tests/providers_cloud.test.luau | 77 ++++++++++++ 8 files changed, 304 insertions(+), 13 deletions(-) create mode 100644 apps/zgx/ui/tests/providers_cloud.test.luau diff --git a/apps/zgx/src/agents.rs b/apps/zgx/src/agents.rs index af62053ae..00506865c 100644 --- a/apps/zgx/src/agents.rs +++ b/apps/zgx/src/agents.rs @@ -411,6 +411,24 @@ 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(); @@ -1948,6 +1966,20 @@ 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] @@ -2228,6 +2260,22 @@ 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/ui/ds/provider_card.luau b/apps/zgx/ui/ds/provider_card.luau index 6e3cb0f3c..959c15355 100644 --- a/apps/zgx/ui/ds/provider_card.luau +++ b/apps/zgx/ui/ds/provider_card.luau @@ -221,6 +221,9 @@ export type CardProps = { -- back, Claude's when it can't finish in the browser) or "failed". foot: (string | () -> string)?, enabled: State, + -- An agent nothing here switches or updates (Cloud's: on every Cloud + -- machine, its accounts alone managed here): no switch, no Update. + fixed: boolean?, -- The account in use, by its email. active: () -> string?, settings: boolean?, @@ -1468,7 +1471,7 @@ function M.Card(c: CardProps): Node gap = "$space.3", items = "center", ui.show(function() - return latest() ~= nil or (c.updating ~= nil and c.updating()) + return not c.fixed and (latest() ~= nil or (c.updating ~= nil and c.updating())) end, Button { locale.t("ds.provider_card.update"), tone = "secondary", @@ -1488,7 +1491,7 @@ function M.Card(c: CardProps): Node on_click = c.on_settings, } else nil, - Switch { value = c.enabled, label = locale.t("ds.provider_card.enabled", { name = provider.name }) :: any }, + if c.fixed then nil else Switch { value = c.enabled, label = locale.t("ds.provider_card.enabled", { name = provider.name }) :: any }, }, } -- Its accounts, a row each, keyed: one arriving or going is that row diff --git a/apps/zgx/ui/locales/en.json b/apps/zgx/ui/locales/en.json index 960b2be33..bd46a6a85 100644 --- a/apps/zgx/ui/locales/en.json +++ b/apps/zgx/ui/locales/en.json @@ -1631,7 +1631,18 @@ }, "remove_row_description": "Chats that used it stay." }, - "couldnt_switch": "Couldn't switch accounts" + "couldnt_switch": "Couldn't switch accounts", + "cloud": "Cloud", + "cloud_keys": { + "title": "API keys", + "section_description": "Instead of signing in, Cloud can use an API key. A key saved here becomes the account its agent uses on every Cloud machine, from its next turn.", + "anthropic": "Anthropic API key", + "openai": "OpenAI API key", + "description": "For {agent} on Cloud. Kept in Zeron's vault, never on this computer.", + "placeholder": "Paste a key", + "save": "Save", + "saved": "{agent} on Cloud now uses this key" + } }, "devices": { "title": "Devices", diff --git a/apps/zgx/ui/locales/zh-Hans.json b/apps/zgx/ui/locales/zh-Hans.json index 1a6a00cc0..27d1fe97e 100644 --- a/apps/zgx/ui/locales/zh-Hans.json +++ b/apps/zgx/ui/locales/zh-Hans.json @@ -1631,7 +1631,18 @@ }, "remove_row_description": "使用过它的对话会保留。" }, - "couldnt_switch": "无法切换账户" + "couldnt_switch": "无法切换账户", + "cloud": "云端", + "cloud_keys": { + "title": "API 密钥", + "section_description": "云端也可以使用 API 密钥,而不必登录。在此保存的密钥会成为该代理在每台云端机器上使用的账户,从下一轮开始生效。", + "anthropic": "Anthropic API 密钥", + "openai": "OpenAI API 密钥", + "description": "用于云端的 {agent}。保存在 Zeron 的密钥库中,不会存放在这台电脑上。", + "placeholder": "粘贴密钥", + "save": "保存", + "saved": "云端的 {agent} 现在使用此密钥" + } }, "devices": { "title": "设备", diff --git a/apps/zgx/ui/screens/settings/devices.luau b/apps/zgx/ui/screens/settings/devices.luau index 9a88ef06c..06637b28c 100644 --- a/apps/zgx/ui/screens/settings/devices.luau +++ b/apps/zgx/ui/screens/settings/devices.luau @@ -169,7 +169,9 @@ local icon_of = M.icon -- choosing one calls `choose` with its id. Built once: its options follow -- the devices as they come, go and are renamed, and the choice follows -- `shown`. -function M.picker(shown: () -> string?, choose: (id: string) -> ()): Node +-- (`extra`: more choices after the computers, each `{ value, label, icon }`: +-- Providers' Cloud, whose accounts every Cloud machine uses.) +function M.picker(shown: () -> string?, choose: (id: string) -> (), extra: (() -> { any })?): Node local function computers(): { sessions.Device } return sessions.computers(sessions.devices:get(), true) end @@ -181,9 +183,12 @@ function M.picker(shown: () -> string?, choose: (id: string) -> ()): Node end return "" end + local function extras(): { any } + return if extra then extra() else {} + end return ui.show( function(): boolean - return #computers() > 1 + return #computers() > 1 or #extras() > 0 end, ui.component(function(): Node local chosen = ui.use_state(shown() or here()) @@ -208,6 +213,9 @@ function M.picker(shown: () -> string?, choose: (id: string) -> ()): Node description = if not d.here and d.online == false then ui.t("settings.devices.offline") else nil, }) end + for _, e in extras() do + table.insert(options, e) + end return options end, on_change = choose, diff --git a/apps/zgx/ui/screens/settings/providers.luau b/apps/zgx/ui/screens/settings/providers.luau index 2876379aa..d1e13d9a3 100644 --- a/apps/zgx/ui/screens/settings/providers.luau +++ b/apps/zgx/ui/screens/settings/providers.luau @@ -23,6 +23,7 @@ local prefs = require("@app/screens/settings/prefs") local registry = require("@account/registry") local add_agent = require("@app/screens/settings/add_agent") local sign_in_terminal = require("@app/screens/settings/sign_in_terminal") +local cloud = require("@account/cloud") local M = {} @@ -108,6 +109,20 @@ local function here(): string? end return nil end +-- Cloud, as one choice after the computers (never its machines): the +-- accounts every Cloud machine uses, kept by the vault, which the engine +-- answers for (crates/engine cloud_accounts: Claude Code and Codex, their +-- logins and API keys). Offered while Cloud is on. +local CLOUD = "cloud" +local function on_cloud(): boolean + return now().target == CLOUD +end +local function cloud_choice(): { any } + if cloud.on() or on_cloud() then + return { { value = CLOUD, label = ui.t("settings.providers.cloud"):get(), icon = "cloud" } } + end + return {} +end -- The device shown: the engine's target, else this one. local function shown_device(): string? return now().target or here() @@ -115,6 +130,9 @@ end -- (In the locale shown: read where it's drawn.) local function device_name(): string local id = shown_device() + if id == CLOUD then + return ui.t("settings.providers.cloud"):get() + end for _, d in computers() do if d.id == id then return if d.here then ui.t("settings.providers.this_mac"):get() else d.name @@ -124,8 +142,11 @@ local function device_name(): string end local function choose_device(id: string) agents.target(if id == here() then nil else id) - -- (The registry as that device sees it: what it has added, its builds.) - registry.load() + -- (The registry as that device sees it: what it has added, its builds. + -- Cloud runs only Zeron's own.) + if id ~= CLOUD then + registry.load() + end end -- Which of the page's views shows: the agents, the registry ("add"), or @@ -152,7 +173,8 @@ local function kind(): string if s == "looking" or s == "unavailable" then return s end - return "found" + -- (Cloud's page is another: its accounts, its keys, nothing to add.) + return if now().target == "cloud" then "cloud" else "found" end -- Which agent's settings are open (none: ""). @@ -223,6 +245,9 @@ local function card(row: State): Node -- no accounts, and signs in its own way. (Its updates come as any -- agent's: the engine's update coordinator, the registry its feed.) local from_registry = (first :: any).registry == true + -- Cloud's (made for it: the cards are keyed by the device shown): on + -- every Cloud machine, its accounts alone managed here. + local cloud_card = on_cloud() -- The switch follows the engine; a flip goes to it, and its answer -- comes back in the row. local on = ui.use_state(first.enabled) @@ -234,7 +259,7 @@ local function card(row: State): Node if flipped ~= said then on:set(said) end - elseif flipped ~= said then + elseif flipped ~= said and not cloud_card then agents.set_enabled(id, flipped) end end) @@ -250,6 +275,7 @@ local function card(row: State): Node return (row:get() :: any).updating == true end, sign_in_only = from_registry, + fixed = cloud_card, login_note = function(): string? return (row:get() :: any).login_note end, @@ -329,7 +355,7 @@ local function card(row: State): Node end return nil end, - settings = true, + settings = not cloud_card, on_settings = function() load_subagents() open_settings:set(id) @@ -421,7 +447,13 @@ local function cards(): Node gap = "$space.4", ui.each(ui.computed(installed), function(_a: agents.Agent, _i: number, row: State): Node return card(row) - end, { key = by_id }), + end, { + -- (By the device shown too: a card is made for its device, + -- Cloud's unlike a computer's.) + key = function(a: agents.Agent): string + return `{now().target or ""}|{a.id}` + end, + }), } ) end @@ -490,6 +522,85 @@ local function more(): Node ) end +-- Cloud's API keys: Anthropic's for Claude Code, OpenAI's for Codex, kept +-- by the vault. A key saved becomes its agent's account in use, every Cloud +-- machine's from its next turn (as signing in does). +local CLOUD_KEYS = { + { provider = "anthropic-key", agent = "Claude Code", label = "settings.providers.cloud_keys.anthropic" }, + { provider = "openai-key", agent = "Codex", label = "settings.providers.cloud_keys.openai" }, +} +local function cloud_key_row(k: { provider: string, agent: string, label: string }): Node + return ui.component(function(): Node + local value = ui.use_state("") + local busy = ui.use_state(false) + local problem = ui.use_state("") + local function save() + local key = value:peek() + if busy:peek() or key == "" then + return + end + busy:set(true) + problem:set("") + host.call("agents.cloud_key", { provider = k.provider, key = key, device = cloud.device() or "" }):after(function() + busy:set(false) + value:set("") + toast.show { title = ui.t("settings.providers.cloud_keys.saved", { agent = k.agent }):get(), tone = "success" } + end, function(err: any) + busy:set(false) + problem:set(if type(err) == "table" and err.message then tostring(err.message) else tostring(err)) + end) + end + return ds.Settings.Row { + label = ui.t(k.label), + description = function(): string + local p = problem:get() + return if p ~= "" then p else ui.t("settings.providers.cloud_keys.description", { agent = k.agent }):get() + end, + control = ui.row { + gap = "$space.2", + items = "center", + ds.TextField { + value = value, + password = true, + w = 220, + size = "sm", + name = ui.t(k.label), + placeholder = ui.t("settings.providers.cloud_keys.placeholder"), + on_commit = function() + save() + end, + }, + ds.Button { + ui.t("settings.providers.cloud_keys.save"), + tone = "secondary", + size = "sm", + busy = function(): boolean + return busy:get() + end, + disabled = function(): boolean + return value:get() == "" + end, + on_click = save, + }, + }, + } + end)({}) +end +local function cloud_keys(): Node + return ds.Settings.Section { + title = ui.t("settings.providers.cloud_keys.title"), + description = ui.t("settings.providers.cloud_keys.section_description"), + ds.Settings.Group { + ui.column { + w_full = true, + cloud_key_row(CLOUD_KEYS[1]), + ds.Settings.Rule(), + cloud_key_row(CLOUD_KEYS[2]), + }, + }, + } +end + local function body(k: string): Node if k == "looking" then return ds.ProviderCard.Loading() @@ -498,6 +609,9 @@ local function body(k: string): Node return device_name() end, agents.load) end + if k == "cloud" then + return ui.column { w_full = true, gap = "$space.6", cards(), cloud_keys() } + end return ui.column { w_full = true, gap = "$space.6", cards(), more() } end @@ -767,7 +881,7 @@ local function agents_page(): Node -- Agents are per device: which one's (a choice once there's more -- than this one). -- (The same choice as Plugins': screens/settings/devices.) - trail = devices_page.picker(shown_device, choose_device), + trail = devices_page.picker(shown_device, choose_device, cloud_choice), -- (At the top right, on the title's line, as Plugins' is.) trail_top = true, ui.presence(kind, body, { w_full = true, enter = { opacity = { 0, 1 }, duration = 120 }, exit = { opacity = 0, duration = 60 }, mode = "wait" }), @@ -792,6 +906,10 @@ function M.view(): Node -- (Once a visit: a hot reload doesn't ask again.) The page opens on the -- agents; the registry is looked at too, for what it has to add. visits.once("providers", function() + -- (Whether Cloud is on, for its choice.) + if cloud.now:peek().phase == "unknown" then + cloud.load() + end agents.load() registry.load() if view:peek() ~= "agents" then diff --git a/apps/zgx/ui/settings_stub.luau b/apps/zgx/ui/settings_stub.luau index e68bd3ff8..3d0e4b6e7 100644 --- a/apps/zgx/ui/settings_stub.luau +++ b/apps/zgx/ui/settings_stub.luau @@ -432,6 +432,21 @@ end -- a switch of device shows whose. local agents = require("@account/agents") local function agents_of(target: string?): any + -- Cloud (the engine answers for it from the vault): Claude Code and + -- Codex, always installed; Codex with an account, so on. + if target == "cloud" then + local function one(id: string, name: string, mark: string, accounts: { any }): any + return { id = id, name = name, mark = mark, installed = true, can_install = false, enabled = #accounts > 0, version = nil, installing = false, login = "idle", accounts = accounts } + end + return { + state = "ready", + target = target, + list = { + one("claude-code", "Claude Code", "claude", {}), + one("codex", "Codex", "openai", { { id = "c1", email = "ada@example.com", plan = "Pro", session = 0.1, week = 0.2, active = true } }), + }, + } + end local name = if target then "Codex" else "Claude Code" local id = if target then "codex" else "claude-code" return { diff --git a/apps/zgx/ui/tests/providers_cloud.test.luau b/apps/zgx/ui/tests/providers_cloud.test.luau new file mode 100644 index 000000000..b6b696335 --- /dev/null +++ b/apps/zgx/ui/tests/providers_cloud.test.luau @@ -0,0 +1,77 @@ +-- Settings → Providers offers Cloud as one more choice after the computers, +-- while Cloud is on: its agents' accounts (the vault's, every Cloud machine +-- uses them), with no switch, no settings and nothing to install, and API +-- keys to save for it. Without Cloud, no such choice. On the shell in +-- ui/shell_fixture.luau, Cloud from ui/cloud_stub.luau. + +local PAGE = "#settings-page" +local NAV = "#settings-nav" + +local function shows(app: any, scope: string, text: string): boolean + return app:tree(scope):find(text, 1, true) ~= nil +end + +local function asked(app: any, entry: string): boolean + for _, c in (app:state("settings_stub_calls") :: any) or {} do + if c == entry then + return true + end + end + return false +end + +local function open(with_cloud: boolean): any + local app = mount("shell_fixture.luau") + app:resize(1200, 900) + app:frames(30) + app:command("settings_stub.sign_in") + if with_cloud then + app:command("cloud_stub.offer") + end + app:command("shell.settings") + app:frames(20) + app:click(`{NAV} >> role:tab "Providers"`) + app:frames(30) + return app +end + +test("with Cloud on, Providers offers Cloud: its agents' accounts, no switch or settings, and its API keys", function() + local app = open(true) + app:click(`{PAGE} >> role:button "Device"`) + app:frames(10) + expect(app:has('role:menuitem "Cloud"')).to_be(true) + app:click('role:menuitem "Cloud"') + app:frames(30) + expect(asked(app, "agents.target:cloud")).to_be(true) + expect(shows(app, PAGE, "Claude Code")).to_be(true) + expect(shows(app, PAGE, "Codex")).to_be(true) + expect(shows(app, PAGE, "ada@example.com")).to_be(true) + -- Nothing to switch, set or install: its accounts alone. + expect(app:has(`{PAGE} >> role:switch "Codex on"`)).to_be(false) + expect(app:has(`{PAGE} >> role:button "Codex settings"`)).to_be(false) + expect(shows(app, PAGE, "Add another agent")).to_be(false) + -- Its API keys, saved for Cloud. + expect(shows(app, PAGE, "Anthropic API key")).to_be(true) + expect(shows(app, PAGE, "OpenAI API key")).to_be(true) + app:type(`{PAGE} >> role:textbox "OpenAI API key"`, "sk-test-123") + app:frames(5) + app:click(`{PAGE} >> role:button "Save" [2]`) + app:frames(10) + expect(asked(app, "agents.cloud_key")).to_be(true) + expect(app:error()).to_be_nil() + -- Back to this computer: its agents as they were, with their switches. + app:click(`{PAGE} >> role:button "Device"`) + app:frames(10) + app:click('role:menuitem "MacBook Pro"') + app:frames(30) + expect(asked(app, "agents.target:")).to_be(true) + expect(app:has(`{PAGE} >> role:switch "Claude Code on"`)).to_be(true) + expect(shows(app, PAGE, "Anthropic API key")).to_be(false) +end) + +test("without Cloud, Providers offers no Cloud", function() + local app = open(false) + app:click(`{PAGE} >> role:button "Device"`) + app:frames(10) + expect(app:has('role:menuitem "Cloud"')).to_be(false) +end) From e48dcbed1254f1ee97cbc4fcfc95de791c3a2122 Mon Sep 17 00:00:00 2001 From: Wing <44917547+wingleeio@users.noreply.github.com> Date: Sat, 14 Nov 2026 21:13:50 -0700 Subject: [PATCH 08/10] Zeron 0.3.6: Cloud's providers managed again; Cloud machines come online MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 0.3.5 plus: - Settings → Providers: Cloud is a choice again while it's on, its accounts (Claude Code, Codex) and API keys managed there (#1456). - Cloud: the updater and the pre-sleep tidy keep zeron-engine, which `zeron headless` runs (#1455; the edge's install and repair, #1454, are live). - Plugins: read the composer's draft and set it aside; compose can replace it or write another chat's (#1445, #1452, #1453). - Browser: a load error over a page that drew can be dismissed (#1431). - The "Task completed" chime and banner come on a finished turn, not your own send; a banner's click opens its chat. Version 0.3.6. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 68 ++++++++++++++++++++++----------------------- Cargo.toml | 2 +- apps/zgx/Cargo.lock | 24 ++++++++-------- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 99cd7cf2e..3e914104a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13347,7 +13347,7 @@ dependencies = [ [[package]] name = "zatex" -version = "0.3.5" +version = "0.3.6" dependencies = [ "tiny-skia", "ttf-parser", @@ -13598,7 +13598,7 @@ dependencies = [ [[package]] name = "zeron" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "clap", @@ -13623,7 +13623,7 @@ dependencies = [ [[package]] name = "zeron-audio" -version = "0.3.5" +version = "0.3.6" dependencies = [ "base64 0.22.1", "cpal 0.18.2", @@ -13635,7 +13635,7 @@ dependencies = [ [[package]] name = "zeron-cli" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "clap", @@ -13651,7 +13651,7 @@ dependencies = [ [[package]] name = "zeron-client" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "async-trait", @@ -13682,7 +13682,7 @@ dependencies = [ [[package]] name = "zeron-doc" -version = "0.3.5" +version = "0.3.6" dependencies = [ "chrono", "loro", @@ -13697,7 +13697,7 @@ dependencies = [ [[package]] name = "zeron-engine" -version = "0.3.5" +version = "0.3.6" dependencies = [ "alacritty_terminal", "anyhow", @@ -13757,7 +13757,7 @@ dependencies = [ [[package]] name = "zeron-harness" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "async-trait", @@ -13791,7 +13791,7 @@ dependencies = [ [[package]] name = "zeron-launch" -version = "0.3.5" +version = "0.3.6" dependencies = [ "libc", "tempfile", @@ -13800,14 +13800,14 @@ dependencies = [ [[package]] name = "zeron-markdown" -version = "0.3.5" +version = "0.3.6" dependencies = [ "pulldown-cmark", ] [[package]] name = "zeron-mcp" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "async-trait", @@ -13829,7 +13829,7 @@ dependencies = [ [[package]] name = "zeron-mobile" -version = "0.3.5" +version = "0.3.6" dependencies = [ "async-trait", "serde", @@ -13856,14 +13856,14 @@ dependencies = [ [[package]] name = "zeron-mobile-bindgen" -version = "0.3.5" +version = "0.3.6" dependencies = [ "uniffi", ] [[package]] name = "zeron-notify" -version = "0.3.5" +version = "0.3.6" dependencies = [ "objc", "sha2", @@ -13872,11 +13872,11 @@ dependencies = [ [[package]] name = "zeron-orb" -version = "0.3.5" +version = "0.3.6" [[package]] name = "zeron-plugin-guard" -version = "0.3.5" +version = "0.3.6" dependencies = [ "serde_json", "tempfile", @@ -13884,7 +13884,7 @@ dependencies = [ [[package]] name = "zeron-preview" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "async-trait", @@ -13914,11 +13914,11 @@ dependencies = [ [[package]] name = "zeron-preview-label" -version = "0.3.5" +version = "0.3.6" [[package]] name = "zeron-proto" -version = "0.3.5" +version = "0.3.6" dependencies = [ "chrono", "pulldown-cmark", @@ -13929,7 +13929,7 @@ dependencies = [ [[package]] name = "zeron-rpc" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "async-trait", @@ -13950,7 +13950,7 @@ dependencies = [ [[package]] name = "zeron-sync" -version = "0.3.5" +version = "0.3.6" dependencies = [ "base64 0.22.1", "block2 0.6.2", @@ -13976,7 +13976,7 @@ dependencies = [ [[package]] name = "zeron-syntax" -version = "0.3.5" +version = "0.3.6" dependencies = [ "thiserror 2.0.20", "tree-sitter", @@ -14011,14 +14011,14 @@ dependencies = [ [[package]] name = "zeron-term" -version = "0.3.5" +version = "0.3.6" dependencies = [ "alacritty_terminal", ] [[package]] name = "zeron-term-link" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "async-trait", @@ -14035,7 +14035,7 @@ dependencies = [ [[package]] name = "zeron-text" -version = "0.3.5" +version = "0.3.6" dependencies = [ "core-foundation 0.10.1", "core-graphics 0.24.0", @@ -14052,7 +14052,7 @@ dependencies = [ [[package]] name = "zeron-theme" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "clap", @@ -14067,7 +14067,7 @@ dependencies = [ [[package]] name = "zeron-ui" -version = "0.3.5" +version = "0.3.6" dependencies = [ "alacritty_terminal", "anyhow", @@ -14150,7 +14150,7 @@ dependencies = [ [[package]] name = "zeron-update" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "futures", @@ -14167,11 +14167,11 @@ dependencies = [ [[package]] name = "zeron-veil" -version = "0.3.5" +version = "0.3.6" [[package]] name = "zeron-visual" -version = "0.3.5" +version = "0.3.6" dependencies = [ "base64 0.22.1", "gltf", @@ -14183,7 +14183,7 @@ dependencies = [ [[package]] name = "zeron-visual-gpu" -version = "0.3.5" +version = "0.3.6" dependencies = [ "image", "pollster 0.4.0", @@ -14194,7 +14194,7 @@ dependencies = [ [[package]] name = "zeron-voice" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "cpal 0.17.3", @@ -14213,7 +14213,7 @@ dependencies = [ [[package]] name = "zeron-voice-media" -version = "0.3.5" +version = "0.3.6" dependencies = [ "async-trait", "semver", @@ -14228,7 +14228,7 @@ dependencies = [ [[package]] name = "zeron-voice-session" -version = "0.3.5" +version = "0.3.6" dependencies = [ "async-trait", "futures", diff --git a/Cargo.toml b/Cargo.toml index 2b3cdd9bb..82952d84d 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ members = [ ] [workspace.package] -version = "0.3.5" +version = "0.3.6" edition = "2024" license = "MIT" publish = false diff --git a/apps/zgx/Cargo.lock b/apps/zgx/Cargo.lock index 437ed1ee8..482ff60eb 100644 --- a/apps/zgx/Cargo.lock +++ b/apps/zgx/Cargo.lock @@ -7067,7 +7067,7 @@ dependencies = [ [[package]] name = "zatex" -version = "0.3.5" +version = "0.3.6" dependencies = [ "ttf-parser", ] @@ -7233,7 +7233,7 @@ checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" [[package]] name = "zeron-cli" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "clap", @@ -7248,7 +7248,7 @@ dependencies = [ [[package]] name = "zeron-launch" -version = "0.3.5" +version = "0.3.6" dependencies = [ "libc", "windows-sys 0.61.2", @@ -7256,7 +7256,7 @@ dependencies = [ [[package]] name = "zeron-notify" -version = "0.3.5" +version = "0.3.6" dependencies = [ "objc", "sha2", @@ -7265,18 +7265,18 @@ dependencies = [ [[package]] name = "zeron-plugin-guard" -version = "0.3.5" +version = "0.3.6" dependencies = [ "serde_json", ] [[package]] name = "zeron-preview-label" -version = "0.3.5" +version = "0.3.6" [[package]] name = "zeron-proto" -version = "0.3.5" +version = "0.3.6" dependencies = [ "chrono", "pulldown-cmark 0.12.2", @@ -7287,7 +7287,7 @@ dependencies = [ [[package]] name = "zeron-theme" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "clap", @@ -7301,7 +7301,7 @@ dependencies = [ [[package]] name = "zeron-update" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "futures", @@ -7318,7 +7318,7 @@ dependencies = [ [[package]] name = "zeron-visual" -version = "0.3.5" +version = "0.3.6" dependencies = [ "base64 0.22.1", "gltf", @@ -7330,7 +7330,7 @@ dependencies = [ [[package]] name = "zeron-visual-gpu" -version = "0.3.5" +version = "0.3.6" dependencies = [ "pollster", "tracing", @@ -7340,7 +7340,7 @@ dependencies = [ [[package]] name = "zeron-voice" -version = "0.3.5" +version = "0.3.6" dependencies = [ "anyhow", "cpal", From 19b04d04d5f7015a847d393e664316618290595b Mon Sep 17 00:00:00 2001 From: Wing <44917547+wingleeio@users.noreply.github.com> Date: Sun, 15 Nov 2026 15:54:23 -0700 Subject: [PATCH 09/10] Composer: a Cloud chat's model menu offers Cloud's accounts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A chat on a Cloud machine had no Account row in its model menu: its accounts were asked of the machine (`cloud-…`), which the engine doesn't answer for, and whose accounts aren't its own anyway. Cloud's are the vault's, every Cloud machine's alike, which this engine answers for under "cloud" (crates/engine cloud_accounts), as Settings → Providers shows them under Cloud (#1456). Any Cloud device (a chat's machine, the account's Cloud device) now reads, switches and refreshes those; a machine is never asked (it would be woken). Test: model_accounts' "a chat on a Cloud machine reads and switches Cloud's accounts" (fails without this: the machine was asked). Full UI suite (1425) passes. Co-Authored-By: Claude Opus 5.5 --- apps/zgx/ui/screens/chat/shared.luau | 15 ++++++++++-- apps/zgx/ui/tests/model_accounts.test.luau | 27 ++++++++++++++++++++++ 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/apps/zgx/ui/screens/chat/shared.luau b/apps/zgx/ui/screens/chat/shared.luau index f16052d41..53a6dba09 100644 --- a/apps/zgx/ui/screens/chat/shared.luau +++ b/apps/zgx/ui/screens/chat/shared.luau @@ -13,6 +13,7 @@ local Quote = require("@ds/quote") local Annotation = require("@ds/annotation") local sessions = require("@account/sessions") local agents = require("@account/agents") +local cloud = require("@account/cloud") local locale = require("@ds/locale") local toast = require("@ds/toast") local ChatLinks = require("@app/screens/chat/chat_links") @@ -1031,9 +1032,19 @@ local here_device = ui.computed(function(): string? end) -- The accounts' key for a device: "" for this one, whose engine answers --- for itself. +-- for itself; "cloud" for any of Cloud's (a chat's machine, or the +-- account's Cloud device), whose accounts are the vault's, every Cloud +-- machine's alike, as Settings → Providers shows them (this engine answers +-- for "cloud": crates/engine cloud_accounts). A machine can't be asked: +-- its accounts aren't its own, and asking would wake it. local function account_key(device: string?): string - return if device == nil or device == here_device:get() then "" else device + if device == nil or device == here_device:get() then + return "" + end + if cloud.on_device(device) or device == cloud.device() then + return "cloud" + end + return device end -- Models of Cursor's own pool (Composer, Grok), not the third-party one. diff --git a/apps/zgx/ui/tests/model_accounts.test.luau b/apps/zgx/ui/tests/model_accounts.test.luau index 3ea1abea1..a79be2447 100644 --- a/apps/zgx/ui/tests/model_accounts.test.luau +++ b/apps/zgx/ui/tests/model_accounts.test.luau @@ -91,6 +91,33 @@ test("a chat on another computer reads that computer's accounts", function() expect(app:state("calls")).to_contain("switch_on:box:claude-code:b2") end) +-- A chat on a Cloud machine: its accounts are Cloud's, the vault's (as +-- Settings → Providers shows them under Cloud), never the machine's own, +-- which isn't asked (it would be woken). +test("a chat on a Cloud machine reads and switches Cloud's accounts", function() + local app = with_accounts({ + [""] = { ["claude-code"] = accounts() }, + cloud = { + ["claude-code"] = { + { id = "v1", email = "team@example.test", plan = "Max", active = true, can_switch = true, windows = { window("Week", 0.4) } }, + { id = "v2", email = "spare@example.test", plan = "Pro", active = false, can_switch = true, windows = {} }, + }, + }, + }) + app:set_state("chat_device", "cloud-f60cde46") + app:frames(10) + expect(app:state("calls")).to_contain("watch_device:cloud") + expect(string.find(app:state("calls"), "watch_device:cloud-f60cde46", 1, true)).to_be(nil) + app:click('role:button "Model"') + app:frames(30) + expect(app:tree("#model-picker-account")).to_contain("team@example.test") + app:click("#model-picker-account") + app:frames(30) + app:click('~"spare@example.test"') + app:frames(30) + expect(app:state("calls")).to_contain("switch_on:cloud:claude-code:v2") +end) + test("a computer whose accounts haven't come has neither, and is asked", function() local app = with_accounts(here(accounts())) app:set_state("chat_device", "somewhere-else") From 55a5c392199ca0f7907c485b57b6a4252cc42e98 Mon Sep 17 00:00:00 2001 From: Wing <44917547+wingleeio@users.noreply.github.com> Date: Sun, 15 Nov 2026 16:41:46 -0700 Subject: [PATCH 10/10] Zeron 0.3.7: Cloud chats switch accounts; a scroll away stays away 0.3.6 plus: - A Cloud chat's model menu offers Cloud's accounts again, to switch the provider account every Cloud machine uses (#1467). - The transcript no longer pulls you back to the end after you scroll away: not during a send's glide, nor at a resize after a scroll (#1450). Version 0.3.7. Co-Authored-By: Claude Opus 5.5 --- Cargo.lock | 68 ++++++++++++++++++++++----------------------- Cargo.toml | 2 +- apps/zgx/Cargo.lock | 24 ++++++++-------- 3 files changed, 47 insertions(+), 47 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3e914104a..4d3ae0f14 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -13347,7 +13347,7 @@ dependencies = [ [[package]] name = "zatex" -version = "0.3.6" +version = "0.3.7" dependencies = [ "tiny-skia", "ttf-parser", @@ -13598,7 +13598,7 @@ dependencies = [ [[package]] name = "zeron" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "clap", @@ -13623,7 +13623,7 @@ dependencies = [ [[package]] name = "zeron-audio" -version = "0.3.6" +version = "0.3.7" dependencies = [ "base64 0.22.1", "cpal 0.18.2", @@ -13635,7 +13635,7 @@ dependencies = [ [[package]] name = "zeron-cli" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "clap", @@ -13651,7 +13651,7 @@ dependencies = [ [[package]] name = "zeron-client" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "async-trait", @@ -13682,7 +13682,7 @@ dependencies = [ [[package]] name = "zeron-doc" -version = "0.3.6" +version = "0.3.7" dependencies = [ "chrono", "loro", @@ -13697,7 +13697,7 @@ dependencies = [ [[package]] name = "zeron-engine" -version = "0.3.6" +version = "0.3.7" dependencies = [ "alacritty_terminal", "anyhow", @@ -13757,7 +13757,7 @@ dependencies = [ [[package]] name = "zeron-harness" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "async-trait", @@ -13791,7 +13791,7 @@ dependencies = [ [[package]] name = "zeron-launch" -version = "0.3.6" +version = "0.3.7" dependencies = [ "libc", "tempfile", @@ -13800,14 +13800,14 @@ dependencies = [ [[package]] name = "zeron-markdown" -version = "0.3.6" +version = "0.3.7" dependencies = [ "pulldown-cmark", ] [[package]] name = "zeron-mcp" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "async-trait", @@ -13829,7 +13829,7 @@ dependencies = [ [[package]] name = "zeron-mobile" -version = "0.3.6" +version = "0.3.7" dependencies = [ "async-trait", "serde", @@ -13856,14 +13856,14 @@ dependencies = [ [[package]] name = "zeron-mobile-bindgen" -version = "0.3.6" +version = "0.3.7" dependencies = [ "uniffi", ] [[package]] name = "zeron-notify" -version = "0.3.6" +version = "0.3.7" dependencies = [ "objc", "sha2", @@ -13872,11 +13872,11 @@ dependencies = [ [[package]] name = "zeron-orb" -version = "0.3.6" +version = "0.3.7" [[package]] name = "zeron-plugin-guard" -version = "0.3.6" +version = "0.3.7" dependencies = [ "serde_json", "tempfile", @@ -13884,7 +13884,7 @@ dependencies = [ [[package]] name = "zeron-preview" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "async-trait", @@ -13914,11 +13914,11 @@ dependencies = [ [[package]] name = "zeron-preview-label" -version = "0.3.6" +version = "0.3.7" [[package]] name = "zeron-proto" -version = "0.3.6" +version = "0.3.7" dependencies = [ "chrono", "pulldown-cmark", @@ -13929,7 +13929,7 @@ dependencies = [ [[package]] name = "zeron-rpc" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "async-trait", @@ -13950,7 +13950,7 @@ dependencies = [ [[package]] name = "zeron-sync" -version = "0.3.6" +version = "0.3.7" dependencies = [ "base64 0.22.1", "block2 0.6.2", @@ -13976,7 +13976,7 @@ dependencies = [ [[package]] name = "zeron-syntax" -version = "0.3.6" +version = "0.3.7" dependencies = [ "thiserror 2.0.20", "tree-sitter", @@ -14011,14 +14011,14 @@ dependencies = [ [[package]] name = "zeron-term" -version = "0.3.6" +version = "0.3.7" dependencies = [ "alacritty_terminal", ] [[package]] name = "zeron-term-link" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "async-trait", @@ -14035,7 +14035,7 @@ dependencies = [ [[package]] name = "zeron-text" -version = "0.3.6" +version = "0.3.7" dependencies = [ "core-foundation 0.10.1", "core-graphics 0.24.0", @@ -14052,7 +14052,7 @@ dependencies = [ [[package]] name = "zeron-theme" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "clap", @@ -14067,7 +14067,7 @@ dependencies = [ [[package]] name = "zeron-ui" -version = "0.3.6" +version = "0.3.7" dependencies = [ "alacritty_terminal", "anyhow", @@ -14150,7 +14150,7 @@ dependencies = [ [[package]] name = "zeron-update" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "futures", @@ -14167,11 +14167,11 @@ dependencies = [ [[package]] name = "zeron-veil" -version = "0.3.6" +version = "0.3.7" [[package]] name = "zeron-visual" -version = "0.3.6" +version = "0.3.7" dependencies = [ "base64 0.22.1", "gltf", @@ -14183,7 +14183,7 @@ dependencies = [ [[package]] name = "zeron-visual-gpu" -version = "0.3.6" +version = "0.3.7" dependencies = [ "image", "pollster 0.4.0", @@ -14194,7 +14194,7 @@ dependencies = [ [[package]] name = "zeron-voice" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "cpal 0.17.3", @@ -14213,7 +14213,7 @@ dependencies = [ [[package]] name = "zeron-voice-media" -version = "0.3.6" +version = "0.3.7" dependencies = [ "async-trait", "semver", @@ -14228,7 +14228,7 @@ dependencies = [ [[package]] name = "zeron-voice-session" -version = "0.3.6" +version = "0.3.7" dependencies = [ "async-trait", "futures", diff --git a/Cargo.toml b/Cargo.toml index 82952d84d..7865ac29a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -38,7 +38,7 @@ members = [ ] [workspace.package] -version = "0.3.6" +version = "0.3.7" edition = "2024" license = "MIT" publish = false diff --git a/apps/zgx/Cargo.lock b/apps/zgx/Cargo.lock index 482ff60eb..d096e16e9 100644 --- a/apps/zgx/Cargo.lock +++ b/apps/zgx/Cargo.lock @@ -7067,7 +7067,7 @@ dependencies = [ [[package]] name = "zatex" -version = "0.3.6" +version = "0.3.7" dependencies = [ "ttf-parser", ] @@ -7233,7 +7233,7 @@ checksum = "e13084392c5e4bc371903e2935a5eaeed24905a7511356b883835e18a78f6879" [[package]] name = "zeron-cli" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "clap", @@ -7248,7 +7248,7 @@ dependencies = [ [[package]] name = "zeron-launch" -version = "0.3.6" +version = "0.3.7" dependencies = [ "libc", "windows-sys 0.61.2", @@ -7256,7 +7256,7 @@ dependencies = [ [[package]] name = "zeron-notify" -version = "0.3.6" +version = "0.3.7" dependencies = [ "objc", "sha2", @@ -7265,18 +7265,18 @@ dependencies = [ [[package]] name = "zeron-plugin-guard" -version = "0.3.6" +version = "0.3.7" dependencies = [ "serde_json", ] [[package]] name = "zeron-preview-label" -version = "0.3.6" +version = "0.3.7" [[package]] name = "zeron-proto" -version = "0.3.6" +version = "0.3.7" dependencies = [ "chrono", "pulldown-cmark 0.12.2", @@ -7287,7 +7287,7 @@ dependencies = [ [[package]] name = "zeron-theme" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "clap", @@ -7301,7 +7301,7 @@ dependencies = [ [[package]] name = "zeron-update" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "futures", @@ -7318,7 +7318,7 @@ dependencies = [ [[package]] name = "zeron-visual" -version = "0.3.6" +version = "0.3.7" dependencies = [ "base64 0.22.1", "gltf", @@ -7330,7 +7330,7 @@ dependencies = [ [[package]] name = "zeron-visual-gpu" -version = "0.3.6" +version = "0.3.7" dependencies = [ "pollster", "tracing", @@ -7340,7 +7340,7 @@ dependencies = [ [[package]] name = "zeron-voice" -version = "0.3.6" +version = "0.3.7" dependencies = [ "anyhow", "cpal",