Skip to content

feat: add the figures to project.zip - #57

Merged
maehr merged 2 commits into
mainfrom
feat/zip-figures
Oct 6, 2026
Merged

maehr merged 2 commits into
mainfrom
feat/zip-figures

Conversation

@maehr

@maehr maehr commented Oct 6, 2026

Copy link
Copy Markdown
Owner

Replaces #55. A merge loop merged #55 into feat/map-explanations instead of main. The content is unchanged. It already includes the Copilot fixes.

Summary

Closes #50.

  • exports.figure_files renders every chart of the result view. An Altair chart becomes a standalone HTML page with its data inside. A word cloud stays a PNG.
  • The group, date, and position charts appear only when their data exists.
  • Privacy: without Include the document text, the document map holds no snippet. The checkbox now governs the figures as it governs the CSV.
  • project.zip writes the files under figures/. README.txt explains the folder and says that an HTML figure loads Vega from a CDN.
  • The download button builds the package only on a click. The word clouds are slow under Pyodide.
  • The export disables the Altair limit of 5,000 rows. A long text can exceed it.

An Altair PluginEnabler.__exit__ annotation rejects a valid with. One ty: ignore[invalid-context-manager] line covers it.

Test

  • Unit tests cover the base figures, the group, date, and long-text branches, the snippet rule, and the row limit.
  • Browser test on Pyodide 314: the newspaper demo gives 19 figures, the book demo gives 30.
  • topic_map.html and document_map.html render outside the app.

🤖 Generated with Claude Code

https://claude.ai/code/session_01EsEUVKgZPLky1kHXnU2aBW

Copilot AI balanced review requested due to automatic review settings October 6, 2026 13:02
@coderabbitai

coderabbitai Bot commented Oct 6, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 24 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 4ab8c1b6-18ba-4cba-9181-e49d069759bd
📥 Commits

Reviewing files that changed from the base of the PR and between 27132db and 83791e9.

📒 Files selected for processing (6)
  • README.md
  • SPECS.md
  • app.py
  • simple_topic_modeling/exports.py
  • simple_topic_modeling/plots.py
  • tests/test_exports.py
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Base automatically changed from feat/map-explanations to main October 6, 2026 13:04
maehr and others added 2 commits October 6, 2026 15:04
exports.figure_files renders every chart of the result view. An Altair chart becomes
a standalone HTML page with its data inside. A word cloud stays a PNG. The group,
date, and position charts appear only when their data exists. Without the document
text, the document map holds no snippet, as the CSV holds no text.

The download button builds the package only on a click, because the word clouds are
slow under Pyodide.

Closes #50.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsEUVKgZPLky1kHXnU2aBW
Altair writes the chart JSON into a script block without escaping. A topic name, a
document ID, or a snippet with </script> would close the block and run as markup when
a reader opens the figure. The export now escapes <, >, and & as JSON unicode escapes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EsEUVKgZPLky1kHXnU2aBW
@maehr
maehr force-pushed the feat/zip-figures branch from 7a7d630 to 83791e9 Compare October 6, 2026 13:04

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot review overview

🟢 Approval recommended

The implementation matches the stated requirements and covers its conditional, privacy, security, and browser-specific behavior.

Review effort: Balanced
Findings: None

What changed in this PR

Adds all result-view charts to project.zip while preserving privacy controls and browser performance.

Changes:

  • Exports Altair charts as standalone HTML and word clouds as PNG.
  • Builds ZIP files lazily and conditionally includes metadata/position figures.
  • Adds script-safe serialization, documentation, and comprehensive tests.
File Description
simple_topic_modeling/​exports.py Generates figure files and adds them to the ZIP.
simple_topic_modeling/​plots.py Makes document snippets optional in tooltips.
app.py Lazily builds the expanded package on download.
tests/​test_exports.py Tests figure contents, conditions, privacy, limits, and escaping.
SPECS.md Specifies figure export behavior.
README.md Documents figures in project.zip.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@maehr
maehr merged commit 1fc64bc into main Oct 6, 2026
6 checks passed
@maehr
maehr deleted the feat/zip-figures branch October 6, 2026 13:05
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.

Feature request: Include figures in project.zip

2 participants