Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
0415dc3
Links: update linked designs that changed while the assembly's tab wa…
chrishamm Oct 27, 2026
87213ad
Docs: the assembly guide says linked designs update when their tab re…
chrishamm Oct 27, 2026
4de37aa
Links: Vietnamese strings, now that vi is a complete catalog
chrishamm Oct 27, 2026
f28b238
Links: remember what each design last read, so an update that fails i…
chrishamm Oct 27, 2026
60547be
Links: no read during a save-changes prompt, records for adopted desi…
chrishamm Oct 27, 2026
c99f9a4
Assemblies: edit a linked component in place, with the assembly aroun…
chrishamm Oct 27, 2026
03287f6
Edit in place: a double-click opens it, Activate only activates
chrishamm Oct 27, 2026
2513e5b
Double-click on a component's face: edit a linked one in place, activ…
chrishamm Oct 27, 2026
f0c0180
Edit in place: fixes from review
chrishamm Oct 27, 2026
7f66211
Edit in place: Finish Editing on the MODEL tab and the mouse's back b…
chrishamm Oct 27, 2026
7810fc9
Edit in place: fixes from the second review
chrishamm Oct 27, 2026
10108b2
Edit in place: fixes from the third review
chrishamm Oct 27, 2026
ca47eea
Edit in place: Update Links run as a command in the part refreshes th…
chrishamm Oct 27, 2026
258ce3b
Edit in place: the ribbon button reads Finish Edit, as Finish Sketch …
chrishamm Oct 27, 2026
f36d0a8
Edit in place: fixes from the fourth review
chrishamm Oct 27, 2026
5512d00
Edit in place: the command is Finish Edit, as Finish Sketch is
chrishamm Oct 27, 2026
ff29f32
Edit in place: a command to start it, and fixes from the full review
chrishamm Oct 27, 2026
f98a1b0
Edit in place: fixes from the second full review
chrishamm Oct 27, 2026
844c6d9
Edit in place: fixes from the third full review
chrishamm Oct 27, 2026
4be3ea7
Merge remote-tracking branch 'origin/main' into edit-in-place
chrishamm Oct 28, 2026
b8f7e9e
Edit in place: help text for the Finish Edit button
chrishamm Oct 28, 2026
f4a7af0
Merge remote-tracking branch 'origin/main' into edit-in-place
chrishamm Oct 28, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions assets/icons/ui/design/requested_icons.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ eye false
fastener false
fillet false
finish false
finish_edit false
fit false
fit_section false
flange false
Expand Down
4 changes: 4 additions & 0 deletions assets/icons/ui/design/svg/model/finish_edit.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
202 changes: 202 additions & 0 deletions assets/locales/pending/edit-in-place.json

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions assets/locales/pending/update-changed-links.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"en": {
"prefs.linked_designs": "Linked designs",
"settings.update_changed_links": "Update changed linked designs when a tab comes back"
},
"ar": {
"prefs.linked_designs": "التصاميم المرتبطة",
"settings.update_changed_links": "تحديث التصاميم المرتبطة التي تغيّرت عند العودة إلى علامة التبويب"
},
"de": {
"prefs.linked_designs": "Verknüpfte Designs",
"settings.update_changed_links": "Geänderte verknüpfte Designs aktualisieren, wenn ein Tab wieder angezeigt wird"
},
"he": {
"prefs.linked_designs": "תכנים מקושרים",
"settings.update_changed_links": "עדכון תכנים מקושרים שהשתנו כשלשונית מוצגת שוב"
},
"ja": {
"prefs.linked_designs": "リンクされたデザイン",
"settings.update_changed_links": "タブに戻ったときに変更されたリンク先デザインを更新"
},
"vi": {
"prefs.linked_designs": "Thiết kế liên kết",
"settings.update_changed_links": "Cập nhật các thiết kế liên kết đã thay đổi khi quay lại một thẻ"
},
"zh": {
"prefs.linked_designs": "链接设计",
"settings.update_changed_links": "返回标签页时更新已更改的链接设计"
}
}
1 change: 1 addition & 0 deletions attribution/pending/finish-edit-icon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
| assets/icons/ui/design/svg/model/finish_edit.svg | SolidCraft contributors | original icon master (64 grid) | MIT OR Apache-2.0 |
53 changes: 53 additions & 0 deletions crates/engine/src/cmd/component.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ use solidcraft_geom::Vec3;

