Skip to content

Commit 58ff9a4

Browse files
committed
Improve system detection diagnostics and error messaging
Add detailed console logging in _detectSystem() showing each system returned by the API with its foundry_system_id and enabled status. Log specific failure reasons: system found but disabled, no matching foundry_system_id, or no systems installed at all. Update Characters tab and Status tab to show actionable troubleshooting steps instead of generic "no match" messages. https://claude.ai/code/session_01J3F55nRmeFHTtK4BnYgGGk
1 parent ffc66d3 commit 58ff9a4

2 files changed

Lines changed: 27 additions & 7 deletions

File tree

scripts/sync-manager.mjs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,6 +219,13 @@ export class SyncManager {
219219
const result = await this.api.get('/systems');
220220
const systems = result.data || [];
221221

222+
// Log API response for debugging system matching issues.
223+
console.debug(`Chronicle: /systems API returned ${systems.length} system(s)`);
224+
for (const s of systems) {
225+
console.debug(` - ${s.id} (foundry_id: ${s.foundry_system_id ?? 'MISSING'}, enabled: ${s.enabled})`);
226+
}
227+
console.debug(`Chronicle: Looking for foundry_system_id: "${this._foundrySystemId}"`);
228+
222229
// Match by foundry_system_id returned from the API.
223230
const match = systems.find(
224231
(s) => s.foundry_system_id === this._foundrySystemId && s.enabled
@@ -231,7 +238,19 @@ export class SyncManager {
231238
console.debug(`Chronicle: System matched — Foundry "${this._foundrySystemId}" → Chronicle "${match.id}"`);
232239
} else {
233240
await setSetting('detectedSystem', '');
234-
console.debug(`Chronicle: No Chronicle system matches Foundry system "${this._foundrySystemId}"`);
241+
// Provide diagnostic info about why matching failed.
242+
const byFoundryId = systems.find(s => s.foundry_system_id === this._foundrySystemId);
243+
if (byFoundryId && !byFoundryId.enabled) {
244+
console.warn(`Chronicle: System "${byFoundryId.id}" matches Foundry system "${this._foundrySystemId}" but is not enabled for this campaign`);
245+
this.logActivity('warning', `System "${byFoundryId.name}" found but not enabled for this campaign`);
246+
} else if (systems.length > 0) {
247+
const ids = systems.map(s => s.foundry_system_id || '(none)').join(', ');
248+
console.warn(`Chronicle: No system has foundry_system_id="${this._foundrySystemId}". Available: ${ids}`);
249+
this.logActivity('warning', `No Chronicle system matches Foundry system "${this._foundrySystemId}"`);
250+
} else {
251+
console.warn('Chronicle: No game systems installed in Chronicle');
252+
this.logActivity('warning', 'No game systems installed in Chronicle');
253+
}
235254
}
236255
} catch (err) {
237256
console.warn('Chronicle: Failed to detect system match', err);

templates/sync-dashboard.hbs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -585,11 +585,12 @@
585585
{{else}}
586586
<div class="dashboard-empty-tab">
587587
<i class="fa-solid fa-puzzle-piece fa-2x"></i>
588-
<p>Character sync requires a matching game system.</p>
589-
<p class="hint">
590-
Chronicle doesn't have a system pack for <strong>{{#if foundrySystem}}{{foundrySystem}}{{else}}this system{{/if}}</strong> yet.
591-
Use the <em>Copy System Debug</em> button on the Status tab to generate a snapshot you can paste into Claude AI to help build one.
592-
</p>
588+
<p>No Chronicle system matches your Foundry game system{{#if foundrySystem}} (<code>{{foundrySystem}}</code>){{/if}}.</p>
589+
<ul class="hint" style="text-align: left; margin-top: 0.5rem;">
590+
<li>Is the game system package installed in Chronicle? (Admin &rarr; Packages)</li>
591+
<li>Is it enabled for this campaign? (Campaign Settings &rarr; Game System)</li>
592+
<li>Check the browser console for detailed diagnostics.</li>
593+
</ul>
593594
</div>
594595
{{/if}}
595596
</div>
@@ -740,7 +741,7 @@
740741
</span>
741742
{{else}}
742743
<span class="system-value system-no-match">
743-
<i class="fa-solid fa-circle-xmark" style="color: #f87171"></i> No Match
744+
<i class="fa-solid fa-circle-xmark" style="color: #f87171"></i> No match &mdash; check Packages &amp; Campaign Settings
744745
</span>
745746
{{/if}}
746747
</div>

0 commit comments

Comments
 (0)