Skip to content

Conversation

@jjspace
Copy link
Contributor

@jjspace jjspace commented Nov 4, 2025

Description

As suggested in this comment there is now a button to clear the console for sandcastle.
I also hooked it up so that calling console.clear() inside the sandcastle itself will clear the console mirror as well. I expect this could be useful to refresh the console while logging frequently during renders which some people may want to do.

Issue number and link

No issue, part of #12894

Testing plan

  • Open sandcastle locally or in CI
  • Add some log statements in the sandcastle so the console is populated
  • Call console.clear() in the code
  • Try the clear console button
    • Ensure the button is only visible when the console is expanded

Author checklist

  • I have submitted a Contributor License Agreement
  • I have added my name to CONTRIBUTORS.md
  • I have updated CHANGES.md with a short summary of my change
  • I have added or updated unit tests to ensure consistent code coverage
  • I have updated the inline documentation, and included code examples where relevant
  • I have performed a self-review of my code

@github-actions
Copy link

github-actions bot commented Nov 4, 2025

Thank you for the pull request, @jjspace!

✅ We can confirm we have a CLA on file for you.

Copy link
Contributor

@javagl javagl left a comment

Choose a reason for hiding this comment

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

I cannot really "review" the changes on the code level. (I had a short look, and ... "Yeah, 🤷‍♂️ looks OK...").

Beyond that, I spent ~1 hour trying to get the build running, and ~5 minutes testing it.


Building:

The npm run build-sandcastle causes this error for me:

[14:19:03] Using gulpfile C:\cesium\gulpfile.apps.js
[14:19:03] Starting 'buildSandcastle'...
[14:19:05] 'buildSandcastle' errored after 2.74 s
[14:19:05] Error: spawn C:\cesium\node_modules\typescript\bin\tsc ENOENT
    at ChildProcess._handle.onexit (node:internal/child_process:285:19)
    at onErrorNT (node:internal/child_process:483:16)
    at process.processTicksAndRejections (node:internal/process/task_queues:90:21)

Figuring out that this came from

const ls = spawn(binPath, ["-p", configPath]);
already took longer than I'd like to admit. Websearches for why this error appears, and how to resolve it didn't lead anywhere. ("This should work...?!").

Eventually, I changed that typescriptCompile promise to do

execSync("npx tsc -p C:/cesium/packages/sandcastle/templates/tsconfig.lib.json");
resolve(0);

But I should probably not create a PR for that 😶


Testing:

I ran a test for the base functionality, and it worked. And I ran a "stress test", trying to emulate the scenario where the "clear" functionality is most important, namely when some debug log is spamming the console with lots of stuff...

let counter = 0;
let delayMs = 5;
function spam() {
  setTimeout(() => {
    let s = " spam, ";
    for (let i=0; i<100; i++) {
      s += "spam, ";
    }
    console.log(counter + s + "with bacon and spam");
    counter++;
    spam();
  }, delayMs);  
}
spam();

And despite the system being busy with generating that output, the "Clear console" button worked, and it cleared the console immediately, without noticable delays, and even when the console was already filled quite a bit.

@javagl javagl mentioned this pull request Nov 5, 2025
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.

3 participants