xonecas.io
8447
Co

conveyor / commit 7a222ba

Dev notes keep what was clicked through an edit, and carry its HTML

The board only sees a ticket's words above ---, and an edit wrote those back as the whole
body, so rewording a draft dev note (or any widget build) dropped what was clicked. Edits
now keep the context below ---; store::words and store::with_context are the one place
that knows the rule. A note also carries the element's rendered HTML, cut at 2000
characters, so the agent can find it in the source by its classes, attributes and text.

Checked against a real conveyord: a draft note posted on 7717, then edited over the
socket with only its words, keeps the page, element, HTML and window below ---.

Co-Authored-By: Claude Opus 5.5

conveyor2026-11-11 7a222baf7a2ffb2c4df71869bfdf9923bd7d2fc7 parent 1d3e8f3

7 files changed

DESIGN.md+1−1
@@ -71,7 +71,7 @@ Measured from the rats store in the VM: 2 projects, 314 tickets, 5 MB in total.
7171
7272 ## Dev notes
7373
74-The Ctrl+click of the widget builder, for a project's own running app. `devnotes.js`, loaded by a dev-only tag, outlines what's under the pointer while Ctrl is held, and a click opens a small form: the note, and a **Ready?** toggle (ticked by default, remembered per app). Enter files a ticket in that project, ready or draft, with the page, the element's selector, the point in it, its text and the window size below `---`. The app never sees the held click or the typing.
74+The Ctrl+click of the widget builder, for a project's own running app. `devnotes.js`, loaded by a dev-only tag, outlines what's under the pointer while Ctrl is held, and a click opens a small form: the note, and a **Ready?** toggle (ticked by default, remembered per app). Enter files a ticket in that project, ready or draft, with the page, the element's selector, the point in it, its text, its rendered HTML (cut at 2000 characters, for the agent to find it in the source) and the window size belo …
7575
7676 ```
7777 <script src="http://127.0.0.1:7717/devnotes.js" data-project="<slug>" async onerror="this.remove()"></script>
crates/conveyor/src/devnotes.js+1−1
@@ -83,7 +83,7 @@
8383 e.preventDefault();
8484 const { el, point } = picked;
8585 const body = { project, note: text.value, ready: ready.checked, url: location.href, selector: selector(el), point,
86- text: (el.innerText || el.value || el.alt || "").trim().slice(0, 200), viewport: `${innerWidth}x${innerHeight}` };
86+ text: (el.innerText || el.value || el.alt || "").trim().slice(0, 200), html: el.outerHTML.slice(0, 2000), viewport: `${innerWidth}x${innerHeight}` };
8787 close();
8888 fetch(api, { method: "POST", headers: { "content-type": "application/json" }, body: JSON.stringify(body) })
8989 .then((r) => r.json())
crates/conveyor/src/devnotes.rs+3−2
@@ -80,10 +80,11 @@ fn note(v: &Value) -> Result<Value, String> {
8080 let context = format!(
8181 "The user clicked their running app, in dev mode, and wrote the words above about what they clicked.\n\n\
8282 - Page: {}\n- Element: `{}`, at ({}) inside it\n- Its text: \"{}\"\n- Window: {}\n\n\
83+ Its HTML as rendered, cut at 2000 characters: search the source for its classes, attributes and text.\n\n```html\n{}\n```\n\n\
8384 To see it, run the app's dev server and open that page, with the window at that size. The port in your VM may differ.",
84- s("url", 2000), s("selector", 500), s("point", 40), s("text", 200), s("viewport", 40));
85+ s("url", 2000), s("selector", 500), s("point", 40), s("text", 200), s("viewport", 40), s("html", 2000));
8586 let state = if v["ready"] == true { "ready" } else { "draft" };
86- let id = store::create(&p.slug, &library::title(&words), &format!("{words}\n\n---\n\n{context}"), state);
87+ let id = store::create(&p.slug, &library::title(&words), &store::with_context(&words, &context), state);
8788 Ok(json!({"id": id, "state": state}))
8889 }
8990
crates/conveyor/src/library.rs+1−1
@@ -97,7 +97,7 @@ pub fn request(r: &Value) -> Result<u32, String> {
9797 tree = s("tree"),
9898 element = if element.is_empty() { "none with a key".into() } else { format!("`{element}`") },
9999 history = if history.is_empty() { "- none yet\n".into() } else { history });
100- let id = store::create(SLUG, &title(&prompt), &format!("{prompt}\n\n---\n\n{context}"), "ready");
100+ let id = store::create(SLUG, &title(&prompt), &store::with_context(&prompt, &context), "ready");
101101 store::attach(SLUG, id, &[paths::data().join("app")])?;
102102 save_build(id, &Build { kind, targets, ..Default::default() });
103103 Ok(id)
crates/conveyor/src/snapshot.rs+1−1
@@ -9,7 +9,7 @@ pub fn snapshot() -> Value {
99 let events = store::events(&p.slug, t.id);
1010 let at = |e: Option<&Value>| e.and_then(|e| e["at"].as_u64()).unwrap_or(0);
1111 json!({"project": t.project, "id": t.id, "title": t.title, "state": t.state,
12- "body": t.body.split("\n\n---\n\n").next().unwrap_or("").trim(),
12+ "body": store::words(&t.body),
1313 "created": at(events.first()), "since": at(events.iter().rev().find(|e| e["kind"] == "state")),
1414 "files": store::files(&p.slug, t.id), "thread": thread::of(&p.slug, &[t.id])})
1515 })).collect();
crates/conveyor/src/store.rs+30−2
@@ -53,6 +53,19 @@ pub fn save_project(p: &Project) {
5353 fs::write(dir.join("project.json"), serde_json::to_string_pretty(p).unwrap()).unwrap();
5454 }
5555
56+/// Parts a ticket's words from what conveyor adds below them: what was clicked, and how to see it.
57+const RULE: &str = "\n\n---\n\n";
58+
59+/// A ticket's words, as the user wrote them, without the context below them.
60+pub fn words(body: &str) -> &str {
61+ body.split(RULE).next().unwrap_or("").trim()
62+}
63+
64+/// A body of `words` with `context` below them, if there is any.
65+pub fn with_context(words: &str, context: &str) -> String {
66+ if context.is_empty() { words.into() } else { format!("{}{RULE}{context}", words.trim_end()) }
67+}
68+
5669 pub fn dir(project: &str, id: u32) -> PathBuf {
5770 paths::projects().join(project).join("tickets").join(id.to_string())
5871 }
@@ -100,12 +113,13 @@ pub fn set_state(project: &str, id: u32, state: &str) {
100113 event(project, id, json!({"kind": "state", "state": state}));
101114 }
102115
103-/// Rewrites a ticket's title and body. A running ticket's text is the agent's, so it's refused.
116+/// Rewrites a ticket's title and words, keeping its context: the app only ever sees the words.
117+/// A running ticket's text is the agent's, so it's refused.
104118 pub fn edit(project: &str, id: u32, title: &str, body: &str) -> Result<(), String> {
105119 let _w = WRITE.lock().unwrap();
106120 let mut t = ticket(project, id).ok_or("no such ticket")?;
107121 if t.state == "running" { return Err("an agent is working this ticket: edit it once it settles".into()); }
108- (t.title, t.body) = (title.replace('\n', " "), body.into());
122+ (t.title, t.body) = (title.replace('\n', " "), with_context(body, t.body.split_once(RULE).map_or("", |(_, c)| c)));
109123 write(&t);
110124 drop(_w);
111125 event(project, id, json!({"kind": "conveyor", "msg": "edited"}));
@@ -167,3 +181,17 @@ pub fn load_activity() {
167181 evs.sort_by_key(|(_, _, e)| e["at"].as_u64().unwrap_or(0));
168182 for (p, id, e) in evs.iter().rev().take(KEEP).rev() { remember(p, *id, e); }
169183 }
184+
185+#[cfg(test)]
186+mod tests {
187+ use super::*;
188+
189+ #[test]
190+ fn context_survives_rewording() {
191+ let body = with_context("Make it blue", "- Element: `#save`");
192+ assert_eq!(words(&body), "Make it blue");
193+ let edited = with_context("Make it red", body.split_once(RULE).map_or("", |(_, c)| c));
194+ assert_eq!(edited, "Make it red\n\n---\n\n- Element: `#save`");
195+ assert_eq!(with_context("Plain", ""), "Plain");
196+ }
197+}
crates/conveyor/src/thread.rs+1−1
@@ -10,7 +10,7 @@ pub fn of(project: &str, tickets: &[u32]) -> Vec<Value> {
1010 let events = store::events(project, id);
1111 if let Some(t) = store::ticket(project, id) {
1212 let at = events.first().map_or(Value::Null, |e| e["at"].clone());
13- out.push(entry("prompt", t.body.split("\n\n---\n\n").next().unwrap_or("").trim().into(), &at));
13+ out.push(entry("prompt", store::words(&t.body).into(), &at));
1414 }
1515 for e in events {
1616 let a = |k: &str| e["args"][k].as_str().unwrap_or("").to_owned();