Fix Sandpack compatibility - #3
Merged
Merged
Conversation
Co-Authored-By: Emilio's Codex <noreply@animaapp.com> Agent-Id: agent_761b01d97593f92f81195daa Anima-Actor-Type: agent Anima-Actor-Id: agent_761b01d97593f92f81195daa
There was a problem hiding this comment.
🟢 Approval recommended
The Sandpack/Vite split, BrowserFS loading path, and markdown renderer swap are cohesive and are backed by focused new tests for the new bundle/navigation/file-loading behavior.
Pull request overview
This PR updates the React/Vite viewer to run both as a normal Vite app and inside Sandpack, by splitting entry points and switching file-loading/rendering paths to be Sandpack-safe.
Changes:
- Moved viewer source under
src/and updated Vite/Vitest andindex.htmlto use the new Vite entry (src/vite-main.jsx). - Added a Sandpack entry (
src/main.jsx) that reads/brainmarkdown via BrowserFS and builds the bundle at runtime. - Replaced the markdown renderer with
markdown-to-jsxand introduced/expanded bundle + navigation utilities with accompanying tests.
File summaries
| File | Description |
|---|---|
| vite.config.js | Updates Vitest include glob to src/**/*.test.js. |
| src/vite-main.jsx | Vite-only entry that renders the pre-bundled brain import. |
| src/main.jsx | Sandpack entry that reads BrowserFS and builds a bundle at runtime. |
| src/render.jsx | Extracts rendering into renderBundle(bundle) for reuse by both entry points. |
| src/brain-files.js | Loads markdown via import.meta.glob(...?raw) for the Vite build path. |
| src/sandpack-files.js | Reads /brain markdown recursively from Sandpack BrowserFS. |
| src/sandpack-files.test.js | Tests BrowserFS-based markdown discovery and error behavior. |
| src/brain.js | Implements bundle building, parsing, link resolution, and graph edge derivation. |
| src/brain.test.js | Tests document parsing, link resolution, graph building, trust/freshness logic. |
| src/navigation.js | Adds folder-tree building and concept filtering for sidebar/search. |
| src/navigation.test.js | Tests folder grouping/sorting and filter behavior. |
| src/App.jsx | Provides the app shell, filtering, theme handling, and lazy-loaded panels. |
| src/Sidebar.jsx | Implements searchable, filterable sidebar UI for concepts/folders. |
| src/Graph.jsx | Implements Cytoscape-based graph visualization and controls. |
| src/Detail.jsx | Switches markdown rendering to markdown-to-jsx with internal link overrides. |
| src/Detail.test.js | Verifies GFM-ish rendering (bold/table) and internal link preservation. |
| src/theme.js | Adds storage/media-safe theme helpers for Sandpack and tests. |
| src/styles.css | Introduces the viewer’s CSS under src/. |
| index.html | Points the Vite entry script to /src/vite-main.jsx. |
| README.md | Updates repository layout docs and clarifies Vite vs Sandpack file loading. |
| package.json | Adds markdown-to-jsx and removes react-markdown/remark-gfm. |
| package-lock.json | Lockfile updates reflecting dependency changes. |
Review details
- Files reviewed: 11/22 changed files
- Comments generated: 0
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
srcChecks
npm test— 22 tests passednpm run build— passed.venv/bin/python -m pytest— 22 tests passed.venv/bin/python -m okf_tools check brain— passed