@agent-link/server 0.1.167 → 0.1.169
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 +1 -1
- package/web/modules/connection.js +32 -2
- package/web/modules/team.js +10 -2
package/package.json
CHANGED
|
@@ -56,6 +56,7 @@ export function createConnection(deps) {
|
|
|
56
56
|
let reconnectAttempts = 0;
|
|
57
57
|
let reconnectTimer = null;
|
|
58
58
|
let pingTimer = null;
|
|
59
|
+
let idleCheckTimer = null;
|
|
59
60
|
const toolMsgMap = new Map(); // toolId -> message (for fast tool_result lookup)
|
|
60
61
|
|
|
61
62
|
// ── toolMsgMap save/restore for conversation switching ──
|
|
@@ -90,6 +91,22 @@ export function createConnection(deps) {
|
|
|
90
91
|
latency.value = null;
|
|
91
92
|
}
|
|
92
93
|
|
|
94
|
+
// Idle-check: if isProcessing stays true with no claude_output for 15s,
|
|
95
|
+
// poll the agent to reconcile stale state (guards against lost turn_completed).
|
|
96
|
+
const IDLE_CHECK_MS = 15000;
|
|
97
|
+
function resetIdleCheck() {
|
|
98
|
+
if (idleCheckTimer) { clearTimeout(idleCheckTimer); idleCheckTimer = null; }
|
|
99
|
+
if (isProcessing.value) {
|
|
100
|
+
idleCheckTimer = setTimeout(() => {
|
|
101
|
+
idleCheckTimer = null;
|
|
102
|
+
if (isProcessing.value) wsSend({ type: 'query_active_conversations' });
|
|
103
|
+
}, IDLE_CHECK_MS);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function clearIdleCheck() {
|
|
107
|
+
if (idleCheckTimer) { clearTimeout(idleCheckTimer); idleCheckTimer = null; }
|
|
108
|
+
}
|
|
109
|
+
|
|
93
110
|
function getSessionId() {
|
|
94
111
|
const match = window.location.pathname.match(/^\/s\/([^/]+)/);
|
|
95
112
|
return match ? match[1] : null;
|
|
@@ -118,6 +135,7 @@ export function createConnection(deps) {
|
|
|
118
135
|
// (e.g. after reconnect before active_conversations response), self-correct
|
|
119
136
|
if (!isProcessing.value) {
|
|
120
137
|
isProcessing.value = true;
|
|
138
|
+
resetIdleCheck();
|
|
121
139
|
if (currentConversationId && currentConversationId.value) {
|
|
122
140
|
processingConversations.value[currentConversationId.value] = true;
|
|
123
141
|
}
|
|
@@ -385,8 +403,9 @@ export function createConnection(deps) {
|
|
|
385
403
|
|
|
386
404
|
// Restore active team state on reconnect
|
|
387
405
|
if (team && msg.activeTeam) {
|
|
388
|
-
team.handleActiveTeamRestore(msg.activeTeam);
|
|
406
|
+
team.handleActiveTeamRestore(msg.activeTeam, workDir.value);
|
|
389
407
|
}
|
|
408
|
+
resetIdleCheck();
|
|
390
409
|
} else if (msg.type === 'error') {
|
|
391
410
|
streaming.flushReveal();
|
|
392
411
|
finalizeStreamingMsg(scheduleHighlight);
|
|
@@ -399,6 +418,7 @@ export function createConnection(deps) {
|
|
|
399
418
|
isProcessing.value = false;
|
|
400
419
|
isCompacting.value = false;
|
|
401
420
|
loadingSessions.value = false;
|
|
421
|
+
clearIdleCheck();
|
|
402
422
|
if (currentConversationId && currentConversationId.value) {
|
|
403
423
|
processingConversations.value[currentConversationId.value] = false;
|
|
404
424
|
}
|
|
@@ -409,6 +429,7 @@ export function createConnection(deps) {
|
|
|
409
429
|
_dequeueNext();
|
|
410
430
|
} else if (msg.type === 'claude_output') {
|
|
411
431
|
handleClaudeOutput(msg, scheduleHighlight);
|
|
432
|
+
resetIdleCheck();
|
|
412
433
|
} else if (msg.type === 'session_started') {
|
|
413
434
|
// Claude session ID captured — update and refresh sidebar
|
|
414
435
|
currentClaudeSessionId.value = msg.claudeSessionId;
|
|
@@ -446,6 +467,7 @@ export function createConnection(deps) {
|
|
|
446
467
|
finalizeStreamingMsg(scheduleHighlight);
|
|
447
468
|
isProcessing.value = false;
|
|
448
469
|
isCompacting.value = false;
|
|
470
|
+
clearIdleCheck();
|
|
449
471
|
toolMsgMap.clear();
|
|
450
472
|
if (msg.usage) usageStats.value = msg.usage;
|
|
451
473
|
if (currentConversationId && currentConversationId.value) {
|
|
@@ -592,7 +614,14 @@ export function createConnection(deps) {
|
|
|
592
614
|
});
|
|
593
615
|
// Clear old history immediately so UI doesn't show stale data
|
|
594
616
|
historySessions.value = [];
|
|
595
|
-
if (team)
|
|
617
|
+
if (team) {
|
|
618
|
+
team.teamsList.value = [];
|
|
619
|
+
team.teamState.value = null;
|
|
620
|
+
team.historicalTeam.value = null;
|
|
621
|
+
if (team.viewMode.value === 'team') {
|
|
622
|
+
team.viewMode.value = 'chat';
|
|
623
|
+
}
|
|
624
|
+
}
|
|
596
625
|
if (loop) loop.loopsList.value = [];
|
|
597
626
|
memoryFiles.value = [];
|
|
598
627
|
memoryDir.value = null;
|
|
@@ -607,6 +636,7 @@ export function createConnection(deps) {
|
|
|
607
636
|
ws.onclose = () => {
|
|
608
637
|
sessionKey = null;
|
|
609
638
|
stopPing();
|
|
639
|
+
clearIdleCheck();
|
|
610
640
|
const wasConnected = status.value === 'Connected' || status.value === 'Connecting...';
|
|
611
641
|
isProcessing.value = false;
|
|
612
642
|
isCompacting.value = false;
|
package/web/modules/team.js
CHANGED
|
@@ -352,10 +352,18 @@ export function createTeam(deps) {
|
|
|
352
352
|
* Handle active_conversations response that includes activeTeam.
|
|
353
353
|
* Called on initial connect + reconnect to restore team state.
|
|
354
354
|
*/
|
|
355
|
-
function handleActiveTeamRestore(activeTeam) {
|
|
355
|
+
function handleActiveTeamRestore(activeTeam, currentWorkDir) {
|
|
356
356
|
if (!activeTeam) return;
|
|
357
|
+
// Skip if the active team belongs to a different workdir
|
|
358
|
+
if (currentWorkDir && activeTeam.workDir && activeTeam.workDir !== currentWorkDir) return;
|
|
359
|
+
|
|
360
|
+
const wasAlreadyLoaded = teamState.value !== null;
|
|
357
361
|
teamState.value = activeTeam;
|
|
358
|
-
|
|
362
|
+
// Only switch to team view on first restore (initial connect / reconnect),
|
|
363
|
+
// not on idle-check polls — otherwise the user gets yanked out of chat.
|
|
364
|
+
if (!wasAlreadyLoaded) {
|
|
365
|
+
viewMode.value = 'team';
|
|
366
|
+
}
|
|
359
367
|
// Re-initialize agent message lists (messages lost on reconnect)
|
|
360
368
|
if (!agentMessages.value['lead']) {
|
|
361
369
|
agentMessages.value['lead'] = [];
|