Support console.clear in playground
Author: mootariCreated Aug 5, 2026Updated Aug 5, 2026
Labelsenhancement
Clearing the playground log output currently requires clicking the Clear button or pressing Meta+Backspace.
When prototyping it's a fairly common practice to include console.clear() in one's code to automatically clear the console on every rerun. Sadly this has no effect in the playground because the iframe only forwards standard console levels (log, warn, etc).
Proposed solution
- In the iframe context, override
console.clearto instead send a message of type"clear"to the parent context: https://github.com/open-circle/valibot/blob/e789528650716333ecef5cc60188e0d7489d89b0/website/src/routes/playground/iframeCode.js#L129-L136 - When receiving a message of type
"clear"in the parent context, invokeclearLogs(): https://github.com/open-circle/valibot/blob/e789528650716333ecef5cc60188e0d7489d89b0/website/src/routes/playground/index.tsx#L170-L174
Source: open-circle/valibot