AI turns documents or topics into real, native PowerPoint decks—with native shapes, transitions and animations, data-backed charts and tables on demand, audio narration from speaker notes, and support for your own .pptx templates. · by Hugo He
feat(confirm-ui): serve /api/catalogs with canvas synced live from config.py
hugohe3219e0adeded8
diff --git a/skills/ppt-master/scripts/confirm_ui/server.py b/skills/ppt-master/scripts/confirm_ui/server.pyindex 59a1040b..dd6405f4 100644--- a/skills/ppt-master/scripts/confirm_ui/server.py+++ b/skills/ppt-master/scripts/confirm_ui/server.py@@ -69,6 +69,9 @@ CONFIRM_DIR_NAME = 'confirm_ui'RECOMMENDATIONS_NAME = 'recommendations.json'RESULT_NAME = 'result.json'+# Static option universe served at /api/catalogs (canvas synced live from config).+_CATALOGS_PATH = Path(__file__).resolve().parent / 'static' / 'catalogs.json'+# Shares port 5050 with the live preview server (svg_editor/server.py). The two# never run at once: confirm is Step 4 and shuts down on confirm (or idle),# freeing the port before live preview starts at Step 6. One port = one forward@@ -165,6 +168,41 @@ def _shutdown_existing(lock_file: Path) -> int:return 0+def _build_catalogs() -> dict:+ """Return the static catalog set with the canvas list synced live from+ ``config.CANVAS_FORMATS`` — the single source of truth for canvas formats —+ so the confirm page can never drift from the pipeline's real formats. The+ set of formats and their dimensions come from config; bilingual labels and+ use text are kept from catalogs.json (with a plain fallback for any new id).+ """+ data = json.loads(_CATALOGS_PATH.read_text(encoding='utf-8'))+ try:+ import config # scripts/ is on sys.path (injected at import time)+ formats = config.CANVAS_FORMATS+ except Exception: # any import/attr failure → serve the static canvas list+ return data+ existing = {+ c.get('id'): c+ for c in data.get('canvas', [])+ if isinstance(c, dict) and c.get('id')+ }+ canvas = []+ for cid, fmt in formats.items():+ entry = dict(existing.get(cid, {}))+ entry['id'] = cid+ entry['dim'] = fmt.get('dimensions', entry.get('dim', ''))+ if not entry.get('label'):+ name = fmt.get('name', cid)+ entry['label'] = name+ entry.setdefault('label_zh', name)+ entry.setdefault('label_en', name)+ if not entry.get('use_en') and fmt.get('use_case'):+ entry['use_en'] = fmt['use_case']+ canvas.append(entry)+ data['canvas'] = canvas+ return data++# --- app --------------------------------------------------------------------def create_app(@@ -221,6 +259,15 @@ def create_app(def index():return send_from_directory(app.static_folder, 'index.html')+ @app.route('/api/catalogs')+ def get_catalogs():+ """Serve the option universe; canvas is synced live from config.py so+ the static catalogs.json copy can never drift from the real formats."""+ try:+ return jsonify(_build_catalogs())+ except (OSError, json.JSONDecodeError) as exc:+ return jsonify({'error': f'invalid catalogs.json: {exc}'}), 500+@app.route('/api/recommendations')def get_recommendations():"""Serve the Strategist-authored recommendations for this project."""diff --git a/skills/ppt-master/scripts/docs/confirm_ui.md b/skills/ppt-master/scripts/docs/confirm_ui.mdindex 01a4ae9d..f966d635 100644--- a/skills/ppt-master/scripts/docs/confirm_ui.md+++ b/skills/ppt-master/scripts/docs/confirm_ui.md@@ -39,7 +39,7 @@ pip install flask## Catalogs — `static/catalogs.json` (the finite option universe)-Served by Flask static at `/static/catalogs.json` (the front-end prefers `/api/catalogs` when the server provides it — e.g. canvas sourced live from `config.py CANVAS_FORMATS` for zero drift). Keys: `canvas`, `modes`, `visual_styles` (grouped), `icons`, `image_usage`, `image_ai_path`, `formula_policy`, `generation_mode`. Each entry is `{ "id", "label", "label_zh", "label_en", ... }`; descriptions use `desc_zh` / `desc_en`, and `visual_styles` groups use `group_zh` / `group_en`. The front-end falls back to legacy `label` / `desc` / `group`, so old catalogs still load, but new user-facing catalog text must be bilingual. English labels should mirror canonical reference names (`pyramid`, `swiss-minimal`, `Path A`, `mixed`, etc.); Chinese labels should be translated for users. Descriptions render inline after the option title, not as a separate selected-option line. `visual_styles` is `[{ "group", "group_zh", "group_en", "items": [...] }]`. `canvas` mirrors `config.py CANVAS_FORMATS` — keep in sync.+The front-end loads `/api/catalogs` (served by the confirm server) and falls back to the static `/static/catalogs.json` if that route is unavailable. `/api/catalogs` returns the static file **with the `canvas` list synced live from `config.py CANVAS_FORMATS`** — the set of formats and their `dim` come from config (single source of truth, zero drift), while bilingual labels / use text stay in catalogs.json (a plain fallback label is synthesized for any new id config adds). Keys: `canvas`, `modes`, `visual_styles` (grouped), `icons`, `image_usage`, `image_ai_path`, `formula_policy`, `generation_mode`. Each entry is `{ "id", "label", "label_zh", "label_en", ... }`; descriptions use `desc_zh` / `desc_en`, and `visual_styles` groups use `group_zh` / `group_en`. The front-end falls back to legacy `label` / `desc` / `group`, so old catalogs still load, but new user-facing catalog text must be bilingual. English labels should mirror canonical reference names (`pyramid`, `swiss-minimal`, `Path A`, `mixed`, etc.); Chinese labels should be translated for users. Descriptions render inline after the option title, not as a separate selected-option line. `visual_styles` is `[{ "group", "group_zh", "group_en", "items": [...] }]`. For `canvas` you only need to maintain the bilingual labels in catalogs.json; the format set and dimensions are authoritative in `config.py CANVAS_FORMATS`.## Round-trip data contract