Add Ink session recovery and Coolify Docker support
This commit is contained in:
@@ -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]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user