Skip to content

Commit ffc66d3

Browse files
committed
Simplify map sync to marker/pin only, remove drawing/token/fog sync
The full interactive map experience (drawings, tokens, fog of war, layers) now lives exclusively on Chronicle's web UI. The Foundry module only syncs map markers as Scene Map Notes (pins). Changes: - Rewrite map-sync.mjs: remove ~800 lines of drawing/token/fog code - Add "View in Chronicle" context menu on linked scenes - Add pin count badge and Chronicle link to dashboard Maps tab - Remove drawing/token/fog/layer from WebSocket type allowlist - Update API contract and architecture docs https://claude.ai/code/session_01J3F55nRmeFHTtK4BnYgGGk
1 parent e47e51a commit ffc66d3

9 files changed

Lines changed: 128 additions & 966 deletions

File tree

.ai.md

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ module.mjs (entry point)
1313
└─ SyncManager (sync-manager.mjs)
1414
├─ ChronicleAPI (api-client.mjs) ← REST + WebSocket client
1515
├─ JournalSync (journal-sync.mjs) ← Entity ↔ JournalEntry
16-
├─ MapSync (map-sync.mjs) ← Map drawings/tokens ↔ Scene
16+
├─ MapSync (map-sync.mjs) ← Map markers/pins ↔ Scene Notes
1717
├─ CalendarSync (calendar-sync.mjs) ← Calendar events/date ↔ Calendaria/SimpleCalendar
1818
├─ ShopWidget (shop-widget.mjs) ← Shop entity inventory in Foundry UI
1919
├─ NoteSync (note-sync.mjs) ← Chronicle Notes ↔ JournalEntry
@@ -49,7 +49,7 @@ All sync modules use a `_syncing` boolean flag to prevent infinite loops:
4949
| `scripts/api-client.mjs` | REST client (Bearer auth) + WebSocket (auto-reconnect, message queue, event emitter) |
5050
| `scripts/sync-manager.mjs` | Orchestrator. Owns API client, routes WS messages, manages sync mapping lookups |
5151
| `scripts/journal-sync.mjs` | Entity ↔ JournalEntry bidirectional sync. Monk's Enhanced Journal support |
52-
| `scripts/map-sync.mjs` | Map drawings/tokens/fog sync. Percentage↔pixel coordinate conversion. Scene-to-map linking via context menu |
52+
| `scripts/map-sync.mjs` | Map marker/pin sync only. Percentage↔pixel coordinate conversion. Scene-to-map linking via context menu. "View in Chronicle" for full map editor |
5353
| `scripts/calendar-sync.mjs` | Adapter pattern for Calendaria and SimpleCalendar. 0-indexed↔1-indexed conversion |
5454
| `scripts/shop-widget.mjs` | Shop window (Application v1). Context menu, drag-to-character-sheet, real-time updates |
5555
| `scripts/actor-sync.mjs` | Actor ↔ character entity bidirectional sync. System adapter loading, hook registration |
@@ -78,7 +78,7 @@ The table below summarizes which module uses which API area:
7878
| Entity Types | `GET /entity-types` | `actor-sync.mjs`, `journal-sync.mjs` |
7979
| Entity Permissions | `GET/PUT /entities/:id/permissions` | `journal-sync.mjs` |
8080
| Relations | `GET /entities/:id/relations`, `POST/PUT/DELETE .../relations/*` | `item-sync.mjs`, `shop-widget.mjs` |
81-
| Maps | `GET /maps`, `GET/POST/PUT/DELETE /maps/:id/drawings/*`, `.../tokens/*`, `.../fog`, `.../layers` | `map-sync.mjs` |
81+
| Maps | `GET /maps` | `map-sync.mjs` |
8282
| Map Markers | `GET/POST/PUT/DELETE /maps/:id/markers/*` | `map-sync.mjs` |
8383
| Calendar | `GET /calendar`, `GET/PUT /calendar/date`, `POST /calendar/advance`, `POST /calendar/advance-time` | `calendar-sync.mjs` |
8484
| Calendar Events | `GET/POST/PUT/DELETE /calendar/events/*` | `calendar-sync.mjs` |
@@ -96,10 +96,7 @@ See API-CONTRACT.md for the full WebSocket protocol. Summary of handling status:
9696
**Handled:**
9797
- `entity.created/updated/deleted` → JournalSync
9898
- `entity_type.created/updated/deleted` → JournalSync (folder updates)
99-
- `drawing.created/updated/deleted` → MapSync
100-
- `token.created/moved/updated/deleted` → MapSync
10199
- `marker.created/updated/deleted` → MapSync
102-
- `fog.updated` → MapSync (renders fog regions as overlay drawings)
103100
- `calendar.event.created/updated/deleted` → CalendarSync
104101
- `calendar.date.advanced` → CalendarSync
105102
- `note.created/updated/deleted` → NoteSync
@@ -112,7 +109,6 @@ See API-CONTRACT.md for the full WebSocket protocol. Summary of handling status:
112109
- `calendar.weather.changed` — Weather set or generated
113110
- `calendar.structure.updated` — Calendar structure modified (months, weekdays, etc.)
114111
- `calendar.era.changed` — Era boundary crossed
115-
- `layer.updated` — Map layer changed
116112
- `sync.error` — Synchronization error
117113
- `sync.conflict` — Data conflict detected
118114

