#22309: fix(export-session): render system prompt section and payload correctly
size: S
## Summary
- Fixes issue #22161 by replacing template placeholders in `export-html/template.html` so generated HTML contains valid embedded JS/CSS payloads.
- Ensures `MARKED_JS`, `HIGHLIGHT_JS`, and the main application script tokens are resolved before write-out.
- Adds regression coverage in `commands-export-session.test.ts` for export payload content and rendered output shape, including expected absence of unresolved template tokens.
- Tightened assertions to validate that the exported HTML includes system prompt block markers used by the viewer and confirms session payload carries `systemPrompt`.
## Why this is safe
- Narrow, local change to static export template generation and tests.
- No runtime command behavior changes outside `/export-session` output path.
- Existing export flow and command arguments are unchanged; only output reliability is improved.
## Testing
- `pnpm -s vitest run src/auto-reply/reply/commands-export-session.test.ts`
- `pnpm -s vitest run src/auto-reply/reply/commands.test.ts src/auto-reply/reply/commands-export-session.test.ts`
Fixes #22161
<!-- greptile_comment -->
<h3>Greptile Summary</h3>
Fixes broken template placeholders in `export-html/template.html` where a formatter had mangled `{{MARKED_JS}}`, `{{HIGHLIGHT_JS}}`, and `{{JS}}` into multi-line `{ { TOKEN; } }` blocks. Since `generateHtml()` uses exact string `.replace()` calls, these mangled tokens were never substituted, producing broken exported HTML with no JS payloads.
- **Template fix**: Restores all three `<script>` placeholders to their correct single-line `{{TOKEN}}` format so `.replace()` matches properly
- **New test coverage**: Adds `commands-export-session.test.ts` with regression assertions verifying that exported HTML contains no unresolved template tokens, includes the system prompt section, and carries correctly base64-encoded session data with `systemPrompt` and `tools` fields
<h3>Confidence Score: 5/5</h3>
- This PR is safe to merge — it fixes a clear template rendering bug and adds regression tests with no runtime behavior changes.
- The template fix is minimal (restoring mangled placeholders to their correct format) and the new test file provides solid regression coverage. The changes are narrowly scoped to the `/export-session` static HTML output path. No logic, dependencies, or runtime command behavior is altered.
- No files require special attention.
<sub>Last reviewed commit: 0cb41dd</sub>
<!-- greptile_other_comments_section -->
<!-- /greptile_comment -->
Most Similar PRs
#20816: fix(export-session): prevent Prettier from corrupting template plac...
by boris721 · 2026-02-19
84.7%
#22776: fix: restore export-session HTML template placeholders broken by Pr...
by miloudbelarebia · 2026-02-21
83.1%
#22695: fix(export): restore HTML template placeholders broken by formatter...
by lailoo · 2026-02-21
80.6%
#21271: fix(commands): pass channel/capabilities/shell/os to runtime in com...
by evansantos · 2026-02-19
73.1%
#16733: fix(ui): avoid injected newlines when tool output is hidden
by jp117 · 2026-02-15
73.0%
#20419: fix(webchat): explicitly pass gfm and breaks options to marked.parse()
by Limitless2023 · 2026-02-18
72.5%
#20795: fix(markdown): prevent triple newlines after blockquotes
by novalis133 · 2026-02-19
72.4%
#16542: fix(sessions): use atomic temp+rename write on Windows
by aldoeliacim · 2026-02-14
72.2%
#16019: fix(plugins): add postinstall patch for ESM-only package exports
by dashed · 2026-02-14
72.1%
#18655: fix(mattermost): preserve markdown formatting and native tables
by echo931 · 2026-02-16
72.1%