Skip to content

Conversation

@abrichr
Copy link
Member

@abrichr abrichr commented Jan 17, 2026

Summary

  • Fix critical bug causing Alpine.js parsing errors when JSON data with quotes is embedded in x-data attributes
  • Add html.escape() wrapper around json.dumps() for all x-data attributes to properly encode quotes as " entities
  • Add new enhanced UI components (video playback, action timeline, comparison view, action filter, failure analysis)
  • Update .gitignore to exclude generated HTML viewer files

Problem

The generated HTML was breaking with:

Alpine Expression Error: Unexpected token ';'
Expression: "{ currentStep: 0, isPlaying: false, ... steps: [{"

This happened because JSON data with double quotes was being embedded directly in HTML attributes, causing the browser's HTML parser to see the quotes as attribute delimiters.

Solution

Wrap all json.dumps() calls with html.escape() when embedding JSON in HTML attributes.

Test plan

  • Run uv run pytest tests/ -v - All 115 tests pass
  • Run uv run python -m openadapt_viewer.examples.capture_example - Generates valid HTML
  • Verify generated HTML has properly escaped JSON
  • Open generated HTML in browser and verify no console errors

Generated with Claude Code

abrichr and others added 2 commits January 17, 2026 01:30
The workflow-name-based badge URL was showing "no status" because
GitHub requires workflow runs on the specified branch. Using the
filename-based URL format (actions/workflows/publish.yml/badge.svg) is
more reliable and works regardless of when the workflow last ran.

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
The JSON data being embedded in x-data attributes was not properly
escaped, causing Alpine.js parsing errors when the data contained
quotes or special characters.

Changes:
- Add html.escape() wrapper around json.dumps() for all x-data attrs
- Add new enhanced UI components with proper escaping:
  - video_playback: Screenshot sequence video player
  - action_timeline: Horizontal/vertical timeline with seek
  - comparison_view: Side-by-side comparison
  - action_filter: Action type filter components
  - failure_analysis: Benchmark failure analysis panel
- Add enhanced_capture_example showing new components
- Update .gitignore to exclude generated HTML viewer files
- Export new components from components/__init__.py

The fix ensures quotes are encoded as &quot; entities so browsers
can properly parse the HTML attributes before Alpine.js processes them.

Closes issue with Alpine Expression Error: Unexpected token ';'

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
@abrichr abrichr merged commit 319d0b9 into main Jan 17, 2026
@abrichr abrichr deleted the fix/json-escaping-alpine-html-attributes branch January 17, 2026 13:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants