feat(m4): playtest friction: perf overlay, fresh import, token seed (#82)

Opt-in ?perf=1 overlay (fps, frame p50/p95, JS p50/p95, tokens, zoom; no node or ticker work when off). fff-vtt import creates and migrates a fresh/empty state dir through the shared server startup path; devbox run serve gains --image. devbox run seed creates deterministic labelled NPC tokens over the real WS (idempotent rerun, --replace), and the GM token form defaults X/Y to the viewport centre.
This commit is contained in:
2026-11-21 17:20:05 +01:00
parent 356705823b
commit 9c7f9de910
20 changed files with 933 additions and 53 deletions
+11 -9
View File
@@ -2380,7 +2380,8 @@ Commands:
gm-key --new Rotate the GM key and revoke all GM sessions. Refused while the server
holds the state-dir lock (stop the server first).
import Slice a PNG/WebP map into the scene's tile tree and update the scene row.
Stop the server first (it reads the scene at startup); restart it after.
A fresh/empty state dir is created and migrated first. Stop the server
first (it reads the scene at startup); restart it after.
Run `fff-vtt import --help` for the import arguments.
The bind address is fixed at 127.0.0.1 and is not a key: put nginx (or another TLS proxy) in front.
@@ -2425,13 +2426,12 @@ proc runGmKey(rawArgs: seq[string]): int =
var conn: DbConn
try:
conn = openDatabase(cfg.dbPath)
conn = openMigratedDatabase(cfg.dbPath).db
except CatchableError as e:
stderr.writeLine "fff-vtt gm-key: cannot open " & cfg.dbPath & ": " & e.msg
stderr.writeLine "fff-vtt gm-key: cannot open or migrate " & cfg.dbPath & ": " & e.msg
return 1
defer: close(conn)
try:
discard migrate(conn)
let created = ensureGm(conn, rotate)
if created.rotated:
stdout.writeLine "GM key (new): " & created.key
@@ -2466,15 +2466,17 @@ proc runServer(cfg: Config): int =
return 1
var conn: DbConn
var applied: int
try:
conn = openDatabase(cfg.dbPath)
let opened = openMigratedDatabase(cfg.dbPath)
conn = opened.db
applied = opened.applied
except MigrationError as e:
lg.log(lvError, "db_migrate_failed", [("path", cfg.dbPath), ("error", e.msg)])
return 1
except CatchableError as e:
lg.log(lvError, "db_open_failed", [("path", cfg.dbPath), ("error", e.msg)])
return 1
let applied = try: migrate(conn)
except CatchableError as e:
lg.log(lvError, "db_migrate_failed", [("path", cfg.dbPath), ("error", e.msg)])
return 1
lg.log(lvInfo, "db_ready", [("path", cfg.dbPath), ("schema_version", $schemaVersion(conn)),
("applied", $applied)])