`, so the existing replacement logic in `commands-export-session.ts` matches and injects content. No API or CLI changes. ## Existing Functionality Check - [x] Searched the codebase for template usage and replacement logic. - [x] Confirmed `commands-export-session.ts` uses exact string `.replace(\"{{MARKED_JS}}\", ...)` etc.; template must contain those exact strings. - [x] Confirmed `.oxfmtrc.jsonc` already ignores `src/auto-reply/reply/export-html/` to avoid re-breaking placeholders. ## What Changed - **Modified `src/auto-reply/reply/export-html/template.html`**: - Replaced multi-line `{ { MARKED_JS; } }` (and similar) with single-line ``. - Same for `{{HIGHLIGHT_JS}}` and `{{JS}}`. - Added an HTML comment noting that these placeholders must not be reformatted (to avoid future breakage). ## Tests - [x] `pnpm test src/auto-reply/reply/export-html/template.security.test.ts` — existing tests still pass (they rely on the same `.replace(\"{{MARKED_JS}}\", ...)` behavior). - [x] No new tests added; fix is restoring intended template format. ## Manual Testing - Build/copy templates so `dist/export-html/template.html` is updated, then trigger session export (e.g. `/export-session` in a session). - Open the generated HTML in a browser: no `MARKED_JS` / `HIGHLIGHT_JS` / `JS` ReferenceErrors; session content renders with markdown and highlighting. ## Files Changed - `src/auto-reply/reply/export-html/template.html` (placeholders restored to single-line; comment added) ## Checklist - [x] Change is limited to template format (one fix per PR). - [x] Run tests: `pnpm test src/auto-reply/reply/export-html/template.security.test.ts` ✅ - [x] Run lint: `pnpm check` (or equivalent) ✅ - [x] Run format check: `pnpm format` ✅ (export-html dir is already in oxfmt ignore). - [x] Describe what & why in this PR ✅ **Sign-Off** - Issue: https://github.com/openclaw/openclaw/issues/43620 - Fix: Restore single-line placeholders in export-html template so substitution succeeds and exported session HTML opens without ReferenceErrors. ## Changed files - `src/auto-reply/reply/export-html/template.html` (modified, +61/-76) --- # PR #43885: fix: restore final response delivery when Telegram reasoning mode is \"on\" - Repository: openclaw/openclaw - Author: jepson-liu - State: closed | merged: False - Link: https://github.com/openclaw/openclaw/pull/43885 ## Description (problem / solution / changelog) ## Summary Fixes #43807 Whe","inLanguage":"en-US","datePublished":"2026-03-12T03:00:21Z","dateModified":"2026-03-12T03:00:21Z","mainEntityOfPage":{"@type":"WebPage","@id":"https://www.stepcodex.com/en/issue/export-html-template-html-malformed-by-formatter-causing"},"author":{"@type":"Person","name":"yunlzhang","url":"https://github.com/yunlzhang","image":"https://github.com/yunlzhang"},"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"}],"keywords":"export-html template.html malformed by formatter causing export failure, openclaw, how to fix, fix, troubleshooting, root cause, solution, StepCodex","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/LikeAction","userInteractionCount":7}},{"@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":"export-html template.html malformed by formatter causing export failure","item":"https://www.stepcodex.com/en/issue/export-html-template-html-malformed-by-formatter-causing"}]}]

