mirror of
https://github.com/getcompanion-ai/co-mono.git
synced 2026-04-17 06:04:51 +00:00
HTML artifacts call window.complete() when page loads
- Inject <script>if (window.complete) window.complete();</script> before </html> - HTML artifacts are long-running and don't time out - Console logs are sent immediately, completion signals when page is ready - Removes need for artificial timeout in HTML artifacts
This commit is contained in:
parent
695bcf9b6f
commit
6bc098e57b
1 changed files with 14 additions and 1 deletions
|
|
@ -101,8 +101,21 @@ export class HtmlArtifact extends ArtifactElement {
|
|||
},
|
||||
};
|
||||
|
||||
// Inject window.complete() call at the end of the HTML to signal when page is loaded
|
||||
// HTML artifacts don't time out - they call complete() when ready
|
||||
let modifiedHtml = html;
|
||||
if (modifiedHtml.includes("</html>")) {
|
||||
modifiedHtml = modifiedHtml.replace(
|
||||
"</html>",
|
||||
"<script>if (window.complete) window.complete();</script></html>",
|
||||
);
|
||||
} else {
|
||||
// If no closing </html> tag, append the script
|
||||
modifiedHtml += "<script>if (window.complete) window.complete();</script>";
|
||||
}
|
||||
|
||||
// Load content - this handles sandbox registration, consumer registration, and iframe creation
|
||||
sandbox.loadContent(sandboxId, html, this.runtimeProviders, [consumer]);
|
||||
sandbox.loadContent(sandboxId, modifiedHtml, this.runtimeProviders, [consumer]);
|
||||
}
|
||||
|
||||
override get content(): string {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue