Skip to content

Conversation

@quanru
Copy link
Collaborator

@quanru quanru commented Jan 7, 2026

Summary

Fixed an issue where aiWaitFor (and other APIs returning undefined) would display the entire reportHTML content in the playground output section, causing very long and unreadable text to appear.

Root Cause

The problem occurred in usePlaygroundExecution.ts where the result extraction logic used:

if (resultObj.result !== undefined) {
  result.result = resultObj.result;
}

This condition failed to handle cases where resultObj.result is undefined, causing:

  1. local-execution.ts wraps the result as: { result: undefined, dump: {...}, reportHTML: "long HTML string" }
  2. The extraction logic didn't update result.result because undefined !== undefined is false
  3. The entire wrapped object (including the long reportHTML) remained in result.result
  4. UI components displayed this via JSON.stringify(result.result), showing the entire HTML string

Solution

Changed the condition to use the in operator:

if ('result' in resultObj) {
  result.result = resultObj.result;
}

This properly handles undefined values by checking for property existence rather than value comparison, ensuring result.result is correctly set to undefined instead of the wrapped response object.

Test Plan

  • Lint checks pass
  • Build successful
  • Verified the fix handles undefined values correctly

Screenshots

Before: Long HTML/JavaScript text displayed in output
After: Clean output with only the actual result displayed

…ground output

Fixed an issue where aiWaitFor (and other APIs returning undefined) would
display the entire reportHTML content in the playground output section.

The problem occurred because the result extraction logic used
`if (resultObj.result !== undefined)` which failed to extract undefined
values. This caused the entire response object (including the long
reportHTML string) to remain in result.result and be displayed via
JSON.stringify.

Changed the condition to `if ('result' in resultObj)` to properly handle
undefined values, ensuring result.result is set to undefined instead of
the wrapped response object.
@netlify
Copy link

netlify bot commented Jan 7, 2026

Deploy Preview for midscene ready!

Name Link
🔨 Latest commit 0e93a34
🔍 Latest deploy log https://app.netlify.com/projects/midscene/deploys/695dee911190d60008eefc87
😎 Deploy Preview https://deploy-preview-1730--midscene.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@quanru quanru merged commit 4f4a7df into main Jan 7, 2026
10 checks passed
@quanru quanru deleted the fix/waitfor-long-output-in-playground branch January 7, 2026 06:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants