Skip to content

CSE machine: StreamViz arrow drawing#3747

Open
of89p wants to merge 36 commits into
masterfrom
streamVis
Open

CSE machine: StreamViz arrow drawing#3747
of89p wants to merge 36 commits into
masterfrom
streamVis

Conversation

@of89p
Copy link
Copy Markdown

@of89p of89p commented Apr 6, 2026

Description

Created new panel in CSE machine for Stream Visualization (pairs and nullary functions belonging to streams).

Displays results from streamViz js-slang PR (source-academy/js-slang#1939). Specifically, we use results from streamLineage from the Context object to draw dotted arrows from a nullary function to the pair(s) it returns.

The map streamLineage (Found in context object, types.ts) that maps the ID of nullary functions to the pairs it returns.

Everytime a CALL0 is called in the control, we push a tuple (nullaryFnID, controlStackHeight) to the pendingStreamFnStack[]. Within generateCSEMachineStateStream, we check the whether the height of the control stack has reached the height of i-1, where i is the controlStackHeight when we pendingStreamFnStack.peek(). If so, we pop pendingStreamFnStack.pop() and we add the pair that is at the top of the stash to the array of pairs that the nullaryFnID maps to, using streamLineage.

See also frontend issue: #3727

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

Checklist

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

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 introduces a "Pair Visualisation" feature to the CSE Machine, enabling stream lineage visualization through a new toggleable mode. The changes include state management for streamsPointSteps, new arrow components, and logic to link array values to their originating functions. Feedback focuses on removing non-portable local file paths in package.json, deleting an accidentally committed build artifact, and cleaning up leftover debug logs, commented-out code, and redundant logic in the FnValue component.

Comment thread package.json Outdated
Comment thread package.json Outdated
Comment thread tsconfig.tsbuildinfo Outdated
Comment thread src/features/cseMachine/CseMachineLayout.tsx Outdated
Comment thread src/features/cseMachine/components/arrows/ArrowFromStreamNullaryFn.tsx Outdated
Comment thread src/features/cseMachine/components/values/ArrayValue.tsx
Comment thread src/features/cseMachine/components/values/FnValue.tsx
Comment thread src/features/cseMachine/CseMachine.tsx
Comment thread src/features/cseMachine/components/values/FnValue.tsx
Comment thread package.json Outdated
Comment thread src/features/cseMachine/CseMachineLayout.tsx Outdated
Comment thread src/features/cseMachine/components/values/FnValue.tsx Outdated
Comment thread src/commons/sideContent/content/SideContentCseMachine.tsx Outdated
@martin-henz martin-henz marked this pull request as ready for review April 10, 2026 01:10
@martin-henz martin-henz added the blocked Something else needs pass review first label Apr 13, 2026
@martin-henz martin-henz mentioned this pull request Apr 13, 2026
7 tasks
@martin-henz martin-henz changed the title StreamViz arrow drawing CSE machine: StreamViz arrow drawing Apr 13, 2026
@martin-henz martin-henz removed the blocked Something else needs pass review first label Apr 17, 2026
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 17, 2026

Coverage Report for CI Build 25439972761

Coverage decreased (-0.09%) to 41.265%

Details

  • Coverage decreased (-0.09%) from the base build.
  • Patch coverage: 63 uncovered changes across 6 files (24 of 87 lines covered, 27.59%).
  • 1 coverage regression across 1 file.

Uncovered Changes

File Changed Covered %
src/features/cseMachine/components/values/FnValue.tsx 25 5 20.0%
src/features/cseMachine/components/arrows/ArrowFromStreamNullaryFn.tsx 19 0 0.0%
src/features/cseMachine/CseMachine.tsx 17 7 41.18%
src/commons/sideContent/content/SideContentCseMachine.tsx 9 1 11.11%
src/features/cseMachine/components/values/ArrayValue.tsx 7 3 42.86%
src/features/cseMachine/components/arrows/DottedArrow.tsx 2 0 0.0%

Coverage Regressions

1 previously-covered line in 1 file lost coverage.

File Lines Losing Coverage Coverage
src/features/cseMachine/CseMachine.tsx 1 49.06%

Coverage Stats

Coverage Status
Relevant Lines: 14263
Covered Lines: 6352
Line Coverage: 44.53%
Relevant Branches: 7271
Covered Branches: 2534
Branch Coverage: 34.85%
Branches in Coverage %: Yes
Coverage Strength: 28.38 hits per line

💛 - Coveralls

Comment on lines +271 to +281
// Clear arrows to prevent duplicates from multiple draw calls

if (pairs != undefined) {
for (const pair of pairs) {
const target = Layout.values.get(pair);
if (target) {
this.addArrow(target);
}
}
}
}

This comment was marked as outdated.

@martin-henz
Copy link
Copy Markdown
Member

This program seems to get stuck at step 81, now:

function make_ints(i) {
    return pair(i, () => make_ints(i + 1));
}

stream_ref(make_ints(0), 10);
Screenshot 2026-04-22 at 10 57 53 AM

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.

I can reproduce the issue flagged by Prof @martin-henz. It's a blocker

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.

7 participants