agentgui 1.0.159 → 1.0.161

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/database.js CHANGED
@@ -349,6 +349,16 @@ export const queries = {
349
349
  return row?.isStreaming === 1;
350
350
  },
351
351
 
352
+ getStreamingConversations() {
353
+ const stmt = prep('SELECT id, title, claudeSessionId, agentType FROM conversations WHERE isStreaming = 1');
354
+ return stmt.all();
355
+ },
356
+
357
+ clearAllStreamingFlags() {
358
+ const stmt = prep('UPDATE conversations SET isStreaming = 0 WHERE isStreaming = 1');
359
+ return stmt.run().changes;
360
+ },
361
+
352
362
  markSessionIncomplete(sessionId, errorMsg) {
353
363
  const stmt = prep('UPDATE sessions SET status = ?, error = ?, completed_at = ? WHERE id = ?');
354
364
  stmt.run('incomplete', errorMsg || 'unknown', Date.now(), sessionId);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentgui",
3
- "version": "1.0.159",
3
+ "version": "1.0.161",
4
4
  "description": "Multi-agent ACP client with real-time communication",
5
5
  "type": "module",
6
6
  "main": "server.js",
package/server.js CHANGED
@@ -1199,75 +1199,30 @@ server.on('error', (err) => {
1199
1199
 
1200
1200
  function recoverStaleSessions() {
1201
1201
  try {
1202
- const staleSessions = queries.getActiveSessions ? queries.getActiveSessions() : [];
1203
1202
  const now = Date.now();
1204
- let resumedCount = 0;
1205
- let failedCount = 0;
1206
1203
 
1204
+ const staleSessions = queries.getActiveSessions ? queries.getActiveSessions() : [];
1207
1205
  for (const session of staleSessions) {
1208
1206
  if (activeExecutions.has(session.conversationId)) continue;
1209
-
1210
1207
  queries.updateSession(session.id, {
1211
1208
  status: 'error',
1212
- error: 'Server restarted - resuming',
1209
+ error: 'Server restarted',
1213
1210
  completed_at: now
1214
1211
  });
1215
-
1216
- const conv = queries.getConversation(session.conversationId);
1217
- if (!conv) {
1218
- queries.setIsStreaming(session.conversationId, false);
1219
- failedCount++;
1220
- continue;
1221
- }
1222
-
1223
- const lastMsg = queries.getLastUserMessage(session.conversationId);
1224
- if (!lastMsg || !conv.claudeSessionId) {
1225
- queries.setIsStreaming(session.conversationId, false);
1226
- debugLog(`[RECOVERY] Conv ${session.conversationId}: no user message or no claudeSessionId, cannot resume`);
1227
- broadcastSync({
1228
- type: 'streaming_error',
1229
- sessionId: session.id,
1230
- conversationId: session.conversationId,
1231
- error: 'Server restarted - could not resume (missing context)',
1232
- recoverable: false,
1233
- timestamp: now
1234
- });
1235
- failedCount++;
1236
- continue;
1237
- }
1238
-
1239
- const content = typeof lastMsg.content === 'string' ? lastMsg.content : JSON.stringify(lastMsg.content);
1240
- const agentId = conv.agentType || conv.agentId || 'claude-code';
1241
-
1242
- debugLog(`[RECOVERY] Resuming conv ${session.conversationId} with claudeSessionId=${conv.claudeSessionId}`);
1243
-
1244
- const newSession = queries.createSession(session.conversationId);
1245
- queries.createEvent('session.created', {
1246
- messageId: lastMsg.id,
1247
- sessionId: newSession.id,
1248
- retryReason: 'server_restart'
1249
- }, session.conversationId, newSession.id);
1250
-
1251
- broadcastSync({
1252
- type: 'streaming_start',
1253
- sessionId: newSession.id,
1254
- conversationId: session.conversationId,
1255
- messageId: lastMsg.id,
1256
- agentId,
1257
- timestamp: now
1258
- });
1259
-
1260
- processMessageWithStreaming(session.conversationId, lastMsg.id, newSession.id, content, agentId)
1261
- .catch(err => debugLog(`[RECOVERY] Resume error for ${session.conversationId}: ${err.message}`));
1262
-
1263
- resumedCount++;
1212
+ }
1213
+ if (staleSessions.length > 0) {
1214
+ console.log(`[RECOVERY] Marked ${staleSessions.length} stale session(s) as error`);
1264
1215
  }
1265
1216
 
1266
- if (resumedCount > 0) {
1267
- console.log(`[RECOVERY] Resumed ${resumedCount} conversation(s) from previous run`);
1217
+ const streamingConvs = queries.getStreamingConversations ? queries.getStreamingConversations() : [];
1218
+ let clearedCount = 0;
1219
+ for (const conv of streamingConvs) {
1220
+ if (activeExecutions.has(conv.id)) continue;
1221
+ queries.setIsStreaming(conv.id, false);
1222
+ clearedCount++;
1268
1223
  }
1269
- if (failedCount > 0) {
1270
- console.log(`[RECOVERY] Failed to resume ${failedCount} conversation(s)`);
1224
+ if (clearedCount > 0) {
1225
+ console.log(`[RECOVERY] Cleared isStreaming flag on ${clearedCount} stale conversation(s)`);
1271
1226
  }
1272
1227
  } catch (err) {
1273
1228
  console.error('[RECOVERY] Stale session recovery error:', err.message);
@@ -60,13 +60,13 @@ class AgentGUIClient {
60
60
  this.setupWebSocketListeners();
61
61
  this.setupRendererListeners();
62
62
 
63
+ // Setup UI elements (must happen before loading data so DOM refs exist)
64
+ this.setupUI();
65
+
63
66
  // Load initial data
64
67
  await this.loadAgents();
65
68
  await this.loadConversations();
66
69
 
67
- // Setup UI elements
68
- this.setupUI();
69
-
70
70
  // Enable controls for initial interaction
71
71
  this.enableControls();
72
72