xonecas.io
8447
Co

conveyor / commit f9bda85

Ctrl+click a widget to follow up on it

The follow-up ticket carries what was clicked: the widget, its file,
the point inside it, the earlier prompt, and what that run decided or
left out. The widget keeps its spot and shows the ticket's state until
the rebuild lands. Install accepts a changed widget, not only a new one.

Co-Authored-By: Claude Opus 5.5

sacenox2026-11-09 f9bda853aacd057bb27de7cf529199950b86cee2 parent bf4eba8

7 files changed

DESIGN.md+1−0
@@ -194,6 +194,7 @@ Ctrl+click (x,y) ─▶ prompt ─▶ conveyord: widgets ticket #n (ready) + can
194194 ```
195195
196196 - Until the widget is built, the canvas shows a card with the ticket's state at the spot you clicked.
197+- Ctrl+click a widget, or a red card, to follow up on it. The new ticket names the widget and its file, where you clicked inside it, the prompt before, and every `decide`, `deviate` and `block` from that run. The widget keeps its spot and shows the new ticket's state until it's rebuilt.
197198 - Drag a widget to move it. The app sends the drop to conveyord (`move`), which writes `canvas.json`.
198199 - A prompt that asks for nothing, such as a keyboard mash, is a `block`: the card turns red and you rewrite it. An agent that guesses fills your library with stand-ins.
199200 - The app restarts with `exec` on the path it read at launch. After cargo replaces the binary, `current_exe()` names the deleted file, so it can't be read again later.
crates/conveyor-app/src/canvas.rs+37−16
@@ -8,7 +8,8 @@ pub struct State {
88 snap: Snapshot,
99 connected: bool,
1010 pointer: (f32, f32),
11- prompt_at: Option<(f32, f32)>,
11+ /// Where the prompt is open, and the widget ticket it follows up on, if a card was clicked.
12+ prompt_at: Option<(f32, f32, Option<u32>)>,
1213 prompt: TextEdit,
1314 inbox: Arc<Mutex<Option<Option<Snapshot>>>>,
1415 /// The binary at launch and its mtime. Read once: after cargo replaces it,
@@ -55,20 +56,28 @@ pub fn poll(s: &mut State, _t: f64, _tx: &mut Tx) -> bool {
5556 }
5657
5758 fn submit(s: &mut State, tx: &mut Tx) {
58- if let Some((x, y)) = s.prompt_at.take() {
59+ if let Some((x, y, about)) = s.prompt_at.take() {
5960 let prompt = s.prompt.text.clone();
6061 s.prompt = TextEdit::new("");
61- if !prompt.trim().is_empty() && client::widget(&prompt, x, y).is_none() {
62+ if !prompt.trim().is_empty() && client::widget(&prompt, x, y, about).is_none() {
6263 eprintln!("conveyord isn't running; the prompt was not sent");
6364 }
6465 }
6566 tx.blur();
6667 }
6768
69+fn open_prompt(s: &mut State, x: f32, y: f32, about: Option<u32>) {
70+ s.prompt_at = Some((x, y, about));
71+ s.prompt = TextEdit::new("");
72+ s.prompt.focused = true;
73+}
74+
6875 /// Moves a widget with the pointer, and tells conveyord where it landed.
69-fn drag(s: &mut State, id: u32, d: &Drag) {
76+/// Ctrl+press instead opens a prompt about the widget.
77+fn drag(s: &mut State, id: u32, d: &Drag, tx: &Tx) {
7078 let Some(p) = s.snap.canvas.iter_mut().find(|p| p.ticket == id) else { return };
7179 match (d.phase, s.drag) {
80+ (Phase::Down, _) if tx.mods().ctrl => { let (x, y) = (p.x + d.x, p.y + d.y); open_prompt(s, x, y, Some(id)) }
7281 (Phase::Down, _) => s.drag = Some((p.x, p.y)),
7382 (Phase::Move, Some((x, y))) => (p.x, p.y) = ((x + d.dx).max(0.0), (y + d.dy).max(0.0)),
7483 (Phase::Up, Some((x, y))) => {
@@ -84,9 +93,13 @@ fn card(key: String, w: f32, h: f32) -> El {
8493 col().key(key).w(w).h(h).radius(10.0).fill(t.card).padding(12.0).gap(6.0)
8594 }
8695
96+fn state_color(state: &str) -> rune::Color {
97+ if state == "failed" || state == "parked" { tok::accent(3, true) } else { tok::accent(0, true) }
98+}
99+
87100 fn pending(id: u32, title: &str, state: &str) -> El {
88101 let t = tok::theme(true);
89- let color = if state == "failed" || state == "parked" { tok::accent(3, true) } else { tok::accent(0, true) };
102+ let color = state_color(state);
90103 card(format!("pending-{id}"), 260.0, 90.0).label(format!("widget #{id} {state}"))
91104 .child(text(format!("#{id} · {state}")).font(tok::type_::LABEL).color(color))
92105 .child(text(title.to_owned()).font(tok::type_::BODY).color(t.text).wrap())
@@ -95,23 +108,35 @@ fn pending(id: u32, title: &str, state: &str) -> El {
95108 fn placed(s: &State, cx: &widgets::api::Cx) -> Vec<El> {
96109 s.snap.canvas.iter().map(|p| {
97110 let built = p.widget.as_deref().and_then(|w| widgets::ALL.iter().find(|(n, _)| *n == w));
111+ let t = s.snap.tickets.iter().find(|t| t.project == "widgets" && t.id == p.ticket);
98112 let el = match built {
99- Some((name, w)) => card(format!("w-{}", p.ticket), w.size.0, w.size.1).label(format!("widget {name}")).child((w.view)(cx)),
113+ Some((name, w)) => {
114+ let card = card(format!("w-{}", p.ticket), w.size.0, w.size.1).label(format!("widget {name}")).child((w.view)(cx));
115+ // A follow-up in flight: the widget stays, with its ticket's state on top.
116+ match t.filter(|t| t.state != "done") {
117+ Some(t) => card.child(text(format!("#{} · {}", t.id, t.state)).font(tok::type_::LABEL).color(state_color(&t.state))
118+ .padding(4.0).radius(6.0).fill(tok::theme(true).bg).absolute(8.0, 8.0)),
119+ None => card,
120+ }
121+ }
100122 None => {
101- let t = s.snap.tickets.iter().find(|t| t.project == "widgets" && t.id == p.ticket);
102123 let state = match (&p.widget, t) { (Some(_), _) => "installing", (_, Some(t)) => t.state.as_str(), _ => "?" };
103124 pending(p.ticket, t.map_or("", |t| t.title.as_str()), state)
104125 }
105126 };
106127 let id = p.ticket;
107- el.absolute(p.x, p.y).on_drag(move |s: &mut State, d: &mut Drag, _: &mut Tx| drag(s, id, d))
128+ el.absolute(p.x, p.y).on_drag(move |s: &mut State, d: &mut Drag, tx: &mut Tx| drag(s, id, d, tx))
108129 }).collect()
109130 }
110131
111-fn prompt_box(s: &State, x: f32, y: f32) -> El {
132+fn prompt_box(s: &State, x: f32, y: f32, about: Option<u32>) -> El {
112133 let t = tok::theme(true);
134+ let heading = match about.and_then(|a| s.snap.canvas.iter().find(|p| p.ticket == a)) {
135+ Some(p) => format!("Change {}", p.widget.clone().unwrap_or_else(|| format!("#{}", p.ticket))),
136+ None => "New widget".into(),
137+ };
113138 card("prompt".into(), 360.0, 120.0).absolute(x, y).focus_ring(2.0, 0.0, tok::accent(0, true))
114- .child(text("New widget").font(tok::type_::LABEL).color(t.text_secondary))
139+ .child(text(heading).font(tok::type_::LABEL).color(t.text_secondary))
115140 .child(text_input(&s.prompt, TextStyle::new(14.0, 400.0)).key("prompt-input").label("Widget prompt").w_full().grow(1.0)
116141 .padding(6.0).radius(6.0).fill(t.bg).color(t.text).placeholder("A clock with the date… Enter to build, Shift+Enter for a new line, Esc to cancel", t.text_secondary)
117142 .on_edit(|s: &mut State| &mut s.prompt)
@@ -134,17 +159,13 @@ pub fn view(s: &State, _: &mut rune::Cx<State>) -> El {
134159 let mut canvas = el().key("canvas").role("canvas").label("Canvas").w_full().grow(1.0).min_h(0.0).fill(t.bg)
135160 .on_pointer_move_local(|s: &mut State, e: rune::PointerEvent, tx: &mut Tx| { s.pointer = (e.x, e.y); tx.live_only(); })
136161 .on_press_tx(|s: &mut State, tx: &mut Tx| {
137- if tx.mods().ctrl {
138- s.prompt_at = Some(s.pointer);
139- s.prompt = TextEdit::new("");
140- s.prompt.focused = true;
141- }
162+ if tx.mods().ctrl { open_prompt(s, s.pointer.0, s.pointer.1, None) }
142163 });
143164 if s.snap.canvas.is_empty() && s.prompt_at.is_none() {
144165 canvas = canvas.child(col().w_full().h_full().center().child(text("Ctrl+click anywhere to make a widget").color(t.text_secondary)));
145166 }
146167 for e in placed(s, &cx) { canvas = canvas.child(e); }
147- if let Some((x, y)) = s.prompt_at { canvas = canvas.child(prompt_box(s, x, y)); }
168+ if let Some((x, y, about)) = s.prompt_at { canvas = canvas.child(prompt_box(s, x, y, about)); }
148169 let status = if s.connected { String::new() } else { "conveyord isn't running".into() };
149170 col().key("root").w_full().h_full().fill(t.bg).child(titlebar::bar(status)).child(canvas)
150171 }
crates/conveyor-app/src/client.rs+2−2
@@ -38,8 +38,8 @@ pub fn state() -> Option<Snapshot> {
3838 serde_json::from_value(call(json!({"op": "state"}))?).ok()
3939 }
4040
41-pub fn widget(prompt: &str, x: f32, y: f32) -> Option<u32> {
42- call(json!({"op": "widget", "prompt": prompt, "x": x, "y": y}))?["id"].as_u64().map(|id| id as u32)
41+pub fn widget(prompt: &str, x: f32, y: f32, about: Option<u32>) -> Option<u32> {
42+ call(json!({"op": "widget", "prompt": prompt, "x": x, "y": y, "about": about}))?["id"].as_u64().map(|id| id as u32)
4343 }
4444
4545 pub fn move_to(ticket: u32, x: f32, y: f32) {
crates/conveyor/src/canvas.rs+5−0
@@ -36,3 +36,8 @@ pub fn set_widget(ticket: u32, widget: &str) {
3636 pub fn move_to(ticket: u32, x: f32, y: f32) {
3737 update(|all| all.iter_mut().filter(|p| p.ticket == ticket).for_each(|p| (p.x, p.y) = (x, y)));
3838 }
39+
40+/// A follow-up ticket takes over the widget's spot from the ticket before it.
41+pub fn retarget(from: u32, to: u32) {
42+ update(|all| all.iter_mut().filter(|p| p.ticket == from).for_each(|p| p.ticket = to));
43+}
crates/conveyor/src/library.rs+32−6
@@ -23,18 +23,44 @@ pub fn ensure() -> Result<(), String> {
2323 }
2424
2525 /// A prompt written on the canvas at (x, y): a ready ticket, and a placeholder where it was clicked.
26-pub fn request(prompt: &str, x: f32, y: f32) -> u32 {
26+/// With `about`, the user Ctrl+clicked the card of that ticket: the new ticket changes its widget.
27+pub fn request(prompt: &str, x: f32, y: f32, about: Option<u32>) -> u32 {
2728 let title: String = prompt.lines().next().unwrap_or("widget").chars().take(70).collect();
28- let id = store::create(SLUG, &title, &format!("{prompt}\n\nThe user asked for this widget by clicking at ({x:.0}, {y:.0}) on the canvas."), "ready");
29- canvas::place(Placed { ticket: id, x, y, widget: None });
29+ let placed = about.and_then(|a| canvas::load().into_iter().find(|p| p.ticket == a));
30+ let context = match &placed {
31+ Some(p) => follow_up(p, x - p.x, y - p.y),
32+ None => format!("The user asked for this widget by clicking at ({x:.0}, {y:.0}) on the canvas."),
33+ };
34+ let id = store::create(SLUG, &title, &format!("{prompt}\n\n---\n\n{context}"), "ready");
35+ match placed {
36+ Some(p) => canvas::retarget(p.ticket, id),
37+ None => canvas::place(Placed { ticket: id, x, y, widget: None }),
38+ }
3039 id
3140 }
3241
42+/// What the user clicked: the widget, the ticket before this one, and what that run left out.
43+fn follow_up(p: &Placed, x: f32, y: f32) -> String {
44+ let prev = store::ticket(SLUG, p.ticket).map(|t| (t.state, t.body)).unwrap_or_default();
45+ let what = match &p.widget {
46+ Some(w) => format!("The user Ctrl+clicked the `{w}` widget, at ({x:.0}, {y:.0}) inside it. Change `widgets/{w}.rs` and keep its name."),
47+ None => format!("The user Ctrl+clicked the card of ticket #{}, which ended `{}` without a widget. Build what it asked for, corrected by this prompt.", p.ticket, prev.0),
48+ };
49+ let left_out: String = store::events(SLUG, p.ticket).iter()
50+ .filter(|e| matches!(e["verb"].as_str(), Some("deviate" | "block" | "decide")))
51+ .map(|e| format!("- {}: {} {}\n", e["verb"].as_str().unwrap_or(""), e["args"]["text"].as_str().or(e["args"]["reason"].as_str()).unwrap_or(""),
52+ e["args"]["recommend"].as_str().map(|r| format!("(recommended: {r})")).unwrap_or_default()))
53+ .collect();
54+ let quoted: String = prev.1.lines().map(|l| format!("> {l}\n")).collect();
55+ format!("{what}\n\nThe ticket before this one, #{}:\n\n{quoted}\nWhat its run decided or left out:\n\n{}", p.ticket,
56+ if left_out.is_empty() { "- nothing recorded\n".into() } else { left_out })
57+}
58+
3359 /// Merges a done widget ticket into the library, then rebuilds the app with it.
3460 pub fn install(p: &Project, id: u32, branch: &str) -> Result<(), String> {
35- let added = git(&p.path, "", &["diff", "--name-only", "--diff-filter=A", &format!("main...{branch}"), "--", "widgets/"])?;
36- let widget = added.lines().find_map(|f| f.strip_prefix("widgets/")?.strip_suffix(".rs")).map(String::from)
37- .ok_or("the branch adds no widgets/<name>.rs")?;
61+ let changed = git(&p.path, "", &["diff", "--name-only", "--diff-filter=AM", &format!("main...{branch}"), "--", "widgets/"])?;
62+ let widget = changed.lines().find_map(|f| f.strip_prefix("widgets/")?.strip_suffix(".rs")).map(String::from)
63+ .ok_or("the branch changes no widgets/<name>.rs")?;
3864 git(&p.path, "", &["-c", "user.name=conveyor", "-c", "user.email=conveyor@localhost", "merge", "-q", "--no-edit", branch])?;
3965 store::event(SLUG, id, json!({"kind": "conveyor", "msg": format!("merged widget {widget}; rebuilding the app")}));
4066 rebuild_app()?;
crates/conveyor/src/server.rs+3−1
@@ -1,6 +1,7 @@
11 //! The socket the app and the CLI use: one JSON request per line, one JSON reply per line.
22 //! {"op":"state"} tickets and canvas
33 //! {"op":"widget","prompt":"…","x":10,"y":20} a widget ticket, placed on the canvas
4+//! + "about":3 …or a follow-up on the widget ticket #3 placed
45 //! {"op":"move","ticket":1,"x":10,"y":20} a widget dragged on the canvas
56 //! {"op":"ticket","project":"…","title":"…","body":"…"}
67 use crate::{canvas, library, paths, store};
@@ -30,7 +31,8 @@ fn handle(r: &Value) -> Value {
3031 match s("op") {
3132 "state" => library::snapshot(),
3233 "widget" if !s("prompt").trim().is_empty() => {
33- json!({"id": library::request(s("prompt").trim(), r["x"].as_f64().unwrap_or(0.0) as f32, r["y"].as_f64().unwrap_or(0.0) as f32)})
34+ let f = |k: &str| r[k].as_f64().unwrap_or(0.0) as f32;
35+ json!({"id": library::request(s("prompt").trim(), f("x"), f("y"), r["about"].as_u64().map(|a| a as u32))})
3436 }
3537 "move" => {
3638 let f = |k: &str| r[k].as_f64().unwrap_or(0.0) as f32;
crates/conveyor/src/store.rs+4−0
@@ -109,3 +109,7 @@ pub fn event(project: &str, id: u32, mut ev: Value) {
109109 let mut f = fs::OpenOptions::new().create(true).append(true).open(dir(project, id).join("events.jsonl")).unwrap();
110110 writeln!(f, "{ev}").unwrap();
111111 }
112+
113+pub fn events(project: &str, id: u32) -> Vec<Value> {
114+ fs::read_to_string(dir(project, id).join("events.jsonl")).unwrap_or_default().lines().filter_map(|l| serde_json::from_str(l).ok()).collect()
115+}