Skip to content

claude-code-chat-browser: YAML escape fix — handle colons, hashes, tabs, bool literals in frontmatter export #102

Description

@clean6378-max-it

Calendar Day

Wednesday, July 2, 2026 (PR 2 of 2)

Planned Effort

3 story points (Medium–High) — sprint item #6

Companion PR: Wednesday PR 1 (SessionMetadataDict #9) — independent; can land in either order.

Problem

The _escape_yaml() helper in utils/md_exporter.py does not handle several YAML-special characters and patterns:

  • Colons followed by space (: ) — interpreted as key-value separator, corrupts frontmatter
  • Hash/pound signs (#) — interpreted as inline comments, truncates values
  • Tab characters — YAML spec forbids tabs for indentation
  • YAML boolean literals (true, false, yes, no, on, off) — unquoted values parsed as booleans

Session titles and project paths from Claude Code regularly contain colons (e.g. C:\Users\..., Fix: handle edge case) and hashes. The resulting YAML frontmatter is malformed and fails to parse in downstream consumers.

Goal

One merged PR that makes exported YAML frontmatter round-trip cleanly through yaml.safe_load() for all real-world session metadata inputs, using always-double-quote scalars as the primary fix.

Scope

Touch points

  • utils/md_exporter.py_escape_yaml(): always double-quote YAML scalar values in frontmatter; escape internal " as \"; use block scalar (| or >) for multiline values
  • tests/test_yaml_frontmatter_roundtrip: extract YAML between --- delimiters, yaml.safe_load(), assert dict matches original metadata
  • tests/ — Hypothesis @given(st.text()) property test for round-trip fidelity

Out of scope

  • Changes to Markdown body export format
  • JS YAML parser compatibility tests (Python round-trip is sufficient)

Acceptance Criteria

  • _escape_yaml() produces valid YAML for values containing : , #, \t, and boolean literals
  • Double quotes within values escaped as \" before wrapping
  • Multiline values use YAML block scalar syntax
  • Exported frontmatter round-trips through yaml.safe_load()
  • Hypothesis property-based test asserts round-trip fidelity
  • Existing export tests pass with properly escaped output
  • Full pytest, mypy --strict, and ruff pass
  • PR approved by at least 1 reviewer

Verification

cd C:\Users\Jasen\CppAliance\claude-code-chat-browser
.\.venv\Scripts\Activate.ps1
pytest tests/ -k yaml -q
pytest -q

Manual: export session with title Fix: handle edge case — confirm frontmatter parses via yaml.safe_load().

Metadata

Metadata

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions