mirror of
https://github.com/storytold/figcraft.git
synced 2026-11-01 14:26:49 -06:00
Tools that act on a document, and the control methods engine.execute, document.inspect, node.get and ui.render, take an optional `document` (an open file's id from doc.list / document.inspect, or its path). The call acts on that file and the tab in front stays in front, so an attached agent keeps editing its own file when the user switches tabs.
This commit is contained in:
@@ -318,15 +318,21 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
}),
|
||||
spec!("doc.nextTab", "Next tab", "{}", false, |s, _| cycle_doc(s, 1)),
|
||||
spec!("doc.previousTab", "Previous tab", "{}", false, |s, _| cycle_doc(s, -1)),
|
||||
spec!("doc.list", "List documents", "{}", false, |s, _| {
|
||||
Ok(Value::Array(
|
||||
spec!(
|
||||
"doc.list",
|
||||
"List documents",
|
||||
"{} → [{index, id, name, path, dirty, active}]: `id` names the file in a control or MCP call's `document`",
|
||||
false,
|
||||
|s, _| {
|
||||
Ok(Value::Array(
|
||||
s.docs
|
||||
.iter()
|
||||
.enumerate()
|
||||
.map(|(i, d)| json!({"index": i, "name": d.doc.name, "path": d.path, "dirty": d.is_dirty(), "active": i == s.active}))
|
||||
.map(|(i, d)| json!({"index": i, "id": d.uid, "name": d.doc.name, "path": d.path, "dirty": d.is_dirty(), "active": i == s.active}))
|
||||
.collect(),
|
||||
))
|
||||
}),
|
||||
}
|
||||
),
|
||||
spec!("doc.home", "Home", "{}", false, |s, _| {
|
||||
s.request_ui("home", json!({}));
|
||||
ok()
|
||||
|
||||
Reference in New Issue
Block a user