Unless I'm missing something—which is quite possible—you can't leaving a floating HTML window onscreen if the macro isn't running. So the first trick would be to design your macro so that it's always running while you need to see this status window.
And this might be a good time to jump backwards a bit, and ask what you're trying to accomplish—perhaps there are other ways to get it done, if we knew the main objective.
While in the options, set the action to "Asynchronously" so the prompt remains on screen but the macro runs to completion.
Add a "Try/Catch" action to your macro, after the AppleScript action, and put your Prompt action in the otherwise section. Edit the body tag in the Prompt's HTML to add an id you can reference:
<body data-kmwindowid="myCustomPrompt">
In the "execute section of the "Try/Catch" add an "Execute a JavaScript in Custom Prompt" action. Set "Window ID" to the ID in your HTML and set the script as location.reload():
The window will show your system "uptime" in seconds. Run it, wait a few seconds, run it again and you should see the number change.
When you run the macro it will try and update the Prompt window. If there isn't one the JavaScript action will fail and the "otherwise" block is executed, creating the Prompt for you.
Reloading the whole "page" wouldn't be great if you had a large amount of HTML, but I doubt that's the case here. And it is a simple method which even my limited JS abilities can handle! But there are some excellent web coders on the Forum who I'm sure will be able to improve on this.
SuperWhisper is a voice dictation app, and you can run different modes (straight voice dictation, pass instructions for the dictated text through LLMs, etc.).
The script shows what mode SuperWhisper is currently running.
I'm currently running a similar macro in the menu bar, but one of the computers I have (MacBook Air M3) only has a 13-inch display, and the mode shown in the menu bar often gets cut off.
What I want to do is run the macro every 30 seconds or so and show what mode is currently selected in a floating window.
Argh, I always forget about that, because I typically build my HTML in a variable then display it using the Execute Javascript in Custom HTML Prompt action. And you can't do that asynchronously.
Can't you spawn the Prompt window async, then target it with your "Execute JavaScript" action? You have to wait a beat for the Prompt to become available but, unless I'm missing the point in my HTML-naivety, this seems to be what you mean: