@aipanel/dsh-client 1.2.10 → 1.2.12

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.
Files changed (2) hide show
  1. package/lib/client.js +34 -5
  2. package/package.json +9 -9
package/lib/client.js CHANGED
@@ -61,6 +61,12 @@ var WIDGET_MSG = {
61
61
  MINIMIZE_STATE: "MINIMIZE_STATE_CHANGE",
62
62
  PROMPT_DOCK_VISIBILITY: "PROMPT_DOCK_VISIBILITY_CHANGE",
63
63
  REVIEW_PANEL_TOGGLE: "REVIEW_PANEL_TOGGLE",
64
+ /** 宿主 → iframe:告知侧栏归属期望(mode: "host" | "provider"),Provider 据此决定是否展示自家侧栏 */
65
+ SIDEBAR_MODE: "AIPANEL_SIDEBAR_MODE",
66
+ /** 宿主 → iframe:host 折叠开关驱动 Provider 收起/展开自家侧栏({ collapsed }) */
67
+ SIDEBAR_COLLAPSE: "AIPANEL_SIDEBAR_COLLAPSE",
68
+ /** iframe → 宿主(可选):Provider 内部折叠变化回传({ collapsed }),供宿主同步左上角开关状态 */
69
+ SIDEBAR_STATE: "AIPANEL_SIDEBAR_STATE",
64
70
  /** 无 deepLink 能力的 Provider:通知 iframe 聚焦指定会话 */
65
71
  FOCUS_SESSION: "AIPANEL_FOCUS_SESSION",
66
72
  /** 无 deepLink 能力的 Provider:iframe 确认目标会话已激活且渲染稳定(携带 sessionId) */
@@ -364,6 +370,7 @@ var MSG = WIDGET_MSG;
364
370
  var inject = ["slots", "sessions", "inputTriggers", "conversation"];
365
371
  var SESSION_SETTLE_MS = 400;
366
372
  var FOCUS_OPEN_MAX_ATTEMPTS = 3;
373
+ var FOCUS_INFLIGHT_TIMEOUT_MS = 1e4;
367
374
  function elementContextRef(e) {
368
375
  return JSON.stringify(e);
369
376
  }
@@ -412,6 +419,7 @@ function apply(ctx, config = {}) {
412
419
  let lastCurrent;
413
420
  let settleTimer = null;
414
421
  let targetSessionId;
422
+ let focusDeadline = 0;
415
423
  let pendingFocusId;
416
424
  let focusAttempts = 0;
417
425
  let refreshing = false;
@@ -431,6 +439,10 @@ function apply(ctx, config = {}) {
431
439
  if (!id) return;
432
440
  const snap = sessions.list.getSnapshot();
433
441
  if (!hasBaseline(snap)) return;
442
+ if (Date.now() >= focusDeadline) {
443
+ clearFocusTarget();
444
+ return;
445
+ }
434
446
  pendingFocusId = void 0;
435
447
  focusAttempts = 0;
436
448
  void tryOpenTarget(id);
@@ -439,7 +451,10 @@ function apply(ctx, config = {}) {
439
451
  if (focusAttempts >= FOCUS_OPEN_MAX_ATTEMPTS) return;
440
452
  focusAttempts += 1;
441
453
  const snap = sessions.list.getSnapshot();
442
- if (snap.current === id) return;
454
+ if (snap.current === id) {
455
+ clearFocusTarget();
456
+ return;
457
+ }
443
458
  if (!listContains(snap, id) && !refreshing) {
444
459
  refreshing = true;
445
460
  try {
@@ -459,8 +474,16 @@ function apply(ctx, config = {}) {
459
474
  } catch {
460
475
  }
461
476
  };
462
- const handleFocus = (sessionId) => {
477
+ const clearFocusTarget = () => {
478
+ targetSessionId = void 0;
479
+ focusDeadline = 0;
480
+ pendingFocusId = void 0;
481
+ };
482
+ const handleFocus = (sessionId, source2 = "host") => {
463
483
  targetSessionId = sessionId;
484
+ if (source2 === "host") {
485
+ focusDeadline = Date.now() + FOCUS_INFLIGHT_TIMEOUT_MS;
486
+ }
464
487
  const snap = sessions.list.getSnapshot();
465
488
  if (!hasBaseline(snap)) {
466
489
  pendingFocusId = sessionId;
@@ -487,8 +510,14 @@ function apply(ctx, config = {}) {
487
510
  settleTimer = null;
488
511
  if (sessions.list?.getSnapshot?.()?.current === current) {
489
512
  notifyReady(current);
490
- if (targetSessionId && targetSessionId !== current) {
491
- handleFocus(targetSessionId);
513
+ if (targetSessionId) {
514
+ if (current === targetSessionId) {
515
+ clearFocusTarget();
516
+ } else if (Date.now() < focusDeadline) {
517
+ handleFocus(targetSessionId, "refocus");
518
+ } else {
519
+ clearFocusTarget();
520
+ }
492
521
  }
493
522
  }
494
523
  }, SESSION_SETTLE_MS);
@@ -604,7 +633,7 @@ function apply(ctx, config = {}) {
604
633
  if (data.type === MSG.SET_THEME && typeof data.theme === "string") {
605
634
  applyThemeFromHost(data.theme);
606
635
  } else if (data.type === MSG.FOCUS_SESSION && typeof data.sessionId === "string") {
607
- handleFocus(data.sessionId);
636
+ handleFocus(data.sessionId, "host");
608
637
  } else if (data.type === MSG.INSERT_FILE_PART && data.element) {
609
638
  insertElement(data.element);
610
639
  } else if (data.type === MSG.SELECT_MODE_CHANGE) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aipanel/dsh-client",
3
- "version": "1.2.10",
3
+ "version": "1.2.12",
4
4
  "type": "module",
5
5
  "description": "AIPanel 浏览器侧插件(dsh web Web Client):注册 @aipanel 文件引用 source,选中元素以 file chip 高亮插入并可供模型解析。",
6
6
  "publishConfig": {
@@ -12,17 +12,17 @@
12
12
  ],
13
13
  "devDependencies": {
14
14
  "@deepseek-ai/cordis": "^4.0.2",
15
- "@deepseek-ai/dsh-api-session-controller": "^0.1.2-rc.1",
16
- "@deepseek-ai/dsh-client-ui-conversation": "^0.1.2-rc.1",
17
- "@deepseek-ai/dsh-client-ui-input-trigger": "^0.1.2-rc.1",
18
- "@deepseek-ai/dsh-client-ui-primitives": "^0.1.2-rc.1",
19
- "@deepseek-ai/dsh-client-ui-theme": "^0.1.2-rc.1",
20
- "@deepseek-ai/dsh-client-ui-tool": "^0.1.2-rc.1",
21
- "@deepseek-ai/dsh-session": "^0.1.2-rc.1",
15
+ "@deepseek-ai/dsh-api-session-controller": "^0.1.3-alpha.2",
16
+ "@deepseek-ai/dsh-client-ui-conversation": "^0.1.3-alpha.2",
17
+ "@deepseek-ai/dsh-client-ui-input-trigger": "^0.1.3-alpha.2",
18
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.1.3-alpha.2",
19
+ "@deepseek-ai/dsh-client-ui-theme": "^0.1.3-alpha.2",
20
+ "@deepseek-ai/dsh-client-ui-tool": "^0.1.3-alpha.2",
21
+ "@deepseek-ai/dsh-session": "^0.1.3-alpha.2",
22
22
  "@types/react": "^18.3.0",
23
23
  "esbuild": "^0.25.0",
24
24
  "react": "^18.3.0",
25
- "@aipanel/core": "1.2.10"
25
+ "@aipanel/core": "1.2.12"
26
26
  },
27
27
  "exports": {
28
28
  ".": "./lib/index.js",