use super::CommandSpec;
use crate::params::{bad, bool_, str_, string_list, vec3};
use crate::schema::component::{EditInPlaceParams, EditInPlaceResult, FinishEditParams, FinishEditResult};
use crate::schema::{TypedContract, output_schema_for};
use crate::{Result, Session};

const EDIT_IN_PLACE_CONTRACT: TypedContract<EditInPlaceParams> = TypedContract::new();
const FINISH_EDIT_CONTRACT: TypedContract<FinishEditParams> = TypedContract::new();

#[path = "component_drag.rs"]
mod drag;
#[path = "component_matrix.rs"]
Expand Down Expand Up @@ -43,6 +48,30 @@ pub static COMMANDS: &[CommandSpec] = &[
.icon("component")
.params("bodies: [names] → one new component per body, named after it"),
CommandSpec::new("component.activate", "Activate Component", activate).icon("activate").noundo().params("component: id or name (0 or \"root\" for the design); occurrence?, path?: exact placement used to author shared geometry"),
CommandSpec::new("component.edit_in_place", "Edit in Place", crate::checked!("component.edit_in_place", edit_in_place))
.icon("edit")
.noundo()
.doc_only()
.contract(&EDIT_IN_PLACE_CONTRACT)
.output(output_schema_for::<EditInPlaceResult>)
.params(
"component: id or name of a linked component; path?: its placement (occurrence ids, default its first) → in the app \
window: open the design it links in a tab of its own with the assembly drawn around it (component.finish_edit goes \
back); fails when it is not linked, the assembly has no file yet, something is open or running in it, or the file is \
missing, on a network location not allowed yet or open in another SolidCraft; asked during the agent's turn it opens \
once the turn ends (queued: true); elsewhere it only checks",
),
CommandSpec::new("component.finish_edit", "Finish Edit", crate::checked!("component.finish_edit", finish_edit))
.icon("finish_edit")
.noundo()
.doc_only()
.contract(&FINISH_EDIT_CONTRACT)
.output(output_schema_for::<FinishEditResult>)
.params(
"no parameters → in the app window: go back from the linked design edited in place to its assembly, which reads it again; \
fails while the design has unsaved changes (run file.save first) or something is open in it; asked during the agent's \
turn it finishes once the turn ends (queued: true); elsewhere nothing changes",
),
CommandSpec::new("component.list", "List Components", list).icon("list").noundo().params(
"compact?: bool (counts of bodies, features, sketches and construction planes instead of their names; occurrences leave out \
identity transforms; children as occurrence ids); bodies?: bool (with compact: body names, not their count)",
Expand Down Expand Up @@ -193,6 +222,30 @@ fn from_bodies(s: &mut Session, p: &Value) -> Result<Value> {
transfer::from_bodies(s, p)
}

/// The app window opens the edit in place from what this returns; here the component and its
/// placement are only checked.
fn edit_in_place(s: &mut Session, p: &Value) -> Result<Value> {
let cmd = "component.edit_in_place";
let id = component(s, p, "component", cmd)?;
if !s.doc.links.contains_key(&id) {
return Err(bad(cmd, "that component is not linked to a design"));
}
let path = match p.get("path") {
Some(_) => serde_json::from_value::<Vec<u64>>(p["path"].clone()).map_err(|_| bad(cmd, "`path` must be occurrence ids"))?,
None => s.doc.first_path(id),
};
if s.occurrence_placement(&path).map_err(|e| bad(cmd, e.to_string()))?.component != id {
return Err(bad(cmd, "`path` is a placement of another component"));
}
serde_json::to_value(EditInPlaceResult { component: id, path, ..Default::default() }).map_err(|e| crate::EngineError::Other(e.to_string()))
}

/// The app window finishes an edit in place (it knows the part's tab and its assembly); here
/// there is none, so nothing changes.
fn finish_edit(_s: &mut Session, _p: &Value) -> Result<Value> {
serde_json::to_value(FinishEditResult::default()).map_err(|e| crate::EngineError::Other(e.to_string()))
}

fn activate(s: &mut Session, p: &Value) -> Result<Value> {
let id = component(s, p, "component", "component.activate")?;
let path = if p.get("path").is_some() || p.get("occurrence").is_some() {
Expand Down
65 changes: 65 additions & 0 deletions crates/engine/src/schema/component.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
//! Contracts and result types for the commands in `cmd/component.rs`.

use schemars::JsonSchema;
use serde::{Deserialize, Serialize};

use super::types::{IdOrName, present};

/// Edit a linked component's design in place. In the app window: open the design it links in a
/// tab of its own, with the rest of the assembly drawn faded around it as the placement `path`
/// puts it; `component.finish_edit` goes back. It fails when the component is not linked, the
/// assembly has no file yet, something is open or running in it, or the linked file is missing,
/// on a network location not allowed yet or open in another SolidCraft. Asked while the
/// assembly's agent is in its turn, the part opens once the turn ends (`queued`). Outside the
/// window it only checks the component and the placement.
#[derive(Debug, Deserialize, JsonSchema)]
#[schemars(deny_unknown_fields)]
pub struct EditInPlaceParams {
/// The linked component, by id or name.
pub component: IdOrName,
/// The placement to edit it at, as occurrence ids from the top of the assembly down
/// (`component.list`). Default: the component's first placement.
#[serde(default, deserialize_with = "present")]
pub path: Option<Vec<u64>>,
}

/// What `component.edit_in_place` returns.
#[derive(Debug, Default, Serialize, JsonSchema)]
pub struct EditInPlaceResult {
/// In the app window, asked while the design's agent is in its turn: the part opens once the
/// turn ends (Stop cancels it).
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub queued: bool,
/// The component, by id.
pub component: u64,
/// The placement it is edited at.
pub path: Vec<u64>,
/// In the warn parameter-check mode: what the call's parameters got wrong.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub param_warnings: Vec<String>,
}

/// Finish editing a linked component's design in place. In the app window: go back to the
/// assembly around it, which reads the link again, and close the part's tab when the edit opened
/// it. It fails while the part has unsaved changes (save it first) or something is open in it;
/// asked while the part's agent is in its turn, it finishes once the turn ends (`queued`). Outside the window
/// nothing is edited in place, so nothing changes.
#[derive(Debug, Deserialize, JsonSchema)]
#[schemars(deny_unknown_fields)]
pub struct FinishEditParams {}

/// What `component.finish_edit` returns.
#[derive(Debug, Default, Serialize, JsonSchema)]
pub struct FinishEditResult {
/// In the app window, asked while the part's agent is in its turn: the edit finishes once the
/// turn ends (Stop cancels it).
#[serde(default, skip_serializing_if = "std::ops::Not::not")]
pub queued: bool,
/// In the warn parameter-check mode: what the call's parameters got wrong.
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub param_warnings: Vec<String>,
}

#[cfg(test)]
#[path = "component_tests.rs"]
mod tests;
34 changes: 34 additions & 0 deletions crates/engine/src/schema/component_tests.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
use std::sync::Arc;

use serde_json::json;

use super::{EditInPlaceParams, FinishEditParams};
use crate::Session;
use crate::schema::input_schema_for;
use crate::schema::tests::assert_keys;

#[test]
fn schemas_and_the_key_check_agree() {
assert_keys(input_schema_for::<EditInPlaceParams>(), &["component", "path"]);
assert_keys(input_schema_for::<FinishEditParams>(), &[]);
}

#[test]
fn editing_in_place_outside_the_window_only_checks_the_component() {
let mut s = Session::default();
let made = s.execute("component.create", &json!({"name": "Bracket"})).unwrap_or_else(|e| panic!("{e}"));
let e = s.execute("component.edit_in_place", &json!({"component": made["component"]})).unwrap_err().to_string();
assert!(e.contains("not linked"), "{e}");
assert!(s.execute("component.edit_in_place", &json!({"component": "nothing"})).is_err());
assert!(s.execute("component.edit_in_place", &json!({})).is_err(), "the component is required");
}

#[test]
fn finishing_an_edit_outside_the_window_changes_nothing() {
let mut s = Session::default();
s.execute("solid.box", &json!({"length": 10, "width": 10, "height": 10})).unwrap_or_else(|e| panic!("{e}"));
let (doc, undo) = (s.doc.clone(), s.undo.len());
let r = s.execute("component.finish_edit", &json!({})).unwrap_or_else(|e| panic!("{e}"));
assert!(r.as_object().is_some_and(serde_json::Map::is_empty), "{r}");
assert!(Arc::ptr_eq(&doc, &s.doc) && s.undo.len() == undo);
}
1 change: 1 addition & 0 deletions crates/engine/src/schema/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ mod coverage_tests;
mod tests;

// The contracts, by command file.
pub mod component;
pub mod edit;
pub mod features;
pub mod inspect;
Expand Down
1 change: 1 addition & 0 deletions crates/gpu/src/view.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3614,6 +3614,7 @@ impl Renderer {
pass.set_bind_group(0, scene_bind(pv, &res.bind), &[]);
tris(pass, &res.ghost, &pv.ghost);
pass.set_bind_group(0, scene_bind(m, &res.bind), &[]);
tris(pass, &res.ghost, &m.ghost);
tris(pass, &res.trans, &m.shadow);
if phase == Phase::BeforeSeeThrough {
return;
Expand Down
11 changes: 11 additions & 0 deletions crates/mcp/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2162,6 +2162,17 @@ fn batch_steps_may_name_tools() {
assert!(body["failed"]["error"].as_str().is_some_and(|e| e.contains("screenshot")), "{body}");
let (_, body, _) = recorded_batch(Ok(json!({})), json!({"commands": [{"command": "body_topology", "params": {"body": "Body1"}}]}));
assert!(body["failed"]["error"].as_str().is_some_and(|e| e.contains("model.edges") && e.contains("model.faces")), "{body}");
// Editing in place goes to another design's tab: never a step, not even one by one
for step in [
json!({"command": "component.edit_in_place"}),
json!({"command": "Component.Finish_Edit"}),
json!({"command": "execute", "params": {"command": "component.finish_edit"}}),
] {
let command = step.to_string();
let (b, body, is_error) = recorded_batch(Ok(json!({})), json!({"commands": [{"command": "solid.box"}, step]}));
assert!(is_error && b.calls.is_empty(), "{command}: {body}");
assert!(body["failed"]["error"].as_str().is_some_and(|e| e.contains("on its own")), "{body}");
}

// Headless, step by step.
let mut s = server();
Expand Down
13 changes: 12 additions & 1 deletion crates/mcp/src/tools.rs
Original file line number Diff line number Diff line change
Expand Up @@ -762,7 +762,18 @@ fn batch(b: &mut dyn Backend, a: &Map<String, Value>) -> Value {
let mut mapped: Vec<Value> = Vec::with_capacity(steps.len());
let mut filters: Vec<(usize, String)> = Vec::new();
for (i, step) in steps.iter().enumerate() {
match batch_step(step) {
// The window goes to another design's tab for these, however the step names them: the
// batch's later steps and its rollback would land in the wrong design.
let step_result = batch_step(step).and_then(|(command, params, filter)| {
let id = if command.is_empty() { step.get("command").or_else(|| step.get("id")).and_then(Value::as_str).unwrap_or("") } else { &command };
match solidcraft_engine::find_command(id).map(|spec| spec.id) {
Some(c @ ("component.edit_in_place" | "component.finish_edit")) => {
Err(format!("`{c}` goes to another design's tab: send it on its own, not in a batch"))
}
_ => Ok((command, params, filter)),
}
});
match step_result {
Ok((command, _, _)) if command.is_empty() => mapped.push(step.clone()),
Ok((command, params, filter)) => {
if let Some(f) = filter {
Expand Down
6 changes: 6 additions & 0 deletions crates/ui-egui/src/agent_chat/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -516,6 +516,10 @@ impl AgentChat {
pub fn state(&self) -> State {
self.state.unwrap_or(State::Off)
}
#[cfg(test)]
pub(crate) fn set_state(&mut self, state: State) {
self.state = Some(state);
}
fn push(&mut self, item: Item) {
if self.items.len() >= MAX_ITEMS {
self.items.drain(..MAX_ITEMS / 10);
Expand Down Expand Up @@ -976,6 +980,7 @@ fn connect_at_start(app: &mut SolveApp, ctx: &egui::Context) {

/// Stop the agent (and everything it started); the conversation stays.
pub fn disconnect(app: &mut SolveApp) {
crate::edit_in_place::forget_after_turn(app);
app.agent_chat.disconnect_document(&mut app.session, false);
}

Expand Down Expand Up @@ -1413,6 +1418,7 @@ pub(crate) fn attach_dropped(app: &mut SolveApp, paths: impl Iterator<Item = std
pub fn cancel(app: &mut SolveApp) {
app.agent_chat.steering = false;
app.agent_chat.stopped = true;
crate::edit_in_place::forget_after_turn(app);
interrupt(app);
}

Expand Down
10 changes: 7 additions & 3 deletions crates/ui-egui/src/browser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1007,6 +1007,7 @@ fn browser_contents(app: &mut SolveApp, ui: &mut egui::Ui, acts: &mut Actions, c
t.secondary_hline(ui.painter(), ui.max_rect().x_range(), ui.cursor().top() + 1.0, t.toolbar.lerp_to_gamma(t.border, 0.5));
ui.add_space(t.space_3);
}
crate::edit_in_place::browser_strip(app, ui);
if collapsible && !stacked {
browser_rows_hugging(app, ui, acts);
} else {
Expand Down Expand Up @@ -1321,7 +1322,7 @@ fn component_rows_inner(
if app.session.doc.parts.contains_key(&id) {
crate::dialogs_part_size::open(app, id);
} else {
let _ = app.run("component.activate", json!({ "component": id }));
crate::edit_in_place::double_click_component(app, json!({ "component": id }));
}
}
if r.hovered {
Expand Down Expand Up @@ -1467,8 +1468,11 @@ fn occurrence_rows_inner(
if r.eye {
let _ = app.run("browser.visibility", json!({"visible": app.session.occurrence_hidden(path), "paths": [path]}));
}
if r.radio || (r.double && !app.session.doc.parts.contains_key(&placement.component)) {
let _ = app.run("component.activate", json!({"component": placement.component, "occurrence": placement.occurrence, "path": path}));
let params = json!({"component": placement.component, "occurrence": placement.occurrence, "path": path});
if r.radio {
let _ = app.run("component.activate", params);
} else if r.double && !app.session.doc.parts.contains_key(&placement.component) {
crate::edit_in_place::double_click_component(app, params);
}
if r.double && app.session.doc.parts.contains_key(&placement.component) {
crate::dialogs_part_size::open(app, placement.component);
Expand Down
1 change: 1 addition & 0 deletions crates/ui-egui/src/command_help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::i18n;
/// The commands that have help text. Each one needs a `help.<id>` message in the catalogs.
pub const DOCUMENTED: &[&str] = &[
"appearance.assign",
"component.finish_edit",
"face.delete",
"material.assign",
"parameters.change",
Expand Down
8 changes: 8 additions & 0 deletions crates/ui-egui/src/context_menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ fn occurrence_items(app: &SolveApp, path: &[u64]) -> Vec<Item> {
item.params = Some(json!({"component": placement.component, "occurrence": placement.occurrence, "path": path}));
item.enabled = app.session.active_occurrence_path.as_deref() != Some(path);
}
"ui.editInPlace" => item.params = Some(json!({"component": placement.component, "path": path})),
"occurrence.ground" => {
item.label = if placement.grounded { "Unground" } else { "Ground" }.into();
item.params = Some(json!({"occurrence": placement.occurrence, "grounded": !placement.grounded}));
Expand Down Expand Up @@ -892,6 +893,7 @@ fn component_items(app: &SolveApp, id: u64) -> Vec<Item> {
let oid = occ.map(|o| o.id).unwrap_or(0);
v.push(act("ui.activate", "Activate", "component").with(json!({ "component": id })).on(!active));
if doc.links.contains_key(&id) {
v.push(act("ui.editInPlace", "Edit in Place", "edit").with(json!({ "component": id })));
v.push(act("ui.openLinkedDesign", "Open Linked Design", "open").with(json!({ "component": id })));
}
v.push(cmd(app, "occurrence.ground", if grounded { "Unground" } else { "Ground" }).with(json!({ "occurrence": oid, "grounded": !grounded })));
Expand Down Expand Up @@ -1423,6 +1425,12 @@ pub fn run_item(app: &mut SolveApp, item: &Item, at: Pos2) {
let _ = app.run("component.activate", p);
}
}
"ui.editInPlace" => {
if let Some(component) = id_of(&p, "component") {
let path = p["path"].as_array().map(|path| path.iter().filter_map(Value::as_u64).collect());
crate::edit_in_place::open(app, component, path);
}
}
"ui.openLinkedDesign" => {
let Some(component) = id_of(&p, "component") else { return };
let links = match app.session.execute("component.links", &json!({})) {
Expand Down
Loading
Loading