Skip to content

Add browser Python editor, badge simulator, and USB app editing - #32

Merged
avni merged 5 commits into
mainfrom
codex/badge-web-editor
Oct 12, 2026
Merged

avni merged 5 commits into
mainfrom
codex/badge-web-editor

Conversation

@crnicholson

@crnicholson crnicholson commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Adds /editor so users can write Python, test complete app projects in a browser simulator, and open installed badge apps over USB for editing and verified re-upload.

The page follows the Badger theme and GitHub branding, runs previews automatically after edits, includes all 23 installable app examples with their modules and assets, and provides file navigation, Open/Download, Undo/Redo, and independently resizable pane widths and workspace height. Badge controls explain the connect, choose an app, edit, and upload workflow. Mobile navigation uses two rows with readable labels and targets at least 44px wide and tall.

Replacing an edited project requires confirmation, including projects with added empty files or a changed name. The guard survives draft restoration. Simulation stages files only at the current badge app's execution directory, /system/apps/<name>. A renamed app that still references its original folder must have its source paths updated before running or uploading.

The locally hosted MicroPython WASM runtime retains the upstream MIT notices and third-party runtime license documents. public/simulator/THIRD_PARTY.md records the dependency audit and artifact hashes. Updates to existing badge apps and examples upload only edited or added files, including after draft restoration. Unchanged files are not read or rewritten, and upload completion updates the cached app list without a full disk rescan. First installs copy every required file. The button shows the eligible file count, with filename progress during writes. Uploads preserve unrelated files, detect external changes to edited files, verify bytes after writing, and roll back failed writes. Only verified files become part of the persisted badge baseline, and UTF-8 byte-order marks are preserved. Simulator networking is unavailable and sensor values are synthetic; physical badge behavior still needs hardware testing.

Validation:

  • npm run build passes.
  • npm run test:editor passes all 29 project and upload tests.
  • npm run test:app-descriptions passes all 11 existing tests.
  • Live browser checks cover examples, local file opening, editing, automatic simulation, per-file Undo/Redo, and horizontal/vertical resizing with persistence and reset.
  • Review follow-up browser checks cover cancelling project replacement, example replacement, empty-file protection after reload, renamed-path validation and corrected-path simulation, and mobile navigation at 320px with 67 by 44px targets.
  • Browser checks against a temporary mock badge confirm that a one-line edit in the nine-file Flappy app uploads only __init__.py, performs only its preflight and verification reads, and avoids an app-list rescan. This covers both opening a badge app and updating from an example.
  • Physical USB uploads and hardware speed remain unverified.
  • npx tsc --noEmit reports the three existing implicit-any errors in astro.config.mjs; no editor errors were reported.

Copilot AI balanced review requested due to automatic review settings October 11, 2026 15:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Project transitions can destroy drafts, simulation can mask invalid hardware paths, and the bundled runtime lacks a required MicroPython notice.

4 open findings
What changed in this PR

Adds a browser-based Python editor, MicroPython badge simulator, bundled app examples, and verified USB project uploads.

Changes:

  • Adds multi-file editing, simulation, drafts, and resizable panes.
  • Adds transactional USB uploads with verification and rollback.
  • Bundles simulator runtime, compatibility modules, examples, tests, documentation, and navigation.
File Description
src/​pages/​editor.astro Editor and simulator interface
src/​lib/​badge-editor.ts Editor workflow and runtime orchestration
src/​lib/​badge-editor-project.ts Project loading, storage, and simulation staging
src/​lib/​badge-editor-upload.ts Verified USB uploads and rollback
src/​lib/​badge-editor-split.ts Resizable workspace behavior
src/​components/​navigation.tsx Adds Editor navigation
src/​components/​Footer.astro Adds Editor footer link
scripts/​sync-editor-apps.mjs Synchronizes upstream examples
public/​editor-apps/​** Bundled app projects, assets, catalog, and license
public/​simulator/​** MicroPython runtime and badge compatibility layer
tests/​badge-editor-*.test.mjs Project and upload tests
package.json Editor dependencies and scripts
.github/​workflows/​ci.yml Runs editor tests in CI
docs/​editor.md Documents behavior, limitations, and verification

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/lib/badge-editor.ts Outdated
Comment thread src/components/navigation.tsx Outdated
Comment thread src/lib/badge-editor-project.ts Outdated
Comment thread public/simulator/LICENSE

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Path collisions can defeat upload rollback, and catalog synchronization can replace the bundle from a truncated tree.

3 open findings
4 resolved since last review

🧠 Review effort: Balanced

Comment thread scripts/sync-editor-apps.mjs Outdated
Comment thread src/lib/badge-editor-upload.ts
Comment thread src/lib/badge-editor.ts Outdated
crnicholson and others added 3 commits October 11, 2026 14:33
Added error handling for incomplete app catalog tree.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@avni
avni merged commit 118e3dc into main Oct 12, 2026
2 checks passed
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.

3 participants