Commit a4d979e
[feat] Implement media asset workflow actions with shared utilities (#6696)
## Summary
Implements 4 missing media asset workflow features and creates shared
utilities to eliminate code duplication.
## Implemented Features
### 1. Copy Job ID ✅
- Properly extracts promptId using `getOutputAssetMetadata`
- Uses `useCopyToClipboard` composable
### 2. Add to Current Workflow ✅
- Adds LoadImage/LoadVideo/LoadAudio nodes to canvas
- Supports all media file types (JPEG, PNG, MP4, etc.)
- Auto-detects appropriate node type using `detectNodeTypeFromFilename`
utility
### 3. Open Workflow in New Tab ✅
- Extracts workflow from asset metadata or embedded PNG
- Opens workflow in new tab
### 4. Export Workflow ✅
- Exports workflow as JSON file
- Supports optional filename prompt
## Code Refactoring
### Created Shared Utilities:
1. **`assetTypeUtil.ts`** - `getAssetType()` function eliminates 6
instances of `asset.tags?.[0] || 'output'`
2. **`assetUrlUtil.ts`** - `getAssetUrl()` function consolidates 3 URL
construction patterns
3. **`workflowActionsService.ts`** - Shared service for workflow
export/open operations
4. **`workflowExtractionUtil.ts`** - Extract workflows from jobs/assets
5. **`loaderNodeUtil.ts`** - Detect loader node types from filenames
### Improvements to Existing Code:
- Refactored to use `formatUtil.getMediaTypeFromFilename()`
- Extracted `deleteAssetApi()` helper to reduce deletion logic
duplication (~40 lines)
- Moved `isResultItemType` type guard to shared `typeGuardUtil.ts`
- Added 9 i18n strings for proper localization
- Added `@comfyorg/shared-frontend-utils` dependency
## Input Assets Support
Improved input assets to support workflow features where applicable:
- ✅ All media files (JPEG/PNG/MP4, etc.) → "Add to current workflow"
enabled
- ✅ PNG/WEBP/FLAC with embedded metadata → "Open/Export workflow"
enabled
## Impact
- **~150+ lines** of duplicate code eliminated
- **5 new utility files** created to improve code reusability
- **11 files** changed, **483 insertions**, **234 deletions**
## Testing
✅ TypeScript typecheck passed
✅ ESLint passed
✅ Knip passed
🤖 Generated with [Claude Code](https://claude.com/claude-code)
┆Issue is synchronized with this [Notion
page](https://www.notion.so/PR-6696-feat-Implement-media-asset-workflow-actions-with-shared-utilities-2ab6d73d365081fb8ae9d71ce6e38589)
by [Unito](https://www.unito.io)
---------
Co-authored-by: Claude <[email protected]>
Co-authored-by: GitHub Action <[email protected]>1 parent 2f81e5b commit a4d979e
File tree
12 files changed
+632
-123
lines changed- src
- locales/en
- platform
- assets
- components
- composables
- utils
- workflow
- core/services
- utils
- utils
12 files changed
+632
-123
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
131 | 131 | | |
132 | 132 | | |
133 | 133 | | |
| 134 | + | |
134 | 135 | | |
135 | 136 | | |
136 | 137 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2036 | 2036 | | |
2037 | 2037 | | |
2038 | 2038 | | |
2039 | | - | |
2040 | | - | |
| 2039 | + | |
| 2040 | + | |
| 2041 | + | |
| 2042 | + | |
| 2043 | + | |
| 2044 | + | |
| 2045 | + | |
| 2046 | + | |
| 2047 | + | |
| 2048 | + | |
| 2049 | + | |
| 2050 | + | |
2041 | 2051 | | |
2042 | 2052 | | |
2043 | 2053 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
37 | 37 | | |
38 | 38 | | |
39 | 39 | | |
40 | | - | |
41 | 40 | | |
42 | 41 | | |
43 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
3 | 6 | | |
4 | 7 | | |
5 | 8 | | |
| |||
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
15 | | - | |
| 18 | + | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
| |||
28 | 31 | | |
29 | 32 | | |
30 | 33 | | |
31 | | - | |
| 34 | + | |
32 | 35 | | |
33 | 36 | | |
34 | | - | |
| 37 | + | |
35 | 38 | | |
36 | 39 | | |
37 | 40 | | |
| |||
42 | 45 | | |
43 | 46 | | |
44 | 47 | | |
45 | | - | |
| 48 | + | |
46 | 49 | | |
47 | 50 | | |
48 | 51 | | |
| |||
52 | 55 | | |
53 | 56 | | |
54 | 57 | | |
55 | | - | |
| 58 | + | |
56 | 59 | | |
57 | 60 | | |
58 | 61 | | |
| |||
85 | 88 | | |
86 | 89 | | |
87 | 90 | | |
| 91 | + | |
| 92 | + | |
88 | 93 | | |
89 | 94 | | |
90 | 95 | | |
| |||
107 | 112 | | |
108 | 113 | | |
109 | 114 | | |
110 | | - | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
111 | 144 | | |
112 | 145 | | |
113 | 146 | | |
| |||
129 | 162 | | |
130 | 163 | | |
131 | 164 | | |
132 | | - | |
| 165 | + | |
133 | 166 | | |
134 | 167 | | |
135 | 168 | | |
| |||
143 | 176 | | |
144 | 177 | | |
145 | 178 | | |
146 | | - | |
| 179 | + | |
147 | 180 | | |
148 | 181 | | |
149 | 182 | | |
150 | 183 | | |
151 | 184 | | |
152 | 185 | | |
153 | | - | |
| 186 | + | |
154 | 187 | | |
155 | 188 | | |
156 | 189 | | |
| |||
0 commit comments