dsh-auto-compaction 0.2.0 → 0.2.1
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 +91 -10
- package/lib/index.js +1 -1
- package/package.json +2 -2
package/lib/client.js
CHANGED
|
@@ -41,10 +41,11 @@ window.__ModuleLoader__.load({
|
|
|
41
41
|
{ id: "strip", label: "状态条" },
|
|
42
42
|
{ id: "ring", label: "进度环" },
|
|
43
43
|
{ id: "topbar", label: "顶部条" },
|
|
44
|
+
{ id: "corner", label: "右上角" },
|
|
44
45
|
];
|
|
45
46
|
var EXAMPLE_WINDOW = 250000, EXAMPLE_RESERVED = 20000, EXAMPLE_HEADROOM = 10000;
|
|
46
47
|
|
|
47
|
-
var DISPLAY_STYLES = ["orbit", "strip", "ring", "topbar"];
|
|
48
|
+
var DISPLAY_STYLES = ["orbit", "strip", "ring", "topbar", "corner"];
|
|
48
49
|
var displayStyle = "orbit";
|
|
49
50
|
var displayStyleListeners = [];
|
|
50
51
|
|
|
@@ -103,7 +104,11 @@ window.__ModuleLoader__.load({
|
|
|
103
104
|
var STATUS_MUTED = "var(--dsh-text-secondary, var(--dsw-alias-label-secondary, #9aa0a6))";
|
|
104
105
|
var STATUS_FAINT = "var(--dsh-text-tertiary, var(--dsw-alias-label-tertiary, #7f858c))";
|
|
105
106
|
var STATUS_BORDER = "var(--dsh-border, var(--dsw-alias-border-l2, #2c2e33))";
|
|
106
|
-
|
|
107
|
+
// Opaque elevated surface. The menu token is intentionally translucent
|
|
108
|
+
// (menu layers add their own backdrop blur); the status surfaces must stay
|
|
109
|
+
// readable over live conversation text without a blur.
|
|
110
|
+
var STATUS_SURFACE = "var(--dsw-alias-bg-layer-3, #353638)";
|
|
111
|
+
var STATUS_PANEL = STATUS_SURFACE;
|
|
107
112
|
var STATUS_ACCENT = "var(--dsw-alias-state-business-primary, #4c8dff)";
|
|
108
113
|
var STATUS_SUCCESS = "var(--dsw-alias-state-success-primary, #3fb950)";
|
|
109
114
|
var STATUS_WARN = "var(--dsw-alias-state-warn-primary, #d29922)";
|
|
@@ -166,6 +171,36 @@ window.__ModuleLoader__.load({
|
|
|
166
171
|
return call(connection, "status", { sessionId: sessionId }, 3500);
|
|
167
172
|
}
|
|
168
173
|
|
|
174
|
+
/**
|
|
175
|
+
* Anchor the corner card to the conversation area instead of the window:
|
|
176
|
+
* its top lines up with the first message row (below the 对话/轨迹 tabs) and
|
|
177
|
+
* its right edge keeps the header's inset, so it never covers the tab row.
|
|
178
|
+
* The width shrinks to the gutter between the message column and the window
|
|
179
|
+
* edge when the window is narrow.
|
|
180
|
+
*/
|
|
181
|
+
function cornerPlacement(desiredWidth) {
|
|
182
|
+
var right = (typeof window === "undefined" ? 0 : window.innerWidth) - 20;
|
|
183
|
+
var top = 96;
|
|
184
|
+
var width = desiredWidth;
|
|
185
|
+
try {
|
|
186
|
+
var body = document.querySelector("[data-conversation-content]");
|
|
187
|
+
var br = body && body.getBoundingClientRect();
|
|
188
|
+
if (br && br.height > 80) {
|
|
189
|
+
top = Math.round(br.top) + 8;
|
|
190
|
+
right = Math.round(br.right) - 20;
|
|
191
|
+
}
|
|
192
|
+
var card = document.querySelector("[data-composer-card]");
|
|
193
|
+
var cr = card && card.getBoundingClientRect();
|
|
194
|
+
if (cr && cr.width > 120) {
|
|
195
|
+
var clearance = parseFloat(getComputedStyle(card).getPropertyValue("--dsh-composer-side-clearance")) || 16;
|
|
196
|
+
var columnRight = Math.round(cr.right) - clearance;
|
|
197
|
+
width = Math.max(184, Math.min(desiredWidth, right - columnRight - 10));
|
|
198
|
+
}
|
|
199
|
+
} catch (error) { /* keep the window-corner fallback */ }
|
|
200
|
+
width = Math.max(160, Math.min(width, right - 12));
|
|
201
|
+
return { left: Math.max(8, Math.round(right - width)), top: Math.round(top), width: Math.round(width) };
|
|
202
|
+
}
|
|
203
|
+
|
|
169
204
|
function StatusDock(props) {
|
|
170
205
|
ensureStatusStyles();
|
|
171
206
|
var connection = props.connection;
|
|
@@ -344,7 +379,7 @@ window.__ModuleLoader__.load({
|
|
|
344
379
|
h("span", { style: {
|
|
345
380
|
display: "inline-flex", alignItems: "center", gap: 7, height: 26, padding: "0 11px",
|
|
346
381
|
borderRadius: 999, border: "1px solid " + STATUS_ACCENT,
|
|
347
|
-
background:
|
|
382
|
+
background: STATUS_SURFACE, color: STATUS_TEXT, fontSize: 11, whiteSpace: "nowrap",
|
|
348
383
|
} },
|
|
349
384
|
h("span", { className: "dsh-handoff-pulse", style: { width: 7, height: 7, borderRadius: "50%", background: STATUS_ACCENT } }),
|
|
350
385
|
"压缩中 · " + statusStep(status) + " · " + clockText(startedAt)
|
|
@@ -352,6 +387,43 @@ window.__ModuleLoader__.load({
|
|
|
352
387
|
);
|
|
353
388
|
return ReactDOM.createPortal(h(React.Fragment, null, topLine, pill), document.body);
|
|
354
389
|
}
|
|
390
|
+
if (themeStyle === "corner") {
|
|
391
|
+
var place = cornerPlacement(268);
|
|
392
|
+
return ReactDOM.createPortal(
|
|
393
|
+
h("div", {
|
|
394
|
+
role: "status",
|
|
395
|
+
"aria-live": "polite",
|
|
396
|
+
"data-dsh-handoff-status": "running",
|
|
397
|
+
title: "压缩期间发送的消息会排队",
|
|
398
|
+
style: {
|
|
399
|
+
position: "fixed",
|
|
400
|
+
left: place.left,
|
|
401
|
+
top: place.top,
|
|
402
|
+
zIndex: 70,
|
|
403
|
+
pointerEvents: "none",
|
|
404
|
+
boxSizing: "border-box",
|
|
405
|
+
width: place.width,
|
|
406
|
+
display: "flex",
|
|
407
|
+
alignItems: "flex-start",
|
|
408
|
+
gap: 8,
|
|
409
|
+
padding: "9px 11px",
|
|
410
|
+
borderRadius: 10,
|
|
411
|
+
background: STATUS_SURFACE,
|
|
412
|
+
border: "1px solid " + STATUS_BORDER,
|
|
413
|
+
borderLeft: "2px solid " + STATUS_ACCENT,
|
|
414
|
+
boxShadow: "0 14px 34px rgba(0,0,0,.38)",
|
|
415
|
+
},
|
|
416
|
+
},
|
|
417
|
+
h("span", { className: "dsh-handoff-pulse", style: { width: 8, height: 8, borderRadius: "50%", background: STATUS_ACCENT, flex: "0 0 auto", marginTop: 5 } }),
|
|
418
|
+
h("div", { style: { minWidth: 0, flex: 1 } },
|
|
419
|
+
h("div", { style: { fontSize: 12, fontWeight: 600, color: STATUS_TEXT, lineHeight: "17px", whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, title),
|
|
420
|
+
h("div", { style: { marginTop: 2, fontSize: 10.5, color: STATUS_MUTED, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } },
|
|
421
|
+
clockText(startedAt) + " · " + statusStep(status) + (place.width >= 216 ? " · 消息会排队" : ""))
|
|
422
|
+
)
|
|
423
|
+
),
|
|
424
|
+
document.body
|
|
425
|
+
);
|
|
426
|
+
}
|
|
355
427
|
var indicator = themeStyle === "ring"
|
|
356
428
|
? h("div", { style: { position: "relative", width: 64, height: 64 } },
|
|
357
429
|
h("div", { style: {
|
|
@@ -388,13 +460,13 @@ window.__ModuleLoader__.load({
|
|
|
388
460
|
// scrim here would falsely suggest the conversation is frozen.
|
|
389
461
|
};
|
|
390
462
|
var cardStyle = {
|
|
391
|
-
width:
|
|
463
|
+
width: 264,
|
|
392
464
|
maxWidth: "82%",
|
|
393
|
-
background:
|
|
465
|
+
background: STATUS_SURFACE,
|
|
394
466
|
border: "1px solid " + STATUS_BORDER,
|
|
395
467
|
borderRadius: 14,
|
|
396
468
|
padding: "16px 16px 14px",
|
|
397
|
-
boxShadow: "0
|
|
469
|
+
boxShadow: "0 20px 46px rgba(0,0,0,.45), 0 2px 8px rgba(0,0,0,.3)",
|
|
398
470
|
display: "flex",
|
|
399
471
|
flexDirection: "column",
|
|
400
472
|
alignItems: "center",
|
|
@@ -406,9 +478,9 @@ window.__ModuleLoader__.load({
|
|
|
406
478
|
h("div", { role: "status", "aria-live": "polite", "data-dsh-handoff-status": "running", style: overlayStyle },
|
|
407
479
|
h("div", { style: cardStyle },
|
|
408
480
|
indicator,
|
|
409
|
-
h("div", { style: { fontSize: 12.5, fontWeight:
|
|
481
|
+
h("div", { style: { fontSize: 12.5, fontWeight: 600, color: STATUS_TEXT } }, title),
|
|
410
482
|
h("div", { style: { fontSize: 11, color: STATUS_MUTED } }, cardSub),
|
|
411
|
-
h("div", { style: { fontSize: 10.5, color:
|
|
483
|
+
h("div", { style: { fontSize: 10.5, color: STATUS_MUTED, opacity: 0.85 } }, "完成后整段历史收成一条交接文档")
|
|
412
484
|
)
|
|
413
485
|
),
|
|
414
486
|
document.body
|
|
@@ -429,6 +501,7 @@ window.__ModuleLoader__.load({
|
|
|
429
501
|
borderLeft: "3px solid " + color,
|
|
430
502
|
borderRadius: 8,
|
|
431
503
|
background: STATUS_PANEL,
|
|
504
|
+
boxShadow: "0 8px 22px rgba(0,0,0,.28)",
|
|
432
505
|
color: STATUS_TEXT,
|
|
433
506
|
fontSize: 12,
|
|
434
507
|
lineHeight: "18px",
|
|
@@ -486,7 +559,7 @@ window.__ModuleLoader__.load({
|
|
|
486
559
|
function ThemePreview(props) {
|
|
487
560
|
var style = normalizeDisplayStyle(props.theme);
|
|
488
561
|
var chatChildren = [
|
|
489
|
-
h("div", { key: "user", style: { marginLeft: "auto", maxWidth: "
|
|
562
|
+
h("div", { key: "user", style: { marginLeft: "auto", maxWidth: "62%", border: "1px solid rgba(76,141,255,.24)", background: "rgba(76,141,255,.14)", borderRadius: "7px 7px 2px 7px", padding: "4px 6px", fontSize: 9, color: "#d9dbde" } }, "请完整读取这个文件并总结…"),
|
|
490
563
|
h("div", { key: "lines", style: { display: "flex", flexDirection: "column", gap: 4, marginTop: 6 } },
|
|
491
564
|
h("i", { key: "l1", style: { height: 4, borderRadius: 99, background: C.line } }),
|
|
492
565
|
h("i", { key: "l2", style: { height: 4, borderRadius: 99, background: C.line, width: "88%" } }),
|
|
@@ -525,6 +598,14 @@ window.__ModuleLoader__.load({
|
|
|
525
598
|
)
|
|
526
599
|
)
|
|
527
600
|
);
|
|
601
|
+
} else if (style === "corner") {
|
|
602
|
+
overlay = h("div", { style: { position: "absolute", right: 8, top: 9, boxSizing: "border-box", width: 104, display: "flex", alignItems: "flex-start", gap: 4, padding: "4px 5px", borderRadius: 5, background: "#23252a", border: "1px solid " + C.line, borderLeft: "2px solid " + C.accent } },
|
|
603
|
+
h("span", { className: "dsh-handoff-pulse", style: { width: 4, height: 4, borderRadius: "50%", background: C.accent, marginTop: 4, flex: "0 0 auto" } }),
|
|
604
|
+
h("div", { style: { minWidth: 0 } },
|
|
605
|
+
h("div", { style: { fontSize: 7, fontWeight: 600, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, "正在压缩历史会话"),
|
|
606
|
+
h("div", { style: { fontSize: 6.5, color: C.muted, whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis" } }, "00:42 · 2/3 写文档")
|
|
607
|
+
)
|
|
608
|
+
);
|
|
528
609
|
}
|
|
529
610
|
var strip = style === "strip"
|
|
530
611
|
? h("div", { style: { margin: "0 8px 4px", border: "1px solid " + C.line, borderLeft: "2px solid " + C.accent, borderRadius: 5, background: "#212226", padding: "4px 6px" } },
|
|
@@ -547,7 +628,7 @@ window.__ModuleLoader__.load({
|
|
|
547
628
|
h("span", { style: { marginLeft: "auto", fontSize: 8.5, color: C.muted, border: "1px solid " + C.line, borderRadius: 999, padding: "0 6px" } }, "轻量本地")
|
|
548
629
|
),
|
|
549
630
|
h("div", { style: { flex: 1, minHeight: 0, padding: (style === "topbar" ? 22 : 7) + "px 8px 7px", position: "relative", overflow: "hidden" } },
|
|
550
|
-
style === "topbar" ? overlay : null,
|
|
631
|
+
(style === "topbar" || style === "corner") ? overlay : null,
|
|
551
632
|
chatChildren,
|
|
552
633
|
(style === "ring" || style === "orbit") ? overlay : null
|
|
553
634
|
),
|
package/lib/index.js
CHANGED
|
@@ -60,7 +60,7 @@ function trace(message) {
|
|
|
60
60
|
|
|
61
61
|
let lastOpenRequest = "";
|
|
62
62
|
|
|
63
|
-
const DISPLAY_STYLES = new Set(["orbit", "strip", "ring", "topbar"]);
|
|
63
|
+
const DISPLAY_STYLES = new Set(["orbit", "strip", "ring", "topbar", "corner"]);
|
|
64
64
|
|
|
65
65
|
function normalizeDisplayStyle(value) {
|
|
66
66
|
return typeof value === "string" && DISPLAY_STYLES.has(value) ? value : "orbit";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-auto-compaction",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"exports": {
|
|
@@ -51,6 +51,6 @@
|
|
|
51
51
|
"access": "public"
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
|
-
"dsh-auto-compaction-engine": "^0.2.
|
|
54
|
+
"dsh-auto-compaction-engine": "^0.2.1"
|
|
55
55
|
}
|
|
56
56
|
}
|