Skip to content

Conversation

Justineo
Copy link
Member

@Justineo Justineo commented Oct 9, 2025

Summary

KM-1668

Schema & types

schema/strict.ts, schema/compat.ts, types.ts

  • Branch node schema, BranchName enum, and branch key constants allow configs to express then/else targets.
  • DatakitUIData now carries groups, with supporting GroupId, GroupInstance, and helper types used downstream.

Editor state

store/branch-group-manager.ts, store/store.ts, store/flow.ts

  • createBranchGroupManager encapsulates branch membership validation, conflict resolution, cycle checks, and history commitments.
  • The main store synchronizes node/config updates with branch groups, keeps groupPositions, and serializes/deserializes DatakitUIData.groups.
  • Flow runtime consumes branch data (via useBranchLayout) to emit group nodes and edges, while node removal/rename hooks clean up memberships.

Branch layout

composables/useBranchLayout.ts, FlowCanvas.vue, node/GroupNode.vue, FlowNode.vue

  • useBranchLayout projects store state into Vue Flow: computes group nodes, branch edges, z-index, and responds to drag interactions.
  • FlowCanvas registers the new GroupNode type
  • FlowNode renders read-only branch handles

Branch form

node-forms/NodeFormBranch.vue, composables/useBranchNodeForm.ts

  • useBranchNodeForm (branched from generic node form) handles multiselect defaults, membership updates, conflict prompts, and toast errors
  • NodeFormBranch delegates to the composable, using EnumField for then/else selections

Visual

node/node-visual.ts, node/NodeBadge.vue, node/NodePanelItem.vue

  • Centralized visuals (icon/color tokens) ensure branch nodes look distinct across panel, badge, and canvas.

@Justineo Justineo requested review from a team as code owners October 9, 2025 10:34
@Justineo Justineo requested a review from Copilot October 10, 2025 02:39
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces branch node support for the Datakit flow editor, enabling conditional execution through "then/else" logic. The implementation adds comprehensive schema definitions, UI components, state management, and visual elements for branch nodes.

  • Adds branch node schema with then/else fields and visual components for the flow editor
  • Implements branch group management with membership validation and cycle detection
  • Creates specialized form components and layout composables for branch node interaction

Reviewed Changes

Copilot reviewed 25 out of 25 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
packages/entities/entities-plugins/src/locales/en.json Updates localization strings for branch nodes and conflict resolution
packages/entities/entities-plugins/src/components/free-form/Datakit/types.ts Extends type definitions with branch-related interfaces and group management types
packages/entities/entities-plugins/src/components/free-form/Datakit/schema/strict.ts Adds BranchNode schema and branch name enum definitions
packages/entities/entities-plugins/src/components/free-form/Datakit/schema/compat.ts Implements compatible branch node schema with loose validation
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/store.ts Integrates branch group management into the main editor store
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/init.ts Handles initialization of branch groups from configuration data
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/history.ts Exports TaggedHistory type for branch group manager
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/helpers.ts Adds utility functions for branch group management and ID generation
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/flow.ts Integrates branch layout composable and updates flow rendering logic
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/store/branch-group-manager.ts Creates comprehensive branch group management system
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/node.ts Updates node metadata to use centralized visual system
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/node-visual.ts Centralizes visual styling definitions for all node types
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/NodePropertiesPanel.vue Registers branch form component in the properties panel
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/NodePanelItem.vue Updates panel item to use centralized visual styling
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/NodeBadge.vue Refactors badge component to use centralized visual system
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/GroupNode.vue Creates new group node component for branch visualization
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node/FlowNode.vue Adds branch handle rendering support to flow nodes
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node-forms/NodeFormCall.vue Removes trailing whitespace
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node-forms/NodeFormBranch.vue Creates specialized form component for branch node configuration
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/node-forms/InputsField.vue Conditionally renders input field sections
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/composables/useBranchNodeForm.ts Implements branch-specific form logic with conflict resolution
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/composables/useBranchLayout.ts Creates comprehensive branch layout management system
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/FlowEditor.vue Updates editor to handle new UI data structure
packages/entities/entities-plugins/src/components/free-form/Datakit/flow-editor/FlowCanvas.vue Registers group node component and handles group node interactions
packages/entities/entities-plugins/src/components/free-form/Datakit/constants.ts Adds constants for branch group layout and z-index management

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@2eha0
Copy link
Contributor

2eha0 commented Oct 10, 2025

q: Should we guard this change by M2 FF?

@kongponents-bot
Copy link
Collaborator

Preview components from this PR in consuming application

In consuming application project install preview versions of shared packages generated by this PR:

@kong-ui-public/entities-plugins@pr-2544

Copy link
Member

@sumimakito sumimakito left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The rest of the PR generally looks good for this new node type.

Comment on lines +188 to +191
export interface NodeDimensions {
width: number
height: number
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Because we are already using XYPosition from @vue-flow/core, maybe we can also try importing Dimensions from there.

// @vue-flow/core

export interface Dimensions {
  width: number
  height: number
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants