Making Workflow Node Resizing Usable: Iterative Fixes and Remaining Limitations

February 20, 2025

While working at PuppyAgent, I helped develop a SaaS application combining a React Flow workflow engine with retrieval-augmented generation (RAG). Resizing its nodes turned into a recurring piece of UI work. A node could contain an editor, a title, controls, and different content views; making its outer rectangle larger or smaller was only part of the problem.

I kept running into size problems. On January 7, I asked Cursor why the height kept increasing. On January 16, I asked for a width threshold because the width was growing too. We adjusted dimensions, offsets, and limits by hand until resizing worked well enough in most scenarios, but I never felt that we had arrived at a consistent layout model. A change that worked for one content view could still leave another view awkward to resize.

I also remember reading the React Flow and Monaco source code while trying to understand the problem. I no longer remember the specific findings well enough to explain them here.

These adjustments were a temporary compromise to get the MVP launched quickly. At the time, I wanted to eventually build our own core node and editor components, replacing Monaco with an editor tailored to the workflow product. I wanted more control over layout, resizing, and editing as we combined several open-source components. We did not implement that replacement, so I cannot say whether it would have solved these problems.

In my original js_tips_dev.md, I left myself three links: JSON indentation, ResizeObserver, and CSS drop-shadow(). For this expanded note, I went back through my commits and conversations with Cursor to describe what I was trying at the time. I still cannot account for every adjustment, but I can explain the problems behind several of them.

Note on dates: I kept the original note's creation and modification times. I revisited my Cursor history on November 16, 2026, while expanding this article. The January conversations and commits came before the February note; I also refer to code as it stood on March 3. Times below use UTC+8. My prompts do not have separate timestamps in these sessions, so the references identify the following assistant request time.

My conversations with Cursor about the growing dimensions

I had this conversation with Cursor on January 7 while working on JsonNode.tsx. My original prompt was:

why the height is ever increasing?

— My prompt to Cursor, January 7, 2025, around 17:12.1

Cursor suggested that I might have a feedback loop: ResizeObserver updates contentSize, React renders, the content dimensions change, and the observer fires again. It proposed comparing the measured dimensions with the previous state before returning a new object. Looking at that suggestion now, I would still want to measure the cycle before calling it a fix. If each render really changes the measured size, an equality check alone permits another update.

Nine days later, I asked Cursor for a more specific workaround:

set a dead zone for width that no change happen if change below certain px so that now bug for infinite grow of width

— My prompt to Cursor, January 16, around 20:22, with my original wording retained.2

I wanted small changes to stop feeding back into the width. Cursor suggested a widthThreshold of 10 pixels, while still allowing any height change to update state. In the code we later committed, the thresholds were 24px for width and 25px for height; a subsequent patch removed them.32 The values changed as we continued adjusting the component.

At that point, I was trying to stop the dimensions from growing on their own. I had not measured a performance improvement, and I do not have a controlled before-and-after test showing how well the threshold worked.

Following the size through the node

React Flow's NodeResizeControl provides a customizable resizing UI and accepts constraints such as minWidth and minHeight.4 Our application also had to fit the node's internal content into the resulting space.

When I trace the text node's sizing code, I get this sequence:

Drag the resize control
        ↓
Node and content-container dimensions change
        ↓
ResizeObserver reports the observed container's dimensions
        ↓
React state stores the measurements
        ↓
The embedded editor receives calculated width and height

The observer was a way to learn about an element's size changes. MDN describes its callback as:

The function called whenever an observed resize occurs.

— MDN contributors, “Parameters,” callback.5

In the March 3 source snapshot, TextBlockNode.tsx observed contentRef, stored entry.contentRect.width and height, and called disconnect() in its Effect cleanup. It passed contentSize.width - 16 and contentSize.height - 32 to the textarea editor.6

Those offsets belonged to our component's layout. I would not reuse them in another node without checking its box model. For an HTML element, contentRect describes the content box, so I need to distinguish padding and borders outside that measurement from controls that still consume space inside it.7

The JSON editor added another layer. JSONForm received dimensions from its parent, applied them to a wrapper, then passed widthStyle - 8 and heightStyle - 12 to Monaco. It also enabled automaticLayout.8 I still needed to follow the calculation through both components: Monaco's automatic layout could not tell me whether the dimensions I passed down were right.

Several patches, with changing assumptions

These are the changes and conversations I picked out while retracing the work:

