@yeaft/webchat-agent 0.1.451 → 0.1.452

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.451",
3
+ "version": "0.1.452",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -503,7 +503,9 @@ export async function handleUnifyLoadHistory(msg) {
503
503
  }
504
504
 
505
505
  /**
506
- * Reset Unify session (for clear messages).
506
+ * Reset Unify session (for clear messages or config change).
507
+ * After shutdown, immediately re-initializes the session and sends
508
+ * session_ready so the frontend picks up updated models/config.
507
509
  */
508
510
  export async function resetUnifySession() {
509
511
  if (currentAbort) {
@@ -517,4 +519,34 @@ export async function resetUnifySession() {
517
519
  unifyConversationId = null;
518
520
  currentMode = 'chat';
519
521
  conversationMessages = [];
522
+
523
+ // Re-initialize session immediately so frontend gets updated config
524
+ try {
525
+ const yeaftDir = ctx.CONFIG?.yeaftDir;
526
+ session = await loadSession({
527
+ ...(yeaftDir && { dir: yeaftDir }),
528
+ skipMCP: false,
529
+ skipSkills: false,
530
+ });
531
+
532
+ unifyConversationId = `unify-${Date.now()}`;
533
+
534
+ // Restore conversation history for LLM context
535
+ const recent = session.conversationStore.loadRecent(50);
536
+ conversationMessages = recent
537
+ .filter(m => m.role === 'user' || m.role === 'assistant')
538
+ .map(m => ({ role: m.role, content: m.content }));
539
+
540
+ sendUnifyEvent({
541
+ type: 'session_ready',
542
+ conversationId: unifyConversationId,
543
+ model: session.config.model,
544
+ availableModels: session.config.availableModels || [],
545
+ skills: session.status.skills,
546
+ mcpServers: session.status.mcpServers,
547
+ tools: session.status.tools,
548
+ });
549
+ } catch (err) {
550
+ console.error('[Unify] Failed to re-initialize session after reset:', err.message);
551
+ }
520
552
  }