feat: introduce frontend mode registry (no behaviour change)

window.INTERCEPT_MODES mirrors the existing modeCatalog, sidebar
toggles, visuals list, destroy map, and switchMode init branches.
Derivations follow in subsequent commits; a temporary console guard
verifies registry/catalog parity at runtime.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
James Smith
2026-06-11 21:16:40 +01:00
parent cdb5285b68
commit 8813d069bc
2 changed files with 312 additions and 0 deletions
+14
View File
@@ -3684,6 +3684,7 @@
<script src="{{ url_for('static', filename='js/core/voice-alerts.js') }}?v={{ version }}&r=voicefix2"></script>
<script src="{{ url_for('static', filename='js/core/keyboard-shortcuts.js') }}"></script>
<script src="{{ url_for('static', filename='js/core/cheat-sheets.js') }}"></script>
<script src="{{ url_for('static', filename='js/mode-registry.js') }}?v={{ version }}"></script>
<script>
// ============================================
@@ -3848,6 +3849,19 @@
const validModes = new Set(Object.keys(modeCatalog));
window.interceptModeCatalog = Object.assign({}, modeCatalog);
// TEMP migration guard (removed in Task 3.2): registry must mirror modeCatalog
(function checkRegistry() {
const a = Object.keys(window.INTERCEPT_MODES).sort().join(',');
const b = Object.keys(modeCatalog).sort().join(',');
if (a !== b) console.error('mode-registry drift:', a, 'vs', b);
for (const [m, def] of Object.entries(window.INTERCEPT_MODES)) {
const c = modeCatalog[m] || {};
for (const f of ['label', 'indicator', 'outputTitle', 'group']) {
if (def[f] !== c[f]) console.error(`mode-registry drift: ${m}.${f}`, def[f], 'vs', c[f]);
}
}
})();
function getModeFromQuery() {
const params = new URLSearchParams(window.location.search);
const requestedMode = params.get('mode');