Skip to content

dotbot/console-web: edit LH2 station boxes in the site editor - #345

Open
geonnave wants to merge 81 commits into
DotBots:mainfrom
geonnave:site-editor-station-boxes
Open

geonnave wants to merge 81 commits into
DotBots:mainfrom
geonnave:site-editor-station-boxes

Conversation

@geonnave

@geonnave geonnave commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Stacked on #330 (site editor as a console panel), on #329, #328, #327, #326, #315 and the LH2 stack to #343 that #326 carries. Merges after them; until then the diff also carries their commits.

Each LH2 station of a calibration carries a valid_mm rectangle, the part of the site its fixes are trusted in. Until now that rectangle came out of the solve and the only way to change it was to edit the TOML by hand, which changes the file without changing its id. This adds a way to redraw those rectangles and save the result properly, as a new calibration.

  • Calibration (dotbot/calibration/station_boxes.py): reboxed returns the source with the named stations' rectangles replaced, the fence recomputed as their union, and everything else, homographies included, unchanged. The result gets a new id, edited_from set to the source id (a new metadata field; placed_from keeps naming the free-frame spin calibration that --append points back to), and a tag of <tag>-boxes, numbered when taken. The source file is never written. Refused, with the reason: a rectangle that is empty, reaches below zero, reaches outside the site's extent or does not fit the wire encoding; a calibration not in the site's frame (free mode, or another site or anchor); a hand-edited source (file id does not match content); no rectangle changed. A rectangle that leaves out spin circles or placement points its station was calibrated on gives a warning, not a refusal.
  • CLI: dotbot swarm calibrate-lh2 rebox SOURCE --station N=RECT [--station ...] [--tag T] [--site S], where RECT is x,y,w,h in mm or a site area name such as field+staging. It prints each station's old and new rectangle, the warnings, the saved path, and the calibrate-lh2 push line. It sends nothing.
  • Site editor: a Station boxes tool (key S) picks a calibration in the site's frame and draws one rectangle per station, moved and resized by its handles, over the site, with undo and arrow nudges like the other tools. Save posts to a new /api/calibrations/{spec}/boxes route, which refuses with 409 when site.toml changed since the page loaded it, and shows the new id, the warnings and the push line. The calibration list now says which entries are in the site's frame. Works in the standalone dotbot site edit and in the console panel from dotbot/console-web: open the site editor as a console panel #330, since both mount the same routes.