Date (UTC+8)Commit and authorRelevant change
January 7, 2025My conversation with CursorI asked about continuously increasing height; Cursor proposed a resize/render feedback loop and an unchanged-size guard.1
January 16, 20252c91af9, S2thend (my account)Introduced HEIGHT_STD = 500, raised the JSON node's resize-control minimum height to that value, and added a lower bound to the editor-height calculation.9
January 16, 2025, around 20:22My conversation with CursorI requested a width dead zone to address infinite growth; Cursor proposed a 10px threshold.2
January 20, 202598f453f, realGuantumAdjusted node layout and label allowances; the text editor's height changed from contentSize.height to contentSize.height - 32.10
January 20, 202542a9cad, S2thendAdded two-space JSON indentation in the embedding view and changed the JSON node content container's top padding from 30px to 45px.11
January 21, 2025d61f1ff, realGuantumRemoved measurement-update thresholds, changed the JSON node's minimum-size constraints, and simplified editor dimensions to contentSize.width - 16 and contentSize.height - 68.3
January 21, 2025d8557c9, realGuantumChanged the text and JSON nodes' resize-control minimum height from 240 to 176.12

The last two changes remind me how many separate constraints we were adjusting. One patch changed several together; the next lowered the control's minimum height again. I had to think about the control's limit, the container's CSS minimum, and the editor's calculated size separately. Changing one did not automatically update the others.

The January 21 commit message says “fixed the node resizer bug.” I remember the broader work as less conclusive: we still needed adjustments afterward. We got the common interactions working, but I would not describe the layout problem as fully solved.

A threshold can leave a small change unapplied

Before d61f1ff, the JSON node's observer compared the latest measurements with stored state and updated only when either difference exceeded a threshold. The following is a shortened reconstruction of that condition, using the original values:3

const widthThreshold = 24;
const heightThreshold = 25;

if (
  Math.abs(previous.width - measured.width) > widthThreshold ||
  Math.abs(previous.height - measured.height) > heightThreshold
) {
  return measured;
}
return previous;

The original comment stated:

Prevent unnecessary updates by checking if size actually changed

The condition did more than skip identical measurements: it also skipped small differences. For example, a width change from 300 to 310 with no height change would retain the old state. Even a change of exactly 24px would not satisfy the width comparison. If dragging stopped there and neither dimension later crossed its threshold, this callback would leave the editor using an older measurement.

Reading this condition now, I can see how it could leave the editor using stale dimensions after a small drag. I cannot attribute every visual problem we had to it. We removed the thresholds and changed other layout constraints in the same patch, so I cannot separate their effects from that diff alone.

This connects to my note on React rendering and memoization. I would profile continuous measurement updates before trying to reduce them, because discarding small changes affects correctness too. My immediate reason for adding the threshold was to stop width growth; I had not demonstrated that it made rendering faster.

JSON indentation was part of the display work

I also saved this formatting example from MDN in my original note:

Indent the output with one space:

console.log(JSON.stringify({ a: 2 }, null, " "));

The space parameter controls whitespace in the serialized representation.13 I used it in commit 42a9cad, changing the embedding view from JSON.stringify(chunks) to JSON.stringify(chunks, null, 2); I have abbreviated the node-data lookup here.11

I wanted the JSON to be easier to read. My original prompt to Cursor was:

can you provide a function that takes in a json string then make it pretty with correct spaces and changeline

— My prompt to Cursor, January 20, 2025, around 16:20.14

I had attached JsonNode.tsx. Cursor suggested parsing the JSON string and then returning JSON.stringify(jsonObject, null, 2). I also changed the top padding in that day's commit, but my formatting request was about readability. I would not count indentation itself as a resize fix.

If I tested the layout again, I would include both compact and formatted JSON to see how each fits. I wrote separately about another issue in When a Workflow Textarea Shows Escaped Newlines: serializing ordinary text before putting it into an editor.

Why I was also looking at shadows

I am less certain why I saved the drop-shadow() link. I was changing shadows around the node and editor, although the patches I found used boxShadow or a Tailwind shadow-* utility:

  • In c2fc94f, I added boxShadow to JSON view-switch styling.15
  • In f58705a, I removed those declarations.16
  • In a866ea8, I removed the JSON editor wrapper's focus shadow, border styling, and transition classes.17

I cannot point to a resize repair where I actually used CSS drop-shadow(). I also need to keep the effects distinct: MDN explains that box-shadow follows an element's box, whereas drop-shadow() produces:

a shadow that conforms to the shape (alpha channel) of the image itself.

— MDN contributors, “Try it,” note comparing the two effects.18

