Skip to content

Bug: Session export HTML is empty due to reformatted JS placeholders in template #49957

@martenzi

Description

@martenzi

Description

In OpenClaw 2026.3.13 (61d171a), the /export_session command generates HTML files that appear empty when opened in a browser, despite having a large file size (containing session data).

Root Cause

The HTML template at dist/export-html/template.html has its JavaScript placeholders formatted as multi-line blocks with semicolons, likely due to an automated code formatter (e.g., Prettier):

<script>
  {
    {
      MARKED_JS;
    }
  }
</script>

However, the injection code in reply-Bm8VrLQh.js (and others) uses a literal string replacement:

template.replace("{{MARKED_JS}}", markedJs)

Because the template contains whitespace and semicolons, the .replace() call fails to match, and zero JavaScript is injected into the exported file. Without the JS, the base64-encoded session data is never decoded or rendered.

Impact

Users cannot view exported session history in the browser.

Workaround / Fix

Restoring the placeholders to single-line compact format fixes the issue:

<script>{{MARKED_JS}}</script>

I have manually patched a local installation by running:

perl -i -0777 -pe 's/\{\s*\{\s*MARKED_JS;\s*\}\s*\}/{{MARKED_JS}}/g; s/\{\s*\{\s*HIGHLIGHT_JS;\s*\}\s*\}/{{HIGHLIGHT_JS}}/g; s/\{\s*\{\s*JS;\s*\}\s*\}/{{JS}}/g' dist/export-html/template.html

Metadata

Metadata

Assignees

No one assigned

    Labels

    clawsweeperTracked by ClawSweeper automation

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions