Add Ink session recovery and Coolify Docker support

This commit is contained in:
2026-05-19 13:14:46 +02:00
parent dbcb8f4284
commit ebc8e1c7df
14 changed files with 290 additions and 20 deletions
+16 -2
View File
@@ -19,8 +19,9 @@ class SocketClientModule extends BaseModule {
this.storyHistory = null;
this.isConnected = false;
this.reconnectAttempts = 0;
this.maxReconnectAttempts = 5;
this.maxReconnectAttempts = Infinity;
this.reconnectDelay = 2000;
this.maxReconnectDelay = 30000;
this.url = null;
this.eventListeners = {};
this.defaultHost = 'localhost:3000';
@@ -41,6 +42,8 @@ class SocketClientModule extends BaseModule {
'newGame',
'loadGame',
'saveGame',
'resumeGame',
'exportGameState',
'chooseChoice',
'hasSaveGame',
'getSaveGames',
@@ -279,6 +282,9 @@ class SocketClientModule extends BaseModule {
const inputMode = data.inputMode || (choices.length > 0 ? 'choice' : 'none');
this.dispatchChoices(choices);
this.dispatchInputMode(inputMode);
document.dispatchEvent(new CustomEvent('story:turn-complete', {
detail: { turnId, turn: data, choices, inputMode }
}));
if (turnBlocks.length === 0 && choices.length > 0) {
document.dispatchEvent(new CustomEvent('story:process-state', {
detail: { state: 'ready', reason: 'choice-only-turn', turnId }
@@ -658,7 +664,7 @@ class SocketClientModule extends BaseModule {
}
this.reconnectAttempts++;
const delay = this.reconnectDelay * this.reconnectAttempts;
const delay = Math.min(this.maxReconnectDelay, this.reconnectDelay * this.reconnectAttempts);
console.log(`Socket Client: Attempting to reconnect in ${delay}ms (attempt ${this.reconnectAttempts})`);
@@ -808,6 +814,14 @@ class SocketClientModule extends BaseModule {
return this.callGameApi('saveGame', [slot]);
}
resumeGame(savedState) {
return this.callGameApi('resumeGame', [savedState]);
}
exportGameState() {
return this.callGameApi('exportGameState', []);
}
chooseChoice(choiceIndex) {
return this.callGameApi('chooseChoice', [choiceIndex]);
}