Looking back, I wonder whether I was trying to make an imperfect boundary look more natural. A softer edge might have made a small seam or alignment problem less conspicuous. I do not remember clearly enough to say that was my intention. Even if it helped the appearance, it would have left the size mismatch underneath.

What I would do differently now

If I returned to this component, I would start by measuring the layout before adding more offsets. These are the checks I would make now; we did not complete this investigation at the time.

First, trace which layer determines each dimension. I would record the node's dimensions, the content container's measured box, the wrapper dimensions, and the dimensions passed to the editor. I would compare them during growth, shrinkage, and after dragging stops, alongside the computed minimum sizes, padding, borders, and overflow in browser DevTools.

Then, reduce competing constraints. I would investigate letting CSS allocate the title and editor regions, measuring the actual editor host only when the embedded editor needs explicit dimensions. This could reduce hand-maintained subtractions. It still needs testing with the original component structure, particularly whether children can shrink and where excess content should scroll.

Check the feedback cycle I discussed with Cursor. An observer can report a size, an update can change layout, and the new layout can trigger another observation. MDN warns that browser loop handling “only prevents user-agent lockup, not the infinite loop itself.”19 Cursor had suggested this cycle when I asked about increasing height on January 7.1 I would now capture the measurements across successive renders to test that explanation. I did not save such a trace or a browser ResizeObserver loop-error message. Moving work into requestAnimationFrame would not by itself correct inconsistent sizing rules.

Treat cleanup and performance as separate checks. Our text node already disconnected its observer on cleanup. For rendering cost, I would profile a sustained resize and check which components update. Skipping a truly unchanged size may avoid unnecessary updates, but if I use a pixel threshold, I also need a way to deliver the final dimensions.

I would include these cases:

CaseWhat to inspect
A small drag followed by an immediate stopWhether the editor reaches the final measured dimensions
Shrinking to the allowed minimumWhether control limits, CSS minima, and editor dimensions agree
Long text and nested, formatted JSONWrapping, clipping, and which element owns scrolling
Switching content views or loading statesWhether the newly visible editor receives the current size
Repeated growth and shrinkageWhether offsets or stale measurements leave visible discrepancies
Removing and recreating a nodeObserver cleanup and measurements for the new DOM element

We made most common scenarios workable after repeated tuning. What I would like to do better next time is write down what each limit and offset assumes. Otherwise, the next layout change leaves me rediscovering why I chose those numbers.

References

