Code Browser
/code is a public, read-only viewer for the Arduino firmware source — lets anyone (teammates, judges, curious visitors) read the actual code without cloning the repo.
Interface
| Element | Behaviour |
|---|---|
| File list (sidebar on desktop, dropdown on mobile) | Every firmware file, ordered by display_order |
| Viewer pane | Selected file's content, syntax-highlighted (C/C++ and HTML tokenizer — tags, strings, comments, preprocessor directives, keywords, numbers) |
| Copy button | Copies the currently-viewed file to the clipboard; shows "Copied ✓" for 1.5s |
| Download All | Downloads every listed file as a single .zip (GET /api/code/download-all) |
The zip preserves Arduino's folder convention: the main sketch files nest under envirobot/ (Arduino IDE requires the .ino's folder to share its name), while rc_page/ and tests/ keep their own prefixes.
Where the Content Comes From
This page never reads the git repo directly — it serves whatever is in the code_files Supabase table + R2, populated by:
node scripts/sync-code.mjs(run locally after any firmware edit) — regenerates the embedded file list inapp/api/admin/seed-code/route.ts. Nothing is redacted — WiFi is AP-only, so the firmware holds no private credentials.POST /api/admin/seed-code(from/admin, orcurlwith the admin cookie) — uploads each embedded file to R2 atcode/{filename}and upserts itscode_filesrow.
If /code shows "No files yet," step 2 hasn't run since the last deploy. See Content Admin for the full seed/edit flow, and Platform Overview for the pipeline diagram.
Caching
File content is served with Cache-Control: immutable — safe because a changed file gets a fresh upload (new bytes at the same r2_key) only via a full re-seed, not an in-place patch. The file list (GET /api/code) caches for 5 minutes.