← Back to MaintStock

MaintStock Build Notes

How MaintStock is put together, where every piece lives, how to sign in to each one, and how to change, release, back up, or rebuild it without help. Written for Chris and anyone he brings in to help. Updated for version 26.1, Dec 5, 2026.

The short version

MaintStock is a website that phones add to their home screen. It has four parts:

Part What it does Where it lives Who signs in
The app files The screens and all the logic. Plain HTML, CSS, and JavaScript. No build step. The private GitHub repository topherbear8742/shop-stock (the main branch is what's live). Nobody; they are just files
GitHub Keeps every version of the files, runs the automatic tests on each change, and hands main to Netlify. github.com/topherbear8742/shop-stock Chris's GitHub account
Netlify Publishes main to maintstock.com by itself after every merge (about a minute). Also the domain registrar for maintstock.com. app.netlify.com Chris's Netlify account
Supabase The database, the sign-in system, photo storage, and the low-stock alert sender supabase.com/dashboard, project shop-stock Chris's Supabase account

Everything a tech does goes from their phone straight to Supabase. Netlify only serves the files. If Netlify went down, phones that already have the app keep working. If Supabase went down, scans save on the phone and sync later.

Accounts and how to get in

No passwords are written here. Keep them in a password manager.

What Address Notes
The app https://maintstock.com/ Each person signs in with their own email and password. Owners manage people on the Team tab.
Demo https://maintstock.com/demo/ Sample data on the visitor's device. No account needed.
Help pages https://maintstock.com/help/ Manual, troubleshooting, what's new, and these notes. No account needed.
GitHub https://github.com/topherbear8742/shop-stock Private. Every change is a pull request; the Tests check must be green before merging. Merging to main goes live.
Netlify https://app.netlify.com Site super-strudel-4e464c, linked to the GitHub repository (publish directory "."). Each pull request gets a Deploy Preview link. The old address https://super-strudel-4e464c.netlify.app still works.
Domain Netlify, under Domains maintstock.com was bought through Netlify on Oct 19, 2026. It renews yearly on the card in Netlify billing. Let it lapse and the app goes offline at that address.
Supabase https://supabase.com/dashboard Project shop-stock, reference id ocmzqdenveflbbcgjzpo, URL https://ocmzqdenveflbbcgjzpo.supabase.co

Adding helpers:

Free plan limits to know:

The repository, file by file

Everything below is in the GitHub repository topherbear8742/shop-stock (clone it, or open it on github.com).

shop-stock/
  index.html            every screen (tabs, sheets, sign-in)
  styles.css            colors and layout, light and dark
  app.js                all app logic (scanning, offline queue, labels, reports, equipment, pool, help)
  itemtypes.js          the list of part types (Plumbing, HVAC...), supplier category matching and the guess from a part name (24.25)
  gl.js                 GL codes: search, the code on each part and on Reorder, loading the coding guide (24.74)
  poolchem.js           pool chemistry math (doses from test results)
  mmreport.js           fills in the mold & moisture form PDF (where each answer goes on the page)
  hvac.js               HVAC troubleshooter: every check, answer and tool (edit NODES to change a check)
  appliance.js          Appliance tab: range, dishwasher and fridge checks, parts links, repair or replace, parts email
  pm.js                 PM tab: units, plan, due list, and the scheduling (starterPlan is the starting plan)
  makeready.js          Make Ready tab: the whiteboard of apartments being turned, and Fill in from a photo or sheet (Excel/CSV import, 24.14)
  supabase/functions/read-board  reads a whiteboard photo with the Anthropic API (the AI key stays in Supabase secrets)
  requests.js           Help > Ideas and problems (feature requests)
  today.js              Today screen, Search everything, Unit history, and the Contacts tab (version 23.0)
  files.js              the one ZIP writer and CSV cell rule (Backup, on-call Excel, unit photo export, every CSV download; 24.98)
  units.js              unit-number examples in each property's format, for every unit box (24.83)
  ctimport.js           Contacts Import sheet: reads .xlsx/CSV into contacts (version 24.13)
  unitgear.js           the equipment card on Unit history, and the Appliance tab's Save to the unit's equipment (24.12); Appliances by unit (24.66)
  city.js               City complaints tab: city notices, deadlines, reinspections, photos, print, CSV and sheet import (24.17)
  activity.js           Activity > Everything: what each person did, by date (version 24.4)
  i18n.js               the language switch: swaps on-screen English for Spanish as it appears
  i18n-es.js            the Spanish word list (English -> Spanish); loads only when Español is picked
  i18n-ksw.js           the S'gaw Karen word list (24.36, short draft); loads only when Karen is picked, demo only for now
  insp-report.js        unit inspection items (edit ITEMS to change the inspection) and its PDF
  finder.js             Find unit tab: each property's buildings on a satellite map, GPS, Walk there (edit PROPERTIES)
  oncall.js             On call tab: this week, who's next, the year, the draft and Publish (24.35)
  mileage.js            Mileage tab: each person's monthly sheet and Send to the property manager (24.43)
  mileage-form.js       StoneCreek's mileage form math and spreadsheet; an exact copy is in supabase/functions/send-mileage/
  region.js             Regional screen, new-property setup checklist, Copy a parts list (24.38)
  othershops.js         Other shops: which other properties have a part, with Call buttons (25.15)
  tips.js               mouse-over tips on a computer (24.48)
  upc.js                barcode lookup on Add item (24.47); one key for any form of a box code (24.89)
  handouts/             printable PDFs for owners (Team tab); their sources and render.js in handouts/source/
  forms/mold-moisture.pdf  the official NAA form (Revised 8.07.19), exactly as issued; never edit it
  forms/mold-moisture-original.pdf  an identical spare copy of the same form
  config.js             Supabase address and public key (safe to be public)
  theme.js              applies the Light/Dark choice before a page draws (app, demo and guides)
  vendor/               the libraries the app uses, kept on our own site (see below)
  _headers              browser safety rules Netlify sends with every page (see below)
  sw.js                 service worker: keeps the app on the phone so it opens with no signal
  manifest.webmanifest  name and icons for "Add to Home Screen"
  icon.svg, icon-192.png, icon-512.png
  netlify.toml          tells Netlify never to cache sw.js, and not to serve tests/, docs/, tools/, .github/ or handouts/source/
  maps/, hvac/          the property site maps (Find unit) and the HVAC wiring diagrams (standing pilot PDF, fan center picture)
  privacy/              the privacy policy page
  screenshots/          wide screenshots for the install prompt (manifest.webmanifest)
  navtest/              Android bottom-bar test pages (keep them on the site)
  AGENTS.md, CLAUDE.md  short rules for AI coding agents
  tests/                the automatic tests (see Automatic tests; not served on the site)
  README.md             developer overview and where every document is
  CHANGELOG.md          every version: what changed, its commit, pull request and tag
  CONTRIBUTING.md       the rules for making and releasing a change
  docs/                 developer documents: handoff, architecture and database, settings, releasing, backups (not served on the site)
  docs/ray-scan-kit/    a separate, MIT-licensed scanning and stock kit made for Ray's own website; not part of the app
  tools/                release and backup scripts and their tests (not served on the site)
  demo/index.html       copy of index.html for the demo (see Demo)
  demo/demo.js          fake database with sample data, used only by the demo
  help/*.md             sources of the help pages (manual, install guide, troubleshooting, release notes, build notes)
  help/*.html           the help pages, built from the .md files
  help/guide.css        styling for the help pages
  help/guide.js         Copy buttons and the Print link on the help pages
  help/build.py         turns help/*.md into help/*.html
  help/img/             example screenshots for the manual and quick start (made by tools/screenshots.js)
  supabase/schema.sql   the whole database: run it to rebuild from nothing
  supabase/functions/low-stock-push/   source of the alert sender (index.ts, webpush.js, board.js)
  supabase/functions/send-mileage/     emails a mileage sheet to the property manager (index.ts, mileage-form.js) (24.43)
  supabase/functions/lookup-upc/       asks UPCitemdb about a box barcode for the phone (24.47)
  supabase/functions/send-report/      source of the report emailer (index.ts)
  supabase/functions/send-welcome/     source of the welcome email (index.ts, welcome.ts)
  supabase/functions/first-login/      first-time sign-in and forgotten passwords: codes, the welcome link, My details (24.45)
  supabase/functions/_shared/signin.ts the welcome link token and sign-in codes, shared by send-welcome and first-login
  supabase/reports.sql  the reports tables and storage (version 17); also at the end of schema.sql
  supabase/properties.sql   report properties (version 21.5): report_settings.properties; also at the end of schema.sql
  supabase/oncall.sql       reports-only logins (version 21.6): staff role 'reports', is_member(); also at the end of schema.sql
  supabase/inspections.sql  unit inspections (version 18): kind column, inspection email and filter sizes; also at the end of schema.sql
  supabase/pm.sql       preventative maintenance (version 19): units, pm_tasks, pm_log; also at the end of schema.sql

The libraries the app uses are copies kept in the vendor folder, taken unchanged from the official npm packages:

Keeping them on our own site means no other website can change the code the app runs. The service worker keeps a copy of each one, so the app opens offline. To update a library, replace its file, change the name in index.html, demo/index.html and the SHELL list in sw.js, and test.

Browser safety rules (_headers): Netlify sends these with every page. They tell the browser to run scripts only from maintstock.com, to refuse to show the app inside another website's frame, and to let the app talk only to https sites and Supabase. Inline scripts and onclick attributes are blocked, so all code goes in .js files. If a new outside service is ever added (a new font host, a new script), it has to be allowed in _headers or the browser blocks it. In Chrome, the console (F12) says "Refused to load" when that happens.

How the app works inside

The database (Supabase)

Table Holds
staff Who can sign in, and their role (owner or tech)
items One row per part: name, bin, supplier, part number, keep on hand, on hand, on order, codes, photo, type (category, 24.25)
stock_log Every take out, put away, return, count, order, and undo, with who and when
equipment One row per loaner unit and its current status
equipment_log Every equipment check-out and check-in
pools Each pool's size, products, and target ranges
pool_tests Every saved pool test with its doses
push_subs Phones that turned on phone alerts
mr_alerts Make Ready changes waiting to be sent as alerts (24.6)
alert_prefs Each person's notification choices: Make Ready (24.6) and, since 24.91, chat, low stock, Friday reorder, on-call and mileage
units Each apartment unit, its building and furnace filter (PM tab)
pm_tasks The preventative maintenance plan (PM tab)
pm_log Every PM visit: done or couldn't do (PM tab)
city_complaints City notices, their deadlines, reinspections, fines and photos, per property (24.17)

Functions:

Other pieces:

Where to look in the Supabase dashboard:

Settings that must stay this way:

Making a change and releasing it

No build tools are needed to change the app. Any text editor works (VS Code is free). The extra tools are Git, Python (rebuilds the help pages) and Node (runs the tests).

  1. Get the files: clone the repository (git clone https://github.com/topherbear8742/shop-stock) or pull the latest main, and make a new branch for the change.
  2. Make the change in the files.
  3. Open app.js and raise the version number on this line near the top:
const VERSION = "23.3 (Oct 26, 2026)";
  1. Open sw.js and change the cache name to match the new version:
const CACHE = "shop-stock-v23.3";

The two must change together, or phones won't pick up the update. 5. Add a section at the top of help/release-notes.md describing the change for the team (Help > What's new), and an entry at the top of CHANGELOG.md for developers, under ## [Unreleased], like ## [23.9] - 2026-10-28 - Title. The Release rules check fails if either is missing. 6. If index.html changed, copy it over demo/index.html, then make the demo edits again: add <base href="../"> right after <head>, change the title to MaintStock Demo, point the License link at ../, take out the Try the demo link and the supabase-js script line, and take out the config.js script line. Then put the scripts in the demo's order, with <script defer src="demo/demo.js"></script> in the middle (the scripts after it need the fake database): theme.js (the only one without defer, so the dark theme shows before anything draws), i18n.js, tips.js, vendor/qrcode-generator, files.js, units.js, pm.js, makeready.js, city.js, requests.js, itemtypes.js, upc.js, region.js, demo/demo.js, poolchem.js, ctimport.js, oncall.js, today.js, unitgear.js, activity.js, app.js. Every script but theme.js has defer (24.63; deferred scripts still run in this order). hvac.js, appliance.js, finder.js, mileage-form.js, mileage.js, insp-report.js and mmreport.js aren't in either page: app.js loads them when their screen first opens (needScript()), and Leaflet's stylesheet comes with Find unit. A new script goes in the same place as in index.html, before demo.js only if it doesn't use the database when it loads. Compare with the old demo/index.html to check nothing else moved. 7. If any help/*.md file changed, rebuild the help pages. On a computer with Python, run these two commands from inside the shop-stock folder (on Chris-PC, C:\Users\Chris\Mainststock). The first one is needed only once. On Windows type py; on a Mac or Linux type python3 instead.

py -m pip install markdown==3.11.2
py help/build.py
  1. Test on the computer: from inside the shop-stock folder, run the command below (Mac or Linux: python3 -m http.server 8000), then open http://localhost:8000/demo/ in Chrome and try the change. The demo uses fake data, so nothing real is touched.
py -m http.server 8000

Add these to the end of the address to test special cases: ?shop=demo-oaks (you're at the second property, Sample Oaks: test every change there too), ?viewonly (a view-only login) and ?big (1,200 parts). This simple server doesn't send the safety rules in _headers, so a blocked script only shows up in the automatic tests or on the Deploy Preview. 9. Run the automatic tests (see Automatic tests below). They tap through every screen of the demo and list anything broken. 10. Deploy: commit, push the branch and open a pull request on GitHub. The quick Tests check (about 2 minutes) and the Release rules check run by themselves, and Netlify posts a Deploy Preview link to try. When every check is green, merge the pull request: Netlify publishes main to maintstock.com within a minute or two. GitHub then tags the version (v23.9 and so on), saves it under Releases with its CHANGELOG entry, and backs up the database for it. The full rules are in CONTRIBUTING.md and docs/RELEASING.md in the repository. 11. On a phone, open the app with signal (or switch back to it). It updates by itself within a few seconds; Help shows the version. Check for update on the Help tab forces it.

To undo a bad release fast, open Netlify Deploys, click the previous deploy, and choose Publish deploy. Phones go back on their next open. Then revert the pull request on GitHub (its Revert button), so the next merge doesn't bring the bad change back. The revert still needs a new, higher version number. Any older version can be looked at or downloaded exactly as it was from GitHub Releases (every version from 21.6 on).

Release rules check: tools/check-release.mjs, run on every pull request. It fails if the VERSION in app.js and the CACHE in sw.js don't match, if the version has no CHANGELOG.md or release-notes.md entry, if app files changed without a new version, if the version went down, if the help pages weren't rebuilt, or if a key or password was added. To run it before pushing: node tools/check-release.mjs --base origin/main.

Automatic tests

The tests/ folder holds a robot tester. It opens the demo (fake data only) in a hidden Chrome window, taps every button on every screen as a phone and as a computer, types odd things into boxes, presses Back on every window, checks the app still opens with no signal, checks the Help links, and times how fast things load on a slow phone. It writes a report sorted into Bugs, Acts strangely, Easier to use and Faster.

It runs by itself on GitHub (the Tests checks). A pull request runs only the quick part (file checks, feature steps, offline and help, about 2 minutes), to stay within GitHub's free Actions minutes (since 2026-10-31). After a merge to main, or with Actions > Tests > Run workflow, GitHub runs everything, split across six machines at the same time (phone taps and computer taps, each in two halves, layout and speed, and everything else), so it takes about 4 minutes; each part is its own check. A red check means it found a Bug; open the check, then Summary, to read the list, and download that part's test-report for the full page with screenshots. Only Bugs turn the check red. The other three lists are suggestions.

To run it on a computer, install Node.js (free, nodejs.org), then from the shop-stock folder run these once:

cd tests
npm install
npx playwright install chromium

Then, from the tests folder, run:

npm test

It takes 10 to 15 minutes (npm run test:quick takes about 5) and writes tests/report/index.html; open it in Chrome. To test a live site or a Netlify deploy preview instead of the files on the computer:

npm test -- --url https://maintstock.com

The tests never touch the real database: they use the demo, and anything trying to reach Supabase is blocked.

Feature checks: besides tapping at random, features() in tests/harness.js walks through features step by step and fails if a step doesn't do what it should (the Properties tab from version 22.17; Today, Search everything, Unit history, Contacts and Español from 23.0; Contacts import from 24.13; vendor details and Copy from another property from 24.58; staff and property manager contacts from 23.1; turning screens off from 23.2). Every new feature adds its own steps there. To run only those (under a minute):

npm test -- --only features

Terms of Use (version 24.65)

Everyone agrees to the Terms of Use (terms/index.html, maintstock.com/terms/) once per version, right after signing in.

Changing the database

  1. In Supabase open SQL Editor.
  2. Paste the SQL and tap Run.
  3. Add the same SQL to the end of supabase/schema.sql with a comment saying what it's for, so a rebuild includes it.
  4. For a new table, also add the view_only_guard trigger (see View-only logins) so view-only logins can't change it.
  5. For a new table, also turn on Row Level Security with is_staff() rules like the other tables. Add the table to the lists inside check_setup so Run setup check watches it.
  6. For a new table, also add grant lines in the same SQL. Since Oct 30, 2026 Supabase no longer opens new tables to the app on its own, and without grants the app gets "permission denied for table ...". Use these, with your table's name in place of new_table:

sql grant select, insert, update, delete on public.new_table to authenticated; grant select, insert, update, delete on public.new_table to service_role;

Give anon (signed-out visitors) nothing. Leave out insert, update or delete for authenticated if the table should only be written by a database function, like stock_log. supabase/schema.sql already has these grants for every existing table, so a rebuild works.

Never edit on_hand or on_order by hand in Table Editor. Use Count in the app so the change is logged.

Setting up report email

Mold & moisture reports (version 17) are emailed by the send-report function in Supabase, through Resend (resend.com). Resend's free plan sends 3,000 emails a month and 100 a day, from your own maintstock.com address. The steps are in the Version 17 setup steps file that came with the release, and in short:

  1. Run supabase/reports.sql in Supabase SQL Editor.
  2. Make a free Resend account and add the domain maintstock.com.
  3. Add the DNS records Resend shows in Netlify, under Domains, maintstock.com, DNS settings.
  4. Make a Resend API key with Sending access.
  5. In Supabase open Edge Functions, then Secrets, and add the secret RESEND_API_KEY with that key.
  6. In the app, set Reports, Report settings, and send yourself a test.

Since version 24.71 Send several reuses a report's last emailed PDF (from report_emails) when the report hasn't changed since, and makes the others 3 at a time.

Since version 24.70 every real send is also copied (CC) to the property's Contacts whose kind is Property manager, Assistant property manager or Maintenance supervisor and who have an email (staffCc() in the function and in app.js).

Since version 24.69 the function also takes several reports in one call, { reports: [{ report_id, pdf_path }, ...], test } (up to 10), and sends them in one email when they all go to the same people; the Reports tab's Send several groups them by recipient first. Older versions of the function answer a batch with "Missing report.", so deploy it after a release that changes it.

The function's source is supabase/functions/send-report/index.ts. To redeploy it, in Supabase open Edge Functions, then send-report, then Code, paste the file, and tap Deploy. To send from a different address, add the secret REPORT_FROM, for example MaintStock Reports <reports@maintstock.com>. The address's domain must be verified in Resend.

How a report is stored: table mm_reports (one row per report: the answers in data, the photo list in photos, sent_at and sent_to), table report_emails (one row per email sent, written only by the function), table report_settings (one row: property, PM, CC), and the private storage bucket report-files (photos and every emailed PDF, under mm/report id/). Team members can add and update reports but can't delete them or their files. The blank form is forms/mold-moisture.pdf, and mmreport.js knows where each answer goes on it. If the lender sends a new revision of the form, the positions in mmreport.js have to be measured again.

Reports per property, camera rollback (version 24.33)

Activity and search per property (version 24.32)

Inspections: back camera, Filter list, Incomplete (version 24.31)

Efficiency rules (version 24.27)

Found in the 24.27 code review; follow them in new code.

Make Ready steps that need confirming (version 25.12)

Late syncs, Undo and sign-out (version 25.11)

Weak signal and smaller updates (version 24.63)

Shop map editor on phones (version 24.26)

Walls use var(--fg) (24.24 used an undefined var(--text), invisible in dark theme). Each wall has a transparent .sm-hit rect around it as a finger-sized target. New and copied pieces are placed by place() so they don't pile up; the selected piece has position boxes (feet from the left and top), Copy and Done with this one. Save map upserts and keeps the editor open; Close asks for a second tap if anything is unsaved.

Don't stock (version 24.79)

Chris: "make it so I can choose to no longer stock an item. Both from items and reorder." dontStock(it) in app.js sets par to 0 with setPar() (an items update, so it needs signal), keeps on_hand, and the toast's Undo restores the old par. needOf() is 0 for any part with par 0, so it leaves To order and never comes back on its own. Buttons: Don't stock on each To order line (.ro-nostock) and Don't stock this part (#f-nostock) on the part's window when par > 0. No database change; it's the same "keep 0 = not stocked" rule Quick count's Don't stock uses (24.59). Tests: in otherSuppliers().

Other suppliers (version 24.78)

Chris bought Kilz from Chadwell and Westlake, so it was two parts with two counts and two bin labels. He wants one part and the supplier picked at reorder, Chadwell by default.

Faster counting (version 24.59)

Chris was the only shop using inventory, and counting 574 parts one at a time wasn't happening. Three shortcuts, all in app.js, none needing a database change: each one saves a normal count (apply_op, type count, so it queues offline and shows in Activity), and keep-on-hand is the existing items.par.

Set up bins and map walls (version 24.24)

Items > Tools > Set up bins (binSetupSheet in app.js) lists parts with a bin box each and saves items.bin one part at a time as you leave the box, the same way Count list saves counts. tidyBin turns "k2-5" into "K2-05". The shop map layout JSON has a third kind, "wall" (no name or label, can be 0.5 ft thin), drawn as a solid bar; cleanMap keeps it. No database change.

Part photos on labels (version 24.23)

Labels print the part's photo (items.photo) at the right end when the label type has room (labelPhotoSize in app.js: the name and bin must keep 25 mm). For label printers the app turns the photo into black and white dots itself at 300 dots per inch (Atkinson dithering in labelPhoto), because the Brother prints black only and its print drivers make gray pictures muddy. Sheets get a small gray JPEG. Photos are fetched when the PDF is made, so it needs signal; a photo that can't be fetched just leaves that label without one. Photos stored in the item-photos bucket always work. A pasted link from another site only works if that site allows it (CORS). The Print part photos checkbox is remembered per phone (localStorage ss-labelphotos).

Pictures in the guides (version 24.22)

The pictures in the manual and on page 2 of the quick start guides are made by tools/screenshots.js from the demo (never the real database), on a phone-sized screen: help/img/.jpg, and help/img/es/.jpg for the Spanish quick start. When a screen changes how it looks, retake them and rebuild:

node tools/screenshots.js
py help/build.py

(On a Mac or Linux: python3 help/build.py.)

node handouts/source/render.js

You can retake just some by name (node tools/screenshots.js today scan); the names are in the SHOTS list at the top of the script. To add a picture to the manual, put a line like What it shows on its own after a paragraph; two lines together show side by side, and the text in the brackets becomes the caption. In a handout, an img with src="SHOT/today" gets the picture when render.js runs. The test harness fails if a picture the manual or a handout names is missing.

Buttons and info look different (version 24.21)

Everything you can tap uses three colors from the top of styles.css: --btn-bg (a tint, light purple in the new look), --btn-line (an edge) and --btn-fg (the text), each set for light and dark. Cards, lists and information rows use --surface and --line. A new kind of button should use the btn variables (or just the class btn) so it never looks like information; a list row that opens something should be a button with class row, which gets the › by itself. The test harness checks this on the Help tab in both themes.

The shared box style in styles.css lists every typed input type (text, number, search, password, email, tel, url, date, month, time, datetime-local) plus select and textarea. A new input type that isn't on that list shows the browser's own gray box, so add it there. Plain links use a { color: var(--accent) }; links styled as buttons use a.btn.

Since 24.99 the menu bar is the rooms (.roombar, see Main menu below). Since the new look it sits along the bottom and its buttons are a fixed 64 px tall, so it never changes height, and the harness's "Boxes, links and menu bar" check measures it on several screens.

Chris: "It's super busy and im having trouble finding things." Every screen lives in exactly one room, and the rooms never move.

New look (26.0)

Chris picked every part side by side in light and dark (2026-11-22). The look is in one block at the end of styles.css ("25.8: Chris's new look", the name it was built under) plus the colors and fonts at the top.

Count asks the same way too (version 25.4)

Chris picked "One count box for every scan". The stepper countSheet() window is gone: countSheet(it, camAgain) now just calls fastCountSheet(), so a part label, a bin label, a search tap and Items' Count all open the same box. fastCountSheet() gained buttons 0-10 (aria-label "Count 7", one tap saves) above the text box. onCameraCode() passes camAgain for any known part in every mode, so the camera reopens after a count too. The count message no longer offers Print N labels (bin labels replace part labels). Checks: countShortcuts() "a part label in Count" (both demo properties). No database change.

Returned, new stock or count in Put away (version 25.18)

Parked during the feature freeze (Nov 21) and built when it ended (Chris, Dec 5: "Build both parked ideas"). Amy and Ron only put back unused parts; Chris puts away deliveries. Since 25.3 a bin label in Put away opened the put-away window on New stock, so a return logged with one tap lowered On order (an order still coming looked received) and was left out of suggested levels, which net return against out. putAwaySheet(it, { fromBin: true }) now shows a three-button row, group label "Returned, new stock or count?" (data-kind return, in, count). It starts on return when it.onOrder is 0 and on in when an order is coming, so a marked-ordered delivery still puts away with one tap. count closes the window (qtySheet() now returns close) and opens fastCountSheet(), replacing the bottom Count instead button in Put away (Take out keeps it). A part label, box barcode or search tap still starts on New stock with the two-button row. Per property with no setting: it only reads the part's own On order. Checks: countShortcuts() (both demo properties): three buttons, starts on Returned with nothing on order, Enter returns 1, New stock + 3, Count opens the count without changing stock, and starts on New stock after an order is marked (through the demo client, so the live update reaches the app). No database change.

Take out and Put away ask the same way (version 25.3)

Chris: "Why does taking out a part have a different procedure than putting away. They should both be easy to understand." qtySheet(it, o) in app.js is the one how-many window: thumb photo, an info line, an optional top (Put away's New stock / Returned switch), buttons 1-10 (aria-label "Take 3" / "Put away 3", one tap saves), extra buttons (Put away: #pa-order "All N on order", #pa-pack "1 pack (N)"), a text box (Enter on empty saves o.def(); a non-number goes to handleCode() as the next scan), Cancel, Count instead (bin labels), and the big button. takeSheet() (#tk-qty, #tk-go, default 1) and putAwaySheet() (#pa-qty, #pa-go, default 1: Chris, "scan the bin label in put away to put away a single part, just like take out"; Returned hides the extra buttons) both call it. binLabelScan() sends a CNT: label to putAwaySheet(it, { fromBin: true }) in Put away (it used to open fastCountSheet()); only Count opens the count. actOn() lost its ask option: a search-suggestion tap asks too, in both modes. onCameraCode() passes camAgain for any known part outside Count, so the camera reopens after a put-away. The old stepper put-away window and its "+1 pack" are gone. Checks: countShortcuts() (both demo properties) "Put away asks the same way". No database change.

One unit box on Scan (version 25.1)

Scan used to have two unit boxes: 24.66's Unit # + Go (TODAY.unitBox("sc"), prepended to #view-scan) and 24.38's For unit (#forunit, Take out only). Now only #forunit is left, under the mode buttons, in every mode. renderForUnit() in app.js sets data-mode on the box: out in Take out (saves take-outs to state.forUnit, repeat-call note, #forunit-open "Open unit 2601 ›"), look in Put away, Count and for Reports-only logins (#forunit-go or Enter opens TODAY.unitHistory, state.forUnit isn't shown or changed). Placeholder and keyboard come from UNITS.fit. Checks: features() "Parts per unit" and "Unit # box".

Calmer look (version 25.0)

Stage 2 of the redesign (stage 1 is Main menu above). Based on the mockups Chris picked, with the design rules from Impeccable (Operate mode: clear hierarchy, familiar controls) and Hallmark's floor (no labels in tracked capitals), used as reading only.

Screen sizes (version 24.51)

Chris: "I need this to have responsive design." MaintStock is one layout that adapts; there is no separate phone or desktop site.

Rows with a number box on phones (version 24.46)

A number box inside a row needs a selector stronger than the shared box rule (input[type="number"] is width 100%, and wins over a lone class), or it stretches across the row and crushes the text beside it to a few letters a line. Use .parent input.myclass (Suggested levels: .sugrow input.sug-in; Reorder and Print labels: .pickrow .qty).

Welcome email (version 24.20)

When an owner adds someone on the Team tab, the app calls the send-welcome edge function, which emails that person how to start, through Resend (the same RESEND_API_KEY as report email). Owners can send it again from Change under a person's name, in English or Spanish.

First-time sign-in (version 24.45)

First time here?, Forgot password and the welcome email's Set up my password button all open one screen (#first-form): email, new password twice, then Save. Passwords are set by the first-login edge function with the admin API, never by Supabase's own confirm or reset emails.

Security pass 8 (version 25.25)

Pass 7's 60 emails a day for everyone could be used up by one login (40 report + 20 mileage emails a day, tests included, and a test goes only to the sender). Database side: supabase/security-pass-8.sql (also at the end of schema.sql).

Security pass 7 (version 25.24)

Resend's free plan sends 100 emails a day for everything (sign-in codes, reports, mileage, Make Ready, chat, welcome, the Friday order email and Supabase Auth's own mail). Database side: supabase/security-pass-7.sql (also at the end of schema.sql).

Security pass 6 (version 25.23)

Database side: supabase/security-pass-6.sql (also at the end of schema.sql); the 25.23 app works before and after it, and it needs no edge function deploy.

Security pass 5 (version 25.22)

Storage object names become file paths in the nightly backup, so they're checked on both sides. Database side: supabase/security-pass-5.sql (also at the end of schema.sql); the app works before and after it.

Security pass 3 (version 25.21)

Chris approved fixing everything the security pass found. Database side: supabase/security-pass-3.sql (also at the end of schema.sql); apply it before deploying low-stock-push, send-welcome and first-login.

Pass 4 (still 25.21). Sections 6 to 8 at the end of security-pass-3.sql; deploy low-stock-push and send-mileage after it (first-login needs no SQL).

Security pass 2 (version 25.20)

Chris approved these in writing ("All 18"). Database side: supabase/security-pass-2.sql (also at the end of schema.sql); apply it before deploying the edge functions, which call it.

Sign in with Google (version 24.66)

A white Sign in with Google button (#login-google, .gsi-btn; the G is a data: SVG in styles.css, nothing loads from Google) sits under Sign in, after an "or" line. It uses Supabase's Google provider (settings in docs/SETTINGS.md; the client secret lives only in Supabase).

Backups and restoring

Rebuilding from nothing

If the Supabase project were lost:

  1. Create a new Supabase project.
  2. In SQL Editor, paste all of supabase/schema.sql and tap Run. Change the owner email at the bottom first if needed.
  3. In Edge Functions, deploy a new function named low-stock-push from supabase/functions/low-stock-push (index.ts plus webpush.js).
  4. In Authentication, URL Configuration, set the Site URL and Redirect URLs as above.
  5. In Project Settings, API, copy the project URL and the anon (publishable) key into config.js.
  6. Deploy the folder to Netlify.
  7. Sign in as the owner, then import items.csv from the latest backup.
  8. Add the team again on the Team tab. Each person sets a new password.
  9. Run Help, Run setup check, and fix anything red.

If Netlify were lost, create a new Netlify site linked to the GitHub repository (publish directory "."), move the domain, set it to Public, and update the Supabase redirect URLs.

HVAC troubleshooter

The HVAC tab is all in hvac.js. Nothing is stored in Supabase. app.js only builds the tab the first time it opens (mountHvac) and gives it the Items list for parts, so it works with no signal.

To change a check: open hvac.js and find NODES. Each step has an id (like "f.fs1"), q (the question), how (how to check, optional), warn (a yellow safety box, optional), and a (the answer buttons, each a label and the id of the next step). An answer has end (the likely cause), fix (what to do), and optionally parts (words to search the Items list for), epa (adds the EPA 608 note), pro (when to call a contractor), danger (a red safety box), and link (a button to another step). EQUIPMENT at the top lists the problems shown for each kind of equipment and the step each one starts at.

To add a problem: add its steps to NODES, then add a line to the right list in EQUIPMENT. Every answer must point to a step that exists. An answer can also point to "tool:" (opens a tool) or "eq:" (25.10: opens that equipment's problem list, used by Not sure what it is?).

Knowledge base (25.17): Chris's HVAC troubleshooter knowledge base (Nov 29, 2026) is folded in as steps, not as a probability engine. Its safety gates G1 to G11 are the s.* steps behind Safety first (s.1, the red button on the first screen). Its era questions are id.1 and id.2. New equipment: ipilot (i., spark pilot), hp (h., heat pump), elec (e., electric furnace or air handler with a fan center), mini (m.), oil (o.*). Furnace, AC and thermostat additions keep their f., p., a. and t. prefixes. Its test scenarios (sections 17.2 and 18.11) are route checks in the harness's static checks (kbRoutes), so a change that sends one of them somewhere else fails the Tests check. Reference numbers are in Quick specs, the extra code charts in CODES.brands, and serialYear() reads the year from a serial (How old is it?). Spanish for every new phrase is in i18n-es.js under "25.10 HVAC troubleshooter knowledge base"; a changed phrase needs its Spanish key changed too, or it shows in English.

Diagrams: a step or answer can have doc: ["/hvac/file", "Button name"], which shows a button that opens the file (PDF or picture). Add the file to the SHELL list in sw.js so it works with no signal. Pictures are drawn in tools/diagrams/ (an HTML page with an SVG drawing each); run node tools/diagrams/render.js to rebuild them into hvac/. Diagrams and fixes found on a real job go into the HVAC tab (Chris, Nov 10, 2026).

Tools (capacitor, superheat, split and rise with strip heat, amps, codes, specs, How old is it?) are near the bottom of hvac.js. The refrigerant pressure charts are in PT, and the blink codes are in CODES.

Bump VERSION in app.js and CACHE in sw.js after any change, so phones pick it up.

Appliance repair

The Appliance tab is all in appliance.js, built like hvac.js and reusing its styles (plus a few appl-* classes). Nothing is stored in Supabase; the current job (model, serial, unit, work order) and the phone's prices are in localStorage (ss-appl-*). app.js builds it the first time it opens (mountAppliance) and passes findParts, openItem, toast, who, propertyName, and supervisors (owners whose property or props include this one, the admin last).

Find unit

finder.js holds the Find unit tab and its data. It doesn't use the database.

Preventative maintenance

The PM tab is all in pm.js. The top half (addMonths through starterPlan) is the scheduling with no screen code; it runs in Node for testing (node -e "console.log(require('./pm.js').expandUnits('101-103'))"). The bottom half draws the tab.

Tables (supabase/pm.sql, also at the end of schema.sql):

Table Holds
units One row per apartment: unit number (the key), building, furnace filter (a part on Items) and how many, notes, and whether it's on the PM list
pm_tasks The plan: one row per recurring task, with who it's for (unit, building, common), how many months apart, first due month, common-area locations, parts, and steps
pm_log Every Done and Couldn't do: task, unit or place, status, note, parts taken, who, and when

The team can add and edit units and tasks; only owners can delete them. pm_log can be added to by the team, and a tech can delete only their own entry (that's how Undo works).

How it fits in app.js: a few lines marked "PM": setView and render call PM.show and PM.render, loadAll calls PM.load, applyOp and applyLocally hand pmdone and pmundo changes to pm.js so they ride the same no-signal queue as scans, and Run setup check looks for pm_log. Parts come off the shelf through the normal apply_op scan out, so they're in Activity and on Reorder.

Due dates are worked out on the phone: the last Done in pm_log for that task and unit plus the task's months, or the end of the First due month if it was never done. The phone loads the last 800 days of pm_log, enough for tasks up to every 2 years. A task done less often than that will show as never done after 800 days; raise LOG_DAYS in pm.js if one is added.

Shop map

Version 20 adds a drawing of the shop (Items > Tools > Shop map) and a Where is it? button on each part. The drawing is one row in the shop_map table, as JSON: the shop's size in feet and a list of boxes (racks with a letter and shelf count, doors and other landmarks, and from 24.24 walls). Everyone on the team can read it; only owners can change it. The app keeps a copy on each phone, so the map works with no signal once it has been opened.

The rack is found from the start of the part's bin name: K2-05 is rack K, shelf 2 from the top, bin 05 from the left.

One-time database step: in Supabase open SQL Editor, paste the whole of supabase/shop_map.sql, and tap Run. It's also at the end of supabase/schema.sql, so a rebuild includes it. Until it's run, the map says it isn't set up yet.

Pack parts (version 23.10)

items.pack_size (integer, default 1) marks a part sold in packs but used one at a time. on_hand, par and on_order stay in single pieces everywhere, so scans, counts, apply_op, low-stock alerts and usage reports didn't change. Only ordering converts: on the Reorder list qtyFor() is in packs (packsFor() rounds the pieces needed up to whole packs) and Mark ordered records packs × pack_size pieces; Receive delivery takes packs and adds packs × pack_size pieces. Labels for a pack part print "EACH" after the code (codeLine in app.js). packFromName() reads the pack size from a name like "10/pk", "25pr/bx", "12/cs", "Package Of 10", "10-Pack" or "(12-Count)"; it fills in new parts and parts added by Import list. The column is at the end of supabase/schema.sql. Download all items has a Pack size column, and Import list reads one.

Make Ready board

Version 21 adds the Make Ready tab (makeready.js). Each apartment being turned is one row in the make_ready table: unit, unit_type, move_out (shown as Vacant), keys_in, ready_by, move_in, full_ready, notes, done_at (set when it's turned and off the board) and steps. steps is JSON with one entry per column, like {"paint": {"d": "2026-10-21", "s": "done", "n": ""}}: d is the date, s is "" (scheduled), "done" or "na", and n is a short note. The step columns are one row in mr_board, as a list of {key, label}.

Everyone on the team can read, add and change rows. Steps are saved through the function mr_set_step, which checks the values and changes only that one step, so two people updating different steps at once don't overwrite each other. Only owners (and, since 24.60, managers) change the columns or delete a row; an owner can set a tech to look at the board only (see Who can change the Make Ready board). Both tables send live updates, so every phone sees changes right away.

Phone cards and Tools (version 24.11)

render() still builds one table. Under 700 px wide, CSS in styles.css turns each row into a card: thead hidden, each tr a grid, each td a labeled block. The labels are real spans (.mr-lab, hidden above 700 px) rather than CSS attr() text, so the Spanish translator sees them. Notes (order 9) and 100% ready (order 10) go to the bottom of the card, and empty notes (.mr-empty) are hidden. The PDF printout is separate code and doesn't change. The toolbar keeps + Add apartment, Fill in from a photo (or sheet, since 24.14), Finished turns and Tools (#mr-tools); toolsSheet() holds Print (#mr-print), Alerts (#mr-alerts), Edit steps (#mr-cols, owners) and Refresh (#mr-refresh).

Same release: the Team tab gives each person one Change button (teamRow in app.js) that opens a window with their Screens, View only, role and Remove buttons, each with a line of explanation; the existing two-tap handlers are reused, and a capture listener closes the window on the confirming tap (or right away for Screens, which opens its own window). PM's Due list drops the Overdue / Next 30 days / Everything buttons; the three boxes (tile() in pm.js) are Overdue, Due in 30 days and Everything, and "done this month" is a line under them.

Each property's own checklist (version 24.15)

The printed apartment checklist (printUnit in makeready.js) used to put report_settings.property_name in the Property box. That old field always holds the first property, so every property printed "Club at Highland Park". shopProp(settings, property, hasShops) now picks the property you're in: the staff property; before per-property shops the first property; on the on-call phone ("all") with several properties, none. shopLabel() gives its name (falling back to property_name). The board printout and pm.js's printouts use it too.

Each property can have its own list, saved with the property as mr_checklist in report_settings.properties (no database change): [{ "en": "Kitchen", "es": "Cocina", "items": [["Fridge cools", "Refrigerador enfría"]] }]. cleanChecklist() checks it (blanks dropped, up to 20 sections of 40 items, 70 characters a line, Spanish from the standard CHECKLIST when the English matches) and returns null for nothing usable, so the standard list prints. Make Ready Tools > Edit checklist (#mr-checklist, checklistSheet) shows for canEditProps() (the admin; the owner before per-property shops). It saves through saveChecklist(id, list) in app.js, which uses saveProp; saving the standard list removes the key. The PDF breaks pages when the list runs long and keeps final notes and signatures together.

The same fix everywhere else, and the second-property test (version 24.15)

Anything that shows or prints a property must use the property you're in, never the old single fields. property_name, property_address, pm_name, pm_email and cc_emails on report_settings are written by saveProp from the first property only, so they're kept for older code and setups without a property list. In 24.15: new reports start on the shop's property (lastProp() in app.js; the last-picked property only counts on the on-call phone or before per-property shops), Help > Check setup describes per-property routing, and downloads carry the shop's name (shopTag() in app.js, fileTag() in makeready.js and pm.js).

To test as someone at a property other than the first, open /demo/?shop=demo-oaks: the demo owner is then in Sample Oaks' shop while Demo Apartments stays first. The harness's secondProperty() run (in npm test -- --only features) goes through every screen, the Make Ready and PM printouts, new reports, Contacts and downloads there, and fails if the first property's name appears. A static check counts property_name / property_address reads per file against ALLOWED in tests/harness.js; a new read fails until someone checks it and raises the count.

Each property's own filter sizes and inspection email (version 24.16)

Filter sizes and the inspection email were the last settings shared by every property (report_settings.filter_sizes, insp_emails). Each property now keeps filter_sizes and insp_emails in report_settings.properties, edited on the Properties tab. A property that hasn't saved its own uses the shared columns, which Report settings still edits.

Techs can't write report_settings, so Save size for the team calls add_filter_size(p_size, p_property) (supabase/property-filter-sizes.sql, security definer). It checks that the caller works at that property (its shop, a ticked property, all properties or the admin), takes the property's list (or the shared one when it has none), adds the size and saves it into that property's entry. The one-argument version is kept for older phones. If the new function isn't there yet, the app falls back to it.

Inspections are emailed to the property's insp_emails, then the shared insp_emails, then the property manager: in send-report (deploy it after this change) and in recipients() in app.js, which shows who it goes to. Find unit opens on your own property and shows .fd-nomap for a property with no map in finder.js.

Who can change the Make Ready board, and managers (version 24.60)

Chris wanted to set who is a manager and who is a tech, and pick who can change the board (a tech had changed scheduled dates that were right). supabase/board-permissions.sql adds two staff columns: manager (default false) and mr_edit (default true, so nobody lost anything when it went in). board_edit(p) is true for someone on the team at property p (not Reports only) who is an owner, a manager or has mr_edit; board_manager(p) for an owner or a manager there. The make_ready insert and update rules use board_edit(property), its delete rule and the mr_board insert and update rules board_manager(property). mr_set_step is security definer, so it skips the table rules: it checks board_edit(my_property()) itself and raises 42501 with a plain message. Owners (and the admin) change both columns through the existing staff_write rule; the staff_guard trigger is unchanged. View-only logins (24.5) are still refused everything by view_only_guard.

In the app, boardEdit() and boardManage() in app.js (from state.manager / state.mrEdit, read at sign-in) are passed to makeready.js as C.boardEdit / C.boardManage. lockWrites() refuses make_ready / mr_board writes and mr_set_step on the phone first. render() swaps each tappable cell for a plain span.mr-ro when the person can't change the board (the 24.21 rule: only tappable things look tappable), drops + Add apartment, Fill in from a photo and Put back, and shows #mr-ro-note. Edit steps and Delete from the board use canManage(). The Team tab's Change window has the two switches for techs (flip() in teamRow) and the list shows Manager (personRole()) and Make Ready view only. See the app as a tech copies the picked person's manager and mr_edit. Demo: Jordan is a manager, Sam view only; /demo/?boardview and /demo/?manager sign in as those.

To run it: Supabase SQL Editor (or supabase db query -f supabase/board-permissions.sql on Chris-PC). Check: select policyname from pg_policies where tablename in ('make_ready','mr_board') and (qual like '%board_%' or with_check like '%board_%'); lists five rules. Until it runs, the new Team buttons say the database isn't set up, and everyone can still change the board.

Roving HVAC tech (version 24.73)

Chris: a position for roving HVAC with the same permissions and screens as Eh Bleh. supabase/roving-hvac.sql adds roving_hvac to staff_title_ok and to the titles staff_title_sync keeps off manager (with Leasing). In app.js TECH_TITLES lists both. When the admin (canEditProps()) picks it, copySetup(p, like) copies all_props / props and the hidden screens (personOff(like) saved as offFor under p's own property, the same way as Team > Screens) from another staff row with roving_hvac. Eh Bleh's row was given the title when the SQL was run, so he is the one copied. Check: select pg_get_constraintdef(oid) like '%roving_hvac%' from pg_constraint where conname = 'staff_title_ok'; is true.

Job titles (version 24.72)

Chris wanted titles like manager for leasing, assistant manager, roving manager, maintenance supervisor, regional manager and regional maintenance supervisor, and picked: Leasing marks steps done like a tech, every other title runs the Make Ready board. supabase/job-titles.sql adds staff.title (check staff_title_ok: pm, apm, leasing, roving_pm, maint_sup, regional_pm, regional_maint, or null for a maintenance tech) and the staff_title_sync trigger, which sets staff.manager from the title whenever the title changes (true for all but Leasing). So the 24.60 board_manager() rules and the 24.68 date guard follow the title with no other change. Owners change title through the existing staff_write rule.

In app.js JOB_TITLES, titleName(), titleRuns() and titleSheet(p); the Change window's Job title button replaces Make manager. personRole() shows the title. The Regional tab uses seesRegion() (admin, owner, or a regional_pm / regional_maint title), not roamsShops() (Chris: only regionals and owners). Otherwise titles are labels: shop access is still property / props / all_props, and team management is still the owner role. Demo: Jordan apm, /demo/?leasing.

To run it: Supabase SQL Editor (or supabase db query -f supabase/job-titles.sql on Chris-PC). Check: select count(*) from information_schema.columns where table_name = 'staff' and column_name = 'title'; is 1. Until then the Job title window says the database isn't set up.

Scheduled vs actual Make Ready dates (version 24.68)

Chris: techs must not change scheduled dates, only record when a step was actually done, so "scheduled the 16th, done the 23rd" shows. A step's JSON is now {d, s, n, c}: d the scheduled day, s '' / done / na, n the note, c the day it was actually done (kept only when s is done). Old done steps have no c, and doneOn() falls back to d for them. daysLate() is c - d in days when both are set.

supabase/mr-actual-dates.sql (needs 24.60's board_manager()): - mr_set_step validates c and, when the caller isn't board_manager(my_property()), puts the stored d back, so an older phone can't move a scheduled day. - mr_dates_guard() (security definer, BEFORE INSERT OR UPDATE on make_ready) lets through server jobs (no auth.uid() and no email) and owners and managers. For everyone else it refuses an insert, a change to unit, unit_type, move_out, ready_by, move_in or property, and any step whose d changed (errcode 42501, plain message). Keys in, notes, 100% ready, s, n and c still pass. - mr_alert_note() (board-alerts.sql) is replaced: the done line uses coalesce(c, d) and adds "(due M/D, N days late)", and a change to c alone says "Prep done date 11/23".

In makeready.js the step sheet shows #mr-step-sched to canManage() and #mr-sched-ro text to others; #mr-step-done (Day it was actually done) shows when Done is picked. The apartment sheet hides the unit, type and date fields from non-managers (#mr-dates-ro) and leaves unit out of their update. + Add apartment and Fill in from a photo are canManage() only. Demo: /demo/?boardtech.

To run it: Supabase SQL Editor (or supabase db query -f supabase/mr-actual-dates.sql on Chris-PC). Check: select tgname from pg_trigger where tgname = 'mr_dates_guard'; returns one row. Until it runs the app already hides the date boxes from techs, but the database would still take a date change from an older phone.

Owners stay inside their own property (version 24.61)

Owner rules use shop_owner(property) (an owner at that property). Two rules still used is_owner() (any owner anywhere): alert_prefs_own and the item-photos update/delete rules on storage.objects. supabase/owner-scope.sql adds owns_person(email) (the admin, or an owner at a property that person works at: their shop, a ticked property or all properties) for alert settings, and limits photo replace/delete to the admin or the owner who uploaded the file (owner_id); the app never does either. New owner-only rules must use shop_owner(property) or owns_person(email), never is_owner() alone. The harness's static check guards these three.

Make Ready alerts (version 24.6)

Every change to a make_ready row (insert, update, delete, from any screen or function) fires the trigger mr_alert_note() (supabase/board-alerts.sql), which writes one line to mr_alerts in plain words: property, unit, what changed ("Paint done 10/30; Keys in"), who (from the sign-in), and when. Step names come from the property's mr_board columns. A change that only touches updated_at/updated_by writes nothing. The trigger catches its own errors, so an alert problem never stops a save.

After each change (and each time the board opens) makeready.js calls the low-stock-push edge function with action: "board", at most once every 3 seconds. Since 24.56 the maintstock-board-alerts scheduled job also calls it every minute while a line is due, so alerts don't depend on that phone keeping signal (see Scheduled jobs). The function looks at the unsent lines of each property. When the first one is 2 minutes old, it claims them all in one UPDATE (sent_at = now; two calls at once can't both get the same line) and sends them. For lines still inside their 2 minutes, it keeps running in the background (EdgeRuntime.waitUntil) until they're due; if that background wait is lost, the next call sends them.

Who gets them (board.js in the same folder, plain JS so the harness tests it): everyone whose current property is that one, or who has it ticked, or has All properties, except the Reports-only login. Each person gets only other people's changes. alert_prefs (email, mr_push, mr_email; no row = both on) turns either off. Everyone edits their own row in Make Ready > Alerts; owners edit anyone's. Phone notes go to that person's rows in push_subs (tag mr-board, so a new note replaces the last one; tapping opens #makeready). Emails go one per person through the Resend batch API with RESEND_API_KEY, from BOARD_FROM or "MaintStock Make Ready alerts@maintstock.com". Resend's free plan allows 100 emails a day. Sent lines are deleted after 30 days.

One-time setup: run supabase/board-alerts.sql in Supabase (SQL Editor), then redeploy low-stock-push (npx supabase functions deploy low-stock-push). Until the SQL runs, Alerts says it isn't set up yet and the board works as before.

Scheduled jobs (version 24.56)

supabase/scheduled-jobs.sql turns on two Postgres extensions Supabase includes on every plan: pg_cron (runs SQL on a timer) and pg_net (lets SQL make a web request). Four jobs, all named maintstock-…, times in UTC (Omaha is UTC-6 in winter, UTC-5 in summer):

Job When What
maintstock-board-alerts every minute If a Make Ready line in mr_alerts has waited 2 minutes unsent, calls low-stock-push with action board. When nothing waits it makes no call.
maintstock-reorder-reminder Fridays 13:30 action reorder: counts To order parts per property (par minus on hand minus on order, the Reorder tab's sum) and sends one "Friday reorder" note per person (board.js teamFor, minus Reports-only and view-only logins), tag reorder, opens #reorder. Since 25.9 it also sends the Friday order email (below).
maintstock-mileage-reminder 22nd and 23rd, 15:00 action mileage: a note to the owner of each mileage_sheets row for the current period with trips and no submitted_at, tag mileage, opens #mileage. The day is worked out in Central time.
maintstock-job-cleanup nightly 08:40 Deletes cron.job_run_details older than 7 days.
maintstock-chat-emails every minute (24.91, notify-prefs.sql) Chat emails a room's quiet burst missed.
maintstock-scan-reminder Mon-Fri 20:30 and 21:30 (25.19, scan-reminder.sql) action scan: the 3:30 PM scan reminder. See Scan reminder below.

How a job reaches the function: public.cron_call(action) reads three Vault values (maintstock_project_url, maintstock_anon_key, maintstock_cron_key) and posts to /functions/v1/low-stock-push with the anon key (so the gateway's JWT check passes) and the header x-maintstock-cron. The function asks public.cron_key_ok(key) (service role only) before doing anything; a wrong key gets 403. The scheduler key is random, made by the SQL file, and never leaves the database. Only the database owner can run cron_call. The helpers that decide who gets what are in supabase/functions/low-stock-push/reminders.js (tests: tools/test/reminders.test.mjs). public.scheduled_jobs() (owners only) gives Run setup check each job's on/off and last result, plus how many pg_net calls failed in the last day.

Friday order email (25.9). supabase/functions/low-stock-push/orderemail.js (tests: tools/test/order-email.test.mjs). For each property in report_settings.properties with order_emails (a comma list, set on the Properties tab), one Resend email from ORDER_FROM (default "MaintStock Reorder alerts@maintstock.com") listing that property's To order parts by main supplier: part # alone in its own cell, quantity in packs (the Reorder tab's packsFor), name, have/keep/bin; then a part #-tab-quantity block for quick-order boxes; then a Mark these N ordered link https://maintstock.com/#ordered=<property>&s=<supplier>&ids=<first 8 hex of each id, joined by .>. No parts: a one-line "nothing to order" email. Items are read with only the columns the email needs (no photos) to keep egress down. No database change: order_emails is a key in the properties JSON. Action order_email (signed in, owner or admin, not view-only) sends the caller's current property's email now (Properties > Send it now).

The app (app.js, top of the file) saves an #ordered= link in localStorage (ss-ordered-link, 3 days) and clears it from the address bar, so it survives signing in and Google's redirect. After loadAll, openOrderedLink() switches shops once if the link is for another property this login can use (tried stops a loop), else refuses; then on To order it unchecks that supplier's other parts (state.roOff), checks the matched ones, outlines the group (.ro-from-email) and says how many it checked and how many were already ordered. Mark ordered is unchanged (tap, tap again). Each To order line also has partCopy() (.ro-copy), which copies just orderFrom(it).part.

One-time setup (from Chris-PC with the Supabase CLI, after the owner's go-ahead): deploy low-stock-push first (npx supabase functions deploy low-stock-push), then run supabase/scheduled-jobs.sql (npx supabase db query --linked -f supabase/scheduled-jobs.sql). Running it again is safe and updates the jobs. To pause one: select cron.unschedule('maintstock-reorder-reminder');. Recent runs: select * from cron.job_run_details order by start_time desc limit 20;, or Supabase > Integrations > Cron. After restoring into a different project, update the two Vault values for the project address and anon key (select vault.update_secret(id, 'new value') from vault.secrets where name = 'maintstock_project_url';).

Scan reminder (version 25.19)

Chris (2026-12-05) after the adoption freeze: Amy and Ron forget to scan parts out, so each workday at 3:30 PM Omaha time the people who take parts get a phone note Took any parts today? / "Scan them now. Tap to open Scan." (tag scan-reminder, so a new one replaces yesterday's; opens #scan, which app.js turns into Scan in Take out).

Board photos (version 23.6)

Fill in from a photo (makeready.js, photoSheet and reviewSheet) shrinks the photo on the phone to 2000 px and sends it to the Supabase edge function read-board (supabase/functions/read-board/index.ts) with the board's step columns. The function checks the person is on the team, sends the photo to the Anthropic API (the model named in read-board/index.ts, unless the BOARD_MODEL secret says otherwise) with a fixed list of fields to fill in, and returns the rows as read. Dates come back as written ("10/14"); the phone adds the year that puts the date closest to today (mdToIso). Nothing is saved by the function: the phone shows every row to fix and saves only the ticked ones, as new rows or as updates to apartments already on the board. The API key lives only in Supabase secrets, never in the app. Each read is logged in board_reads (who, when, how many rows; only the function can see it) so a person can read 20 photos a day.

Importing an Excel or CSV board (24.14). The same window has Import Excel or CSV (#mr-sheet-file). CTIMPORT.readFile (ctimport.js, the reader the Contacts import uses; no library) turns the file into rows of text on the phone. sheetRead() in makeready.js finds the header row (the first of the top 30 rows with an apartment column and two other known columns), matching words with SHEET_FIELDS and step columns by the board's step labels (same name, or one starts with the other). It returns rows in the photo reader's shape, so draftsFrom, reviewSheet and rowBody are shared. Extras for sheets: Excel day numbers and 2026-10-14 dates are turned into M/D/YYYY (sheetDate); Done/X/✓ and N/A in a step set its state (step s, which rowBody keeps); separate Bldg and Unit columns become building + 2-digit unit; rows without an apartment number (titles, totals) are skipped; unknown columns are listed on the check screen. Nothing goes to a server until Add, and no board_reads row is written. Test file: tests/fixtures/make-ready-sheet.xlsx (made by tests/fixtures/make-make-ready-sheet.py).

One-time setup (owner):

  1. At console.anthropic.com, sign in or sign up, add some credit under Billing (reading one board photo costs roughly 10 to 25 cents), and create a key under API Keys. Copy it.
  2. In Supabase open Edge Functions, then Secrets, and add a secret named ANTHROPIC_API_KEY with the key as its value.
  3. Deploy the function from the shop-stock folder: npx supabase functions deploy read-board.
  4. In Supabase open SQL Editor, paste the whole of supabase/board-photo.sql, and tap Run (it's also at the end of supabase/schema.sql).

Until the key is set, the button says "Reading board photos isn't set up yet".

Version 24.10: when Anthropic turns a photo read down, read-board writes "read-board failed" with the error number, type and message to its log (Supabase, Edge Functions, read-board, Logs; never the key), and 400, 403 and 404 get their own messages instead of "The photo couldn't be read".

Version 24.8: the photo window has Take a photo (an input with capture="environment", straight to the camera) and Upload a photo (no capture, so the phone offers its gallery and Files). board_reads gets a property column and a read rule (your own reads, an owner's property, the admin everywhere, as activity_log), and activity.js lists it as "Read a Make Ready board photo"; that part of board-photo.sql runs once in the SQL Editor, and read-board is redeployed so it records the property. Marking 100% ready (toggleReady, and a photo row read as ready in rowBody) also sets done_at, so the apartment moves to Finished turns; Undo and Put back clear both. Turned, take it off the board only shows for apartments marked ready before 24.8 and refuses one that isn't ready (in the app only; Delete is still there for owners).

Ideas and problems

Version 21 adds Help > Ideas and problems (requests.js). Each one is a row in feature_requests: kind ("feature" or "problem"), body, by_email (always the sender's own login), status ("new", "planned", "done" or "not now"), reply. Anyone on the team can add and read them. Only owners change the status or reply, or delete one.

One-time database step for both: in Supabase open SQL Editor, paste the whole of supabase/makeready.sql, and tap Run. Then do the same with supabase/requests.sql. Both are also at the end of supabase/schema.sql, so a rebuild includes them. Until they're run, the Make Ready tab and the Ideas and problems list say they aren't set up yet.

Android's bottom button bar

On Android the installed app's bottom bar (Back, Home, Recent) is dark charcoal, the manifest's background_color (checked on a phone 2026-10-26 with plain test pages in navtest/). Don't put viewport-fit=cover back in a page's viewport tag: with it, Chrome lets the page draw under the bar and paints the bar with the light theme's page color, even in dark mode. chrome://webapks on the phone shows the colors Chrome saved for the installed app.

Version 23.4: opened from its home screen icon, the installed app still had a light bar, because Chrome colors it from the page's own background (the html element). The test pages had only been opened from links, which run in Chrome itself with Chrome's dark bar. theme.js, which every page loads first, now sets the html element's background to #12181b, and body has min-height 100vh so the light theme still fills the screen. Keep both.

Turning screens off

Version 23.2. Each property in report_settings.properties can have off (a list of screens hidden for everyone at that property) and offFor (an email mapped to the screens hidden for that one person). A person's list is saved under their own property but read from every property, so it follows them when they switch shops. No database change was needed, and only the admin can save it, like the rest of the property list. In app.js, OPTIONAL_TABS lists the screens that can be turned off (Today, Help, Team and Properties can't). isOff(view) answers for the signed-in person; applyOff() hides those menu buttons after sign-in and whenever the property list changes; setView() refuses a turned-off screen whatever link asks for it; and today.js asks C.isOff() before showing a card, a search result or a unit history entry. Hiding is only on screen: the data and the database rules are unchanged, so turning a screen back on brings everything back.

On-call schedule (version 24.35)

Chris (2026-11-03): put the on-call schedule in the app, everyone can view, only he edits ("let me assign who can edit"); all four properties share one schedule; notify people when it changes, but "Nobody should be notified or see changes until I have published them"; people join and quit; make 2027 from his 2026 sheet with nobody covering the same holiday as in 2026.

Today, search, unit history and contacts

All in today.js (version 23.0). Today reads what the other tabs already loaded (PM.snapshot(), MR.snapshot(), FR.snapshot(), the parts, equipment and reports), so it adds no database queries of its own. Unit history also looks up older reports, Make Ready rows and equipment moves for that unit in Supabase when there's signal. Contacts are stored with each property in report_settings.properties (a contacts list on each property), so only the admin can change them, and no new table was needed. The contact types are the KINDS list near the top of today.js: the property's own people first (Property manager is shown as the main contact), then vendors. Add a type there, and its Spanish in i18n-es.js.

Import sheet (version 24.13). ctimport.js (window.CTIMPORT) reads the blank sheet forms/contacts-sheet.xlsx once it's filled in, or any CSV with a Name and Phone header. There's no spreadsheet library: an .xlsx is a zip of XML, so readXlsx() finds the files in the zip's directory, inflates them with the browser's DecompressionStream("deflate-raw"), and pulls cell text out of the first visible sheet (shared strings and inline strings) with regular expressions, so it also runs in Node. parse() finds the "Property:" cell and the header row by its words, maps "What they're for" to KINDS (exact name, then a few aliases, else Other with "For: ..." in the notes), puts who to ask for and the account # in notes, and runs each row through today.js's checkContact() so imports follow the same rules as typing. merge() matches on name + type: a match is updated with the sheet's non-empty fields, anything else is added; nothing is removed. Saving goes through C.saveContacts like a single contact. To change the blank sheet, edit forms/contacts-sheet.xlsx (keep the header words), then rerun python3 tests/fixtures/make-contacts-filled.py for the test copy. Old .xls files aren't supported.

Vendor details and Copy from another property (version 24.58). A contact can also hold address, ins (insurance end date, YYYY-MM-DD), yardi (Yardi vendor code) and nvid (NetVendor ID), still inside report_settings.properties[].contacts, so no database change. cleanContact() reads them, checkContact() checks the date and lengths, and slim() drops the empty ones so older contacts save exactly as before. insState() gives "ok", "soon" (ends within 30 days) or "expired"; vendorBits() draws the address, the insurance line (.ct-ins.soon orange, .ct-ins.expired red, data-ins for tests) and the codes. The admin's Today Contacts card counts vendors with soon/expired insurance. copySheet() (button #ct-copy, admin only, shown when another property has non-staff contacts) lists another property's contacts minus STAFF_KINDS, ticks the ones with vendor details, and saves through C.saveContacts + CTIMPORT.merge(), so a contact with the same name and type is never added twice and every copy gets a new id (each property owns its copy). merge() now also fills in the four vendor fields. New KINDS: General contractor, Painting, Cleaning & make ready, Carpet & flooring, Landscaping, Pool, Trash & hauling, Laundry (Spanish in i18n-es.js). Club at Highland Park's 21 approved vendors were added on Nov 10, 2026 from Kaitlyn's NetVendor screenshots, with a REST update of report_settings (id 1) that read the list first and only appended to CHP's contacts.

Barcode lookup (version 24.47)

Chris asked for the app to "figure out what an item is from its barcode ... when adding new items", and picked a free lookup (option 1, daily limit) over a paid one.

Barcode kinds and matching (version 24.89)

Chris's toilet seat box (MFG# W201SC) wouldn't scan, and he asked that "the app needs to be able to scan a variety of codes" because every maker and supplier uses its own. That box's barcode turned out to be artwork: 18 digits printed under UPC-style guard bars, every space the same width (a real UPC's spaces vary), and no decoder (ZXing in the app, zxing-cpp with every format on the photo) reads it. Nothing can scan it, so 24.89 adds a hint in the camera and makes everything readable scan and match.

GL codes (version 24.74)

Chris asked for the 2026 GL codes and a way to "search my item and tell us what GL code to use", inside MaintStock. The source is StoneCreek's Yardi GL Coding Guide 2026 (an Excel sheet: income 4000s, expenses 6000s, capital 7000s, each with a description of what goes in it). He picked a lookup plus a code on every part and on Reorder, kept in the database.

Mileage (version 24.43)

Chris sent StoneCreek's mileage form ("SC Mileage Tracking Form 2026 - Updated 7-16", Excel) and asked for it in the app, keeping its payout calculations, with a way to add trips and submit to the property manager. Then (2026-11-05): StoneCreek now wants only a total per property ("a line for mileage associated with club ... and another line for mapleview"), though the form's directions weren't updated. So trips are logged one by one in the app, each with the property it was for, and the form gets one line per property.

Chat (version 24.90)

Chris (2026-11-18) asked for "a live chat so people using the app can talk to each other in real time", one room per property. It runs on Supabase Realtime, which the app already uses for scans and the Make Ready board, so there's no new service or cost.

Notifications (version 24.91)

Chris (2026-11-18): "Yes, message notifications. But i want users to be able to select which app/email notifications they receive."

Top bar (version 24.91)

Chris: "the number of items doesn't need to be displayed on the top bar of the app. Adding the messages button cut it off, as well as the online status." renderSync() no longer shows "515 items · live". #sync shows only the property (with the switch button for people at more than one), View only, Reports only, "No signal" and "N scans waiting for signal", and hides when there's nothing to say. Help > status still shows Connection and Parts on this phone.

City complaints (version 24.17)

From Maple View's idea ("A tab for city complaints"). Chris picked city notices plus reinspections. Maple View keeps a "City Complaint List" tab in its Day to Day workbook (Date of Complaint, Unit of Complaint, Deadline from city, Issue of Complaint, Completion Date, Notes), so the tab uses the same words and can import that sheet.

Resident notices (version 24.95)

Chris (2026-11-19): "Here is the CHP logo we use on printed notices. Can you build a notice generator into the app. It should always have the logo at the top."

Unit equipment card (version 24.12)

unitgear.js, table unit_equipment (supabase/unit-equipment.sql, also at the end of schema.sql). Unit history (today.js) calls GEAR.section(unit, reopen) once per window and puts the card under the buttons; the card loads its own rows (.eq("unit", canon(u)), plus .eq("property", ...) when the person is in a property's shop) and redraws itself, so Unit history's own redraws keep it. Each unit's rows are cached on the phone (localStorage ss-gear-<property>-<unit>), so the card still shows with no signal; adding or changing needs signal (it says so).

Unit # lookup and Appliances by unit (version 24.66)

No database change: it reads unit_equipment with the same read rule (in_shop(property)).

Activity by person and date (version 24.4)

activity.js, wired into the Activity tab in app.js. The Show list picks "Parts scans" (the older live list in app.js, renderActivity and loadLog, which now also takes the From and To dates) or Everything / one area, which activity.js draws into the same #activity-list. Owners and the admin start on Everything, others on Parts scans; the pick is saved per phone (ss-act-show).

Everything reads, for the person and dates picked, up to 500 rows each from stock_log, equipment_log, pool_tests, pm_log, mm_reports (by created_by and created_at), report_emails, feature_requests and activity_log, turns each into one line (SOURCES and describeTrail in activity.js), sorts them newest first and shows 300. Download CSV pages through everything with fetchAll. Dates are local days: From's midnight up to the midnight after To (ACT.core.dayRange).

activity_log is new (supabase/activity.sql, also at the end of schema.sql). The trigger function log_activity() runs after each insert, update or delete on items, equipment, pools, units, pm_tasks, make_ready, mr_board, shop_map, staff, report_settings, mm_reports, feature_requests and pm_log; the trigger's argument says which actions to log for that table (for example only deletes for pm_log, because doing a PM visit is already in pm_log). It records who (the signed-in email from the JWT; blank for SQL run in the dashboard, shown as "System"), the property, a label, and only the columns that changed. Columns that change as a side effect of something already logged (items.on_hand from a scan, equipment.status from a check-out), timestamps and updated_by are left out, and an update with nothing else changed writes nothing. To log a new table, add it to the list at the end of activity.sql, a noun and area in NOUN in activity.js, and its friendly column names in FIELD; the demo's copy of the rules is TRAIL in demo/demo.js.

Who sees what: activity_log's read rule allows your own rows, owners of that property and the admin. The screen matches it: a tech's person list in Everything only has themselves. The other log tables keep their old read rules (the team already sees every scan in Parts scans).

Mouse-over tips (version 24.48)

tips.js (loaded right after i18n.js) gives buttons a one-line tip that shows when a mouse rests on them. TIPS maps an element's id ("#help-sync") or its English words ("Copy list") to the tip. A MutationObserver gives each button, a.btn, [role=button], select and checkbox with no title its tip as its title; a symbol-only button with an aria-label gets that. On pointerover from a real mouse (and (hover: hover) and (pointer: fine)) the bubble (.tip in styles.css, #tip) opens after 350 ms, from any element with a title, including titles the app set itself. While it shows, the title moves to data-tip-on so the browser's own tooltip doesn't double it; it's put back when the mouse leaves. Keyboard Tab (:focus-visible) shows it too; click, Esc, scroll and wheel close it. Taps never open it.

To add or change a tip: edit TIPS in tips.js (the key must match the button's English exactly, or use #id), add the Spanish to i18n-es.js under "Mouse-over tips" (the harness fails on a tip with no Spanish), and release. Add data-no-tip to an element to keep tips off it and everything inside it. In Spanish, tips.js maps a button's Spanish words back to English with I18N.t() to find its tip.

Hover color: the @media (hover: hover) block in styles.css (24.48, made stronger in 24.52 because Chris couldn't see the first shade) fills plain buttons with --accent / --accent-fg, darkens filled buttons (brightness(.8), 1.25 in the dark theme), fills .btn.danger red, and gives tiles, rows and tabs --btn-hover (a strong blue tint, set per theme). Keep the change obvious: a faint shade reads as no change. New tappable styles should be added to that block.

Spanish (language switch)

The app is written in English. With Español picked (Help > Language, saved per phone as ss-lang), i18n.js swaps each bit of English on screen for its Spanish as it appears, using i18n-es.js: an exact list ("Save" -> "Guardar") and patterns with {0}, {1} for the parts that change ("{0} on hand" -> "{0} en existencia"). Anything not in the list stays in English. Text marked translate="no" (names, notes, what people typed) is never touched. Reports, PDFs and emails are made from the code, not the screen, so they stay in English. Since 24.63 picking a language switches in place (I18N.use(l), which fires an i18n-change event the app redraws on): every swap keeps the English it replaced, so English comes back without a reload, and nothing typed, queued or open is lost. I18N.set(l) still reloads (the welcome link's &lang=es uses it). A <textarea>'s words are never translated, but its placeholder and aria-label are. On-screen dates asked for with a [] locale follow the app language (es-US); dates the app writes in English itself ("Thu Nov 12") use the word list's dates day and month names. While the Spanish list loads at start-up, html.i18n-wait hides the page for up to 2.5 s so English doesn't flash.

To fix or add a Spanish phrase: open i18n-es.js, find the English (exactly as it appears on screen), and change or add the Spanish beside it. Keep the {0}, {1} placeholders. Then bump the version like any release.

Karen (24.36). i18n.js keeps a list of languages (LISTS: code -> word list file and the global it sets). Karen is ksw (S'gaw Karen, written in Myanmar script), word list i18n-ksw.js. Languages in PREVIEW only load under /demo/; on the real app a phone set to one of them gets English. Karen stays in PREVIEW until Eh Bleh (a native speaker) has checked the words (review sheet: project files karen-review/MaintStock-Karen-words.xlsx). The list is a short draft written without a native speaker, so it only covers the main screens and common buttons; a short list of right words beats a long list of wrong ones. styles.css :lang(ksw) puts Myanmar fonts first and turns off letter spacing and capitals, which break the stacked letters. Android has Noto Sans Myanmar built in, so no font file is shipped.

To turn Karen on: put the checked words in i18n-ksw.js (the English side must match the screen exactly; the harness fails on an English phrase the app doesn't have), remove "ksw" from PREVIEW in i18n.js, add <button class="btn" type="button" data-lang-pick="ksw" lang="ksw">ကညီကျိာ် Karen</button> to the Language group in index.html (the harness checks both go together), and release. Welcome emails have no Karen version.

Adding another language: a word list file like i18n-es.js setting its own global, an entry in LISTS, a button in the demo first (and PREVIEW), and harness steps like the Karen ones.

Demo

maintstock.com/demo runs the real app against demo/demo.js instead of Supabase. demo.js builds the sample data in the browser:

Nothing reaches the real database, and reloading starts the demo over. Demo data saves on the device under names starting with "demo-", so it never mixes with real scans on the same phone. To change the sample data, edit the lists near the top of demo.js. Test switches: /demo/?shop=demo-oaks (the second property), /demo/?viewonly (a view-only login), /demo/?big (1,200 parts).

Handouts (version 24.2)

The Team tab's Handouts to print (owners only, hidden in the demo) saves the PDFs in handouts/. To change one, edit its HTML in handouts/source/ (features.html, quick-start.html, quick-start-es.html; the Full user guide is printed from help/manual.html, so update the manual instead), run py help/build.py (Mac: python3) and then node handouts/source/render.js from the repository root (needs Playwright and Chromium), check the PDFs, and release as usual. A new handout needs its PDF in handouts/, a button with data-handout="<file name>" in index.html and demo/index.html, and Spanish for the button in i18n-es.js. The resident thermostat guides (24.88, Thermostat-Guide.pdf, Guia-del-Termostato.pdf) are data-guide buttons on the Help tab for everyone, not Team-tab handouts; their HTML is written by python3 tools/thermostat-handout.py handouts/source (edit the text and drawings there, not the HTML), then render.js prints them. They must stay one page (the harness checks). handouts/source/ isn't served. The PDFs are public files whose buttons only owners see, so never put anything private in one.

Other documents

Unit inspections

Unit inspections (version 18) are stored in the same mm_reports table as mold reports, with kind = 'insp', so they share the photo storage (under mm/inspection id/), the no-delete rules, the email log and the send-report function. supabase/inspections.sql adds the kind column, two settings (insp_emails: where inspections are emailed, blank means the property manager; filter_sizes: the team's filter size list), and the add_filter_size function that lets any team member add a size.

To change the inspection's items or their choices, edit ITEMS at the top of insp-report.js. Each item has an id (stored with the answers, so don't rename one that's been used), a title, and its choices. A choice marked true needs attention: it shows red and is counted on the PDF. The form, the PDF and the counts all follow ITEMS. Bump VERSION in app.js and CACHE in sw.js so phones pick it up.

Report properties

Version 21.5 adds report_settings.properties (supabase/properties.sql): a list of { id, name, address, pm_name, pm_email, cc_emails }. Each report stores the picked property's id in data.propertyId (and its name in data.property). send-report looks the property up by id, then by name, and emails that property's manager and copies; with no property list it uses the old single pm_email and cc_emails. Saving Report settings also copies the first property into the old fields. The mold form, forms/mold-moisture.pdf, is the official NAA form exactly as issued (the same file as forms/mold-moisture-original.pdf) and must not be edited; "Who assessed the situation?" prints on an attached page made by mmreport.js.

Reports-only logins

Version 21.6 adds a third staff role, 'reports' (supabase/oncall.sql), for the shared on-call phone. is_staff() now means "on the team and not reports-only", so every inventory, PM, Make Ready, pool and equipment policy and function shuts that login out with no other change. The report tables (mm_reports, report_settings read, report_emails read, the report-files bucket and report_upload_ok) use the new is_member() (anyone on the team) instead. staff_read also lets anyone read their own row so the app learns its role. In app.js, startSignedIn calls startReportsOnly() for that role: it hides every tab but Reports, HVAC, Appliance, Find unit and Help (REPORTS_TABS), hides New unit inspection, skips loading items, and the reports list leaves out inspections. Owners switch roles on the Team tab (Make owner, Reports only, Make tech).

View-only logins (version 24.5)

supabase/view-only.sql adds staff.view_only. It sits on top of any role: a view-only owner, tech or Reports-only login sees exactly what that role and their properties allow, and can't change anything. The lock is in the database. A trigger, view_only_guard, runs before every insert, update and delete on every public table (push_subs, board_reads and activity_log are left out; activity_log is written only by the log_activity trigger, which must still record a view-only person switching property) and refuses the change when the signed-in person is view only. Because it's a trigger, it also stops changes made inside the security definer functions (apply_op, equip_op, mr_set_step, add_filter_size), which skip the row rules. The one change it lets through is a view-only person's own staff row when only property changes, so switch_property still works for someone with several properties. Three restrictive policies on storage.objects refuse their uploads, file changes and deletes. The send-report and read-board edge functions refuse them (403). The admin can't be view only (check staff_view_only_admin), so nobody can lock the admin out.

In app.js, lockWrites() wraps the Supabase client: for a view-only login, insert, update, upsert and delete, every rpc except check_setup and switch_property, every edge function except low-stock-push, and storage uploads return the error "This login is view only…" without going to the server, and runOp refuses before anything is queued offline. The Scan screen is off for them (isOff), a banner says View only, the sync line starts with "View only ·", and the obvious add and save buttons are hidden (body.view-only in styles.css). Since 24.9 any button built in JavaScript that only changes things gets the class vo-hide, which the same rule hides (Mark ordered, Receive delivery, + Add apartment, Fill in from a photo or sheet, Edit steps, PM Done and Done for all); give new buttons like that the class too. Owners turn it on and off with View only / Allow changes on the Team tab (two taps). Try it in the demo at /demo/?viewonly.

Any new table needs the trigger, in the same SQL that creates it:

create trigger view_only_guard before insert or update or delete on public.new_table for each row execute function public.view_only_guard();

See the app as a tech (version 24.40)

Team > See the app as a tech (#as-tech, owners and the admin; canSeeAsTech()) opens pickAsTech(): Any tech, or a tech who works at the current property (worksHere()). seeAsTech(who) saves the real role, admin, allProps and props in state.real, sets the tech values, and refreshRoleView() redoes what startSignedIn() does for tabs (unhide, Team, Properties, Regional, applyOff()), the yellow bar (renderAsTechBar(), before #banner), the header line (renderSync()) and the open screen. isOff() reads the picked person's own screen list (personOff(state.asTech.email); blank for Any tech) instead of yours. endAsTech() puts state.real back. It's in memory only, so a reload ends it; startSignedIn() re-applies it if a new sign-in token arrives while looking. Screen only: requests still go out as the real login, so the database allows what the real role allows. Any new owner-only or admin-only button should keep checking state.role / state.admin / canEditProps() at render time (not once at start-up) so this view hides it.

Separate shops per property

Version 22.1 (supabase/property-shops.sql, also at the end of schema.sql) gives staff a property column (an id from report_settings.properties: chp, fox-ridge, terrace-garden, mapleview; "all" only for Reports-only logins) and an admin flag (Chris). Every shop table (items, stock_log, equipment, equipment_log, pools, pool_tests, units, pm_tasks, pm_log, make_ready, mr_board, shop_map, feature_requests) has a property column that defaults to my_property(), so the app never has to send it. Policies use in_shop(property) (on the team, not reports-only, at that property) and shop_owner(property) instead of is_staff() and is_owner(). apply_op, equip_op and mr_set_step only touch the caller's property's rows, and the log rows copy the parent's property. shop_map and mr_board are one row per property (primary key property); units are unique per (property, unit) and equipment codes per (property, code). staff_read: your own row, your property's team, or everyone for the admin. staff_write: the admin, or an owner for their own property's non-admin people.

mm_reports.property is set by a trigger from data.propertyId (or the property name). can_see_report() lets you read your property's reports, the ones you wrote, or all of them with property "all". report_emails and report-files reads follow the report. Report settings updates are admin-only. send-report checks the same rule; low-stock-push only alerts phones of people at the part's property.

In the app, startSignedIn reads property and admin (state.property, state.admin, state.hasShops; hasShops is false on a database without the column, which keeps the old single-shop behaviour). If the phone's saved shop (ss-property) is for another property it clears the shop caches and reloads. The Team tab groups people by property for the admin, with a property box per person, a property box on Add, and I'm working at + Switch, which updates the admin's own staff.property and reloads.

Version 22.2 (supabase/all-properties.sql) adds staff.all_props. With it, a tech or owner can call switch_property(p), which sets their own staff.property (the shop they're working in now; the admin uses it too), and can_see_report() lets them read every property's reports. The staff_guard trigger stops anyone but the admin from changing all_props or admin. On the Team tab the admin's per-person property box has All properties: for a Reports-only login it sets property 'all', and for anyone else it sets all_props. send-report follows the same report rule.

Version 23.5 (supabase/mm-shared.sql, also at the end of schema.sql) shares mold & moisture reports with every property: the mm_reports read and update policies allow any row with kind = 'mm' to anyone on the team (is_member()), and keep can_see_report() for unit inspections (kind = 'insp'). Photos (report-files) and report_emails follow, since their rules check that the report can be seen. In the app, unit history (today.js) skips reports whose property (mm_reports.property, or data.propertyId) isn't the shop you're working at.

Version 22.3 (supabase/multi-properties.sql) adds staff.props, a list of property ids. switch_property() and can_see_report() also allow any property in it, and staff_guard() keeps it admin-only. On the Team tab the admin gets a tick box per property plus All properties: one ticked sets property and clears props, several set props (and keep property if it's still ticked), All sets all_props (or property 'all' for Reports only). send-report follows the same rule.

Parts per unit, Regional screen and new-property setup (version 24.38)

Chris picked these from a feature check ahead of the 14-property rollout. SQL: supabase/portfolio.sql (also at the end of schema.sql).

Parts per unit. #forunit on the Scan screen shows only in Take out (renderForUnit(), called from setMode()). setForUnit() cleans the unit (unitClean(): drops Apt/Unit/#/spaces, capitals, 20 characters) and keeps it in ss-forunit with a time; it's dropped after two hours. takeOut() puts unit on the op and undo() passes it to the undo, so apply_op saves stock_log.unit on both and the parts net out. applyOp() adds p_unit only when the op has one; on PGRST202 (the database's apply_op has no p_unit yet) it sets state.noUnitCol and resends without it, so scans never fail before the SQL is run. Queued ops keep unit, so offline take-outs are saved with it when they sync. loadUnitPast() reads the unit's out/undo rows from the last 30 days (TODAY.core.variants() matches 909 / 0909); unitVisits() groups those older than 6 hours by day and nets undos; anything left shows the yellow Repeat call? box. Unit history (today.js) reads the unit's rows too (up to 300) and shows a Parts line per day and person, plus a Repeat calls note when parts were taken on 2+ days in 30. Activity and Parts scans show Unit 2601 in the line and the CSV.

Regional screen (region.js, #tab-region / #view-region). Shown when roamsShops() (admin, all_props, or 2+ props); hidden for Reports-only. Not one of the screens that can be turned off. REGION.load() calls region_summary() (cached for a minute; Refresh forces it). REGION.core.stats(row, property.off) turns a row into the labeled numbers and leaves out screens the property turned off; tone bad (red) for out of stock, past ready-by, past deadline and overdue equipment. Open its shop calls switchShop(). Copy summary uses summaryText(). A missing function shows "isn't set up yet" instead of an error.

Setup checklist and copying parts. REGION.core.setupSteps(property, summaryRow, hasFindMap) is the 11-line checklist (Find unit map = the id is in FINDER.PROPERTIES). setupButton(id) (Properties tab rows and Regional cards, admin only, once the summary is in) opens setupSheet(id). startField() is the Start its parts list from box on Add a property (propSheet() in app.js, admin with shops only); after saving, copyParts(from, to, levels) runs and the checklist opens. copySheet(toId) copies into an existing property (two taps). copy_parts() is admin only, skips names already in the target (case-insensitive), and gives each copy a new SS- code from the same alphabet as newCode(); box barcodes (codes not starting SS-) are kept. If the copy is into the shop you're in, the parts list reloads.

Change name. Team > Change > Change name (renameSheet() in app.js) updates staff.name with the staff_write rule (admin, or an owner at that person's property who isn't changing the admin). The button shows for owners, on every row except the admin's (the admin's own row has it). No database change.

Demo. apply_op keeps the unit; two older take-outs are tagged unit 101; region_summary counts the shop you're in from the sample data and makes up the other sample property's numbers; copy_parts records names in __demoDb.copied_parts. Harness: portfolio() (features run) and a REGION.core static check.

24.97: contacts and a fuller checklist. Add a property's Start its contacts from (startField().ctField in region.js) copies TODAY.startContacts(from): every contact not in STAFF_KINDS, cleaned with checkContact(), pref off and new ids via CTIMPORT.merge([], …). app.js propSheet() puts them on the new property before its one saveProp(). setupSteps(p, s, mapped, unitFmt) adds unitfmt (unit_example, or UNITS.KNOWN / 3+ units seen), staffcts (a Contacts entry of kind Maintenance supervisor, because send-report copies that kind and Assistant property manager on every report) and pmunits (from region_summary().pm_units, supabase/setup-units.sql; the line is left out while the count is missing).

Other shops (version 25.15)

Chris asked for it after a Saturday morning calling every property for one switch. othershops.js (window.OTHERSHOPS, init from app.js with state, el, toast, openSheet, propList, demo). canUse(): signed in, not Reports-only, at a property (or the plain demo), and 2+ properties. Entry points: #f-othershops in itemSheet() (existing parts only) and #td-others in today.js results() (always, as the last group, under "Nothing matches" when this shop has nothing; uses the scanned part when a label code was typed). The window calls find_part_elsewhere() (supabase/find-elsewhere.sql): security definer, read-only, every other property, matched by normalized supplier part # (incl. alt_suppliers), non-SS box barcode, or same name (from a part) / every word (typed). OTHERSHOPS.core.group() makes one card per property, ordered counted-with-stock, never counted, counted 0. Call buttons from callsFor(): Maintenance supervisor contacts (phone, after hours), then the property's office phone, deduplicated, at most 3. The demo answers find_part_elsewhere with the other sample property's made-up counts. Tests: otherShops() at both sample properties, plus static checks of the helpers.

Switch property from the header (version 24.18)

Chris asked to change properties from the bar up top. renderSync() (app.js) draws the property part of the header status (#sync) as a button (#prop-switch, the short name and a ▾) when roamsShops() is true: the property column exists and the person is the admin, has all properties, or has two or more in staff.props. Anyone else gets the old plain text. The button opens the Switch property sheet (pickShop()), one button per property from shopsICanUse() (the same list as the Team tab's I'm working at box), with the current one marked You're here. Picking another calls switchShop(id), the same code as Team > Switch: refuses while scans wait for signal, calls switch_property, clears the shop caches and reloads. No database change. In the demo, switch_property succeeds and the app reopens /demo/?shop=<id>, since the demo keeps nothing between loads. Harness: features() checks a one-property login gets no button; secondProperty() opens the list, checks both properties and You're here, switches to the first property and checks the header and the list follow.

Unit photos (version 24.93)

Photos tied to a unit and property (unitphotos.js), shown on Unit history. One-time database step:

  1. Open Supabase, SQL Editor, New query.
  2. Paste all of supabase/unit-photos.sql and tap Run. It's safe to run again.
  3. Check: select id, public, file_size_limit from storage.buckets where id = 'unit-photos'; gives unit-photos | false | 1048576 (1 MB, with 50 MB per person a day, since supabase/security-pass-6.sql (25.23) was applied on 2026-12-05; before that it was 2097152).

Export (24.94): Today > ⬇ Export photos and Unit history > ⬇ Download all build a ZIP on the phone (no library: FILES.makeZip in files.js, stored, not compressed), up to 400 photos, with photos.csv. Each export downloads the full photos, about 120 KB each, which counts toward Supabase egress (the free plan allows 5 GB a month).

Until it's run, Unit history says "Unit photos aren't set up yet" and photos taken wait on the phone. Storage: about 110 KB a photo (1200 px at JPEG 0.6 plus a 240 px preview). The free plan's 1 GB held about 180 MB of other files in November 2026, so roughly 7,000 to 8,000 unit photos fit before the Pro plan ($25 a month, 100 GB) is needed. Check Storage size in Supabase, Reports, now and then. Previews are cached on each phone by path, so looking at photos again uses little egress.

Unit number examples (version 24.83)

units.js (window.UNITS) decides what a unit number looks like at each property, so every unit box's example ("Like 2601") and keyboard match. It's loaded before pm.js in both index.html and demo/index.html and kept in sw.js SHELL. The example comes from, in order: the property's How unit numbers look on the Properties tab (unit_example on the property in report_settings.properties, no database change); the units this phone has seen at that property (pm.js, makeready.js and unitgear.js call UNITS.learn(source, units) when they save their cache, app.js calls UNITS.learnReports() when reports load, and primeUnits() reads up to 300 unit numbers from units and make_ready after sign-in when it has fewer than 3), where the most common shape (2601 and 1210 are both 9999) wins; then KNOWN in units.js for the four mapped properties; then 101. To add a property's built-in example, add it to KNOWN (the harness checks Find unit can find each mapped property's examples). A unit box uses UNITS.fit(input, propertyId, text) or UNITS.example() / pair() / inputMode(); a report or trip with a property picker passes the picked property. UNITS.building(u) names the building in a number (2601 -> 26, 351504 -> 3515, 10834-23 -> 10834) for PM's Add units, and UNITS.range() gives Add units' example range, which pm.js expandUnits reads back. finder.js lookup also reads the building and unit typed together (351504) when the front is a building on that map.