Skip to content

Do not show debug suggestion when a project can't compile #10721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 2, 2025

Conversation

thsparks
Copy link
Contributor

@thsparks thsparks commented Jul 1, 2025

Fixes microsoft/pxt-microbit#6372

For text errors, we were able to determine if an error was a compile or runtime error using the presence of a stack trace, but for block errors, there are some that do not prevent running the program but also do not have a stack, so the same method was not as reliable (hence, we just always showed the button).

However, looking more closely, I believe we can determine if it's a run-blocking error based on whether we detect the error in the typescript compile diagnostics or not. With that in mind, I've added a specific preventsRunning flag to errors, which we can now set and use for determining if we should show the debugger suggestion. When we detect a typescript compile error in blocks, we set this to true. If it's a runtime or blocks compilation error, we set it to false. I've switched the monaco errors to use this as well, though the actual behavior is unchanged.

Upload target: https://makecode.microbit.org/app/3b1b8b4f477f1fa3d985f34d8d1728b0a2e88ef2-82f12bc8d0

… errors and use that for determining if we should show the debugger suggestion or not.
@thsparks thsparks requested review from a team and Copilot July 1, 2025 17:43
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new preventsRunning flag to errors so the UI can hide the debug suggestion when compilation errors block execution.

  • Introduce preventsRunning in the ErrorDisplayInfo interface.
  • Update Monaco and block-based error factories to set preventsRunning appropriately.
  • Change the error list UI to only show the debugger suggestion when no error has preventsRunning: true.

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
webapp/src/monaco.tsx Always pass startDebugger and tag JS/TS diagnostics with preventsRunning.
webapp/src/errorList.tsx Add preventsRunning to ErrorDisplayInfo and update showDebuggerSuggestion logic.
webapp/src/blocks.tsx Extend block error factory to accept and propagate preventsRunning.
Comments suppressed due to low confidence (2)

webapp/src/errorList.tsx:33

  • Consider adding a JSDoc comment to preventsRunning in ErrorDisplayInfo to explain its semantics (i.e., whether the error blocks program execution).
    preventsRunning?: boolean;

webapp/src/errorList.tsx:107

  • Add unit tests for ErrorList to verify that the debugger suggestion is hidden when any error has preventsRunning: true and shown otherwise.
        const showDebuggerSuggestion = startDebugger && !pxt.shell.isReadOnly() && !errors.some(e => e.preventsRunning);

@thsparks thsparks enabled auto-merge (squash) July 2, 2025 19:34
@thsparks thsparks merged commit b630fff into master Jul 2, 2025
20 checks passed
@thsparks thsparks deleted the thsparks/smarter_debug_suggestion_in_blocks branch July 2, 2025 19:39
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.

Not able to open debugger
2 participants