Skip to content

feat(callstack): optional source locations and playback line highlight#121

Open
mkayander wants to merge 5 commits intomainfrom
cursor/callstack-frame-line-tracking-462a
Open

feat(callstack): optional source locations and playback line highlight#121
mkayander wants to merge 5 commits intomainfrom
cursor/callstack-frame-line-tracking-462a

Conversation

@mkayander
Copy link
Copy Markdown
Owner

@mkayander mkayander commented Apr 7, 2026

Summary

Adds optional source: { line, column? } on visualization frames (no new frame types). At runtime, CallstackHelper.addOne enriches frames with the current execution location when probes have set it.

JavaScript

  • Babel injects globalThis.__dstructSetExecutionSource(line, column) before statements only inside the first return function … / return () => … (dStruct template). Top-level JSDoc and other code outside that subtree are not instrumented. Falls back to raw code if no matching return.
  • Fix: Instrument the solution function’s own body explicitly (traverse skips the root path).
  • If transform fails or pattern missing, original code runs (frames lack source).
  • Benchmark path skips instrumentation.
  • setGlobalRuntimeContext assigns onto globalThis.

Python

  • LineTrackingTransformer inserts set_execution_source before statements after list tracking.
  • TrackedList attaches source from execution_location.
  • Fixed list comprehension: __callstack__ in array_tracker_transformer.py.
  • Comment on generic_visit order for nested functions.

Types / layering

  • SourceLocationSnapshot lives in #/shared/lib/sourceLocationSnapshot; callstackSlice uses it for CallFrameSource. executionSourceContext uses the same type (no domain → codeRunner type dependency).

UI / Redux

  • selectPlaybackSourceLine walks backward from frameIndex.
  • Monaco whole-line class dstruct-editor-playback-line.
  • Stale highlights: markCodeSnapshotStale only when buffer text differs from lastRunCodeSource (undo back to run text keeps highlights). Format still forces stale.

Tests

  • Instrumenter tests including “no return function” fallback.

Dependencies

  • @babel/generator, @babel/parser, @babel/traverse, @babel/types + dev @types/babel__*
Open in Web Open in Cursor 

- Add optional source { line, column? } on CallFrameBase and consoleLog frames
- CallstackHelper.addOne merges current execution location from globalThis hook
- Babel-based JS instrumentation before run; benchmark path unchanged
- Python: line probes + execution_location; TrackedList frames carry source
- Fix list comprehension transformer to use __callstack__
- Redux: lastRunCodeSource, codeModifiedSinceRun, markCodeSnapshotStale
- Monaco whole-line decoration; stale after edit or format
- Move runtime context assignment to globalThis for worker compatibility

Co-authored-by: Max Kayander <mkayander@users.noreply.github.com>
@vercel
Copy link
Copy Markdown

vercel bot commented Apr 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
dstruct Ready Ready Preview, Comment Apr 8, 2026 8:40am

cursoragent and others added 2 commits April 7, 2026 17:56
…marter stale

- Add SourceLocationSnapshot in shared; callstack imports type from shared only
- Instrument only bodies under first return function/arrow (template); fix root body
- Mark code snapshot stale only when buffer differs from lastRunCodeSource
- Drop redundant clearExecutionSource before run (finally still clears)
- Document Python LineTrackingTransformer visit order; extend instrument tests

Co-authored-by: Max Kayander <mkayander@users.noreply.github.com>
Resolve conflicts in package.json (keep Babel types), pnpm-lock.yaml (pnpm install),
and CodePanel (main's format worker flow + markCodeSnapshotStale after format).
…r merge

- Prettier wrap setExecutionSource; babel types import as babelTypes
- LandingGlowCard: rename x/y to pointerXPct/pointerYPct
- useLandingReveal: eslint-disable for reduce/revealed setState; entry in IO callback
…instrumentation

- executionSourceContext: clear/set/peek behavior
- CallstackHelper.addOne with mocked peek: merge, preserve source, skip error
- callstackSlice: frameIndex -1, removeAll snapshot fields, setStatus fields
- instrumentUserJs: narrow scope (2 probes), return arrow block body
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.

2 participants