Spaces:
Running

michdubai commited on
Commit
7deb684
·
verified ·
1 Parent(s): df1116b

Update frontend/js/main.js

Browse files
Files changed (1) hide show
  1. frontend/js/main.js +21 -5
frontend/js/main.js CHANGED
@@ -204,6 +204,13 @@ class GeminiApp {
204
  try {
205
  const config = this.uiController.getConfig();
206
 
 
 
 
 
 
 
 
207
  await this.webSocketClient.connect(config, {
208
  onMessage: this.handleWebSocketMessage.bind(this),
209
  onClose: this.handleWebSocketClose.bind(this),
@@ -261,6 +268,9 @@ class GeminiApp {
261
 
262
  this.webSocketClient.disconnect();
263
 
 
 
 
264
  try {
265
  if (typeof this.audioManager.stopCapture === 'function') {
266
  this.audioManager.stopCapture();
@@ -334,6 +344,13 @@ class GeminiApp {
334
  }
335
  break;
336
 
 
 
 
 
 
 
 
337
  case 'gemini_text':
338
  case 'text':
339
  const tokenValue = response.text !== undefined ? response.text : response.data;
@@ -431,12 +448,11 @@ class GeminiApp {
431
  appendGeminiToken(textToken) {
432
  if (!textToken) return;
433
 
434
- const checkToken = textToken.trim();
435
  if (
436
- checkToken.startsWith('**') ||
437
- checkToken.toLowerCase().includes('thought:') ||
438
- checkToken.includes('Analyzing') ||
439
- checkToken.includes('Clarifying')
440
  ) {
441
  return;
442
  }
 
204
  try {
205
  const config = this.uiController.getConfig();
206
 
207
+ // Resume previous session if a handle was stored
208
+ const savedHandle = localStorage.getItem('gemini_resumption_handle');
209
+ if (savedHandle) {
210
+ config.resumption_handle = savedHandle;
211
+ this.uiController.showInfo('Attempting to resume previous session...');
212
+ }
213
+
214
  await this.webSocketClient.connect(config, {
215
  onMessage: this.handleWebSocketMessage.bind(this),
216
  onClose: this.handleWebSocketClose.bind(this),
 
268
 
269
  this.webSocketClient.disconnect();
270
 
271
+ // Clear session token on explicit stop so next start is a fresh conversation
272
+ localStorage.removeItem('gemini_resumption_handle');
273
+
274
  try {
275
  if (typeof this.audioManager.stopCapture === 'function') {
276
  this.audioManager.stopCapture();
 
344
  }
345
  break;
346
 
347
+ case 'session_resumption':
348
+ if (response.new_handle) {
349
+ localStorage.setItem('gemini_resumption_handle', response.new_handle);
350
+ this.uiController.showInfo('Session resumption token stored.');
351
+ }
352
+ break;
353
+
354
  case 'gemini_text':
355
  case 'text':
356
  const tokenValue = response.text !== undefined ? response.text : response.data;
 
448
  appendGeminiToken(textToken) {
449
  if (!textToken) return;
450
 
451
+ const checkToken = textToken.trim().toLowerCase();
452
  if (
453
+ checkToken.includes('thought:') ||
454
+ checkToken.includes('analyzing') ||
455
+ checkToken.includes('clarifying')
 
456
  ) {
457
  return;
458
  }