Skip to content

fix(thumbnail): translate subflow block nodes#114

Merged
crimx merged 1 commit intomainfrom
loud-eel
Jan 8, 2026
Merged

fix(thumbnail): translate subflow block nodes#114
crimx merged 1 commit intomainfrom
loud-eel

Conversation

@hyrious
Copy link
Contributor

@hyrious hyrious commented Jan 8, 2026

业务上 block doc 会读这些 nodes 生成 slot 文档,但是云函数并不能传 slot(可以从 UI 上过滤掉),所以影响不大。

@hyrious hyrious requested review from BlackHole1, crimx and l1shen January 8, 2026 03:06
@coderabbitai
Copy link

coderabbitai bot commented Jan 8, 2026

Summary by CodeRabbit

  • Refactor
    • Updated internal thumbnail data structures and processing for improved consistency and maintainability in block rendering.

✏️ Tip: You can customize this high-level summary in your review settings.

Walkthrough

This pull request modifies the thumbnail utility to introduce stricter typing for node collections. The public BlockThumbnail interface's nodes property type is changed from Node[] to NodeThumbnail[]. To support this, subflow thumbnail generation now uses an asynchronous _getNodesThumbnail() helper function that converts raw nodes to the new type. A new private helper function aggregates individual node thumbnail conversions, while existing _getNodeThumbnail() logic for single-node transformation remains unchanged.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • BlackHole1
  • l1shen
🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title follows the required format <type>(<scope>): <subject> with 'fix' as type and 'thumbnail' as scope, and clearly describes the main change of translating/transforming subflow block nodes.
Description check ✅ Passed The description is in Chinese and discusses how block documentation reads nodes to generate slot documentation, relating to the technical changes in the PR about node transformation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
src/utils/thumbnail.ts (1)

380-392: LGTM! Clean extraction of node transformation logic.

The helper function correctly transforms raw nodes into NodeThumbnail[], with proper handling of edge cases.

♻️ Optional: Consider refactoring `_getFlowThumbnail` to use this helper

The logic in _getFlowThumbnail (lines 361-369) duplicates this helper's functionality. You could reduce duplication:

 private async _getFlowThumbnail(flowData: FlowLikeData): Promise<FlowThumbnail | undefined> {
-    const nodes: NodeThumbnail[] = [];
-    for (const nodeManifest of flowData.data.nodes || []) {
-        if (nodeManifest?.node_id) {
-            const node = await this._getNodeThumbnail(nodeManifest, flowData);
-            if (node) {
-                nodes.push(node);
-            }
-        }
-    }
+    const nodes = await this._getNodesThumbnail(flowData.data.nodes, flowData);
     return {
         name: flowData.manifestName,
         title: this.wsPkgData.localize(flowData.title),

Note: _getFlowThumbnail has an additional nodeManifest?.node_id check that _getNodesThumbnail doesn't have. You'd need to verify whether that check is necessary or if it's redundant.

📜 Review details

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 0d849a1 and 7eeacfe.

📒 Files selected for processing (1)
  • src/utils/thumbnail.ts
🔇 Additional comments (2)
src/utils/thumbnail.ts (2)

314-314: LGTM! Properly transforms subflow nodes.

The change correctly uses the new helper function to transform raw nodes into NodeThumbnail[], fixing the bug where subflow block nodes weren't being translated like flow nodes were.


32-32: Good type alignment with FlowThumbnail.

This change makes BlockThumbnail.nodes consistent with FlowThumbnail.nodes (line 18), ensuring both use NodeThumbnail[] instead of raw Node[]. This properly transforms subflow block nodes via the new _getNodesThumbnail helper (line 314).

@crimx crimx merged commit 6223572 into main Jan 8, 2026
2 checks passed
@crimx crimx deleted the loud-eel branch January 8, 2026 03:11
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.

2 participants