diff --git a/CHANGELOG.md b/CHANGELOG.md
index b176c6cb..c1d366d5 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -13,6 +13,8 @@ and adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
### 🐛 Bug fixes
+- Fixed issue where object boxes would be drawn on top of stack frames in diagrams with large left margins.
+
### 📚 Documentation and demo website changes
### 🔧 Internal changes
diff --git a/memory-viz/src/automate.ts b/memory-viz/src/automate.ts
index 3e3e295b..9e368030 100644
--- a/memory-viz/src/automate.ts
+++ b/memory-viz/src/automate.ts
@@ -119,7 +119,7 @@ function drawAutomatedStackFrames(stack_frames: DrawnEntity[], configuration) {
min_required_height = height + min_required_height;
}
- required_width += configuration.padding;
+ required_width += configuration.left_margin;
return {
StackFrames: draw_stack_frames,
diff --git a/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap b/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap
index 93d5de5c..4bf5b5db 100644
--- a/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap
+++ b/memory-viz/src/tests/__snapshots__/draw.spec.tsx.snap
@@ -34,6 +34,8 @@ exports[`draw function renders a diagram with 'small' width value and a mix stac
exports[`draw function renders a diagram with 'small' width value and no stack frames 1`] = `""`;
+exports[`draw function renders a diagram with large left margins 1`] = `""`;
+
exports[`draw function renders a dict 1`] = `""`;
exports[`draw function renders a float 1`] = `""`;
diff --git a/memory-viz/src/tests/draw.spec.tsx b/memory-viz/src/tests/draw.spec.tsx
index 141c5a71..9d763461 100644
--- a/memory-viz/src/tests/draw.spec.tsx
+++ b/memory-viz/src/tests/draw.spec.tsx
@@ -848,4 +848,45 @@ describe("draw function", () => {
const svg: String = m.serializeSVG();
expect(svg).toMatchSnapshot();
});
+
+ it("renders a diagram with large left margins", () => {
+ const objects: Array