Skip to content

fix: restore export HTML template placeholders broken by Prettier#50001

Closed
henry-the-frog wants to merge 1 commit into
openclaw:mainfrom
henry-the-frog:fix/export-html-placeholders
Closed

fix: restore export HTML template placeholders broken by Prettier#50001
henry-the-frog wants to merge 1 commit into
openclaw:mainfrom
henry-the-frog:fix/export-html-placeholders

Conversation

@henry-the-frog

Copy link
Copy Markdown

Problem

Session exports via /export_session render as empty pages in the browser (#49957).

Prettier reformatted the {{MARKED_JS}}, {{HIGHLIGHT_JS}}, and {{JS}} placeholders in template.html into multi-line blocks with semicolons:

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

The .replace("{{MARKED_JS}}", ...) calls in commands-export-session.ts no longer match, so no JavaScript is injected into the export.

Fix

  • Restored compact {{PLACEHOLDER}} format in the template
  • Added the template to .prettierignore to prevent recurrence

Testing

Verified locally that the placeholder strings match what commands-export-session.ts expects.

Closes #49957

@greptile-apps

greptile-apps Bot commented Mar 18, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR fixes a regression (#49957) where session exports rendered as blank pages because Prettier had reformatted the {{PLACEHOLDER}} tokens inside plain <script> tags in template.html into multi-line JavaScript block syntax ({ { PLACEHOLDER; } }), causing the .replace("{{...}}", ...) calls in commands-export-session.ts to silently no-op.

  • template.html: Restores all three script-block placeholders ({{MARKED_JS}}, {{HIGHLIGHT_JS}}, {{JS}}) to their compact single-line form, matching the exact strings used in generateHtml().
  • .prettierignore: Adds the template file to prevent Prettier from mangling the placeholders again in the future.

All five placeholders in the template ({{CSS}}, {{SESSION_DATA}}, {{MARKED_JS}}, {{HIGHLIGHT_JS}}, {{JS}}) now align with their corresponding .replace(...) calls. The fix is minimal, targeted, and correct.

Confidence Score: 5/5

  • This PR is safe to merge — it is a minimal, targeted fix that restores previously working behavior with no logic changes.
  • The change precisely restores three placeholder strings to the exact format expected by the replacement logic in commands-export-session.ts, and adds a .prettierignore entry to prevent recurrence. No new logic is introduced, no other files are touched, and all five template placeholders are confirmed to match their corresponding .replace() calls.
  • No files require special attention.

Last reviewed commit: "fix: restore templat..."

@WingedDragon

Copy link
Copy Markdown

✅ Approved

Clean fix. The problem is clear: Prettier reformats {{MARKED_JS}} handlebars-style placeholders in HTML templates into broken syntax, breaking the template engine substitution.

Strengths:

  • Adding to .prettierignore is the correct fix — the template file should never be formatted
  • Minimal, surgical change with no side effects
  • The template content restoration is straightforward

No concerns.

Prettier reformatted {{MARKED_JS}}, {{HIGHLIGHT_JS}}, and {{JS}} placeholders
in the session export HTML template into multi-line blocks with semicolons:

    { { MARKED_JS; } }

This broke the string .replace() calls in commands-export-session.ts, causing
exported sessions to render as empty pages (no JS injected).

Restored compact {{PLACEHOLDER}} format and added the template to
.prettierignore to prevent recurrence.

Fixes openclaw#49957
@henry-the-frog henry-the-frog force-pushed the fix/export-html-placeholders branch from 66a054e to 48f6644 Compare March 21, 2026 20:46
@clawsweeper

clawsweeper Bot commented Apr 26, 2026

Copy link
Copy Markdown
Contributor

Closing this as duplicate or superseded after Codex automated review.

Close #50001 as superseded by #41861. The export bug is still real on current main and the latest release, but #41861 is the better canonical fix because it restores the placeholders and also addresses the JS string-replacement $ hazard that #50001 leaves behind.

Best possible solution:

Close #50001 as a duplicate/superseded PR and keep #41861 as the canonical fix candidate for #49957. The landed fix should restore formatter-safe placeholders and use function replacers for JS injection so vendored/app JS bytes are preserved verbatim.

What I checked:

So I’m closing this here and keeping the remaining discussion on the canonical linked item.

Codex Review notes: model gpt-5.5, reasoning high; reviewed against 54f8e4145e43.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

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

2 participants