Footnotes

  1. CaiBorui & Cursor. (2025, January 7). Fixing Infinite Resize Loop in React [Local conversation excerpt]. Cursor. Session b2e4eeb0-8b74-40be-a86d-4f88f28376e3, original messages 1–2; code suggestion targets PuppyFlow/app/components/workflow/nodes/JsonNode.tsx. Archived original question and response. The precise time comes from the assistant's timingInfo.clientStartTime; the user message has no separate timestamp. Verified November 16, 2026, by read-only access to the legacy inline conversation in composerData:<session-id>. ↩ ↩2 ↩3

  2. CaiBorui & Cursor. (2025, January 16). Implementing Dead Zone for Width Changes [Local conversation]. Cursor. Session 2a63de8f-9fc2-40c4-82a6-ac79af4c4853, messages 1–2; user request and proposed widthThreshold = 10 in JsonNode.tsx. Archived original wording and suggestion. The precise time comes from the assistant request, not a separately timestamped user message. Verified November 16, 2026. ↩ ↩2 ↩3

  3. realGuantum. (2025, January 20). Fixed the node resizer bug [Commit d61f1ff]. GitHub, puppyone-ai/puppyone-cloud. JsonNode.tsx diff, observer callback and editor dimensions; quoted comment is from the removed implementation. https://github.com/puppyone-ai/puppyone-cloud/commit/d61f1ffc5d8298255899e069b30678b6bb9a9694 ↩ ↩2 ↩3

  4. xyflow. (n.d.). The NodeResizeControl component. React Flow. “Props,” minWidth and minHeight. https://reactflow.dev/api-reference/components/node-resize-control ↩

  5. MDN contributors. (n.d.). ResizeObserver: ResizeObserver() constructor. MDN Web Docs. “Parameters,” callback, first sentence. https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver/ResizeObserver#parameters ↩

  6. PuppyAgent contributors. (2025, March 3). TextBlockNode.tsx [Source code at commit b809a2d]. GitHub, puppyone-ai/puppyone-cloud. Observer Effect at lines 166–181; editor dimensions at lines 437–441. https://github.com/puppyone-ai/puppyone-cloud/blob/b809a2daf392ff5e27f7b3339b0506310fd49a0b/PuppyFlow/app/components/workflow/blockNode/TextBlockNode.tsx#L166-L181 ↩

  7. MDN contributors. (2023, July 7). ResizeObserverEntry: contentRect property. MDN Web Docs. “Value,” second paragraph. https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry/contentRect#value ↩

  8. PuppyAgent contributors. (2025, March 3). JSONForm.tsx [Source code at commit b809a2d]. GitHub, puppyone-ai/puppyone-cloud. Wrapper styles and Editor props. https://github.com/puppyone-ai/puppyone-cloud/blob/b809a2daf392ff5e27f7b3339b0506310fd49a0b/PuppyFlow/app/components/tableComponent/JSONForm.tsx#L230-L275 ↩

  9. S2thend. (2025, January 16). Fix json node size [Commit 2c91af9]. GitHub, puppyone-ai/puppyone-cloud. https://github.com/puppyone-ai/puppyone-cloud/commit/2c91af9b8b69e1ea3d5458160a30d581b5110f08 ↩

  10. realGuantum. (2025, January 19). Updated the block node layout [Commit 98f453f]. GitHub, puppyone-ai/puppyone-cloud. https://github.com/puppyone-ai/puppyone-cloud/commit/98f453fd25da815726bce2c0e8512c6459c889ba ↩

  11. S2thend. (2025, January 20). Style ajustment, default expand embedding view json object [Commit 42a9cad]. GitHub, puppyone-ai/puppyone-cloud. https://github.com/puppyone-ai/puppyone-cloud/commit/42a9cad2f31c0ca595f97440225c79559cc0ba44 ↩ ↩2

  12. realGuantum. (2025, January 20). Modified the text and structured text default size [Commit d8557c9]. GitHub, puppyone-ai/puppyone-cloud. https://github.com/puppyone-ai/puppyone-cloud/commit/d8557c9024d43ec62c77031cafcdcde2f24e7223 ↩

  13. MDN contributors. (n.d.). JSON.stringify(). MDN Web Docs. “Using the space parameter,” introductory sentence and first example. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#using_the_space_parameter ↩

  14. CaiBorui & Cursor. (2025, January 20). Pretty Print JSON Function [Local conversation]. Cursor. Session 19421450-9891-4b07-9e5a-006ab9ddbea2, messages 1–2; request for spacing and line breaks and the assistant's prettyPrintJson example. Archived original wording and suggestion. The precise time comes from the assistant request. Verified November 16, 2026. ↩

  15. S2thend. (2025, January 14). Finish new json node view switch style [Commit c2fc94f]. GitHub, puppyone-ai/puppyone-cloud. https://github.com/puppyone-ai/puppyone-cloud/commit/c2fc94f04470d33280deebb8dfcbf380f159c39d ↩

  16. S2thend. (2025, January 16). Finish ui adjustments on jsonnode [Commit f58705a]. GitHub, puppyone-ai/puppyone-cloud. https://github.com/puppyone-ai/puppyone-cloud/commit/f58705af88ce8274e7b9d02edc07555399279285 ↩

  17. S2thend. (2025, January 16). Finish json node style adjustment [Commit a866ea8]. GitHub, puppyone-ai/puppyone-cloud. JSONForm.tsx wrapper changes. https://github.com/puppyone-ai/puppyone-cloud/commit/a866ea846c48b4cc1df7772e15db179c1dc6f26e ↩

  18. MDN contributors. (n.d.). drop-shadow() CSS function. MDN Web Docs. “Try it,” note comparing box-shadow and drop-shadow(). https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Values/filter-function/drop-shadow#try_it ↩

  19. MDN contributors. (n.d.). ResizeObserver. MDN Web Docs. “Observation Errors,” explanation immediately after the loop-error message. https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver#observation_errors ↩

© 2025 borui. All rights reserved. This content may be freely reproduced, displayed, modified, or distributed with proper attribution to borui and a link to the article: borui (2025-02-20). Making Workflow Node Resizing Usable: Iterative Fixes and Remaining Limitations. https://caiborui.com/blog/2025-02-20-en-workflow-node-resizing

@misc{borui2025-ec00e92f,
  author = {borui},
  title = {{Making Workflow Node Resizing Usable: Iterative Fixes and Remaining Limitations}},
  year = {2025},
  publisher = {borui's blog},
  url = {https://caiborui.com/blog/2025-02-20-en-workflow-node-resizing}
}