Tutorial: Race-Condition bei Neustart behoben

- start(forceRestart) awaited jetzt API.resetTutorialState()
- _startInternal awaited API.saveTutorialState(step 0)
- stop() ueberspringt State-Save wenn _isRestarting flag gesetzt
- start() kann jetzt auch bei laufendem Tutorial Restart ausfuehren
Dieser Commit ist enthalten in:
Claude Dev
2026-03-23 22:17:15 +01:00
Ursprung 383fe1ca8c
Commit 485a527bf6

Datei anzeigen

@@ -1217,6 +1217,11 @@ const Tutorial = {
// Lifecycle // Lifecycle
// ----------------------------------------------------------------------- // -----------------------------------------------------------------------
async start(forceRestart) { async start(forceRestart) {
// Bei Restart: laufendes Tutorial erst sauber beenden
if (this._isActive && forceRestart) {
this._isRestarting = true;
this.stop();
}
if (this._isActive) return; if (this._isActive) return;
// Chat schliessen falls offen // Chat schliessen falls offen
@@ -1233,7 +1238,7 @@ const Tutorial = {
} }
if (forceRestart) { if (forceRestart) {
try { API.resetTutorialState(); } catch(e) {} try { await API.resetTutorialState(); } catch(e) {}
} }
this._startInternal(forceRestart ? 0 : null); this._startInternal(forceRestart ? 0 : null);
}, },
@@ -1260,15 +1265,16 @@ const Tutorial = {
}); });
}, },
_startInternal(resumeStep) { async _startInternal(resumeStep) {
this._isActive = true; this._isActive = true;
this._highestStep = -1; this._highestStep = -1;
this._currentStep = -1; this._currentStep = -1;
// Server-State auf Anfang setzen wenn Neustart // Server-State auf Anfang setzen wenn Neustart
if (!resumeStep || resumeStep === 0) { if (!resumeStep || resumeStep === 0) {
API.saveTutorialState({ current_step: 0, completed: false }).catch(function() {}); try { await API.saveTutorialState({ current_step: 0, completed: false }); } catch(e) {}
} }
this._isRestarting = false;
// Overlay einblenden + Klicks blockieren // Overlay einblenden + Klicks blockieren
this._els.overlay.classList.add('active'); this._els.overlay.classList.add('active');
@@ -1344,8 +1350,10 @@ const Tutorial = {
this._resizeHandler = null; this._resizeHandler = null;
} }
// Fortschritt serverseitig speichern // Fortschritt serverseitig speichern (nicht bei Restart)
if (this._lastExitedStep >= 0 && this._lastExitedStep < this._steps.length - 1) { if (this._isRestarting) {
// Restart - State wird von start() zurueckgesetzt
} else if (this._lastExitedStep >= 0 && this._lastExitedStep < this._steps.length - 1) {
// Mittendrin abgebrochen — Schritt speichern // Mittendrin abgebrochen — Schritt speichern
API.saveTutorialState({ current_step: this._lastExitedStep }).catch(function() {}); API.saveTutorialState({ current_step: this._lastExitedStep }).catch(function() {});
} else { } else {