Commit Graph

15 Commits

Author SHA1 Message Date
7ee15f8eac Stop tracking workspace/; bundled-demos/ is the canonical demo source
`workspace/` is runtime state (per-user folders, no-auth dev's `code/`)
and shouldn't be in git. The same files were previously committed under
both `workspace/code/` and `src/static/bundled-demos/`, which forced a
Docker `diff -q` sync check and leaked user-scoped paths into version
control.

- /workspace/ added to .gitignore; all previously tracked files removed
  via `git rm --cached`.
- src/static/bundled-demos/ becomes the single source of truth: panel16
  demos, led_tutorial, led_patterns, neopixel demos, and main.py move
  here alongside the existing canonical demos.
- New BUNDLED_DEMOS_DIR config; user_workspace seeders read from it.
- main.py lifespan seeds WORKSPACE_ROOT/code/ on startup so a fresh
  clone running `pipenv run dev` still gets the full sample set
  (existing files never overwritten — user edits survive restarts).
- Dockerfile drops `COPY workspace` and the diff sanity check.
- README/LED_TUTORIAL repointed at the new canonical paths.
- test_led_patterns loads led_patterns.py from bundled-demos.
- test_api uses mkdir(exist_ok=True) for `code/` (startup pre-creates).

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 06:55:59 +12:00
b8d62e01d9 Fix Docker build by relying on committed bundled-demos copies
The previous build step copied `workspace/code/<demo>.py` into
`src/static/bundled-demos/` at image-build time. That failed for some
build contexts where `workspace/` wasn't materialised when the RUN
ran (cp: cannot stat ... No such file or directory).

Since `src/static/bundled-demos/*.py` are version-controlled and ship
with `COPY src ./src`, the runtime image already has them. Replace the
fragile cp loop with a `diff -q` invariant that fails the build if a
canonical demo drifted between `workspace/code/` and
`src/static/bundled-demos/`, catching mismatches at build time instead
of runtime.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 06:44:53 +12:00
76129469a1 Add 'Reset demos' button to refresh canonical demo files
Existing accounts (including admin) seeded before new demos shipped
had no easy way to pull in the latest copies — the registration-time
seeder is intentionally non-destructive. The new badge action fetches
src/static/bundled-demos/manifest.json, confirms the overwrite, and
re-copies each canonical demo into code/. Open tabs of those files are
refreshed in place so the user sees the new content immediately.

src/static/bundled-demos/ ships the six canonical files plus the
manifest so this works in local mode and on a static-only host. The
Dockerfile now mirrors workspace/code/<demo>.py into bundled-demos/
during the image build, keeping the two locations in sync.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 06:35:03 +12:00
655f8b78fd Seed pin/ADC/serial demos into new accounts
`_CANONICAL_DEMO_FILENAMES` now also lists `pin_demo.py`,
`adc_slider_demo.py`, and `serial_demo.py` so first-time users get
working examples for every simulator. Seeding stays idempotent — the
dst-exists guard keeps re-registration / sign-in from clobbering edits.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 06:21:36 +12:00
ca0ca6fe7e Add local-mode workspace, ZIP import/export, and richer pin/ADC/serial sims
Boot:
- Editor now picks local vs server mode based on URL flag, sign-in
  state, and a stale local-mode flag. Signed-in users are no longer
  bounced to IndexedDB if they had previously clicked "Use locally".

Local mode:
- New LocalWorkspaceClient (src/static/local-workspace.js) with
  pluggable IndexedDB and File System Access backends. Picked folder
  handles persist across reloads with a Reconnect button when the
  permission lapses.
- Static-only host: scripts/serve_static_editor.py serves src/static/
  with COOP/COEP so SharedArrayBuffer-backed sims keep working.
- Bundled MicroPython stubs ship under src/static/bundled-lib/ for
  static hosting; FastAPI also exposes them at /api/public/lib-bundle.

Workspace import / export:
- Zero-dep ZIP encoder + reader (STORE + DEFLATE via
  DecompressionStream). Export/Import buttons in the workspace badge
  work in both local and server modes; imports are confined to code/.

Pin / ADC / Serial simulation:
- machine.py grows ADC, UART, expanded Pin, and PWM mocks, all driven
  by SharedArrayBuffer when cross-origin isolated and falling back to
  postMessage + [pin-out] stdout markers otherwise — pins, ADC slider,
  and serial input now keep working over plain HTTP / LAN-IP origins.
- NeoPixel pins are claimed via a [pin-claim] marker and dropped from
  the Pins panel so the data line doesn't flicker per write().
- New demos: adc_slider_demo.py, pin_demo.py, serial_demo.py.

Lib layout:
- Single source of truth at repo lib/; workspace/lib/ caching layer
  removed and the directory deleted. Filesystem service reads stubs
  directly from PROJECT_ROOT/lib.

UI:
- Home page slimmed to "Sign in" + "Use locally" with optional editor
  / manage-users links. Admin user/invite UI moved to /users.
- Workspace badge gains storage indicator, Folder…/Reconnect, Export,
  Import, and Exit controls.
- Mobile-friendly tweaks: safer-area padding, larger touch targets,
  iOS-zoom-proof serial input, file-tree highlight fix.

Tests:
- test_auth.py patches PROJECT_ROOT for the lib-shared test so the
  repo-root lib refactor stays green. test_api.py asserts the new
  "LED Editor" branding.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 06:16:02 +12:00
9f28eabd2d Rename UI to LED Editor and improve mobile editor layout
Use "LED Editor" in page titles and the home heading. On narrow
viewports, make the file tree an off-canvas drawer with backdrop,
hamburger toggle, Escape to close, and auto-close after opening a
file. Add safe-area and tap-target tweaks, cache-bust static assets.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 03:16:35 +12:00
a2318f2244 Ship MicroPython stubs from repo lib/ and seed workspace lib on startup
Move machine.py and neopixel.py into a tracked /lib/ at the repo root and
auto-copy them into WORKSPACE_ROOT/lib whenever files are missing, so empty
volumes and fresh per-user workspaces always have the read-only stubs
available to Jedi and Pyodide. Allow all users to browse lib/ in the UI
(writes still gated by the API), and add tests covering initial seeding
and re-population after the dir is wiped.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 02:59:34 +12:00
f7892dd31b Admin user editing, knight-rider demos, self-contained user seeds
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 02:23:53 +12:00
b02a182bf1 Ignore per-user workspaces and dev .reload-token
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 01:49:50 +12:00
687a8347f8 Default per-user main.py; invite-only by default
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 01:45:20 +12:00
6fc651ad72 Add tutorial route; gate lib workspace for superusers; Py worker v4
- Serve /tutorial and add tutorial.html/tutorial.js assets
- Fetch auth role; hide lib from non-superusers in tree and restored tabs
- Cache workspace Python sources briefly for Py worker
- Pyodide worker and home/index links/styling tweaks

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-05-10 01:14:51 +12:00
7d682cce8d Add admin invites and user workspace management tools.
Implement invite-token registration with optional email delivery, add admin UI actions for creating invites and opening user workspaces, and support superuser workspace override while preserving per-user code isolation with shared read-only lib.

Made-with: Cursor
2026-05-01 21:13:13 +12:00
e4c811f51d Expand browser editor runtime and LED simulation workflows.
Add Docker deployment support, richer Selenium/LED pattern tests, in-browser diagnostics, responsive UI improvements, and 16x16 panel simulation tooling to speed iteration and hardware-style prototyping.

Made-with: Cursor
2026-05-01 20:24:05 +12:00
f204109a84 Add browser Python editor with Pyodide, user auth, and workspace API
- FastAPI serves static UI, file CRUD under code/ and read-only lib/
- Pyodide worker runs Python and Jedi completions in the browser
- SQLite accounts: login/register, session cookies, superuser user management
- Optional EDITOR_API_KEY, AUTH_* env vars, .env.example
- Pipenv, pytest, Selenium smoke test, README

Made-with: Cursor
2026-05-01 14:33:26 +12:00
d245ecd353 Initial commit 2026-05-01 01:34:55 +00:00