``` 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 ## Changed files - `.prettierignore` (modified, +1/-0) - `src/auto-reply/reply/export-html/template.html` (modified, +3/-15) --- # PR #50037: fix(export): restore JS placeholders in export HTML template - Repository: openclaw/openclaw - Author: reed1898 - State: closed | merged: False - Link: https://github.com/openclaw/openclaw/pull/50037 ## Description (problem / solution / changelog) Fixes #49957 — Session export HTML renders empty in browser because Prettier reformats {{PLACEHOLDER}} syntax into multi-line blocks with semicolons, breaking the .replace() calls in the export pipeline. Changes: - template.html: Restore {{MARKED_JS}}, {{HIGHLIGHT_JS}}, {{JS}} to single-line compact format with prettier-ignore comments - .prettierignore: Added template.html to prevent future corruption Root cause: template.replace('{{MARKED_JS}}', markedJs) expects the exact string. Prettier reformats it into nested blocks with a label (valid JS), silently corrupting the template. All 5 existing export security tests pass. ## Changed files - `.prettierignore` (modified, +3/-0) - `src/auto-reply/reply/export-html/template.html` (modified, +6/-21) --- # PR #50320: Fix priority regressions in export attachments auth and denyCommands - Repository: openclaw/openclaw - Author: imleoo - State: open | merged: False - Link: https://github.com/openclaw/openclaw/pull/50320 ## Description (problem / solution / changelog) ## Summary - fix export session HTML token injection by supporting both plain and formatted script placeholders - normalize HEIC and HEIF chat attachments to JPEG before prompt image upload - treat google-vertex ADC sentinel as oauth mode and do not pass it as apiKey - add config set warnings for gateway.nodes.denyCommands unknown or pattern-like entries - add regression tests for all four fixes ## Linked issues - closes #49957 - closes #50081 - closes #50053 - closes #50011 ## Validation - pnpm test src/auto-reply/reply/export-html/template.security.test.ts src/gateway/chat-attachments.test.ts src/agents/model-auth.test.ts src/cli/config-cli.test.ts - pnpm check and pnpm tsgo still report existing unrelated repo-wide TypeScript errors ## Changed files - `src/agents/model-auth.test.ts` (modified, +32/-0) - `src/agents/model-auth.ts` (modified, +20/-0) - `src/auto-reply/reply/commands-export-session.ts` (modified, +22/-6) - `src/auto-reply/reply/export-html/template.security.test.ts` (modified, +10/-1) - `src/cli/config-cli.test.ts` (modified, +49/-0) - `src/cli/config-cli.ts` (modified, +152/-0) - `src/gateway/chat-attachments.test.ts` (modified, +46/-0) - `src/gateway/chat-attachments.ts` (modified, +35/-2) --- # PR #51105: feat(cli): add session export to markdown - Repository: openclaw/openclaw - Author: mvanhorn - State: closed | merged: False - Link: https://github.com/openclaw/openclaw/pull/51105 ## Description (problem / solution / changelog) ## Summary Adds `openclaw sessions export` - a CLI subcommand that converts sessi","inLanguage":"en-US","datePublished":"2026-03-18T18:14:55Z","dateModified":"2026-03-18T18:14:55Z","mainEntityOfPage":{"@type":"WebPage","@id":"https://www.stepcodex.com/en/issue/bug-session-export-html-is-empty"},"author":{"@type":"Person","name":"martenzi","url":"https://github.com/martenzi","image":"https://github.com/martenzi"},"publisher":{"@type":"Organization","name":"StepCodex","url":"https://www.stepcodex.com"},"articleSection":"openclaw","about":[{"@type":"Thing","name":"openclaw","url":"https://www.stepcodex.com/en/category/openclaw"}],"contributor":[{"@type":"Person","name":"Hollychou924","url":"https://github.com/Hollychou924","image":"https://github.com/Hollychou924"}],"keywords":"Bug: Session export HTML is empty due to reformatted JS placeholders in template, openclaw, how to fix, fix, troubleshooting, root cause, solution, StepCodex","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/LikeAction","userInteractionCount":4}},{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://www.stepcodex.com/en/issue"},{"@type":"ListItem","position":2,"name":"openclaw","item":"https://www.stepcodex.com/en/category/openclaw"},{"@type":"ListItem","position":3,"name":"Bug: Session export HTML is empty due to reformatted JS placeholders in template","item":"https://www.stepcodex.com/en/issue/bug-session-export-html-is-empty"}]}]

openclaw - ✅(Solved) Fix Bug: Session export HTML is empty due to reformatted JS placeholders in template [5 pull requests, 3 comments, 2 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#49957Fetched 2026-04-08 01:00:47
View on GitHub
Comments
3
Participants
2
Timeline
14
Reactions
0
Author
Timeline (top)
referenced ×6cross-referenced ×5commented ×3

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.

Fix Action

Fix / Workaround

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

PR fix notes

PR #49961: fix: restore compact JS placeholders in session export template

Description (problem / solution / changelog)

Fixes #49957

The session export template at src/auto-reply/reply/export-html/template.html had its JS placeholders reformatted into multi-line blocks. This prevented the .replace() calls in the export logic from finding and injecting the vendored JS, resulting in empty exports in the browser.

This PR restores the single-line format.

Changed files

  • .prettierignore (modified, +1/-0)
  • src/auto-reply/reply/export-html/template.html (modified, +3/-15)

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

Description (problem / solution / changelog)

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

Changed files

  • .prettierignore (modified, +1/-0)
  • src/auto-reply/reply/export-html/template.html (modified, +3/-15)

PR #50037: fix(export): restore JS placeholders in export HTML template

Description (problem / solution / changelog)

Fixes #49957 — Session export HTML renders empty in browser because Prettier reformats {{PLACEHOLDER}} syntax into multi-line blocks with semicolons, breaking the .replace() calls in the export pipeline.

Changes:

  • template.html: Restore {{MARKED_JS}}, {{HIGHLIGHT_JS}}, {{JS}} to single-line compact format with prettier-ignore comments
  • .prettierignore: Added template.html to prevent future corruption

Root cause: template.replace('{{MARKED_JS}}', markedJs) expects the exact string. Prettier reformats it into nested blocks with a label (valid JS), silently corrupting the template.

All 5 existing export security tests pass.

Changed files

  • .prettierignore (modified, +3/-0)
  • src/auto-reply/reply/export-html/template.html (modified, +6/-21)

PR #50320: Fix priority regressions in export attachments auth and denyCommands

Description (problem / solution / changelog)

Summary

  • fix export session HTML token injection by supporting both plain and formatted script placeholders
  • normalize HEIC and HEIF chat attachments to JPEG before prompt image upload
  • treat google-vertex ADC sentinel as oauth mode and do not pass it as apiKey
  • add config set warnings for gateway.nodes.denyCommands unknown or pattern-like entries
  • add regression tests for all four fixes

Linked issues

  • closes #49957
  • closes #50081
  • closes #50053
  • closes #50011

Validation

  • pnpm test src/auto-reply/reply/export-html/template.security.test.ts src/gateway/chat-attachments.test.ts src/agents/model-auth.test.ts src/cli/config-cli.test.ts
  • pnpm check and pnpm tsgo still report existing unrelated repo-wide TypeScript errors

Changed files

  • src/agents/model-auth.test.ts (modified, +32/-0)
  • src/agents/model-auth.ts (modified, +20/-0)
  • src/auto-reply/reply/commands-export-session.ts (modified, +22/-6)
  • src/auto-reply/reply/export-html/template.security.test.ts (modified, +10/-1)
  • src/cli/config-cli.test.ts (modified, +49/-0)
  • src/cli/config-cli.ts (modified, +152/-0)
  • src/gateway/chat-attachments.test.ts (modified, +46/-0)
  • src/gateway/chat-attachments.ts (modified, +35/-2)

PR #51105: feat(cli): add session export to markdown

Description (problem / solution / changelog)

Summary

Adds openclaw sessions export - a CLI subcommand that converts session JSONL transcripts to clean markdown or pretty-printed JSON. Tool calls and tool results are collapsed into <details> blocks. Long tool results are truncated at 500 characters.

Why this matters

The existing /export-session slash command generates HTML, but it has been broken for months because Prettier keeps corrupting the template's JS placeholders:

IssueProblem
#41862export-session HTML renders blank
#22595/export-session generates broken HTML
#49957Session export HTML empty due to reformatted placeholders

Five open PRs are trying to fix the HTML template corruption. This PR takes a different approach: plain markdown output with no template placeholders, so there is nothing for formatters to break.

Users also want portable session history (#50701 - WebUI history resets after updates, #50865 - access to old sessions). A CLI export to markdown gives users a working way to archive conversations.

Changes

  • src/commands/session-export.ts: New command that reads session JSONL via SessionManager.open(), walks SessionMessageEntry entries, and formats them as markdown with timestamps and speaker labels. User messages shown directly, assistant text blocks shown, tool calls collapsed into <details> with the tool name and arguments, tool results collapsed with truncation. Also supports --format json for raw output.
  • src/commands/session-export.test.ts: 10 vitest tests covering empty sessions, user/assistant exchanges, tool calls, tool results, error results, image content, compaction markers, long result truncation, and null headers.
  • src/cli/program/register.status-health-sessions.ts: Registers sessions export as a subcommand alongside sessions cleanup. Accepts --session, --agent, --format, --output flags.

Usage

openclaw sessions export --session main
openclaw sessions export --session main --format json
openclaw sessions export --session main --output chat.md
openclaw sessions export --session main --agent work

Testing

pnpm test -- src/commands/session-export.test.ts
# 10 passed

All 10 tests pass. Files pass oxfmt format check and oxlint individually. Note: pnpm tsgo has pre-existing type errors in extensions/msteams/ on upstream/main that are unrelated to this change.

This contribution was developed with AI assistance (Claude Code).

Changed files

  • src/cli/program/register.status-health-sessions.ts (modified, +33/-0)
  • src/commands/session-export.test.ts (added, +256/-0)
  • src/commands/session-export.ts (added, +234/-0)

Code Example

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

---

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

---

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

---

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
RAW_BUFFERClick to expand / collapse

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

extent analysis

Fix Plan

To resolve the issue, update the HTML template to use single-line compact format for JavaScript placeholders.

Step-by-Step Solution:

  • Update dist/export-html/template.html to replace multi-line blocks with single-line placeholders:
<script>{{MARKED_JS}}</script>
<script>{{HIGHLIGHT_JS}}</script>
<script>{{JS}}</script>
  • Alternatively, run the following Perl command to automate the replacement:
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
  • Verify that the reply-Bm8VrLQh.js (and other similar files) can now correctly inject JavaScript into the exported HTML files using the .replace() method.

Verification

After applying the fix, export a new session and verify that the generated HTML file:

  • Has a non-zero size
  • Can be opened in a browser and displays the session data correctly
  • Contains the injected JavaScript code

Extra Tips

  • Consider updating the automated code formatter (e.g., Prettier) configuration to preserve single-line format for JavaScript placeholders in HTML templates.
  • Regularly review and test exported files to catch similar issues early.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - ✅(Solved) Fix Bug: Session export HTML is empty due to reformatted JS placeholders in template [5 pull requests, 3 comments, 2 participants]