forked from 1b-agent/fieldcraft-upstream
ui: command forms drawn from the parameter schema
The context panel's form shows typed fields instead of the JSON text: numbers with the model's units, drop-downs of choices and of the model's sets, materials, steps and bodies, checkboxes, vectors, groups and one-of variants (a load's type switches its fields), lists of rows. Defaults are filled in, required fields are marked, a value the schema finds wrong is noted under its field, and OK waits while a field holds text that is not a value. The JSON text stays as the Advanced view. fields.rs holds the generic widgets (row, number, drop-down, text), adapted from SolidCraft's dialog rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01UhhZMBTviDQxZvwnyP89fo
This commit is contained in:
1 parent
8848ef9e7c
commit
217628ead4
6 files changed
+662
-7
No files matched your search
@@ -28,7 +28,9 @@ pub mod browser;
|
||||
pub mod capture;
|
||||
pub mod context;
|
||||
pub mod control;
|
||||
pub mod fields;
|
||||
pub mod files;
|
||||
pub mod form;
|
||||
pub mod frame;
|
||||
pub mod gpu;
|
||||
pub mod icons;
|
||||
@@ -155,6 +157,8 @@ pub struct ParamsDialog {
|
||||
/// The parameters as JSON text.
|
||||
pub text: String,
|
||||
pub error: Option<String>,
|
||||
/// The JSON text is shown instead of the typed fields.
|
||||
pub advanced: bool,
|
||||
}
|
||||
|
||||
/// A status bar message.
|
||||
@@ -519,7 +523,9 @@ impl ModelApp {
|
||||
/// Open a command's parameter form with `params` filled in.
|
||||
pub fn open_form(&mut self, command: &str, params: Value) {
|
||||
if let Some(spec) = fieldcraft_engine::find_command(command) {
|
||||
self.dialog = Some(ParamsDialog { command: spec.id, text: params.to_string(), error: None });
|
||||
// The schema's defaults are filled in, so the form starts as the command would run.
|
||||
let params = spec.form.map_or(params.clone(), |form| fieldcraft_engine::schema::prefill(form, ¶ms));
|
||||
self.dialog = Some(ParamsDialog { command: spec.id, text: params.to_string(), error: None, advanced: spec.form.is_none() });
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user