Commit graph

7 commits

Author SHA1 Message Date
642d74c9f8 Debounce changed to seconds. 2026-05-12 18:34:31 -06:00
43c630c1f7 Port End Session dialogs to DialogV2 for v13/v14
V1 Dialog and Dialog.confirm are deprecated in v13 and removed in v14.
Migrate the three sites in macros.js (attendance grid, single-session
confirm, multi-session pick) to foundry.applications.api.DialogV2, and
drop the jQuery used in their callbacks in favor of querySelector +
dataset/value on dialog.element. Use rejectClose: false to preserve
the prior null-on-close behavior.

Bump version to 0.2.0 and widen compatibility to verified 13, max 14
(min stays at 12 — DialogV2 has been available since v12).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-12 18:21:33 -06:00
0df05e0d0b Attendance dialog in End Session flow
endSession() now pulls the session roster from Frappe, computes a
default-correct attendance proposal from Foundry actor activity, and
presents it as a dropdown grid the GM can override.

Activity = actor.system._stats.modifiedTime since session_start, OR a
non-GM owner currently online. Notice rows are preserved as-is so the
player's stated intent is respected; the GM can still flip them
manually in the dialog.

finalize_attendance runs BEFORE complete_session so a failure there
leaves the session Scheduled and re-runnable rather than Completed-
with-no-attendance.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-11 01:32:22 -06:00
ed853de6a2 Push module credits at end-of-session
endSession() now pushes the world's active module list to Frappe after
the snapshot push. Each module is projected to {id, title, url,
authors[].name + url} — versions and compatibility info are intentionally
omitted so the eventual public credits page doesn't leak dependency
versions. The Frappe endpoint also strips these fields server-side.

Module inventory push is treated as non-critical: a failure logs a
warning and adds a line to the chat summary, but doesn't abort the
session-completion flow. The chat summary now reports the count of
modules tracked.

Public API gains seitimeBridge.pushModuleInventory() for manual pushes.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 03:17:30 -06:00
c7159ee84b End Session macro flow
Adds the GM-facing end-of-session orchestration. The expected use is a
Foundry macro of type Script with body:

  seitimeBridge.endSession();

Flow:
1. Fetch scheduled sessions for this world from Frappe.
2. If 0 → notify and abort. If 1 → confirm dialog. If 2+ → picker dialog.
3. POST complete_session to mark the chosen session Completed and
   schedule the next one (Frappe-side schedule_next_session).
4. Push snapshots for every PC in parallel (Promise.allSettled — partial
   failures are surfaced, not fatal).
5. Whisper a summary chat message to the GM (counts and any failed
   actor names with errors).

scripts/macros.js holds the orchestration; scripts/api.js gains thin
fetch wrappers for list_scheduled_sessions and complete_session. HTML in
dialogs and chat is escaped on output since session titles ultimately
come from user input.

Public API now: testConnection, pushManifest, pushSnapshot,
pushAllSnapshots, endSession.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:51:01 -06:00
2b7fb97696 Snapshot push on actor and item edits
Foundry side of the per-PC snapshot flow: the primary GM pushes a debounced
snapshot of any character that gets edited, including embedded item changes
(updateItem/createItem/deleteItem don't trigger updateActor in v12).

Payload is actor.toObject() augmented with a denormalized _player_name
field — the Frappe extractor reads it from there since Foundry's ownership
map uses opaque user IDs.

Per-actor debouncers (default 5s, configurable) keep combat HP edits from
spamming the webhook. Toggle off via the snapshotAutoSync setting if you
want explicit-only pushes from a macro.

API exposed at globalThis.seitimeBridge.pushSnapshot(actor) for manual
pushes (single argument: a Foundry Actor document).

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:43:09 -06:00
bc3aa10ab2 Initial scaffolding: settings + manifest push
Foundry v12 ESM module that pushes the world's PC actor manifest to a
companion Frappe app via webhook.

Structure:
- scripts/main.js: registers settings on init, exposes API on ready,
  wires createActor/deleteActor/periodic hooks. All push operations
  gated to game.users.activeGM to avoid duplicate pushes from co-GMs.
- scripts/settings.js: Frappe URL, shared secret, world ID, periodic
  interval. Secret uses `secret: true` for masked input but is still
  readable by all connected clients (documented in setting hint).
- scripts/api.js: bridgeFetch helper with X-Bridge-Secret/-World
  headers, pushManifest, testConnection.
- scripts/constants.js: MODULE_ID.

Public API exposed at globalThis.seitimeBridge:
  seitimeBridge.testConnection()  // round-trip empty manifest
  seitimeBridge.pushManifest()    // push current world manifest

dnd5e is declared as a related system in module.json.
Snapshot push and End Session macro come in subsequent commits.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-10 02:26:53 -06:00