forked from 1b-agent/opencadstudio-upstream
Merge pull request #1423 from felixriestra:pr/python-host-model
The bundled `opencad.python` plugin drives OCS through plugin API v7: all 43 canvas entity kinds, the drawing tables, and OCS's own commands run step by step. RustPython stays in the plugin process — the plugin crate is outside the workspace with its own lock file, so the application's own dependencies are unchanged. Reconciled with the plugin command work that landed as #1425, which the branch was written before: - Both added `impl Drop for PluginProcessInteractiveAdapter`, which git merges silently into two impls that do not compile. One body now cancels the command and then drops it from the runner, in that order: a plugin waiting on a step has to be released before the runner forgets the command. - `execute_command` (#1425) and `run_command` (#1423) are both routes from a script to the command line, and only the second was guarded. The SCRIPTCOMMANDS switch and the denylist are shared now, so neither route is the unguarded one. - `run_command` dispatched with plugin dispatch still enabled, so a script naming a plugin command re-entered the plugin that was blocked waiting for it. It sets the suppression flag for the length of the dispatch, as `execute_command` does. The denylist read the command as typed, while the dispatcher resolves aliases: a user-defined `Q` for `QUIT` (ALIASEDIT writes those) walked past it. It resolves the alias first. Also: the active-command comparison ran on every message, a mouse move included, allocating two strings for names that are already `&'static str`; SCRIPTCOMMANDS' own messages go through the translation macros; and `docs/.DS_Store` (now ignored) and an unrelated RTF note about constraint commands are out of the tree. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
commit
41ecc0c458
72 files changed
+30614
-91
No files matched your search
@@ -283,6 +283,8 @@ impl OpenCADStudio {
|
||||
// selection check has to run on this path too.
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
self.notify_plugins_selection_changed();
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
self.notify_plugins_document_changed();
|
||||
res
|
||||
}
|
||||
|
||||
@@ -767,6 +769,46 @@ impl OpenCADStudio {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
#[test]
|
||||
fn clayer_command_sets_layer_used_by_new_geometry() {
|
||||
let mut app = super::OpenCADStudio::new_for_test();
|
||||
app.automation_op(r#"{"op":"new"}"#);
|
||||
app.automation_op(r#"{"op":"run","cmd":"LAYER NEW Annotations"}"#);
|
||||
app.automation_op(r#"{"op":"run","cmd":"CLAYER Annotations"}"#);
|
||||
app.automation_op(r#"{"op":"run","cmd":"LINE 0,0 10,0"}"#);
|
||||
let lines = app.automation_op(r#"{"op":"query","type":"Line"}"#);
|
||||
assert_eq!(lines["entities"][0]["layer"], "Annotations");
|
||||
}
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[test]
|
||||
fn built_in_edits_advance_plugin_document_fingerprint_once() {
|
||||
let mut app = super::OpenCADStudio::new_for_test();
|
||||
app.automation_op(r#"{"op":"new"}"#);
|
||||
let before = app.last_plugin_document.expect("new drawing published");
|
||||
app.automation_op(r#"{"op":"run","cmd":"LINE 0,0 10,0"}"#);
|
||||
let after = app.last_plugin_document.expect("line edit published");
|
||||
assert_eq!(after.0, app.tabs[app.active_tab].id);
|
||||
assert_ne!(after, before);
|
||||
assert_eq!(after.1, app.tabs[app.active_tab].scene.geometry_epoch);
|
||||
app.automation_op(r#"{"op":"query","type":"Line"}"#);
|
||||
assert_eq!(app.last_plugin_document, Some(after));
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
#[test]
|
||||
fn plugin_edit_publication_is_not_repeated_at_message_boundary() {
|
||||
use acadrust::entities::Point;
|
||||
use acadrust::EntityType;
|
||||
|
||||
let mut app = super::OpenCADStudio::new_for_test();
|
||||
app.automation_op(r#"{"op":"new"}"#);
|
||||
let tab = app.active_tab;
|
||||
let mut host = super::super::plugin_host::HostSession::new(&mut app, tab);
|
||||
host.add_entity(EntityType::Point(Point::new()));
|
||||
let published = app.last_plugin_document.expect("plugin write published");
|
||||
app.notify_plugins_document_changed();
|
||||
assert_eq!(app.last_plugin_document, Some(published));
|
||||
}
|
||||
use crate::app::OpenCADStudio;
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user