@@ -146,9 +142,8 @@ or WS vs REST payload differences. Verify with the Chronicle dev before changing
146142

147143
## Known Limitations
148144

149-
- **Fog of war**: One-way sync (Chronicle → Foundry). Fog regions rendered as
150-
semi-transparent polygon drawings on the Foundry scene. No Foundry → Chronicle
151-
push yet (Foundry's native fog is vision-based, Chronicle's is polygon-based)
145+
- **Map drawings/tokens/fog/layers**: Managed by Chronicle's web map editor only.
146+
Not synced to Foundry. Only markers (pins) sync as Foundry Scene Map Notes
152147
- **SimpleCalendar events**: Limited — events managed as journal notes, no CRUD hooks
153148
- **Shop icon field**: Always returns null (`shop-widget.mjs:146`)
154149
- **Single scene**: Only the active Foundry scene syncs (no multi-scene)

API-CONTRACT.md

Lines changed: 3 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -547,41 +547,9 @@ Generic sync endpoint for batch operations.
547547
#### GET /maps
548548
Lists all maps in the campaign.
549549

550-
#### GET /maps/:mapId/drawings
551-
Lists drawings for a map.
552-
553-
#### POST /maps/:mapId/drawings
554-
Creates a new drawing.
555-
556-
#### PUT /maps/:mapId/drawings/:drawingId
557-
Updates a drawing.
558-
559-
#### DELETE /maps/:mapId/drawings/:drawingId
560-
Deletes a drawing.
561-
562-
#### GET /maps/:mapId/tokens
563-
Lists tokens for a map.
564-
565-
#### POST /maps/:mapId/tokens
566-
Creates a token.
567-
568-
#### PATCH /maps/:mapId/tokens/:tokenId/position
569-
Moves a token (x, y only).
570-
571-
#### PUT /maps/:mapId/tokens/:tokenId
572-
Full token update.
573-
574-
#### DELETE /maps/:mapId/tokens/:tokenId
575-
Deletes a token.
576-
577-
#### GET /maps/:mapId/fog
578-
Gets fog of war data.
579-
580-
#### PUT /maps/:mapId/fog
581-
Updates fog of war data.
582-
583-
#### GET /maps/:mapId/layers
584-
Lists map layers.
550+
> **Note:** Drawing, token, fog, and layer endpoints exist on the Chronicle API
551+
> but are consumed by Chronicle's web map editor only — they are not synced to
552+
> Foundry. Only markers are synced as Foundry Scene Map Notes.
585553
586554
#### GET /maps/:mapId/markers
587555
Lists map markers (pins/notes on the map).
@@ -891,18 +859,9 @@ If the token is invalid, the server rejects the upgrade.
891859
| `entity_type.created` | Full entity type object | Entity type created |
892860
| `entity_type.updated` | Full entity type object | Entity type modified |
893861
| `entity_type.deleted` | `{ id: "uuid" }` | Entity type deleted |
894-
| `drawing.created` | Full drawing object | Map drawing created |
895-
| `drawing.updated` | Full drawing object | Map drawing modified |
896-
| `drawing.deleted` | `{ id, map_id }` | Map drawing deleted |
897-
| `token.created` | Full token object | Map token created |
898-
| `token.moved` | `{ id, map_id, x, y }` | Map token moved |
899-
| `token.updated` | Full token object | Map token modified |
900-
| `token.deleted` | `{ id, map_id }` | Map token deleted |
901862
| `marker.created` | Full marker object | Map marker created |
902863
| `marker.updated` | Full marker object | Map marker modified |
903864
| `marker.deleted` | `{ id }` | Map marker deleted |
904-
| `fog.updated` | `{ map_id, fog_data }` | Fog of war changed |
905-
| `layer.updated` | Full layer object | Map layer changed |
906865
| `note.created` | Full note object | Note created |
907866
| `note.updated` | Full note object | Note modified |
908867
| `note.deleted` | `{ id }` | Note deleted |

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ scripts/ # ES modules (.mjs)
2121
sync-manager.mjs # Orchestrator, API routing, WS management
2222
api-client.mjs # REST + WebSocket client
2323
journal-sync.mjs # Entity ↔ JournalEntry sync
24-
map-sync.mjs # Map drawings/tokens/fog sync
24+
map-sync.mjs # Map marker/pin sync (markers ↔ Scene Notes)
2525
calendar-sync.mjs # Calendar adapter (Calendaria/SimpleCalendar)
2626
actor-sync.mjs # Character entity ↔ Actor sync
2727
item-sync.mjs # Item sync

lang/en.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
},
2525
"SyncMaps": {
2626
"Name": "Sync Maps",
27-
"Hint": "Sync Chronicle maps with Foundry scenes (drawings, tokens)"
27+
"Hint": "Sync Chronicle map markers with Foundry scene pins"
2828
},
2929
"SyncCalendar": {
3030
"Name": "Sync Calendar",

scripts/api-client.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import { getSetting } from './settings.mjs';
1717
*/
1818
const ALLOWED_WS_TYPE_PREFIXES = Object.freeze([
1919
'entity.', 'entity_type.',
20-
'drawing.', 'token.', 'marker.', 'fog.', 'layer.',
20+
'marker.',
2121
'note.',
2222
'calendar.',
2323
'relation.',

0 commit comments

Comments
 (0)