openclaw - ✅(Solved) Fix export-html template.html malformed by formatter causing export failure [5 pull requests, 1 comments, 1 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#43620Fetched 2026-04-08 00:16:44
View on GitHub
Comments
1
Participants
1
Timeline
12
Reactions
0
Author
Participants
Timeline (top)
referenced ×7cross-referenced ×5

Error Message

Uncaught ReferenceError: MARKED_JS is not defined Uncaught ReferenceError: HIGHLIGHT_JS is not defined Uncaught ReferenceError: JS is not defined

Root Cause

Placeholders in dist/export-html/template.html are incorrectly split into multi-line format by code formatters (e.g., prettier):

Expected format:

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

Actual format:

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

The code uses .replace("{{MARKED_JS}}", markedJs) for substitution, but since the placeholder is split across lines, the replacement fails, resulting in undefined JavaScript variables in the generated HTML.

Fix Action

Workaround

Manually edit dist/export-html/template.html and restore single-line placeholder format.

PR fix notes

PR #43634: fix: restore export-html template placeholders and prevent reformatting

Description (problem / solution / changelog)

This PR fixes the export-html template that was broken by a formatter.

What was broken:

  • The template placeholders , , and were being split into multiple lines by the formatter
  • This caused the export-html functionality to fail because the placeholders couldn't be recognized

What this PR does:

  1. Restores the original template.html with correct placeholder formatting
  2. Adds to to prevent future reformatting
  3. Keeps the existing ignore in as an extra layer of protection

Closes #43616, #43620

Changed files

  • .gitattributes (modified, +1/-0)
  • src/auto-reply/reply/export-html/template.html (modified, +45/-79)

PR #43635: # fix(export-html): Restore template placeholders to fix session HTML export failure

Description (problem / solution / changelog)

fix(export-html): Restore template placeholders to fix session HTML export failure

Summary

This PR fixes session HTML export failure (Fixes #43620). Exported session HTML files did not open correctly because the template placeholders {{MARKED_JS}}, {{HIGHLIGHT_JS}}, and {{JS}} in src/auto-reply/reply/export-html/template.html had been split into multi-line form (e.g. by a formatter). The runtime uses .replace("{{MARKED_JS}}", markedJs) etc., so the split placeholders were never replaced. The generated HTML therefore contained invalid script content and the browser reported MARKED_JS is not defined (and same for HIGHLIGHT_JS, JS). This change restores single-line placeholders so substitution works and exported session HTML opens without errors.

Use Cases

  • Users who run /export-session or /export get a single HTML file that opens in the browser without console errors.
  • Exported session HTML correctly injects vendored scripts (marked, highlight.js) and app JS.

Behavior Changes

  • Template only: The three script placeholders in template.html are again single-line {{MARKED_JS}}, {{HIGHLIGHT_JS}}, {{JS}} inside <script>...</script>, so the existing replacement logic in commands-export-session.ts matches and injects content. No API or CLI changes.

Existing Functionality Check

  • Searched the codebase for template usage and replacement logic.
  • Confirmed commands-export-session.ts uses exact string .replace("{{MARKED_JS}}", ...) etc.; template must contain those exact strings.
  • Confirmed .oxfmtrc.jsonc already ignores src/auto-reply/reply/export-html/ to avoid re-breaking placeholders.

What Changed

  • Modified src/auto-reply/reply/export-html/template.html:
    • Replaced multi-line { { MARKED_JS; } } (and similar) with single-line <script>{{MARKED_JS}}</script>.
    • Same for {{HIGHLIGHT_JS}} and {{JS}}.
    • Added an HTML comment noting that these placeholders must not be reformatted (to avoid future breakage).

Tests

  • pnpm test src/auto-reply/reply/export-html/template.security.test.ts — existing tests still pass (they rely on the same .replace("{{MARKED_JS}}", ...) behavior).
  • No new tests added; fix is restoring intended template format.

Manual Testing

  • Build/copy templates so dist/export-html/template.html is updated, then trigger session export (e.g. /export-session in a session).
  • Open the generated HTML in a browser: no MARKED_JS / HIGHLIGHT_JS / JS ReferenceErrors; session content renders with markdown and highlighting.

Files Changed

  • src/auto-reply/reply/export-html/template.html (placeholders restored to single-line; comment added)

Checklist

  • Change is limited to template format (one fix per PR).
  • Run tests: pnpm test src/auto-reply/reply/export-html/template.security.test.ts
  • Run lint: pnpm check (or equivalent) ✅
  • Run format check: pnpm format ✅ (export-html dir is already in oxfmt ignore).
  • Describe what & why in this PR ✅

Sign-Off

Changed files

  • src/auto-reply/reply/export-html/template.html (modified, +61/-76)

PR #43885: fix: restore final response delivery when Telegram reasoning mode is "on"

Description (problem / solution / changelog)

Summary

Fixes #43807

When using /reasoning on in Telegram, users only received the thinking content — the final response was silently dropped and never delivered. /reasoning off and /reasoning stream both worked correctly.

Root cause: two separate bugs in the reply pipeline:

  1. Reasoning payloads suppressed on the wrong path. The generic onBlockReply handler in dispatch-from-config.ts unconditionally dropped all payloads where isReasoning: true. A comment in that file claimed Telegram had its own dispatch path, but in reasoning="on" mode Telegram was actually going through this generic path. The reasoning payload was swallowed before it could reach the Telegram lane coordinator, which meant the pipeline registered a "did stream" state but never forwarded the final answer, leaving the user with no response at all.

  2. Answer fragmented across multiple messages. blockReplyBreak defaulted to "text_end", so in reasoning="on" mode the answer was split into many small Telegram messages rather than one coherent reply.

Behavior Changes

  • /reasoning on: now delivers both the reasoning block (as a separate Telegram message) and the final answer (as a single consolidated message). Previously only the reasoning block appeared.
  • /reasoning off / /reasoning stream: behavior unchanged.
  • Other channels (WhatsApp, web, etc.): unaffected — reasoning payloads are still suppressed on those paths.

Existing Functionality Check

  • Searched for all call sites of shouldSuppressReasoningPayload and onBlockReply to confirm no other channel is affected.
  • Verified forceBlockStreamingForReasoning is only true when reasoningLevel === "on", so allowReasoningPayloads is never set for other reasoning levels or other channels.
  • Confirmed blockReplyBreak = "message_end" override is scoped to resolvedReasoningLevel === "on" only.

What Changed

  • src/auto-reply/types.ts

    • Added allowReasoningPayloads?: boolean to GetReplyOptions. Channels with a dedicated reasoning lane (Telegram reasoning="on") set this to true to bypass generic reasoning suppression.
  • src/auto-reply/reply/dispatch-from-config.ts

    • The shouldSuppressReasoningPayload guard is now conditional: suppression is skipped when params.replyOptions?.allowReasoningPayloads is true.
  • src/auto-reply/reply/get-reply-directives.ts

    • resolvedBlockStreamingBreak is forced to "message_end" when resolvedReasoningLevel === "on", ensuring the answer is delivered as one complete message instead of many fragments.
  • src/telegram/bot-message-dispatch.ts

    • Passes allowReasoningPayloads: forceBlockStreamingForReasoning in replyOptions so the new guard in dispatch-from-config.ts is activated for Telegram reasoning="on" sessions.
  • src/telegram/bot-message-dispatch.test.ts

    • Extended the "keeps block streaming enabled when session reasoning level is on" test to assert:
      • replyOptions includes allowReasoningPayloads: true
      • deliverReplies is called with the reasoning block ("Reasoning:\n_step_")
      • deliverReplies is also called with the final answer ("Hello")

Tests

  • src/telegram/bot-message-dispatch.test.ts66 tests passed
  • src/auto-reply/reply/dispatch-from-config.test.ts44 tests passed

Files Changed

  • src/auto-reply/types.ts (+4 lines)
  • src/auto-reply/reply/dispatch-from-config.ts (+5 lines, -4 lines)
  • src/auto-reply/reply/get-reply-directives.ts (+3 lines, -1 line)
  • src/telegram/bot-message-dispatch.ts (+1 line)
  • src/telegram/bot-message-dispatch.test.ts (+6 lines)

Checklist

  • Test locally with your OpenClaw instance
  • Run tests: node_modules/.bin/vitest.CMD run src/telegram/bot-message-dispatch.test.ts
  • Run tests: node_modules/.bin/vitest.CMD run src/auto-reply/reply/dispatch-from-config.test.ts
  • Keep PRs focused (one thing per PR) ✅
  • Describe what & why ✅

Sign-Off

  • Models used: Claude
  • Submitter effort: AI-assisted with manual code review
  • Agent notes: Fix is minimal and surgical — 19 lines changed across 5 files. No new abstractions introduced; the allowReasoningPayloads flag follows the same opt-in pattern already used by disableBlockStreaming and onPartialReply in GetReplyOptions.

Changed files

  • src/auto-reply/reply/dispatch-from-config.ts (modified, +5/-4)
  • src/auto-reply/reply/get-reply-directives.ts (modified, +3/-1)
  • src/auto-reply/types.ts (modified, +4/-0)
  • src/telegram/bot-message-dispatch.test.ts (modified, +6/-0)
  • src/telegram/bot-message-dispatch.ts (modified, +1/-0)

PR #47288: fix: restore export-html template placeholders to single-line format (closes #43620)

Description (problem / solution / changelog)

Summary

  • Problem: The {{MARKED_JS}}, {{HIGHLIGHT_JS}}, and {{JS}} placeholders in template.html were split across multiple lines by a code formatter, causing .replace("{{MARKED_JS}}", ...) calls to silently fail. Exported HTML files then throw ReferenceError: MARKED_JS is not defined.
  • Why it matters: Session HTML export is completely broken — exported files cannot be opened in a browser.
  • What changed: Restored the three script placeholders to single-line <script>{{PLACEHOLDER}}</script> format in template.html.
  • What did NOT change (scope boundary): The replacement logic in commands-export-session.ts; no formatter config changes needed since oxfmt does not process HTML files.

Change Type

  • Bug fix

Scope

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #43620

User-visible / Behavior Changes

Exported session HTML files now correctly include vendored JavaScript libraries (marked.js, highlight.js) and the main application code, allowing the files to open and render properly in a browser.

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Steps

  1. Export a session with /export-session
  2. Open the generated HTML file in a browser

Expected

  • Page renders correctly with syntax-highlighted code blocks

Actual (before fix)

  • Browser console shows ReferenceError: MARKED_JS is not defined, HIGHLIGHT_JS is not defined, JS is not defined

Evidence

  • Failing test/log before + passing after
  • template.security.test.ts — 5 tests pass
  • pnpm tsgo passes (only pre-existing ui errors)

Human Verification

  • Verified scenarios: template.security.test.ts passes; replacement strings {{MARKED_JS}} etc. now match the patterns used in commands-export-session.ts
  • Edge cases checked: {{CSS}} and {{SESSION_DATA}} were already on single lines (unaffected)
  • What you did NOT verify: runtime end-to-end HTML export testing

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery

  • How to disable/revert: revert this commit

Risks and Mitigations

None

Changed files

  • .agent/workflows/update_clawdbot.md (added, +380/-0)
  • .agents/maintainers.md (added, +1/-0)
  • .detect-secrets.cfg (added, +45/-0)
  • .dockerignore (added, +70/-0)
  • .env.example (added, +80/-0)
  • .gitattributes (added, +3/-0)
  • .github/CODEOWNERS (added, +54/-0)
  • .github/ISSUE_TEMPLATE/bug_report.yml (added, +137/-0)
  • .github/ISSUE_TEMPLATE/config.yml (added, +8/-0)
  • .github/ISSUE_TEMPLATE/feature_request.yml (added, +70/-0)
  • .github/actionlint.yaml (added, +23/-0)
  • .github/actions/detect-docs-changes/action.yml (added, +53/-0)
  • .github/actions/ensure-base-commit/action.yml (added, +47/-0)
  • .github/actions/setup-node-env/action.yml (added, +113/-0)
  • .github/actions/setup-pnpm-store-cache/action.yml (added, +76/-0)
  • .github/codeql/codeql-javascript-typescript.yml (added, +18/-0)
  • .github/dependabot.yml (added, +127/-0)
  • .github/instructions/copilot.instructions.md (added, +64/-0)
  • .github/labeler.yml (added, +252/-0)
  • .github/pull_request_template.md (added, +115/-0)
  • .github/workflows/auto-response.yml (added, +524/-0)
  • .github/workflows/ci.yml (added, +803/-0)
  • .github/workflows/codeql.yml (added, +137/-0)
  • .github/workflows/docker-release.yml (added, +383/-0)
  • .github/workflows/install-smoke.yml (added, +115/-0)
  • .github/workflows/labeler.yml (added, +717/-0)
  • .github/workflows/openclaw-npm-release.yml (added, +195/-0)
  • .github/workflows/sandbox-common-smoke.yml (added, +62/-0)
  • .github/workflows/stale.yml (added, +217/-0)
  • .github/workflows/workflow-sanity.yml (added, +89/-0)
  • .gitignore (added, +135/-0)
  • .jscpd.json (added, +16/-0)
  • .mailmap (added, +13/-0)
  • .markdownlint-cli2.jsonc (added, +52/-0)
  • .npmignore (added, +1/-0)
  • .npmrc (added, +1/-0)
  • .oxfmtrc.jsonc (added, +26/-0)
  • .oxlintrc.json (added, +39/-0)
  • .pi/extensions/diff.ts (added, +117/-0)
  • .pi/extensions/files.ts (added, +134/-0)
  • .pi/extensions/prompt-url-widget.ts (added, +190/-0)
  • .pi/extensions/redraws.ts (added, +26/-0)
  • .pi/extensions/ui/paged-select.ts (added, +82/-0)
  • .pi/git/.gitignore (added, +2/-0)
  • .pi/prompts/cl.md (added, +58/-0)
  • .pi/prompts/is.md (added, +22/-0)
  • .pi/prompts/landpr.md (added, +73/-0)
  • .pi/prompts/reviewpr.md (added, +134/-0)
  • .pre-commit-config.yaml (added, +157/-0)
  • .secrets.baseline (added, +13017/-0)
  • .shellcheckrc (added, +25/-0)
  • .swiftformat (added, +51/-0)
  • .swiftlint.yml (added, +150/-0)
  • .vscode/extensions.json (added, +3/-0)
  • .vscode/settings.json (added, +22/-0)
  • AGENTS.md (added, +337/-0)
  • CHANGELOG.md (added, +4363/-0)
  • CLAUDE.md (added, +1/-0)
  • CONTRIBUTING.md (added, +198/-0)
  • Dockerfile (added, +249/-0)
  • Dockerfile.sandbox (added, +24/-0)
  • Dockerfile.sandbox-browser (added, +35/-0)
  • Dockerfile.sandbox-common (added, +48/-0)
  • LICENSE (added, +21/-0)
  • README.md (added, +559/-0)
  • SECURITY.md (added, +292/-0)
  • Swabble/.github/workflows/ci.yml (added, +54/-0)
  • Swabble/.gitignore (added, +33/-0)
  • Swabble/.swiftformat (added, +8/-0)
  • Swabble/.swiftlint.yml (added, +43/-0)
  • Swabble/CHANGELOG.md (added, +11/-0)
  • Swabble/LICENSE (added, +21/-0)
  • Swabble/Package.resolved (added, +69/-0)
  • Swabble/Package.swift (added, +55/-0)
  • Swabble/README.md (added, +111/-0)
  • Swabble/Sources/SwabbleCore/Config/Config.swift (added, +77/-0)
  • Swabble/Sources/SwabbleCore/Hooks/HookExecutor.swift (added, +75/-0)
  • Swabble/Sources/SwabbleCore/Speech/BufferConverter.swift (added, +50/-0)
  • Swabble/Sources/SwabbleCore/Speech/SpeechPipeline.swift (added, +114/-0)
  • Swabble/Sources/SwabbleCore/Support/AttributedString+Sentences.swift (added, +62/-0)
  • Swabble/Sources/SwabbleCore/Support/Logging.swift (added, +41/-0)
  • Swabble/Sources/SwabbleCore/Support/OutputFormat.swift (added, +45/-0)
  • Swabble/Sources/SwabbleCore/Support/TranscriptsStore.swift (added, +45/-0)
  • Swabble/Sources/SwabbleKit/WakeWordGate.swift (added, +191/-0)
  • Swabble/Sources/swabble/CLI/CLIRegistry.swift (added, +71/-0)
  • Swabble/Sources/swabble/Commands/DoctorCommand.swift (added, +37/-0)
  • Swabble/Sources/swabble/Commands/HealthCommand.swift (added, +16/-0)
  • Swabble/Sources/swabble/Commands/MicCommands.swift (added, +62/-0)
  • Swabble/Sources/swabble/Commands/ServeCommand.swift (added, +81/-0)
  • Swabble/Sources/swabble/Commands/ServiceCommands.swift (added, +77/-0)
  • Swabble/Sources/swabble/Commands/SetupCommand.swift (added, +26/-0)
  • Swabble/Sources/swabble/Commands/StartStopCommands.swift (added, +35/-0)
  • Swabble/Sources/swabble/Commands/StatusCommand.swift (added, +34/-0)
  • Swabble/Sources/swabble/Commands/TailLogCommand.swift (added, +20/-0)
  • Swabble/Sources/swabble/Commands/TestHookCommand.swift (added, +30/-0)
  • Swabble/Sources/swabble/Commands/TranscribeCommand.swift (added, +61/-0)
  • Swabble/Sources/swabble/main.swift (added, +151/-0)
  • Swabble/Tests/SwabbleKitTests/WakeWordGateTests.swift (added, +82/-0)
  • Swabble/Tests/swabbleTests/ConfigTests.swift (added, +23/-0)
  • Swabble/docs/spec.md (added, +33/-0)

PR #47778: fix: restore export-html template placeholders to single-line format (closes #43620)

Description (problem / solution / changelog)

Summary

  • Problem: The {{MARKED_JS}}, {{HIGHLIGHT_JS}}, and {{JS}} placeholders in template.html were split across multiple lines by a code formatter, causing .replace("{{MARKED_JS}}", ...) calls to silently fail. Exported HTML files then throw ReferenceError: MARKED_JS is not defined.
  • Why it matters: Session HTML export is completely broken — exported files cannot be opened in a browser.
  • What changed: Restored the three script placeholders to single-line <script>{{PLACEHOLDER}}</script> format in template.html.
  • What did NOT change (scope boundary): The replacement logic in commands-export-session.ts; no formatter config changes needed since oxfmt does not process HTML files.

Change Type

  • Bug fix

Scope

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #43620

User-visible / Behavior Changes

Exported session HTML files now correctly include vendored JavaScript libraries (marked.js, highlight.js) and the main application code, allowing the files to open and render properly in a browser.

Security Impact

  • New permissions/capabilities? No
  • Secrets/tokens handling changed? No
  • New/changed network calls? No
  • Command/tool execution surface changed? No
  • Data access scope changed? No

Repro + Verification

Steps

  1. Export a session with /export-session
  2. Open the generated HTML file in a browser

Expected

  • Page renders correctly with syntax-highlighted code blocks

Actual (before fix)

  • Browser console shows ReferenceError: MARKED_JS is not defined, HIGHLIGHT_JS is not defined, JS is not defined

Evidence

  • Failing test/log before + passing after
  • template.security.test.ts — 5 tests pass
  • pnpm tsgo passes (only pre-existing ui errors)

Human Verification

  • Verified scenarios: template.security.test.ts passes; replacement strings {{MARKED_JS}} etc. now match the patterns used in commands-export-session.ts
  • Edge cases checked: {{CSS}} and {{SESSION_DATA}} were already on single lines (unaffected)
  • What you did NOT verify: runtime end-to-end HTML export testing

Review Conversations

  • I replied to or resolved every bot review conversation I addressed in this PR.

Compatibility / Migration

  • Backward compatible? Yes
  • Config/env changes? No
  • Migration needed? No

Failure Recovery

  • How to disable/revert: revert this commit

Risks and Mitigations

None

Changed files

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

Code Example

Uncaught ReferenceError: MARKED_JS is not defined
Uncaught ReferenceError: HIGHLIGHT_JS is not defined
Uncaught ReferenceError: JS is not defined

---

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

---

<script>
 {
 {
 MARKED_JS;
 }
 }
</script>
RAW_BUFFERClick to expand / collapse

Bug Description

Exported session HTML files fail to open. Browser console shows:

Uncaught ReferenceError: MARKED_JS is not defined
Uncaught ReferenceError: HIGHLIGHT_JS is not defined
Uncaught ReferenceError: JS is not defined

Root Cause

Placeholders in dist/export-html/template.html are incorrectly split into multi-line format by code formatters (e.g., prettier):

Expected format:

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

Actual format:

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

The code uses .replace("{{MARKED_JS}}", markedJs) for substitution, but since the placeholder is split across lines, the replacement fails, resulting in undefined JavaScript variables in the generated HTML.

Affected Placeholders

  • {{MARKED_JS}}
  • {{HIGHLIGHT_JS}}
  • {{JS}}

Suggested Fixes

  • Protect placeholders with HTML comments to prevent formatting
  • Add formatting ignore rules for .html files in the build process
  • Use regex replacement in code to tolerate whitespace

Workaround

Manually edit dist/export-html/template.html and restore single-line placeholder format.

Environment

  • OpenClaw version: latest (2026-03-11)
  • Node: v22.12.0
  • OS: macOS (arm64)

extent analysis

Fix Plan

To fix the issue, we will use regex replacement in code to tolerate whitespace. We will modify the replacement code to use a regex pattern that matches the placeholders across multiple lines.

Code Changes

// Before
const html = template.replace("{{MARKED_JS}}", markedJs);
const html = template.replace("{{HIGHLIGHT_JS}}", highlightJs);
const html = template.replace("{{JS}}", js);

// After
const html = template.replace(/{{\s*MARKED_JS\s*}}/g, markedJs);
const html = html.replace(/{{\s*HIGHLIGHT_JS\s*}}/g, highlightJs);
const html = html.replace(/{{\s*JS\s*}}/g, js);

Verification

After making the code changes, verify that the exported session HTML files open correctly in the browser and that the browser console does not show any Uncaught ReferenceError messages.

Extra Tips

  • Consider adding formatting ignore rules for .html files in the build process to prevent this issue in the future.
  • Use a code formatter that can be configured to ignore certain files or patterns to prevent unwanted formatting changes.

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