Skip to main content

jellyflow_runtime/runtime/events/
connection.rs

1use serde::{Deserialize, Serialize};
2
3use crate::rules::EdgeEndpoint;
4use jellyflow_core::core::{EdgeId, PortId};
5use jellyflow_core::interaction::NodeGraphConnectionMode;
6
7/// Connection start kind (UI-driven).
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
9#[serde(tag = "kind", rename_all = "snake_case")]
10pub enum ConnectDragKind {
11    New {
12        from: PortId,
13        bundle: Vec<PortId>,
14    },
15    Reconnect {
16        edge: EdgeId,
17        endpoint: EdgeEndpoint,
18        fixed: PortId,
19    },
20    ReconnectMany {
21        edges: Vec<(EdgeId, EdgeEndpoint, PortId)>,
22    },
23}
24
25#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
26pub struct ConnectStart {
27    pub kind: ConnectDragKind,
28    pub mode: NodeGraphConnectionMode,
29}
30
31#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
32#[serde(rename_all = "snake_case")]
33pub enum ConnectEndOutcome {
34    /// A graph transaction was committed.
35    Committed,
36    /// A target was chosen but the connect plan was rejected.
37    Rejected,
38    /// The workflow opened a conversion picker (domain-specific UX).
39    OpenConversionPicker,
40    /// The workflow opened an insert-node picker (drop on empty background).
41    OpenInsertNodePicker,
42    /// The gesture was canceled (escape, focus lost, etc.).
43    Canceled,
44    /// Gesture ended without committing or opening a picker.
45    NoOp,
46}
47
48#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
49pub struct ConnectEnd {
50    pub kind: ConnectDragKind,
51    pub mode: NodeGraphConnectionMode,
52    pub target: Option<PortId>,
53    pub outcome: ConnectEndOutcome,
54}