forked from 1b-agent/opencadstudio-upstream
fix(plugin): drive headless tasks, invalidate layer cache, and handle cancel event
This commit is contained in:
1 parent
bc6ad1a5fe
commit
270b6102de
10 files changed
+208
-20
No files matched your search
@@ -419,7 +419,12 @@ impl HostApi for PluginHostApi {
|
||||
|
||||
fn add_layer(&mut self, config: crate::host::LayerConfig) -> Option<Handle> {
|
||||
match self.client.request(PluginRequest::AddLayer(config)) {
|
||||
Ok(PluginResponse::OptHandle(h)) => h,
|
||||
Ok(PluginResponse::OptHandle(h)) => {
|
||||
if h.is_some() {
|
||||
self.document_cache = OnceCell::new();
|
||||
}
|
||||
h
|
||||
}
|
||||
Ok(other) => {
|
||||
eprintln!("[plugin] unexpected AddLayer response: {other:?}");
|
||||
None
|
||||
@@ -433,7 +438,12 @@ impl HostApi for PluginHostApi {
|
||||
|
||||
fn modify_layer(&mut self, config: crate::host::LayerConfig) -> bool {
|
||||
match self.client.request(PluginRequest::ModifyLayer(config)) {
|
||||
Ok(PluginResponse::Bool(b)) => b,
|
||||
Ok(PluginResponse::Bool(b)) => {
|
||||
if b {
|
||||
self.document_cache = OnceCell::new();
|
||||
}
|
||||
b
|
||||
}
|
||||
Ok(other) => {
|
||||
eprintln!("[plugin] unexpected ModifyLayer response: {other:?}");
|
||||
false
|
||||
|
||||
@@ -27,9 +27,14 @@ pub use acadrust::{CadDocument, EntityType, Handle};
|
||||
/// Events the host forwards to an active plugin `InteractiveCommand`.
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub enum InteractiveEvent {
|
||||
/// User clicked or specified a point coordinate.
|
||||
Point([f64; 3]),
|
||||
/// User pressed Enter or Return to complete input.
|
||||
Enter,
|
||||
/// User selected an existing entity in the drawing.
|
||||
ObjectPick { handle: Handle, pt: [f64; 3] },
|
||||
/// User cancelled the prompt (e.g. pressed ESC), resetting interactive collection.
|
||||
Cancel,
|
||||
}
|
||||
|
||||
/// Initial handshake sent by the plugin runner immediately after connecting.
|
||||
|
||||
@@ -733,7 +733,12 @@ impl HostApi for V4PluginHostApi {
|
||||
|
||||
fn add_layer(&mut self, config: crate::host::LayerConfig) -> Option<Handle> {
|
||||
match self.request(PluginRequest::AddLayer(config)) {
|
||||
Ok(PluginResponse::OptHandle(h)) => h,
|
||||
Ok(PluginResponse::OptHandle(h)) => {
|
||||
if h.is_some() {
|
||||
self.document_cache = OnceCell::new();
|
||||
}
|
||||
h
|
||||
}
|
||||
Ok(other) => {
|
||||
eprintln!("[plugin] unexpected AddLayer response: {other:?}");
|
||||
None
|
||||
@@ -747,7 +752,12 @@ impl HostApi for V4PluginHostApi {
|
||||
|
||||
fn modify_layer(&mut self, config: crate::host::LayerConfig) -> bool {
|
||||
match self.request(PluginRequest::ModifyLayer(config)) {
|
||||
Ok(PluginResponse::Bool(b)) => b,
|
||||
Ok(PluginResponse::Bool(b)) => {
|
||||
if b {
|
||||
self.document_cache = OnceCell::new();
|
||||
}
|
||||
b
|
||||
}
|
||||
Ok(other) => {
|
||||
eprintln!("[plugin] unexpected ModifyLayer response: {other:?}");
|
||||
false
|
||||
|
||||
Reference in new issue
Block a user