Atomic building placement: add site_id to UpdateBuilding for in-modal site editing
- Dominant language
- Go
- Stars
- 55
- Forks
- 16
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 87
Description
## Context
Follow-up from the #702 work (PR adding rack/building placement to the create/edit modals).
Rack edit gained in-modal placement editing because `SaveRack` is a single RPC that commits both metadata (`RackInfo`) and placement (`site_id`/`building_id`) atomically.
Buildings have no equivalent. `UpdateBuilding` **deliberately excludes `site_id`** (the proto comment points callers to `AssignBuildingsToSite`). So supporting site editing on the building **settings/update** modal today would require two client calls on Save — `UpdateBuilding` (metadata) + `AssignBuildingsToSite` (site + descendant cascade) — with no server transaction spanning them, i.e. a real cross-RPC partial-failure surface (name saved, placement not, or vice versa).
We deferred in-modal building site-editing rather than ship the two-call version.
## Proposal
Give buildings the same atomic, single-RPC placement path racks have:
- Add optional `site_id` to `UpdateBuildingRequest` (proto), mirroring `RackInfo.site_id` semantics: unset = preserve current site, explicit value = move (with the existing descendant `device.site_id` / rack cascade), explicit `0` = unassign.
- Server: apply the site change + cascade inside the same transaction as the metadata update (reuse the `AssignBuildingsToSite` cascade logic).
- Regen (`just gen`).
- Client: add a Site dropdown to `BuildingSettingsModal` **edit** mode; on Save, gate a site change behind a confirmation dialog noting downstream effects ("moves N racks / M miners to ").
## Not a gap today
Building→site re-homing already works via `ManageBuildingsModal` (a site's manage-buildings flow) and `FleetBuildingsPage`, both using `AssignBuildingsToSite`. This is about unifying it into the building settings modal, atomically.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Contributor guide
Research direction
Start by tracing UpdateBuildingRequest/UpdateBuilding and the existing AssignBuildingsToSite cascade, then inspect BuildingSettingsModal edit mode and the related #702 work. Run just gen after the proto change. Done means site changes, descendant cascades, and metadata commit atomically, while the edit modal confirms downstream effects before saving.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- backend-api-design, frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100