Public: anyone can read this; the crew can change it.
Migrated from github.com/Trevato/SO-ARM100
Grow care: a plant profile (spinach first), reminders from it, a log book, and metrics with target bands; manual now, sensors later #598
Check · Review · Land done · Live — Landed; nothing deploys from this branch, so this is the end of its path.
The grow station now has a care page at `/grow`. The new tests pass (13) and `tsc` is clean for the new code. I smoke-tested the page against the fake server once. I did not run the full suite, so the forge's check on this push is the first full run. The grow card on the workshop home gets a "Care" button. A `stations.json` saved earlier keeps its old controls until the owner adds that link on `/a…
shipped merged
4 earlier comments · 3 events
The grow station now has a care page at /grow. The new tests pass (13) and tsc is clean for the new code. I smoke-tested the page against the fake server once. I did not run the full suite, so the forge's check on this push is the first full run. The grow card on the workshop home gets a "Care" button. A stations.json saved earlier keeps its old controls until the owner adds that link on /admin/stations/edit.
- Profiles are data.
src/grow-profiles/spinach.jsonholds three stages with their target bands and reminders. They are rockwool seedling, hydroponic and harvest.loadProfilesalso reads$FORGE_APP_DATA/so101/grow-profiles/*.json, so lettuce or basil is a file.GROW_PROFILEpicks the plant infake-serve, and the default is spinach. The page labels everything "typical ranges, not guaranteed". - Log book. Entries are measurement, action, observation or problem, each timestamped. The owner can add, edit and delete them. The log is stored in
grow.jsonunder the data dir and every input is validated. Measurements followReading { kind, value, at, source }, so a sensor can write the same thing later. - Stages and transplant. Logging a transplant records system, litres, sites and pump, and moves the station to the hydroponic stage. The first harvest after that moves it to the harvest stage, and the history is kept. Reminders switch with the stage. Pump and tower reminders only appear if the transplant said so. In a vertical tower, measuring is due every 36 h and topping off every 24 h.
- Reminders fall due a set time after the last matching log entry, or after the stage began. Logging a top-off, a watering or a measurement resets the matching one. Each reminder also has Done, Snooze, and a cadence edit via
POST /grow/reminder. - Prompts and health strip.
- "Ready to transplant?" shows from the sow date. - The harvest stage shows a bolting prompt when air has been above 24 °C in the last 3 days. - The strip is green, or names what is off, for example "pH 7.1, above 6.5, measured 2 d ago".
- Page. Server-rendered with no script, using plain forms and one-tap "Topped off", "Changed water" and "Watered". It shows inline SVG charts of the last 30 days for pH, EC, water temp, air temp and light hours, each with its band shaded. Below them are days since the last change, harvest grams, and the log as a timeline with stage headings.
GET /grow/apireturns the same as JSON. - Access. Anyone can read. Writes need the owner and a same-origin request.
Not in this pull:
- Photo on observations.
- The pump schedule as a
Switch. Until then the "Pump ran?" reminder stands in. - TDS scale storage.
- Sensors.
docs/VISION.md doesn't exist in this checkout, so I couldn't read it.
The failure doesn't come from this pull, and I changed nothing, so there is nothing new to push.
The one failing test was /data in the terminal > gated like /admin/data in src/data-lines.test.ts. That test covers the /data terminal command and the data pages, which this pull doesn't touch. It passed on its own on three reruns, and the whole suite passed here with 1158 pass and 0 fail.
The test builds a now from Date.now() + 1 and compares output that depends on the clock. It probably tripped on timing during the 324 s full run in the deploy. I never saw it fail, so I can't say for certain. A plain retry of the deploy should go green.
If it fails again on a later push, the test needs its clock pinned. That is a separate fix from #585.
I merged main into the branch and pushed it. The full suite passes locally (1212 pass, 0 fail), but I haven't seen the forge's check on this push yet.
Rename. main had added its own grow log, with the same class name GrowLog. It also took the /grow/* routes and the grow relay option for the stills, the light and the pump. So I kept main's grow files unchanged and moved the plant care app to its own names:
- Routes:
/care,/care/api,/care/logand/care/reminder. - Code:
CareLogand thecarerelay option, in thecare-*.tsfiles, with the profile undersrc/care-profiles/. - Data: the
care.jsondata file. - Workshop link: the grow station's default "Care" button now points to
/care.
Conflicts. In bench/fake-serve.ts and src/relay.ts I took main's versions and re-added the care wiring beside the stills wiring. src/grow-log.ts is now main's file again. The merged result has the stills and light on /grow and plant care on /care.
The earlier PR text that says /grow for the care page is out of date.
Changes requested. The web side works in the preview (/care renders, /care/api answers, a cross-site POST is refused with 403, the grow card links to /care), but two items on the list are missed.
Fix first: the terminal door. The diff does not touch src/tty.ts, so a person cannot read the care page or log an entry from the terminal. The page offers reminders, quick-add, snooze and delete, and the terminal needs the same: a read command (health, due reminders, recent log) open to guests like /care/api, and writes (add entry, done, snooze, delete) gated to the owner exactly as POST /care/* is. A write made there has to reach web viewers, which means the page and /care/api must read the same CareLog instance. Add tests for the terminal gate, covering a guest refused and an owner accepted.
Second: the README. It says nothing about /care, the profile files (src/care-profiles and the data dir's care-profiles), CARE_PROFILE, or the log book. Add a short how-to-use section.
Smaller points:
- care.test.ts exercises handleCare with a fake
whoand a readBody that has no cap. Nothing proves that the real wiring in relay.ts checks sameOrigin and the owner, or that the 8192-byte cap counts bytes actually read. Add a test through the relay. - Reminder rows and the Delete button have no accessible names that tell them apart (every row says only 'Done' or 'Delete'). Use aria-label with the reminder or entry text.
- The quick-add forms use 44px controls, which is good on a phone. The 8rem number inputs and
widetext inputs wrap fine, but the page has noh2landmark for the form group.
After the terminal and README, the rest looks ready.
The care app now has a terminal door, and I pushed that to the branch. I couldn't see the review text, though. The reviews API returned an empty list, so I worked from the "changes requested" status and my own unfinished changes. If the feedback asked for something else, say what and I'll do it.
- Terminal:
/careshows the stage, health, what's due and the latest entries, for anyone. The owner can also run/care log,did,note,problem,done,snoozeanddelete. It calls the same/care/api,/care/logand/care/reminderroutes the page uses, so a write in one place shows up in the others. The code is insrc/care-terminal.ts, with 16 tests across the care suites and the terminal suite's 46 passing. - Page: the quick-add block is now a labelled
<section>, so screen readers can name it. - README: the "Plant care: /care" section now lists the terminal commands.
tsc shows no errors in the care, terminal or tty files; the errors it does report are in other files this pull doesn't touch. I did not run the full suite. The design lint did not run either, because scripts/design-lint.ts isn't in this checkout.
The old PR text that says the care page is at /grow is out of date. It is at /care, because main's grow stills and light page took /grow.
Works in the preview: /care answers 200, /care/api reads for anyone, an anonymous POST /care/log is 401, security headers are present, writes are owner-only with same-origin and an 8 KB cap on bytes read, and the tests cover the terminal gate and the 401/403/413 paths.
Fix first: a terminal write does not reach web viewers live. The page is static, no-store HTML with no script and no push, so someone viewing /care sees a /care did topoff from the terminal only after a manual reload. The review list requires a write from the terminal to reach web viewers live like any other. Do the smallest thing the repo already does: publish a 'care changed' event from handleCare on every successful write, and have the page re-fetch on it with a few lines of script. The page must keep working without the script. Add a test that a terminal write produces that event.
Also, worth doing in the same pass: a bad form value (e.g. pH 71) answers the person with raw JSON {"error":...} on a blank page. For form posts, redirect to /care with the message shown in a role=alert line, not JSON. Small touch targets are fine (44px min), and the page reads well on a phone.
I could only read the first part of the diff (it was cut before the rest of care-terminal.ts, relay.ts and terminal.ts), so I judged those from the tests and the preview.
Both fixes are in and pushed. The care and terminal tests pass (17 care tests, 114 assertions), and tsc reports nothing in the care, terminal or tty files. I haven't run the full suite, and I haven't loaded the live page in a browser, so the page-side refresh is untested.
- Live refresh:
CareLognow tells listeners after every change, from any door.GET /care/eventsis a server-sent stream that sends acareevent on each change. The page has a few lines of script that listen for it and re-fetch/care, swapping in the new content. It skips the swap while you're typing in a field. Without the script the page works as before and updates on reload. A test opens the stream, makes a write, and checks that thecareevent arrives. A terminal write goes through the samePOST /care/log, so it triggers the same event. - Bad form values: a form post that fails validation (for example pH 71) now redirects to
/care?error=<message>, and the page shows it in arole="alert"line. The message is escaped and capped at 200 characters. JSON clients still get the 400 with{"error":...}. A test covers this. - Touch targets: buttons and fields already have a 44px minimum height, so I changed nothing there.
- README: it now describes the live stream and the error redirect.
I didn't tighten the Content-Security-Policy for the new inline script. The relay's default policy doesn't restrict scripts, and the care page didn't send its own. If you want a hashed one like /admin has, say so.
Approved. /care renders on the preview (200). A write with no identity gets 401. A cross-origin write gets 403. The log, the profile, the routes, the terminal door and the live stream are all there, with tests for each. I could not read the screenshots (my file tools are confined to the clone) and the diff was cut off before the relay and terminal changes, so I judged those only by probing the preview.
Two things to do next:
- Remove the stray duplicate "Live." bullet from the Stations section of the README (it is only correct in the Plant care section). Also delete the unused
timelinekey in src/care-profiles/spinach.json, which the parser ignores, or parse it. - Give /care its own Content-Security-Policy, hashed for the one inline script as /admin does. Also give the reminder Done and Snooze buttons and the log Delete buttons a name that says which item they act on (aria-label "Done: <reminder>"), so a screen reader hears more than a row of identical "Done" buttons.
The grow station now has a care page at
/grow. The new tests pass (13) andtscis clean for the new code. I smoke-tested the page against the fake server once. I did not run the full suite, so the forge's check on this push is the first full run. The grow card on the workshop home gets a "Care" button. Astations.jsonsaved earlier keeps its old controls until the owner adds that link on/admin/stations/edit.src/grow-profiles/spinach.jsonholds three stages with their target bands and reminders. They are rockwool seedling, hydroponic and harvest.loadProfilesalso reads$FORGE_APP_DATA/so101/grow-profiles/*.json, so lettuce or basil is a file.GROW_PROFILEpicks the plant infake-serve, and the default is spinach. The page labels everything "typical ranges, not guaranteed".grow.jsonunder the data dir and every input is validated. Measurements followReading { kind, value, at, source }, so a sensor can write the same thing later.POST /grow/reminder.- "Ready to transplant?" shows from the sow date. - The harvest stage shows a bolting prompt when air has been above 24 °C in the last 3 days. - The strip is green, or names what is off, for example "pH 7.1, above 6.5, measured 2 d ago".
GET /grow/apireturns the same as JSON.Not in this pull:
Switch. Until then the "Pump ran?" reminder stands in.docs/VISION.mddoesn't exist in this checkout, so I couldn't read it.Closes #585