Validation. pytest (calibration, CLI and route tests: each refusal, the warning, tag numbering, the saved file reading back with the source untouched) and vitest (box geometry, the tool's draw, undo and save flow); typecheck, lint and build pass. Two failures in the full run are not from this branch: test_camera_service::test_a_registration_without_controls_warns_about_nothing, and nine test_calibration_session tests that need opencv-python, which the local venv lacks; both fail on the base too. By hand: headless browser smoke tests of the tool on copies of a real two-station site, with the simulator running 6 robots. No robot-side test of this feature.

+ - Files
#315, the LH2 stack to #343, #326, #327, #328, #329 and #330, carried underneath (merge separately) +12482 -421 105
This PR, tests +505 -0 5
This PR, source +977 -25 11
This PR's files + -
dotbot/console-web/src/siteEditor/StationBoxesPanel.tsx +217 -0
dotbot/tests/test_calibration_station_boxes.py +199 -0
dotbot/calibration/station_boxes.py +177 -0
dotbot/console-web/src/siteEditor/siteEditor.test.tsx +148 -0
dotbot/console-web/src/siteEditor/SiteEditor.tsx +141 -10
dotbot/console-web/src/siteEditor/Canvas.tsx +134 -5
dotbot/cli/swarm_lh2.py +130 -0
dotbot/tests/test_site_placement.py +85 -0
dotbot/site_placement.py +66 -5
dotbot/console-web/src/siteEditor/boxes.ts +61 -0
dotbot/console-web/src/siteEditor/boxes.test.ts +51 -0
5 small files: lighthouse2.py, placement.py, api.ts, types.ts, test_site_editor_panel.py +73 -5
Total, 16 files +1482 -25

AI-assisted: Claude Opus 5.5
AI-assisted: Claude Opus 5.5
… page

Any web page in the browser can send requests to 127.0.0.1 with a valid
Host header, and behind a permissive CORS policy read the replies, so the
Host check alone let it save site.toml; a server bound beyond loopback
took any Host. The peer address, Origin and Sec-Fetch-Site are checked.

AI-assisted: Claude Opus 5.5
…ng tables

A patched file is read back and must give the model that was sent, so a
layout the patcher does not follow is refused rather than written.

AI-assisted: Claude Opus 5.5
Breaking: schema 3 calibration files are refused, so a calibration is
collected again. swarmit's own calibration reader still expects schema 3
and needs its matching change before the dashboard reads these files.

AI-assisted: Claude Opus 5.5
…tangle

Breaking, cross-repo: the messages and the config page (magic SWRP, 872
bytes) only match a swarmit bootloader and net core that store stations
by mask, and swarmit's Python must accept mask messages before it relays
them. Robots below device info 4 are refused with a reflash.

AI-assisted: Claude Opus 5.5
Breaking wire change, landing with DotBot-libs' 16-bit calibrated field:
every advertisement field after the mask moves by one byte and the
vendored dotbot_control.wasm is rebuilt at ABI 3 from that change. With
the one-byte mask, a calibration naming station 8 or above read every
sandbox robot as missing it and resent homographies on each advert.

AI-assisted: Claude Opus 5.5
AI-assisted: Claude Opus 5.5
…leave omitted tables

AI-assisted: Claude Opus 5.5
…anged

placed_from keeps naming the free-frame spin calibration that `--append`
points back to; the calibration an edit was made from is edited_from.

AI-assisted: Claude Opus 5.5
AI-assisted: Claude Opus 5.5
@codecov

codecov Bot commented Oct 15, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.22498% with 282 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.52%. Comparing base (ddc43f7) to head (3158b2a).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
dotbot/console-web/src/siteEditor/Canvas.tsx 85.30% 109 Missing ⚠️
dotbot/console-web/src/siteEditor/SiteEditor.tsx 86.75% 100 Missing ⚠️
dotbot/console-web/src/siteEditor/api.ts 86.60% 15 Missing ⚠️
dotbot/console-web/src/siteEditor/main.tsx 0.00% 8 Missing and 1 partial ⚠️
dotbot/console-web/src/App.tsx 74.07% 7 Missing ⚠️
dotbot/console-web/src/siteEditor/Inspector.tsx 98.45% 7 Missing ⚠️
dotbot/console-web/src/siteEditor/edit.ts 96.58% 7 Missing ⚠️
dotbot/cli/swarm_lh2.py 91.80% 5 Missing ⚠️
dotbot/tests/lh2_multi_fixture.py 94.80% 4 Missing ⚠️
dotbot/console-web/dev/fake_swarmit_server.py 0.00% 3 Missing ⚠️
... and 8 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #345      +/-   ##
==========================================
+ Coverage   88.21%   88.52%   +0.31%     
==========================================
  Files         227      243      +16     
  Lines       36147    39642    +3495     
  Branches     2324     3012     +688     
==========================================
+ Hits        31886    35092    +3206     
- Misses       4257     4545     +288     
- Partials        4        5       +1     
Flag Coverage Δ
console 83.78% <90.87%> (+1.78%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
dotbot/cli/main.py 95.83% <ø> (ø)
dotbot/cli/site_cmd.py 91.54% <ø> (-0.04%) ⬇️
dotbot/config.py 98.59% <ø> (-0.29%) ⬇️
dotbot/console-web/src/BotMarker.tsx 100.00% <100.00%> (ø)
dotbot/console-web/src/GridView.tsx 88.20% <100.00%> (-0.22%) ⬇️
dotbot/console-web/src/ListView.tsx 88.78% <100.00%> (+0.64%) ⬆️
dotbot/console-web/src/LocalizationPanel.tsx 86.09% <100.00%> (ø)
dotbot/console-web/src/MapView.tsx 97.63% <100.00%> (+0.09%) ⬆️
dotbot/console-web/src/RightPane.tsx 97.39% <100.00%> (+0.08%) ⬆️
dotbot/console-web/src/botFacts.ts 98.10% <100.00%> (+0.66%) ⬆️
... and 53 more

... and 3 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant