feat(meshcore): saved-regions catalog + region pickers for scopes (#3770)#3783
Conversation
) Add a user-maintained, GLOBAL catalog of MeshCore region names so operators can save/manage regions and pick them when setting scopes, instead of typing the scope every time. A MeshCore "scope" is a transport code derived purely from a region name (sha256("#region")[:16]), so the catalog is not source- scoped — it mirrors the global-by-design channel_database / automations tables. Data model: - New table meshcore_saved_regions (id, name UNIQUE+normalized, note, created_at, updated_at) via migration 108 (SQLite/Postgres/MySQL, idempotent). - Schema + activeSchema wiring; SavedRegionsRepository with normalize/add (idempotent)/list/getByName/delete; exposed as databaseService.savedRegions. - Added to migrate-db TABLE_ORDER (global, no FK). API (under the source-scoped meshcore router, operating on the global table): - GET /saved-regions list - POST /saved-regions add (idempotent; { name, note? }) - DELETE /saved-regions/:id delete UI (4 touchpoints from the issue): 1. Save a repeater-reported region: + button on each discovered-region chip in MeshCoreSettingsView (✓ when already saved). 2. Manage the list: add/delete section in MeshCoreSettingsView. 3. Channel settings: scope field gains a datalist of saved regions (MeshCoreChannelsConfigSection). 4. Per-message override: the scope-override datalist now unions saved + discovered regions (MeshCoreChannelsView). useMeshCore gains fetchSavedRegions/addSavedRegion/deleteSavedRegion. Tests: - savedRegions repository unit tests (normalize, idempotent add, note update, invalid-name reject, case-insensitive lookup, ordering, delete). - meshcore routes tests for list/add/delete (auth, validation, 400 paths). - migrations.test count 107→108 + last-name; migrationTables coverage updated. Full vitest suite green (excludes 4 pre-existing env-broken spiderfier suites). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01VBLhGGNh35oMwTL53va1Y5
|
Claude finished @Yeraze's task —— View job PR Review: feat(meshcore): saved-regions catalog + region pickers for scopesTasks
Overall AssessmentThis is a well-structured feature with clear design rationale. The global-by-design decision is correct, the layering is clean, and the test coverage is solid. A few items worth addressing: Issues1.
|
Closes #3770
Summary
MeshMonitor can request regions/scopes from nearby MeshCore repeaters, but until now scopes had to be typed by hand everywhere. This adds a user-maintained, global catalog of MeshCore region names and wires it into every place a scope is chosen, so operators save a region once and pick it from a list thereafter.
A MeshCore "scope" is a transport code derived purely from a region name (
sha256("#region")[:16]), so the catalog is not source-scoped — it is global-by-design, mirroring the existingchannel_database/automationstables.Data model
New table
meshcore_saved_regions(migration 108, all three backends, idempotent):idname#,[a-z0-9-]), UNIQUEnotecreated_at/updated_atsrc/db/schema/savedRegions.ts) +activeSchemawiring.SavedRegionsRepository(src/db/repositories/savedRegions.ts):getAllAsync,getByNameAsync,addAsync(normalizing + idempotent — returns existing on duplicate, updates note),updateNoteAsync,deleteAsync. Exposed asdatabaseService.savedRegions.TABLE_ORDER(global, no FK).API
Mounted under the existing source-scoped meshcore router (reusing its auth), operating on the global table:
GET /api/sources/:id/meshcore/saved-regions— listPOST /api/sources/:id/meshcore/saved-regions—{ name, note? }, idempotent addDELETE /api/sources/:id/meshcore/saved-regions/:regionId— deleteconfigurationread/write permission, consistent with the default-scope routes.The 4 UI touchpoints
MeshCoreSettingsViewgets a+save button (shows✓when already saved).MeshCoreSettingsViewwith an add field and per-item delete.MeshCoreChannelsConfigSectiongains a<datalist>populated from the saved catalog (free typing still allowed).<datalist>inMeshCoreChannelsViewnow offers the union of saved + discovered regions, de-duplicated.useMeshCoregainsfetchSavedRegions/addSavedRegion/deleteSavedRegion.Testing
savedRegionsrepository unit tests: normalization, idempotent add, note update on re-add, invalid-name rejection, case-insensitive lookup, ordering, delete.migrations.test.tscount 107→108 + last-name assertion;migrationTablesschema-coverage updated.ts-overlapping-marker-spiderfier-leafleton the base tree too (pre-existing worktree dependency issue, unrelated to this change).tscclean on all changed files; no new settings keys; no device-comms code touched (nosystem-testlabel needed).🤖 Generated with Claude Code