fix(free-layout-core): recompute line path when version unchanged but path is empty - #1147
Open
zyh94946 wants to merge 1 commit into
Open
fix(free-layout-core): recompute line path when version unchanged but path is empty#1147zyh94946 wants to merge 1 commit into
zyh94946 wants to merge 1 commit into
Conversation
… path is empty WorkflowLineRenderData.update() skips recomputation when the position version is unchanged. However, when a line entity is created before its line contribution (bezier/fold/straight, registered by free-lines-plugin onReady) is available, the first update() sets the version to the real coordinates while currentLine is still undefined, so the computed path stays empty. Once the contribution becomes available the version is already up to date, so the guard permanently skips recomputation and the path remains empty - the line never renders. This reproduces the initial-load-only failure described in bytedance#1070 (lines fail to render after fromJSON; drag-and-drop and manual connections are unaffected). Fix: only skip recomputation when the version is unchanged AND a path has already been computed. A line whose path is still empty is recomputed once its contribution becomes available. Lines with a non-empty path are unaffected, preserving the original performance optimization. Refs bytedance#1070
zyh94946
requested review from
YuanHeDx,
dragooncjw,
louisyoungx,
luics,
sanmaopep and
xiamidaxia
as code owners
June 26, 2026 18:17
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
In the free layout editor, some connection lines fail to render (their SVG
pathstays empty) after loading a graph via
fromJSON. It only happens on initial load —dragging nodes or creating connections manually works fine. Same problem as #1070.
Root cause
WorkflowLineRenderData.update()skips recomputation when the positionversionisunchanged (a performance optimization), and
pathcomes from the line contribution:get path() { return this.currentLine?.path ?? ''; }.When a line entity is created before its line contribution (bezier/fold/straight,
registered by
free-lines-plugininonReady) is available:update()writes the real coordinates intoversion, butcurrentLineis still
undefined, sopathis left empty.versionequals the stored one.oldVersion === newVersionis true, the guard returns early,currentLine.update()is never called, and the empty
pathis locked in permanently — the line neverrenders.
This matches #1070's observation that it's specific to initial
fromJSONloading(manual drag/connect happens after contributions are registered).
Fix
Skip recomputation only when the version is unchanged and a path has already been
computed:
A line whose
pathis still empty is recomputed once its contribution becomesavailable. Lines that already have a non-empty
pathare unaffected, preserving theoriginal optimization.
Testing
Added
__tests__/workflow-line-render-data.test.ts:fails without the fix (
pathstays''), passes with the fix.update()on a line that already has a path is a no-op.rush build --to @flowgram.ai/free-layout-coresucceeds; free-layout-core tests allpass (86 cases, incl. the 2 new ones).
Refs #1070