EmilySun621 opened a new issue, #5165: URL: https://github.com/apache/texera/issues/5165
### Feature Summary During the hackathon I prototyped Workflow Snippets: reusable operator groups that users can drag onto the canvas as a bundle. (Reference: PR #5117) Users frequently rebuild the same operator chains from scratch — CSV File Scan → Filter → Remove Duplicates for data cleaning, Train/Test Split → Logistic Regression → **Sklearn** Testing for classification. There's no way to save a group of connected operators as a reusable template. Workflow Snippets lets users save and reuse common operator bundles. Instead of dragging operators one by one and connecting them manually, users drag one snippet onto the canvas and get a fully connected operator chain in a single action. This is a UI-level feature: each operator in the snippet stays independent on the canvas (unlike Macro Operators #5115, which merge operators into a single engine-level node). Snippets and Macros solve different problems and coexist naturally. Reference prototype: PR #5117 ### Proposed Solution or Design ### What is a snippet? A snippet is a small piece of workflow JSON, the same format as `workflow.content`, just containing **a few operators and their links** instead of an entire workflow. --- ### How to create a snippet? **Path 1 : From the canvas:** > Select 2+ connected operators → right-click → **"Save as Snippet"** → enter a name → saved. > Reuses the existing `OperatorMenuService.copyOperator()` serialization format. **Path 2 : From a dedicated Snippets page:** > Sidebar → Your Work → **Snippets** → "+ Create Snippet" → pick operators from the catalog → arrange in order → save. > This lets users build snippets **without having a workflow open**. --- ### How to use a snippet? The operator panel gets a new **"Snippets"** section at the bottom, listing saved snippets. Drag a snippet onto the canvas: 1. System creates all operators with **fresh IDs** (reusing `assignNewOperatorIds()`) 2. Connects them automatically 3. Wrapped in one **undo/redo** action via `WorkflowActionService.addOperatorsAndLinks()` --- ### How to store? New `workflow_snippet` + `snippet_user_access` tables, following the existing `workflow` / `workflow_user_access` pattern. Backend CRUD via a new `SnippetResource` mirroring `WorkflowResource`. ### How to share? Toggle a snippet as **"public"** → other users can browse and use it. --- ### Suggested PR breakdown 1. Database tables + backend CRUD (`SnippetResource`) 2. Snippets page: create and manage snippets 3. Snippets section in operator panel + drag-to-canvas 4. Right-click "Save as Snippet" from canvas --- demo purpose: <img width="1136" height="467" alt="Image" src="https://github.com/user-attachments/assets/7ca641df-c565-49de-be2c-0ac977ab8cac" /> **Would appreciate feedback on this one.** ### Affected Area Workflow UI -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
