@aipanel/dsh-client 1.2.22 → 1.2.23
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/lib/client.js +18 -9
- package/package.json +15 -11
package/lib/client.js
CHANGED
|
@@ -367,7 +367,7 @@ function registerDiagnosticsView(ctx, enabled = true) {
|
|
|
367
367
|
|
|
368
368
|
// dsh-client/src/client/index.ts
|
|
369
369
|
var MSG = WIDGET_MSG;
|
|
370
|
-
var inject = ["slots", "sessions", "inputTriggers", "conversation"];
|
|
370
|
+
var inject = ["slots", "sessions", "inputTriggers", "conversation", "uiWorkspace"];
|
|
371
371
|
var SESSION_SETTLE_MS = 400;
|
|
372
372
|
var FOCUS_OPEN_MAX_ATTEMPTS = 3;
|
|
373
373
|
var FOCUS_INFLIGHT_TIMEOUT_MS = 1e4;
|
|
@@ -415,6 +415,7 @@ function mapAipanelTheme(t) {
|
|
|
415
415
|
function apply(ctx, config = {}) {
|
|
416
416
|
registerDiagnosticsView(ctx, config.enableDiagnostics !== false);
|
|
417
417
|
const sessions = ctx.get("sessions");
|
|
418
|
+
const uiWorkspace = ctx.get("uiWorkspace");
|
|
418
419
|
if (sessions) {
|
|
419
420
|
let lastCurrent;
|
|
420
421
|
let settleTimer = null;
|
|
@@ -426,10 +427,18 @@ function apply(ctx, config = {}) {
|
|
|
426
427
|
const notifyReady = (sessionId) => {
|
|
427
428
|
postToHost(MSG.SESSION_READY, { sessionId });
|
|
428
429
|
};
|
|
429
|
-
const
|
|
430
|
-
|
|
431
|
-
|
|
430
|
+
const isMainView = (snap, id) => (snap?.byId?.[id]?.retainedBy?.mainView ?? 0) > 0;
|
|
431
|
+
const findMainView = (snap) => {
|
|
432
|
+
if (!snap) return void 0;
|
|
433
|
+
for (const id of snap.ids ?? []) {
|
|
434
|
+
if (isMainView(snap, id)) return id;
|
|
435
|
+
}
|
|
436
|
+
for (const row of Object.values(snap.byId ?? {})) {
|
|
437
|
+
if ((row?.retainedBy?.mainView ?? 0) > 0) return row.id;
|
|
438
|
+
}
|
|
439
|
+
return void 0;
|
|
432
440
|
};
|
|
441
|
+
const hasBaseline = (snap) => snap?.phase === "ready";
|
|
433
442
|
const listContains = (snap, id) => {
|
|
434
443
|
if (!snap) return false;
|
|
435
444
|
return !!snap.byId?.[id] || snap.ids?.includes(id) === true;
|
|
@@ -451,7 +460,7 @@ function apply(ctx, config = {}) {
|
|
|
451
460
|
if (focusAttempts >= FOCUS_OPEN_MAX_ATTEMPTS) return;
|
|
452
461
|
focusAttempts += 1;
|
|
453
462
|
const snap = sessions.list.getSnapshot();
|
|
454
|
-
if (snap
|
|
463
|
+
if (isMainView(snap, id)) {
|
|
455
464
|
clearFocusTarget();
|
|
456
465
|
return;
|
|
457
466
|
}
|
|
@@ -470,7 +479,7 @@ function apply(ctx, config = {}) {
|
|
|
470
479
|
}
|
|
471
480
|
}
|
|
472
481
|
try {
|
|
473
|
-
|
|
482
|
+
uiWorkspace?.openSession(id);
|
|
474
483
|
} catch {
|
|
475
484
|
}
|
|
476
485
|
};
|
|
@@ -494,7 +503,7 @@ function apply(ctx, config = {}) {
|
|
|
494
503
|
};
|
|
495
504
|
const probe = () => {
|
|
496
505
|
const snapshot = sessions.list?.getSnapshot?.();
|
|
497
|
-
const current = snapshot
|
|
506
|
+
const current = findMainView(snapshot);
|
|
498
507
|
if (!current) {
|
|
499
508
|
lastCurrent = void 0;
|
|
500
509
|
if (settleTimer) {
|
|
@@ -508,7 +517,7 @@ function apply(ctx, config = {}) {
|
|
|
508
517
|
if (settleTimer) clearTimeout(settleTimer);
|
|
509
518
|
settleTimer = setTimeout(() => {
|
|
510
519
|
settleTimer = null;
|
|
511
|
-
if (sessions.list?.getSnapshot?.()
|
|
520
|
+
if (findMainView(sessions.list?.getSnapshot?.()) === current) {
|
|
512
521
|
notifyReady(current);
|
|
513
522
|
if (targetSessionId) {
|
|
514
523
|
if (current === targetSessionId) {
|
|
@@ -600,7 +609,7 @@ function apply(ctx, config = {}) {
|
|
|
600
609
|
const INSERT_RETRY_DELAY_MS = 80;
|
|
601
610
|
const insertElement = (element) => {
|
|
602
611
|
if (!element) return;
|
|
603
|
-
const current = sessions.list.getSnapshot()
|
|
612
|
+
const current = findMainView(sessions.list.getSnapshot());
|
|
604
613
|
if (!current) return;
|
|
605
614
|
let inputFor;
|
|
606
615
|
try {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aipanel/dsh-client",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.23",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "AIPanel 浏览器侧插件(dsh web Web Client):注册 @aipanel 文件引用 source,选中元素以 file chip 高亮插入并可供模型解析。",
|
|
6
6
|
"publishConfig": {
|
|
@@ -11,18 +11,21 @@
|
|
|
11
11
|
"lib"
|
|
12
12
|
],
|
|
13
13
|
"devDependencies": {
|
|
14
|
+
"@aipanel/core": "1.2.23",
|
|
14
15
|
"@deepseek-ai/cordis": "^4.0.2",
|
|
15
|
-
"@deepseek-ai/dsh-api-session-controller": "^0.1.
|
|
16
|
-
"@deepseek-ai/dsh-client-
|
|
17
|
-
"@deepseek-ai/dsh-client-ui-
|
|
18
|
-
"@deepseek-ai/dsh-client-ui-
|
|
19
|
-
"@deepseek-ai/dsh-client-ui-
|
|
20
|
-
"@deepseek-ai/dsh-client-ui-
|
|
21
|
-
"@deepseek-ai/dsh-
|
|
16
|
+
"@deepseek-ai/dsh-api-session-controller": "^0.1.6-alpha.2",
|
|
17
|
+
"@deepseek-ai/dsh-client-store": "^0.1.6-alpha.2",
|
|
18
|
+
"@deepseek-ai/dsh-client-ui-conversation": "^0.1.6-alpha.2",
|
|
19
|
+
"@deepseek-ai/dsh-client-ui-input-trigger": "^0.1.6-alpha.2",
|
|
20
|
+
"@deepseek-ai/dsh-client-ui-primitives": "^0.1.6-alpha.2",
|
|
21
|
+
"@deepseek-ai/dsh-client-ui-session": "^0.1.6-alpha.2",
|
|
22
|
+
"@deepseek-ai/dsh-client-ui-theme": "^0.1.6-alpha.2",
|
|
23
|
+
"@deepseek-ai/dsh-client-ui-tool": "^0.1.6-alpha.2",
|
|
24
|
+
"@deepseek-ai/dsh-client-ui-workspace": "^0.1.6-alpha.2",
|
|
25
|
+
"@deepseek-ai/dsh-session": "^0.1.6-alpha.2",
|
|
22
26
|
"@types/react": "^18.3.0",
|
|
23
27
|
"esbuild": "^0.25.0",
|
|
24
|
-
"react": "^18.3.0"
|
|
25
|
-
"@aipanel/core": "1.2.22"
|
|
28
|
+
"react": "^18.3.0"
|
|
26
29
|
},
|
|
27
30
|
"exports": {
|
|
28
31
|
".": "./lib/index.js",
|
|
@@ -36,7 +39,8 @@
|
|
|
36
39
|
"slots",
|
|
37
40
|
"sessions",
|
|
38
41
|
"inputTriggers",
|
|
39
|
-
"conversation"
|
|
42
|
+
"conversation",
|
|
43
|
+
"uiWorkspace"
|
|
40
44
|
]
|
|
41
45
|
}
|
|
42
46
|
},
|