← Back to PRs

#22309: fix(export-session): render system prompt section and payload correctly

by AIflow-Labs open 2026-02-21 01:18 View on GitHub →
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