Title: fix(workflow): stop subflows resizing themselves after every load by waleedlatif1 · Pull Request #6639 · simstudioai/sim · GitHub
Open Graph Title: fix(workflow): stop subflows resizing themselves after every load by waleedlatif1 · Pull Request #6639 · simstudioai/sim
X Title: fix(workflow): stop subflows resizing themselves after every load by waleedlatif1 · Pull Request #6639 · simstudioai/sim
Description: Summary A subflow renders at one size on load and then visibly grows a moment later, on every refresh. The container sizes itself from its children. When a child had not yet reported a height it used estimateBlockDimensions instead — a guess of ceil(subBlockCount / 2) rows clamped to [3,7], which reads a 39-field Gmail card as 276px tall against the 112px it actually draws. The container painted that, the real height arrived a frame later, and it resized between the two. A card's height depends on what it actually renders — which rows survive its conditions, whether it draws a summary sentence, and for a reactive field even a credential it has to fetch (useReactiveConditions → useWorkspaceCredential). The card is the only thing that can know it. So: size only from heights children have themselves reported, and hold the container at its current size until they have. getBlockDimensions keeps the estimate for callers that only need a rough box (clamping a drag, placing a paste) and is now that same lookup plus the fallback, rather than a second copy of the policy. The gate reads layout (in-memory, written by updateBlockLayoutMetrics for cards and updateNodeDimensions for containers), not height/data.height. Those are persisted, so an unreported block can still carry last session's numbers and an unsized inner container hands back its 500x300 default — both of which the gate would otherwise treat as measured, and the second of which made nested containers resize twice. Separately, calculateContainerDimensions counted the container's chrome twice. Child coordinates are relative to the container's own origin and already held clear of the header by clampPositionToContainer, so a child's far edge is the distance to cover and only the trailing padding is owed. Adding the header and leading padding again left every container 66px taller and 16px wider than its contents. For the reported workflow, the Loop went 300 → 565.5 → 401.5 on load. It now settles once, at 603 × 335.5 — the child's far edge plus exactly one padding. Type of Change Bug fix Testing New unit tests pin the sizing contract; two of them fail on the old math (expected { width: 619, height: 401.5 } to deeply equal { width: 603, height: 335.5 }, and expected 82 to be 16 for the gap under a child). Full utils suite green (62), type-check and lint clean. The two sizes were derived by running the real functions against the exported workflow state, and cross-checked against the reported screenshots: scaling both by the Gmail card's known 112px height (both at 0.58) gives container heights of ~412 and ~579 against the computed 401.5 and 565.5, with the child's offset staying ~207.5 in both. That also confirms the coordinate convention the padding fix depends on — children are positioned from the container's outer origin. Not verified in the running app. I brought up dev:full but could not sign in to the local instance, so this is verified by unit test and arithmetic only. Follow-ups (not in this PR) MCP blocks on the field-row path still resize once. estimateWorkflowBlockDimensions is exact on the sentence path but deliberately biased high on the field-row path, because a mcp-dynamic-args field expands into one row per schema property when the card mounts. The bias is correct for autolayout (a gap beats an overlap) but still moves a container. It is fixable — contrary to that function's doc, the count is derivable from block state, since _toolSchema is an ordinary subblock value — but removing the slack changes autolayout spacing, so it wants its own change. estimateWorkflowBlockDimensions (lib/workflows/autolayout/utils.ts) already estimates from block state rather than type alone, and is far more accurate than estimateBlockDimensions. Routing the remaining estimate callers through it would fix the guess everywhere it is still painted (workflow.tsx:2747 feeds it into React Flow node height, so selection bounds are 276px on a 112px card). preview-workflow.tsx re-implements calculateContainerDimensions — and already uses the corrected formula, independent corroboration that the double-count was a bug. getNodeAbsolutePosition hardcodes headerHeight = 50 / leftPadding = 16 / topPadding = 16 and adds them to a child's position, which contradicts the outer-origin convention the rest of the code uses. It looks like a latent bug for nested containers, but it feeds reparenting math and deserves its own verification. Containers still resize once per load, monotonically. Correcting my own commit message: block.height and container data.width/data.height are persisted — what is missing is the write-back. updateNodeDimensions is a raw store action with no collaborative sync, and the realtime subflow-config handler re-floors data to 500x300, so a container paints the default on load and grows once when its children report. A tall loop still visibly grows from 300px each refresh. Removing that frame means writing the derived size back, which is a bigger change than this one. updateContainerDimensionsDuringMove (the drag path) still feeds calculateContainerDimensions estimates. Plausibly correct — a best-effort box while dragging — but it duplicates the gather loop. Checklist Code follows project style guidelines Self-reviewed my changes Tests added/updated and passing No new warnings introduced I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)
Open Graph Description: Summary A subflow renders at one size on load and then visibly grows a moment later, on every refresh. The container sizes itself from its children. When a child had not yet reported a height it u...
X Description: Summary A subflow renders at one size on load and then visibly grows a moment later, on every refresh. The container sizes itself from its children. When a child had not yet reported a height it u...
Opengraph URL: https://github.com/simstudioai/sim/pull/6639
X: @github
Domain: github.com
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react-reconciler,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@d5750093facf |
| route-pattern | /:user_id/:repository/pull/:id/files(.:format) |
| route-controller | pull_requests |
| route-action | files |
| fetch-nonce | v2:7937831d-aadd-4bf1-a6fe-f4d8f0a6ea0d |
| current-catalog-service-hash | ae870bc5e265a340912cde392f23dad3671a0a881730ffdadd82f2f57d81641b |
| request-id | C0A2:EE197:B120A8:F2B8CD:6AFB5260 |
| html-safe-nonce | 69f21a13f81e392c0a75cc6f697083eb459535aba7894ed67e7ed0c6c3fc7948 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMEEyOkVFMTk3OkIxMjBBODpGMkI4Q0Q6NkFGQjUyNjAiLCJ2aXNpdG9yX2lkIjoiMTE0MTI3MjE0MjA1MDcxMDExMiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c26997ac3400d47b882e21844503f5101a1589c926a6fe3d058e13b97b66de08 |
| hovercard-subject-tag | pull_request:4265463866 |
| github-keyboard-shortcuts | repository,pull-request-list,pull-request-conversation,pull-request-files-changed,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/simstudioai/sim/pull/6639/files |
| twitter:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| twitter:card | summary_large_image |
| og:image | https://avatars.githubusercontent.com/u/40672544?s=400&v=4 |
| og:image:alt | Summary A subflow renders at one size on load and then visibly grows a moment later, on every refresh. The container sizes itself from its children. When a child had not yet reported a height it u... |
| og:site_name | GitHub |
| og:type | object |
| hostname | github.com |
| expected-hostname | github.com |
| None | 7122bb414b542dba14d71a3f0b9f6fd2abce715b9f5912d082800563e6c806d1 |
| turbo-cache-control | no-preview |
| diff-view | unified |
| go-import | github.com/simstudioai/sim git https://github.com/simstudioai/sim.git |
| octolytics-dimension-user_id | 199344406 |
| octolytics-dimension-user_login | simstudioai |
| octolytics-dimension-repository_id | 912559512 |
| octolytics-dimension-repository_nwo | simstudioai/sim |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 912559512 |
| octolytics-dimension-repository_network_root_nwo | simstudioai/sim |
| turbo-body-classes | logged-out env-production page-responsive full-width |
| disable-turbo | true |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | cbf66c024bb6d10e6955baa7413c54cf13a201bb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width