@yeaft/webchat-agent 0.1.986 → 0.1.988

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.
@@ -548,9 +548,9 @@ export async function handleMessage(msg) {
548
548
 
549
549
  case 'yeaft_abort_all':
550
550
  case 'unify_abort_all':
551
- // task-325c: user-initiated abort of ALL in-flight queries across
552
- // every thread. Always emits `yeaft_aborted` ack.
553
- handleYeaftAbortAll();
551
+ // task-325c: user-initiated abort. With sessionId present this is scoped
552
+ // to that Yeaft Session; older clients omit it and keep abort-all.
553
+ handleYeaftAbortAll(msg);
554
554
  break;
555
555
 
556
556
  case 'yeaft_abort_turn':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.986",
3
+ "version": "0.1.988",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -3416,16 +3416,20 @@ function emitQueuedTurnAbort(meta, turnId) {
3416
3416
  } catch { /* never crash WS pipeline */ }
3417
3417
  }
3418
3418
 
3419
- function abortAllVpRuntime(aborted) {
3419
+ function abortAllVpRuntime(aborted, sessionId = null) {
3420
3420
  for (const [key, ctrl] of vpAborts) {
3421
+ if (sessionId && !key.startsWith(`${sessionId}::`)) continue;
3421
3422
  try {
3422
3423
  if (!ctrl.signal.aborted) { ctrl.abort(); aborted.push(`vp:${key}`); }
3423
3424
  } catch { /* best-effort */ }
3425
+ vpAborts.delete(key);
3424
3426
  }
3425
- vpAborts.clear();
3426
- for (const inbox of vpInboxes.values()) {
3427
+ for (const [key, inbox] of vpInboxes) {
3428
+ if (sessionId && !key.startsWith(`${sessionId}::`)) continue;
3427
3429
  if (Array.isArray(inbox)) inbox.length = 0;
3430
+ if (sessionId) vpInboxes.delete(key);
3428
3431
  }
3432
+ if (!sessionId) vpInboxes.clear();
3429
3433
  }
3430
3434
 
3431
3435
  /**
@@ -3482,22 +3486,32 @@ export function handleYeaftAbortThread(_msg = {}) {
3482
3486
 
3483
3487
  /**
3484
3488
  * Abort all in-flight Yeaft runtime work.
3489
+ * With sessionId set, abort only work owned by that Yeaft Session.
3490
+ *
3491
+ * @param {{ sessionId?: string }} msg
3485
3492
  * @returns {{ aborted: string[], all: boolean }}
3486
3493
  */
3487
- export function handleYeaftAbortAll() {
3494
+ export function handleYeaftAbortAll(msg = {}) {
3495
+ const sessionId = typeof msg.sessionId === 'string' && msg.sessionId ? msg.sessionId : null;
3488
3496
  const aborted = [];
3489
- if (currentAbortCtrl && !currentAbortCtrl.signal.aborted) {
3497
+ if (!sessionId && currentAbortCtrl && !currentAbortCtrl.signal.aborted) {
3490
3498
  try { currentAbortCtrl.abort(); aborted.push('main'); } catch { /* best-effort */ }
3491
3499
  }
3492
- currentAbortCtrl = null;
3500
+ if (!sessionId) currentAbortCtrl = null;
3493
3501
  // Also abort all per-VP turn controllers.
3494
3502
  for (const [turnId, ctrl] of turnAbortCtrls) {
3503
+ const meta = turnAbortMeta.get(turnId);
3504
+ if (sessionId && meta?.sessionId !== sessionId) continue;
3495
3505
  try { if (!ctrl.signal.aborted) { ctrl.abort(); aborted.push(turnId); } } catch { /* best-effort */ }
3506
+ turnAbortCtrls.delete(turnId);
3507
+ turnAbortMeta.delete(turnId);
3496
3508
  }
3497
- turnAbortCtrls.clear();
3498
- turnAbortMeta.clear();
3499
- abortAllVpRuntime(aborted);
3500
- sendSessionEvent({ type: 'yeaft_aborted', aborted, all: true });
3509
+ if (!sessionId) {
3510
+ turnAbortCtrls.clear();
3511
+ turnAbortMeta.clear();
3512
+ }
3513
+ abortAllVpRuntime(aborted, sessionId);
3514
+ sendSessionEvent({ type: 'yeaft_aborted', aborted, all: true, sessionId }, sessionId ? { sessionId } : undefined);
3501
3515
  return { aborted, all: true };
3502
3516
  }
3503
3517
 
@@ -3526,7 +3540,7 @@ export function handleYeaftAbortTurn(msg = {}) {
3526
3540
 
3527
3541
  turnAbortCtrls.delete(turnId);
3528
3542
  turnAbortMeta.delete(turnId);
3529
- sendSessionEvent({ type: 'yeaft_turn_aborted', turnId, success });
3543
+ sendSessionEvent({ type: 'yeaft_turn_aborted', turnId, success, sessionId: meta?.sessionId || null }, meta?.sessionId ? { sessionId: meta.sessionId } : undefined);
3530
3544
  }
3531
3545
 
3532
3546
  /**