Skip to content

QOL: Arrow bending and termination#3723

Merged
RichDom2185 merged 9 commits intosource-academy:masterfrom
wjh3355:rz-new
Apr 4, 2026
Merged

QOL: Arrow bending and termination#3723
RichDom2185 merged 9 commits intosource-academy:masterfrom
wjh3355:rz-new

Conversation

@RogerZhang888
Copy link
Copy Markdown
Contributor

@RogerZhang888 RogerZhang888 commented Apr 1, 2026

Description

[This is an updated PR that only includes changes to the arrows' apperance. Arrow filtering is in a separate PR].

Arrows now have
• standardised radius of curvature (except when there are space constraints)
• Terminating segment length (so there is no abrupt "bent" arrow-head)

The arrows which pointed to arrays from the left were initially straight arrows. Now, they also follow Manhattan routing like the rest of the arrows.

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Code quality improvements

How to test

Run any Source program and step through the CSE Machine to see the arrows.

Checklist

  • I have tested this code
  • I have updated the documentation

@martin-henz
Copy link
Copy Markdown
Member

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refines the CSE Machine's layout and arrow routing logic, including updates to configuration constants and improved path generation for arrows to prevent corner collapse. It also introduces a parentFrame reference for text components to ensure arrows extend beyond frame boundaries before bending and mocks directory fetch requests in the test setup. Feedback identifies an accidentally committed temporary file and trailing whitespace that should be removed.

Comment thread .coverage-fix.tmp Outdated
Comment thread src/features/cseMachine/components/arrows/ArrowFromText.tsx Outdated
Comment thread src/features/cseMachine/components/arrows/ArrowFromText.tsx Outdated
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request enhances the CSE Machine's visual layout and arrow routing logic. Key changes include updating layout constants in CseMachineConfig, refactoring ArrowFromText to handle frame boundaries and Manhattan segments, and improving corner radius calculations in GenericArrow. Additionally, it fixes a typo in ArrayValue, updates test snapshots, and mocks fetch in the test setup. Review feedback suggests removing a mistakenly included temporary file and refining the routing logic comments in ArrowFromText to be more accurate.

Comment thread .coverage-fix.tmp Outdated
Comment thread src/features/cseMachine/components/arrows/ArrowFromText.tsx Outdated
Copy link
Copy Markdown
Contributor

@Akshay-2007-1 Akshay-2007-1 left a comment

Choose a reason for hiding this comment

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

Simple fixes!

Comment thread src/global.ts
Comment thread src/i18n/i18next.ts
this._x = frameX + newReference.frame.width() + Config.FrameMarginX;

this._y = newReference.y();
this._y = newReference.y() + Config.ArrayVerticalOffset;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Bug: Adding ArrayVerticalOffset to ArrayValue without updating the parent Binding's height calculation causes layout issues, as the binding's height is now too small to contain the array.
Severity: MEDIUM

Suggested Fix

Update the height calculation for bindings in Binding.tsx. When the value is an ArrayValue, the height calculation must also include the ArrayVerticalOffset (and any other y-offsets) to ensure the binding is tall enough to fully contain the positioned array. The new height should be approximately max(key.height(), keyYOffset + ArrayVerticalOffset + value.totalHeight).

Prompt for AI Agent
Review the code at the location below. A potential bug has been identified by an AI
agent.
Verify if this is a real issue. If it is, propose a fix; if not, explain why it's not
valid.

Location: src/features/cseMachine/components/values/ArrayValue.tsx#L53

Potential issue: A new vertical offset, `Config.ArrayVerticalOffset`, is applied to
`ArrayValue` components at `ArrayValue.tsx:53`. However, the height calculation for the
parent `Binding` was not updated to account for this new offset. The binding's height is
calculated based on the array's `totalHeight`, but it fails to include the added
vertical offset. This results in the binding being shorter than its contents, causing
subsequent bindings in the same frame to be drawn too high and overlap with the array.
This visual bug affects all layouts containing array bindings, making frames appear too
short to contain their content.

Did we get this right? 👍 / 👎 to inform future reviews.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

@RogerZhang888 please check if it's valid. I'll merge the PR first so we can test. Feel free to make a new PR to fix this if it turns out to be valid.

@RichDom2185 RichDom2185 enabled auto-merge (squash) April 4, 2026 18:28
Copy link
Copy Markdown
Member

@RichDom2185 RichDom2185 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@RichDom2185 RichDom2185 merged commit 29b49c7 into source-academy:master Apr 4, 2026
7 checks passed
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.

4 participants