# Ultrawork Notepad â€” Smart-mapping sidebar/buttons/auberges restructure
Started: 2026-08-03T18:30:00Z

## Goal (BINDING)
Restructure the cesium-map sidebar to exactly 3 tabs (All / Gouvernorats / Auberges), governorateâ†’auberge hierarchy (opening a governorate shows its auberges), point creation in map-settings that names an auberge inside the governorate where clicked, governorate name labels visible on map load, remove border-radius from buttons, fix yellow nav-arrow hover to palette colors, translate "auberge" en/fr/ar.

## Scenarios (the contract)
- S1 (happy): Map loads â†’ governorate names visible as labels on the map. Verify: Playwright screenshot shows text labels; computed style color = palette.
- S2 (happy): Sidebar shows exactly 3 tabs (All/Gouvernorats/Auberges). Verify: DOM count of .filter-tab = 3, labels match.
- S3 (happy): Opening a governorate tab item â†’ drill-down lists its auberges (names+details). Verify: click governorate â†’ hierarchy view shows auberge names.
- S4 (edge): Clicking "point" in map-settings on the map â†’ naming dialog appears, name saved to backend/entity associated with the governorate under the click point. Verify: dialog appears with name input; created location has parentId = governorate id.
- S5 (visual): Buttons rectangular (no border-radius), nav-arrow hover red/navy not yellow. Verify: computed border-radius = 0, hover style = palette.
- S6 (i18n): 'auberge' translated en/fr/ar. Verify: translation JSONs contain key; /en/cesium shows English, /fr shows French.

## Now
Waiting for 4 explore agents (sidebar/hierarchy, point creation, labels/i18n, button CSS).

## Todo (remaining, ordered)
1. Collect explore results
2. Plan agent wave graph
3. Implement per waves
4. Build + test + Playwright QA
5. Cleanup

## Findings
- Previous session: 3-color theme (#D9D9D9/#E41B23/#153242) applied, uncommitted (git status shows M on 10 files + 2 new). THIS session builds on that.
- Backend :8080 was DOWN during prior QA; intro overlay never completes without it. QA must account for that.
- localStorage key smart_mapping_sidebar_config_v1 can override sidebar theme (cleared during QA).

## Learnings
- Angular dev server serializes #E41B23 as rgb(228,27,35) in served CSS â€” hex checks fail, use computed styles.
- Cesium canvas is WebGL; getContext('2d') returns null â€” verify via screenshots + computed styles, not canvas sampling.

---
## RUN 3 — Governorate labels only in map-settings, auberge click-to-fly, no project pins
Started: 2026-08-03T20:00:00Z

## Goal (BINDING)
1. Governorate NAME LABELS appear ONLY in map-settings, NOT in cesium-map (public map).
2. Clicking an auberge (cesium-map sidebar + map-settings) flies/zooms camera to that auberge.
3. NO project pins rendered anywhere (both components).
4. map-settings keeps governorate borders + name labels on load (already done, verify).

## Scenarios (contract)
- S1 (cesium-map): governorate name labels NOT visible; pins/billboards still present. Verify: grep ensureGovernoratePin label block removed/hidden; Playwright screenshot no navy label text on public map.
- S2 (auberge click): clicking an auberge row in cesium-map sidebar flies camera to it. Verify: focusAubergeOnMap has camera fly logic; Playwright click ? camera moved.
- S3 (no project pins): zero project pins in both components. Verify: grep all project-pin render paths suppressed; bundle has no active project-pin creation.
- S4 (map-settings): governorate borders + name labels visible on load. Verify: renderGovernorateBorderAndLabel wired in displayTunisiaDistricts; Playwright pixel check cyan borders + navy labels.

## Findings
- Wave-2 (prior run): cesium-map ensureGovernoratePin (L4712+) has label block using PIN.aubergeLabel; map-settings renderGovernorateBorderAndLabel (L3900+) renders cyan borders + navy labels at load (from displayTunisiaDistricts L3746).
- Prior run also: renderZoneProjectPins early-returns (cesium-map), renderLocationEntities skips PROJECT via shouldRenderPoint, toggleZonePoints skips projects. map-settings displayLocationsOnMap skips isProjectCategory. Need to verify no OTHER project-pin paths remain.

---
## RUN 4 — Auberge not listed under governorate in cesium-map + gov borders/names in map-settings
Started: 2026-08-03T20:30:00Z

## Goal (BINDING)
1. FIX: creating an auberge in map-settings inside a governorate ? its name appears in that governorate's auberges list in cesium-map.
2. VERIFY/FIX: map-settings map shows governorate borders + names on load.

## Scenarios (contract)
- S1 (bug fix, happy): auberge created in map-settings (category AUBERGE, parentId=governorate id) appears in cesium-map governorate drill-down auberges list. Verify: parentId chain intact (creation), allAuberges hydration + hierarchy refresh (display), build green.
- S2 (edge): governorate name mismatch between geojson NAME_1 and backend location name does not break linkage. Verify: fallback logic in filterAubergesByGovernorate + findGovernorateLocationByNames.
- S3 (adjacent): map-settings still renders governorate borders (cyan) + navy name labels on load; cesium-map shows NO governorate name labels. Verify: grep + build + Playwright.
- S4 (regression): existing specs (point-pin-policy/map-theme/auberge-utils) stay green.

## Now
3 explore agents tracing: (A) creation side parentId chain in map-settings, (B) display side allAuberges hydration in cesium-map, (C) backend category model + map-settings borders wiring.

## Findings (to be appended after exploration)

## Findings (RUN 4 — root cause confirmed)
- CREATION (map-settings createAubergeAtLocation L2320-2360): parentId resolution fails because 2b matches English GeoJSON NAME_1 (e.g. 'Bizerte') against ARABIC backend governorate names (e.g. '?????') with EXACT normalized equality ? no match ? falls to 2c country fallback (parentId = countryLocationId). Auberge ends up parented to COUNTRY, not governorate. (Silent bug.)
- 2a sidebar path also fragile: pin clicks build selectedLocation with id:0 (falsy) so it's skipped.
- DISPLAY (cesium-map): allAuberges derived from allLocations (summary endpoint returns all non-PROJECT incl AUBERGE). getStrictGovernorateAuberges L2145-2156 matches parentId===govId (string) else name fallback. findGovernorateLocationByNames L2589-2609 uses containment; if it returns null ? govId undefined ? hydrateGovernorateNode L3171-3176 early-returns ? auberges list NEVER recomputed on open. _hierarchyCache L2960-2961 has NO TTL check at read (returns cached unconditionally), cleared only at L482/881/5757/7422.
- BACKEND: category is free string (no enum), AUBERGE accepted. create() honors parentId. update() (L378-429) NEVER updates parentId. No AUBERGE rows in SQL backup (frontend-only concept).
- map-settings borders/labels: ALREADY wired on load (displayTunisiaDistricts L1414 ? renderGovernorateBorderAndLabel L3748). Only guard is countryName 'tunisia' (passes, default map id 41). NOT broken.

## Fix strategy (proposed)
1. map-settings createAubergeAtLocation: resolve governorate by matching backend location against BOTH English+Arabic member names from tunisiaDistrictsMapping[districtId] (not just GeoJSON NAME_1 vs DB name). Ensures parentId = governorate id even for Arabic-stored names.
2. cesium-map: getStrictGovernorateAuberges + hydrateGovernorateNode must work even when govId undefined (name fallback with EN+AR names); don't early-return on missing location.id — recompute auberges by name; add TTL/invalidate on _hierarchyCache read or clear on locationCreated.
3. Verify map-settings borders/labels (already working).
