Writing a workbench
A workbench is a crate that implements
core_document::Workbench. The application never refers to a
workbench by name. Everything a workbench shows, draws, picks, rebuilds
or asks for goes through this trait and the workbench registry
(DocumentService).
Workbench itself holds what a workbench is and its
lifecycle (descriptor, configure, activation,
frames, the state that moves with a tab). The rest is in one supertrait
per concern, every method with a default:
| Trait | What it covers |
|---|---|
BenchFeatures |
How owned features show in the tree and the view, picking, deleting, the edit session |
BenchTools |
Tool buttons, input, what the workbench draws in the view while active |
BenchPanels |
The task panel's state, the floating card, menu entries, its settings |
BenchBuild |
Rebuild plans, mesh histories, derived working data |
BenchParameters |
Numbers formulas set, the property panel's hints and swappable inputs |
BenchOutput |
Reports, annotations, threads, bought bodies, print parts |
BenchCommands |
Running the commands it registered |
A workbench implements all of them, writing out only the methods it uses and leaving a group it does not need empty:
impl Workbench for MyWorkbench { /* descriptor, configure, ... */ }
impl BenchFeatures for MyWorkbench { /* feature_info, ... */ }
impl BenchTools for MyWorkbench {}
impl BenchPanels for MyWorkbench {}
impl BenchBuild for MyWorkbench {}
impl BenchParameters for MyWorkbench {}
impl BenchOutput for MyWorkbench {}
impl BenchCommands for MyWorkbench {}The host calls every group through dyn Workbench. Code
that calls a group's method on a concrete workbench type (a test)
imports that trait.
Design (crates/workbenches/wb_design), the Sketcher
(crates/workbenches/wb_sketch), Surface and Assembly are
complete examples. This guide is for a built-in workbench; one installed
as a package is written against the guest SDK instead (Workbench packages).
1. Create the crate
[package]
name = "wb_mine"
[features]
default = ["egui"]
egui = ["dep:egui", "dep:ui_kit", "dep:bench_panel"]
[dependencies]
core_document = { path = "../../core_document" }
kernel_api = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
egui = { workspace = true, optional = true }
ui_kit = { path = "../../ui_kit", optional = true }
bench_panel = { path = "../../bench_panel", optional = true }The egui feature enables the bench's drawing side: what
it draws itself with egui is bench_panel::BenchUi
(ui_task_panel, ui_settings,
ui_left_panel, ui_viewport_strip, each drawing
nothing by default), implemented on the bench's own type beside its
Workbench:
#[cfg(feature = "egui")]
impl bench_panel::BenchUi for MyWorkbench {
fn ui_task_panel(
&mut self,
ui: &mut egui::Ui,
ctx: &mut WorkbenchRuntimeContext,
request: TaskRequest,
) -> TaskOutcome {
// ...
}
}The workbenches crate gives every bench it lists its
drawing side, so nothing else is needed. Panel code takes colours and
sizes from ui_kit::tokens, never as literal values.
Add it to the workspace members and to the workbenches
crate's dependencies, then register it in
crates/workbenches/src/lib.rs:
listed!(
SketchWorkbench,
DesignWorkbench,
SurfaceWorkbench,
AssemblyWorkbench,
MyWorkbench
);Every bench in that list registers with its drawing side, so it must
implement BenchUi, even if only as an empty
impl.
The order matters. A new document opens in the first workbench that is not modal, and Preferences lists workbench pages in this order. The switcher and menus sort by label.
2. Describe the workbench
fn descriptor(&self) -> WorkbenchDescriptor {
WorkbenchDescriptor::new("wb.mine", "Mine", "What it is for.")
.icon("workbench-mine")
.feature_kinds(["wb.mine"])
}iconnames an icon inui_kit::icon. Add icons withscripts/vendor-icons.mjs.feature_kindslists the feature kinds this workbench owns. The owner draws, picks, edits and deletes features of those kinds. Each kind can have one owner only; registration fails otherwise. Design also ownscore.datum..modal()marks an editing session, like the Sketcher. Entering it remembers the previous workbench, and leaving returns there..bought_kinds([..])names owned kinds whose bodies are bought rather than made (catalog hardware): the parts list counts them bought unless the user says otherwise, and exports and the slicer leave them out..radial([..])names up to eight of its tools or commands, clockwise from the top, for the radial menu a right press held still opens while the workbench is active. The user can choose others in Preferences › Input › Radial menu; a workbench that names none offers its most used tools.
3. Add tools
configure runs once and registers the tools:
fn configure(&self, context: &mut WorkbenchContext) {
context.register_tool(
ToolDescriptor::new_action("mine.thing", "Thing", Some("shape")).icon("thing").row(1),
);
}- Tool panels group tools by the first segment of their category, in registration order; an empty category belongs to General. Each panel shows pinned icon buttons above its caption. Click the caption for every tool, with headings for full categories and indented rows for variants. Without the bench tabs, the bench switcher leads the row. New, Open, Save, Undo, Redo and the tool search sit in the menu bar; Measure, Print bed and Annotations on the view's pill; Recompute on the status bar.
- A bench starts with its descriptor's
radialtools pinned, plus the first non-planned tool in any panel left empty. Menu checkboxes pin or unpin tools; right-click a pinned button to unpin it. Pins are saved per workbench inUserSettings.tool_panel_pins, in pin order. Reset pins in any panel menu restores that whole bench's defaults. An empty panel keeps its caption. - Preferences › General › Interface offers Workbench
tabs and Tool panels: the first is on by
default, the second off. Turning off Workbench tabs restores the
dropdown. With Tool panels off, the toolbar keeps its draggable groups
and saved positions: row 0 holds the workbench switcher beside the
workbench's first row, and rows 1 and 2 are its others. Tabs and tool
panels scroll horizontally when the window is narrow. Dragging a
workbench tab moves it; the order is saved in
UserSettings.workbench_orderand the dropdown follows it. Document and chat tabs move the same way. - The workbench menu lists tools by category. A tool that only looks
at the model takes
core_document::INSPECT_CATEGORY, and the Inspect menu lists it among every workbench's checks. new_action,new_radio_groupandnew_checkchoose how the button behaves..variants(..)adds a dropdown..planned(note)shows a disabled button for a designed tool that is not built yet.is_tool_enabledandtool_toggledare called every frame.- Clicking an action tool calls
on_inputwithWorkbenchInputEvent::ToolActivated. ReturnInputResult::consumed()when handled.
4. Add keyboard shortcuts
A tool gets a default key with .shortcut. Pressing it
while the workbench is active works like clicking the tool's button:
ToolDescriptor::new("mine.line", "Line", Some("draw")).shortcut("L")For a key that is not a tool, register an action. Its key sends
WorkbenchInputEvent::Action { id } to
on_input:
context.register_action(
ActionDescriptor::new("mine.flip", "Flip direction").shortcut("Shift+F"),
);- Keys are written like
L,Shift+F,Ctrl+Alt+KorF5. A key that does not parse panics at registration, so a typo shows up in tests. - Users can change every key in Preferences › Keyboard. Ids are saved as they are, so keep them stable.
- A workbench's keys work only while it is active, and win over the application's keys there.
- Keys without Ctrl or Alt are left to text fields while one has focus.
- The application uses 0 to 6, O, P, F, Shift+F, H, F2, F11, Space, Shift+Space and Delete without Ctrl or Alt. A workbench key on one of them hides it while the workbench is active.
- A workbench that takes typed numbers from the viewport returns
truefromtakes_numeric_inputmeanwhile, so the digit keys,.,,and-reach it rather than their shortcuts.takes_text_inputdoes the same for every key that types text, letters included, while it types a formula. - To name a key in a hint, implement
shortcuts_changed. It receives the keys in effect by id at start and after every change.
5. Add commands
A command is something a script can call by name, with named
arguments. Keep each command's spec beside the function that runs it in
a CommandTable, so its id is written once: the table
registers the specs in configure, answers which ids are the
bench's and runs them in run_command.
use std::sync::OnceLock;
fn commands() -> &'static CommandTable<MyWorkbench> {
static TABLE: OnceLock<CommandTable<MyWorkbench>> = OnceLock::new();
TABLE.get_or_init(|| {
let mut t = CommandTable::default();
t.add(
CommandSpec::new("mine.slab", "Add a slab")
.param("width", ParamKind::Number, "In millimetres")
.optional("name", ParamKind::String, "Its name in the tree")
.returns("the feature's id"),
slab,
);
t
})
}
fn slab(args: &CommandArgs, ctx: &mut WorkbenchRuntimeContext) -> CommandResult {
let width = Args(args).number("width")?;
let made: FeatureId = todo!("add a {width} mm slab to ctx.document");
Ok(json!(made.0.to_string()))
}
// In `impl Workbench for MyWorkbench`:
fn configure(&self, context: &mut WorkbenchContext) {
commands().register(context);
}
// In `impl BenchCommands for MyWorkbench`:
fn run_command(&mut self, id: &str, args: &CommandArgs, ctx: &mut WorkbenchRuntimeContext) -> CommandResult {
commands().run_on(self, id, args, ctx)
}- A handler that reads the bench's own state (its settings, a cache)
takes it:
t.add_on(spec, |bench, args, ctx| ...)gets&mut MyWorkbench. A bench whose commands need none usesCommandTable<()>. - A step several commands share (find the feature they work on, store
it after) is a function that wraps each command's own step into a
handler, added with
t.add_free(spec, wrapper(step)); the sketcher'seditingis one. - With many commands, keep one module per family, each with a
table(t: &mut CommandTable<MyWorkbench>)adding its own, and build the bench's table from them. - The host checks the arguments against the spec before the call.
- A command changes the document through its mutators, so the change is undoable like a click. It never opens a task or waits for input.
.read_only()marks one that changes nothing (an AI agent never waits for approval to run it);.agent_always_asks()and.agent_never(reason)restrict what an agent may do with it.- A tool or panel action that ends in what a command does calls
ctx.record(id, args, result), so recordings and scripts see the same call. - Ids are unique across the application; registration fails on a duplicate.
- Scripts reach it as
pc.mine.slab{width = 20}. - The scripting reference (
docs/SCRIPTING.md, generated) lists a bench's commands in the order it registers them. A built-in bench whose commands live in one module per family (the Sketcher, the Assembly) sorts them by oneORDERlist in itscommands.rsbefore registering; a new command goes into that list too, and a test fails until it does.
A command that takes a file as path can also serve File
› Import. Register the file kind beside it:
context.register_import(FileImport::new("Slab drawing", ["slab"], "mine.import"));- The import dialog offers the extensions, and a picked file with one
of them runs the command with
pathset, recorded as that command. - A feature id the command answers is selected in the tree.
- Registration fails when the command is not one the workbench registers.
6. Store features
Define a type implementing WorkbenchFeature (see Document model) and add it with
ctx.document.add_feature_in_body(feature, name, body).
For each kind it owns, the workbench answers these (in
BenchFeatures, except property_hints,
references and set_reference in
BenchParameters, and not_printed,
print_parts and cosmetic_threads in
BenchOutput):
/// Icon and labels for the tree row.
fn feature_info(&self, node: &FeatureNode) -> FeatureInfo;
/// What to draw for the feature when it is visible and not being edited.
/// `node_revision(node)` gives a revision that changes with the data;
/// `region` (a `PassiveRegion`: a profile and an opacity) has the host
/// shade what the lines enclose.
fn passive_geometry(&self, doc: &Document, id: FeatureId, node: &FeatureNode)
-> Option<PassiveGeometry>;
/// Distance in pixels from the cursor to the feature, if close enough.
fn pick_feature(&self, doc: &Document, id: FeatureId, node: &FeatureNode, pick: &ViewportPick)
-> Option<f32>;
/// Remove the feature and fix up what depended on it.
/// The default just removes it.
fn delete_feature(&mut self, ctx: &mut WorkbenchRuntimeContext, id: FeatureId) -> bool;
/// Which data fields are lengths and which refer to other features,
/// for the property panel.
fn property_hints(&self) -> PropertyHints;
/// Bodies that are not made (bought parts): an export of every visible
/// body and the slicer leave them out. `bought_kinds` are the kinds every
/// bench declares bought.
fn not_printed(&self, doc: &Document, bought_kinds: &[WorkbenchId]) -> Vec<BodyId>;
/// The parts to print and how many of each, for the print layout. The
/// first bench that answers (the Assembly's parts list) is the one used.
fn print_parts(&self, doc: &Document, bought_kinds: &[WorkbenchId])
-> Option<Vec<PrintPart>>;
/// Bores the feature threads without cutting the thread, with their
/// designation, for the view, the parts list and STEP.
fn cosmetic_threads(&self, doc: &Document, id: FeatureId, node: &FeatureNode)
-> Vec<ThreadCallout>;
/// The curves and points the feature lays out, for an array of copies
/// along a path or at points.
fn feature_paths(&self, doc: &Document, id: FeatureId, node: &FeatureNode)
-> Option<FeaturePaths>;
/// A problem that does not stop the feature building (a sketch whose
/// projected edges are gone), shown on its tree row. Asked whenever the
/// tree draws, so answer from what was last worked out.
fn feature_warning(&self, doc: &Document, kernel: Option<&dyn KernelQueries>, id: FeatureId)
-> Option<String>;
/// Features of other bodies that act on `body` (a joint holding one
/// body to another); the tree lists each under `body` too, as a link.
fn linked_features(&self, doc: &Document, body: BodyId) -> Vec<FeatureId>;
/// Inputs the property panel lets the user swap (a profile sketch), and
/// how to swap one.
fn references(&self, doc: &Document, id: FeatureId, node: &FeatureNode)
-> Vec<FeatureReference>;
fn set_reference(&mut self, ctx: &mut WorkbenchRuntimeContext, id: FeatureId,
key: &str, to: ReferenceChoice) -> Result<(), String>;A click on a feature in the tree only selects it: it becomes the
active document object. A double click switches to its owner and calls
edit_feature, which is where the workbench opens the
feature's task; never open one on selection alone.
editing_feature names the feature under edit (the tree
badges it, and a feature that builds solid gets a preview);
locks_view_to_plane keeps the camera square to the plane
while editing_feature is Some.
finish_editing ends the edit session when the user finishes
it, or when undo takes away the feature under edit.
shows_origin_planes draws the origin's planes whatever the
view's setting, for the user to pick one; the plane under the cursor
arrives as ctx.hovered_base_plane.
7. Take formulas
parameters and values_moved are in
BenchParameters; settle and the
derive steps in BenchBuild.
parameters lists an owned feature's numbers that
formulas may set and read: a Parameter with a stable key,
the name formulas call it, a JSON pointer into the feature's data, a
Dim (length, angle, number), a scale for an angle kept in
radians, and whether it is a count. The workbench builds, draws and
edits from Document::feature_values, which has every
formula's value in; its own data keeps plain numbers.
A feature type can state both lists where its fields are declared:
#[derive(Walk)] (core_document::walk) gives
each field a role, a number formulas set
(#[walk(length("depth", "Depth"))]), a setting, or its own
type's walk, where every FeatureId is a feature it reads.
Walker::of(&feature) then answers its
parameters and its dependencies, and a field
added without a role does not compile. Design's features are written so
(wb_design/src/feature/).
settlemakes the data whole once values are in (a sketch solves).derive,derive_on_solidandderive_on_geometrybring working data up to what it follows: another feature, what the last build found of the solid (BuildPlan::probes), the bodies' geometry. All are derived and never recorded.values_movedrecords results that follow formulas but are kept rather than derived (placements a joint solves for), in the same undo step.
8. Build solids
A workbench whose features make a body's solid implements, in
BenchBuild:
/// Bodies to rebuild now, each with a plan. Called every frame.
/// Clear the dirty flags of the planned features here, or the same job
/// comes back next frame.
fn rebuild_jobs(&self, doc: &mut Document) -> Vec<RebuildJob>;
/// The body's history changed: rebuild it from the start.
fn invalidate_body(&self, doc: &mut Document, body: BodyId);
/// Every solid is out of date (undo, redo, Recompute All).
fn invalidate_all(&self, doc: &mut Document);A BuildPlan is a list of
kernel_api::SolidOps (ops) with the feature
that made each one (op_features); the application runs it
on the kernel worker, and a kernel failure is shown on the feature whose
op failed. A feature that cannot be planned stops the plan: put its
BuildError in failed and the features after it
in unbuilt, and the body shows the history before it.
probes asks the solid questions part way through (where a
face a sketch stands on is now); the answers come back through
derive_on_solid. A job whose plan is
Err(BuildError) puts the error on its feature and builds
nothing; an empty plan drops the body's derived solid.
9. Add menu entries
In BenchPanels:
fn menu_items(&self, scope: &MenuScope, doc: &Document) -> Vec<MenuItem>;
fn on_command(&mut self, id: &str, scope: &MenuScope, ctx: &mut WorkbenchRuntimeContext) -> bool;The scopes are the right-click menu on a body, a feature, body or
component row in the tree, the Edit menu (edit.cut,
edit.copy, edit.paste on the active
workbench), and the start page. A start page item becomes a New card.
Its command runs in a fresh document with one body. A
MenuItem can be checked, drawn ticked: the
choice that stands among its entries.
For something the bench draws itself (a node or handle of its own),
it opens its own menu at the pointer, typically on a right click it sees
in on_input:
ctx.request(HostRequest::OpenMenu {
bench: WorkbenchId::from("mine"),
tag: node.to_string(),
items: vec![MenuItem::new("mine.corner", "Corner").checked(true)],
});The pick comes back to that bench's on_command with
MenuScope::Popup(tag), the tag saying what the menu was
for; Escape or a click elsewhere closes it and says nothing. A right
click that opens one opens no body menu as well.
10. Ask the host for things
Every hook that acts gets a WorkbenchRuntimeContext: the
document, the camera and viewport, hover and selection
(selected_faces, selected_edges,
selected_face_in(body) for a body's own frame), the active
document object, the kernel's queries (kernel), the colours
to draw in (sketch_palette), projection helpers, and
logging (log_info and others).
Anything else goes through a request:
ctx.request(HostRequest::ActivateTool("mine.select".into()));
ctx.request(HostRequest::SelectBody(body));
ctx.request(HostRequest::SelectFeatures(vec![a, b]));
ctx.request(HostRequest::JournalLabel("Create thing".into()));
ctx.request(HostRequest::CloseToolGesture { bench: WorkbenchId::from("mine") });
ctx.request(HostRequest::UndoToolGesture { bench: WorkbenchId::from("mine"), entry });
ctx.request(HostRequest::StartOn { workbench: WorkbenchId::from("wb.sketch"), attach });
ctx.request(HostRequest::SwitchWorkbench(WorkbenchId::from("wb.design")));
ctx.request(HostRequest::OrientCamera(CameraOrientRequest { .. }));
ctx.request(HostRequest::FinishEditing);
ctx.request(HostRequest::SaveFile { name, kind, extension, contents });
ctx.request(HostRequest::RecordAnimation { name, frames, frame_ms });SelectFeatures selects several tree rows as Ctrl-clicks
would, the first the active document object.
RecordAnimation asks where to save and writes the scene as
the camera sees it, once per frame with the bodies at that frame's
placements. CloseToolGesture closes the undo step now and
UndoToolGesture takes back entry only while it
is the newest step; the answer comes back at once through
tool_history (ToolHistoryReply), and
ctx.undo_entry is the newest step at every hook.
The host applies requests after the method returns, collected with
everything else the hook left (HookOutcome). Requests from
on_activate and on_deactivate that switch
workbench are ignored, since those run during a switch.
StartOn switches workbench and passes attach
to the new one as ctx.attach_request.
11. Draw panels
task, floating_card,
card_event and the settings methods are in
BenchPanels; viewport and
cancel_pointer_gesture in BenchTools;
on_frame, suspend_session,
resume_session and busy on
Workbench.
task()opens the task panel on the right;ui_task_panel(onBenchUi, as areui_left_panelandui_settings) draws it and handles Done and Cancel, which the host draws in the panel's header with the task's title, itssubtitleand itsstatusas a pill. One task is one undo step, unless itsTaskInfoisstepwise(the sketcher's session, where each edit is a step). Cancel needs no restore of the document: the host takes back through its journal everything done while the task was open, the feature a tool made included. A bench drops only its own state (the task, picks, the selection). A task that records calls part way through sendsHostRequest::KeepTaskEdits, so Cancel goes back only to there.- A panel's fields line up on
ui_kit::widgets::LabelColumn(one per section, as wide as its longest label); declared panels (bench_panel, which draws a package's and the Assembly's) use the same column and the same rows, folds, chips and badges as the native panels. floating_cardputs a card over the view next to what it edits, for a quick edit of a value or two: a sketch dimension, a corner's size. It returns abench_api::FloatingCard(its widgets, the world or view point it sits by, and the text field that has the keys as it opens, its text selected so typing replaces it); the host draws it with the task panel's widgets and OK and Cancel, and sendscard_eventthe widgets' events andPanelEvent::CardClose. Enter is OK, Escape is Cancel, and a click elsewhere in the view is OK unless the card'srefusalholds OK back. Keep the edit in the bench until OK; the host makes what OK writes one undo step and takes back anything written while the card was open on Cancel. A card withok_onlyhas no Cancel: Escape is OK too, for what a step already made leaves to set. Whatever else puts a card away (the edit finished, another tool or bench picked) is OK; only a refused card is then dropped. A feature with more to set (a pad, a fillet on a solid, anything with several sections or picks) is a task, not a card.ui_left_paneldraws above the model tree, and not while the left panel is folded to its icons.viewportis asked once a frame while the workbench is active and returns oneViewportOutput; fill the fields you draw and leave the rest at..Default::default().meshesdraw in the scene and turn with the view;overlays,polygons,images,marksandlabelsdraw over it in viewport pixels, keeping their size at any zoom (polygons are filled shapes beneath the lines, the Assembly's move handles).hudandstatusfill the viewport corners and the status bar,scalar_mapscolour bodies by a value per vertex, andfadednames bodies drawn see-through, still pickable, that a tool asks the user to see past.clip_planecuts the scene at a plane of any direction while it is set (the sketcher's section view), in drawing and picking alike, standing in for the view toolbar's clipping plane, andview_griddraws a grid on a plane of the bench's own in place of the scene's.on_frameruns every frame while the workbench is active, with the time since the last.cancel_pointer_gestureputs back a held drag when the window loses focus or the bench's tab leaves the screen, since the release may never arrive. Nothing the pointer held comes back with the tab.ui_settingsdraws the workbench's page in Preferences;has_settingsreturning true is what gives it a place there. A bench with nothing to set leaves both alone and gets no page.settings_jsonandapply_settings_jsonkeep its settings in the user's file.suspend_sessionandresume_sessionhand the host the editing state that belongs to the document on screen, so each tab keeps its own.busykeeps frames coming while work of the workbench runs away from the window.
Checklist
descriptorwithiconandfeature_kinds, and a test that the icons exist.configurewith the tools and their default keys, andis_tool_enabledwhere tools have preconditions.feature_info, pluspassive_geometry,pick_feature,delete_feature,property_hints,referencesandset_referenceas needed, andparametersfor the numbers formulas may set.rebuild_jobs,invalidate_bodyandinvalidate_allif it builds solids.on_inputfor the tools.edit_feature,editing_feature,taskandui_task_panelfor editing,suspend_session/resume_sessionfor per-tab state,has_settingsandui_settingsfor preferences.menu_itemsandon_commandfor menus and start cards.- A
CommandTableregistered inconfigureand run inrun_commandfor what scripts can do, andregister_importfor files it reads. - Registration in
crates/workbenches/src/lib.rs.
crates/app_shell/src/app/seam_lint.rs fails if a
workbench crate, id or feature type appears in the application, and CI
checks the same. The application builds parts from workbench features
only through the facade (crates/workbenches, the
calibration coupon) and, for its bench hooks,
bench_fixtures
(crates/workbenches/fixtures).
Adding to printCAD: the files each addition touches
Every addition ends with tests that measure what it made at its
strongest boundary (a solid's volume, area and bounds; a sketch's
closure; a placement), not the code's inner steps, and with
fmt, clippy,
node scripts/test-budget.mjs --changed and
lint-comment-rot.mjs passing.
A Design feature
wb_design/src/feature/: theDesignFeaturevariant and its new fields with#[serde(default)](mod.rs), its icon and label (labels.rs), and its arms in the walks over features (access.rs: sketches and borrows it reads,refine,boolean_tolerance).wb_design/src/build.rs: theSolidOps it plans, in the body's frame.wb_design/src/params.rsandreferences.rs: the numbers formulas may set, and the inputs the property panel swaps.wb_design/src/editors.rs(or a file undereditors/): its task panel;handles.rsif it drags in the view.wb_design/src/lib.rs: the tool (ToolDescriptor, icon, row, key);commands.rs: itsdesign.*command, with notes and an example ending inasserts.- A new kind of solid work: a
SolidOpvariant inkernel_api, built inkernel_ogeom/src/ops/and dispatched inkernel_ogeom/src/chain.rs. - Tests: the full stack in
kernel_ogeom/tests/kernel/design_stack.rsorscripted_design.rs, measuring the solid. PRINTCAD_WRITE_DOCS=1 cargo test -p app_shell scripting_guideto bring the command reference indocs/SCRIPTING.mdup to date, and a line in the bench's guide.
A command of the application's own
- Its
CommandSpecinapp_shell/src/app/scripts.rs(doc_commandsorapp_commands), withread_onlyand the agent access it needs. - Its arm:
document_commandwhen it needs only the document (headless runs it too, listed inDOC_COMMANDSinheadless.rs), otherwise the app's dispatch. - An example; the generated reference as above.
A UI action
- One variant in
app_ui/src/contract/commands.rsand one arm inapp/commands.rs::fold_command. A change to settings alone needs no variant: pushUiCommand::EditSettings(SettingsEdit::set(..)). - A keymap entry in
app_ui/src/keymap.rswhen it takes a key, which also makes it a command.
A host request a bench may make
- The
HostRequestvariant incore_document/src/runtime.rs, with its place inrank. - Its arm in
app/workbench_host.rs::apply_hook_outcome. - For packages: the
bench_api::Requestvariant, its conversion inwb_wasm/src/convert.rs, and the capability it needs.
A field of the package contract
bench_api: a field with#[serde(default)], or a new variant; never a new field on a variant a package builds (seedocs/PLUGINS.md, Versions).- A new host function: both WIT copies
(
crates/bench_api/witandsdk/printcad-bench-sdk/wit, which a test holds equal), its arm inwb_wasm/src/guest.rs, and the SDK'shostwrapper. - The probe or rogue package under
sdk/tests/exercising it, and a test inwb_wasm/tests/packages.rs.