dsh-sessions-manager 3.7.5 → 3.7.7
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/assets/screenshot-dark-controls.png +0 -0
- package/assets/screenshot-id-copied.png +0 -0
- package/assets/screenshot-id-idle.png +0 -0
- package/lib/client.js +341 -27
- package/lib/client.js.map +2 -2
- package/lib/index.js +1 -1
- package/package.json +1 -1
- package/src/client/index.jsx +356 -33
- package/src/client/logic.js +93 -0
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/lib/client.js
CHANGED
|
@@ -314,6 +314,61 @@ function filterShapeFromSaved(item) {
|
|
|
314
314
|
if (tag === "" && f.tag !== "") degraded.push("tag");
|
|
315
315
|
return { view, workspace, sort, tag, degraded };
|
|
316
316
|
}
|
|
317
|
+
function remainingRows(visibleTotal, renderedVisible) {
|
|
318
|
+
if (visibleTotal == null || visibleTotal === "") return null;
|
|
319
|
+
const total = Number(visibleTotal);
|
|
320
|
+
if (!Number.isFinite(total)) return null;
|
|
321
|
+
const shown = Number(renderedVisible);
|
|
322
|
+
const shownCount = Number.isFinite(shown) ? Math.max(0, Math.floor(shown)) : 0;
|
|
323
|
+
return Math.max(0, Math.max(0, Math.floor(total)) - shownCount);
|
|
324
|
+
}
|
|
325
|
+
function countRenderedVisible(rows, visibleIds) {
|
|
326
|
+
if (!Array.isArray(rows) || !visibleIds || typeof visibleIds.has !== "function") return 0;
|
|
327
|
+
let n = 0;
|
|
328
|
+
for (const row of rows) {
|
|
329
|
+
if (!row || row.pluginHidden) continue;
|
|
330
|
+
if (row.id && visibleIds.has(row.id)) n++;
|
|
331
|
+
}
|
|
332
|
+
return n;
|
|
333
|
+
}
|
|
334
|
+
function aliveSessionCount(sessions, hiddenIds) {
|
|
335
|
+
if (!Array.isArray(sessions) || !sessions.length) return null;
|
|
336
|
+
let alive = 0;
|
|
337
|
+
let seen = 0;
|
|
338
|
+
for (const node of sessions) {
|
|
339
|
+
if (!node || node.id == null) continue;
|
|
340
|
+
const id = String(node.id);
|
|
341
|
+
if (!id) continue;
|
|
342
|
+
seen++;
|
|
343
|
+
if (node.blank) continue;
|
|
344
|
+
if (hiddenIds && typeof hiddenIds.has === "function" && hiddenIds.has(id)) continue;
|
|
345
|
+
alive++;
|
|
346
|
+
}
|
|
347
|
+
return seen === 0 ? null : alive;
|
|
348
|
+
}
|
|
349
|
+
function overflowPlan(text, more) {
|
|
350
|
+
const raw = typeof text === "string" ? text : "";
|
|
351
|
+
const unknown = more == null || !Number.isFinite(Number(more));
|
|
352
|
+
const remaining = unknown ? 0 : Math.max(0, Math.floor(Number(more)));
|
|
353
|
+
const m = raw.match(/(\d[\d,]*)/);
|
|
354
|
+
const base = m ? Number(m[1].replace(/,/g, "")) : null;
|
|
355
|
+
if (base === null || unknown) {
|
|
356
|
+
return { text: raw, hide: false, base, more: unknown ? null : remaining, changed: false };
|
|
357
|
+
}
|
|
358
|
+
if (remaining === 0) {
|
|
359
|
+
return { text: raw, hide: base > 0, base, more: 0, changed: false };
|
|
360
|
+
}
|
|
361
|
+
if (remaining === base) {
|
|
362
|
+
return { text: raw, hide: false, base, more: remaining, changed: false };
|
|
363
|
+
}
|
|
364
|
+
return {
|
|
365
|
+
text: raw.slice(0, m.index) + String(remaining) + raw.slice(m.index + m[1].length),
|
|
366
|
+
hide: false,
|
|
367
|
+
base,
|
|
368
|
+
more: remaining,
|
|
369
|
+
changed: true
|
|
370
|
+
};
|
|
371
|
+
}
|
|
317
372
|
|
|
318
373
|
// src/client/index.jsx
|
|
319
374
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
@@ -327,6 +382,21 @@ function loadPanelPrefs() {
|
|
|
327
382
|
}
|
|
328
383
|
}
|
|
329
384
|
var CSS = `
|
|
385
|
+
/* \u517C\u5BB9 shim\uFF082026-09-30 \u5BF9 0.2.0-rc.2 \u5B9E\u6D4B\uFF09\uFF1A\u5F53\u524D runtime \u7684\u8BBE\u8BA1\u4EE4\u724C\u4E0D\u518D\u63D0\u4F9B
|
|
386
|
+
fill-elevated / fill-subtle / fill-secondary / label-inverted / state-warning-primary
|
|
387
|
+
\u8FD9\u51E0\u4E2A alias\uFF0C\u7F3A\u4F4D\u4F1A\u8BA9\u8F93\u5165\u6846\u3001\u4E0B\u62C9\u6846\u3001\u5361\u7247\u3001\u5FBD\u6807\u6574\u4F53\u56DE\u9000\u6210\u900F\u660E\u3002\u8FD9\u91CC\u628A\u5B83\u4EEC\u91CD\u6620\u5C04
|
|
388
|
+
\u5230 runtime \u73B0\u6709 token\uFF08\u5B98\u65B9 Input/Pill \u5206\u522B\u7528 bg-layer-1 / bg-layer-2\uFF09\u3002\u9009\u62E9\u5668\u7528
|
|
389
|
+
:where(:root)\uFF08\u96F6\u7279\u5F02\u6027\uFF09\uFF1Aruntime \u5C06\u6765\u6062\u590D\u5B98\u65B9\u5B9A\u4E49\u65F6\u81EA\u52A8\u80DC\u51FA\uFF0Cshim \u53EA\u5728\u7F3A\u4F4D\u65F6\u515C\u5E95\u3002
|
|
390
|
+
state-warning-primary \u662F\u65E7\u540D\uFF0C\u73B0\u540D\u4E3A state-warn-primary\u3002 */
|
|
391
|
+
:where(:root){--dsw-alias-fill-elevated:var(--dsw-alias-bg-layer-2);--dsw-alias-fill-subtle:var(--dsw-alias-bg-layer-1);--dsw-alias-fill-secondary:var(--dsw-alias-bg-layer-2);--dsw-alias-label-inverted:var(--dsw-alias-label-primary-foreground);--dsw-alias-state-warning-primary:var(--dsw-alias-state-warn-primary)}
|
|
392
|
+
/* \u539F\u751F <select> \u7684\u5F39\u51FA\u5217\u8868\u7531 Chromium \u6309 color-scheme \u7ED8\u5236\uFF0C\u4E0D\u58F0\u660E\u65F6\u6697\u8272\u4E3B\u9898\u4E0B
|
|
393
|
+
\u4ECD\u662F\u767D\u5E95\uFF0C\u53E0\u52A0\u672A\u9002\u914D\u7684\u6587\u5B57\u8272\u5BFC\u81F4\u4E0D\u53EF\u8BFB\uFF1B\u8DDF\u968F DSH \u7684\u6697\u8272\u4E3B\u9898\u6807\u8BB0\u5207\u6362\u3002 */
|
|
394
|
+
.archv{color-scheme:light}
|
|
395
|
+
body[data-ds-dark-theme] .archv{color-scheme:dark}
|
|
396
|
+
/* \u515C\u5E95\uFF1A\u539F\u751F\u5F39\u5C42\u884C\u7684\u914D\u8272\u76F4\u63A5\u5199\u5728 option \u4E0A\uFF08Chromium \u6309 option \u81EA\u8EAB\u7684
|
|
397
|
+
background/color \u7ED8\u5236\u5F39\u5C42\uFF09\uFF0C\u5373\u4F7F color-scheme \u5224\u5B9A\u88AB\u6269\u5C55\u6216\u73AF\u5883\u5E72\u6270\uFF0C
|
|
398
|
+
\u6697\u8272\u4E0B\u4E5F\u4E0D\u4F1A\u51FA\u73B0\u767D\u5E95\u914D\u6D45\u8272\u6587\u5B57\u7684\u4E0D\u53EF\u8BFB\u7EC4\u5408\u3002 */
|
|
399
|
+
.archv option{background:var(--dsw-alias-bg-layer-2);color:var(--dsw-alias-label-primary)}
|
|
330
400
|
.archv{--dsm-radius-tag:9px;--dsm-radius-ctl:9px;--dsm-radius-sheet:10px;--dsm-radius-card:12px;display:flex;flex-direction:column;gap:4px;max-width:800px;padding:8px 2px 28px}
|
|
331
401
|
.archv-head{display:flex;align-items:center;gap:10px;margin:0 0 2px}
|
|
332
402
|
.archv-title{font-size:16px;font-weight:650;color:var(--dsw-alias-label-primary);letter-spacing:-0.01em;margin:0}
|
|
@@ -403,7 +473,9 @@ var CSS = `
|
|
|
403
473
|
\u5206\u652F\uFF08\u7EFF\uFF09/\u7A7A\u767D\uFF08\u7070\uFF09\uFF0C\u540D\u5B57\u8D85\u957F\u7701\u7565\u53F7\uFF1B+N \u8BA1\u6570 chip \u4E2D\u6027\u8272\u3002 */
|
|
404
474
|
.dsm-tagchip{display:inline-flex;align-items:center;flex:none;max-width:9em;min-height:22px;padding:0 8px;border:1px solid color-mix(in srgb,var(--dsw-alias-state-warn-primary,#EAB308) 45%,transparent);border-radius:var(--dsm-radius-tag);background:color-mix(in srgb,var(--dsw-alias-state-warn-primary,#EAB308) 10%,transparent);color:var(--dsw-alias-label-secondary);font-size:11px;font-weight:500;line-height:1;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
405
475
|
.dsm-tagchip-more{max-width:none;color:var(--dsw-alias-label-tertiary);border-color:var(--dsw-alias-border-l2);background:var(--dsw-alias-fill-subtle)}
|
|
406
|
-
.archv-id{font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:10.5px;color:var(--dsw-alias-label-tertiary);flex:none;margin-left:auto;white-space:nowrap}
|
|
476
|
+
.archv-id{appearance:none;border:none;background:none;padding:0;font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;font-size:10.5px;color:var(--dsw-alias-label-tertiary);flex:none;margin-left:auto;white-space:nowrap;cursor:pointer;transition:color .12s ease}
|
|
477
|
+
.archv-id:hover{color:var(--dsw-alias-label-secondary)}
|
|
478
|
+
.archv-id-copied{color:var(--dsw-alias-state-business-primary)}
|
|
407
479
|
.archv-dot{color:var(--dsw-alias-border-l3);flex:none}
|
|
408
480
|
.archv-check{width:15px;height:15px;accent-color:var(--dsw-alias-state-business-primary);flex:none;cursor:pointer}
|
|
409
481
|
.archv-star{appearance:none;width:22px;height:22px;flex:none;display:inline-flex;align-items:center;justify-content:center;border:none;background:0 0;padding:0;line-height:0;color:var(--dsw-alias-label-tertiary);cursor:pointer;border-radius:50%;transition:color .15s ease,transform .12s ease}
|
|
@@ -1093,6 +1165,34 @@ function SessionPanel({ workspacesSvc }) {
|
|
|
1093
1165
|
}
|
|
1094
1166
|
}
|
|
1095
1167
|
};
|
|
1168
|
+
const copiedTimer = (0, import_react.useRef)(null);
|
|
1169
|
+
const [copiedId, setCopiedId] = (0, import_react.useState)(null);
|
|
1170
|
+
const copySessionId = (id) => {
|
|
1171
|
+
const markCopied = () => {
|
|
1172
|
+
setCopiedId(id);
|
|
1173
|
+
if (copiedTimer.current) clearTimeout(copiedTimer.current);
|
|
1174
|
+
copiedTimer.current = setTimeout(() => setCopiedId(null), 1400);
|
|
1175
|
+
};
|
|
1176
|
+
const viaExecCommand = () => {
|
|
1177
|
+
try {
|
|
1178
|
+
const ta = document.createElement("textarea");
|
|
1179
|
+
ta.value = id;
|
|
1180
|
+
ta.setAttribute("readonly", "");
|
|
1181
|
+
ta.style.cssText = "position:fixed;left:-9999px;top:0;opacity:0";
|
|
1182
|
+
document.body.appendChild(ta);
|
|
1183
|
+
ta.select();
|
|
1184
|
+
const ok = document.execCommand("copy");
|
|
1185
|
+
ta.remove();
|
|
1186
|
+
if (ok) markCopied();
|
|
1187
|
+
else showToast("\u590D\u5236\u5931\u8D25\uFF0C\u5B8C\u6574 ID\uFF1A" + id, "err");
|
|
1188
|
+
} catch (e) {
|
|
1189
|
+
showToast("\u590D\u5236\u5931\u8D25\uFF0C\u5B8C\u6574 ID\uFF1A" + id, "err");
|
|
1190
|
+
}
|
|
1191
|
+
};
|
|
1192
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
1193
|
+
navigator.clipboard.writeText(id).then(markCopied).catch(viaExecCommand);
|
|
1194
|
+
} else viaExecCommand();
|
|
1195
|
+
};
|
|
1096
1196
|
const refresh = () => {
|
|
1097
1197
|
setError(null);
|
|
1098
1198
|
Promise.all([
|
|
@@ -2378,7 +2478,10 @@ function SessionPanel({ workspacesSvc }) {
|
|
|
2378
2478
|
tagChips(it.sessionId),
|
|
2379
2479
|
kidsBadge(it.sessionId),
|
|
2380
2480
|
branchGroupBadge(it.sessionId),
|
|
2381
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("
|
|
2481
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", { type: "button", className: "archv-id" + (copiedId === it.sessionId ? " archv-id-copied" : ""), title: it.sessionId + "\uFF08\u70B9\u51FB\u590D\u5236\u5B8C\u6574 ID\uFF09", "aria-label": "\u590D\u5236\u4F1A\u8BDD ID " + it.sessionId, onClick: (e) => {
|
|
2482
|
+
e.stopPropagation();
|
|
2483
|
+
copySessionId(it.sessionId);
|
|
2484
|
+
}, children: copiedId === it.sessionId ? "\u5DF2\u590D\u5236" : shortId(it.sessionId) })
|
|
2382
2485
|
] }),
|
|
2383
2486
|
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "archv-meta", children: [
|
|
2384
2487
|
it.archived ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "archv-wtag archv-wgone", children: "\u5DF2\u5F52\u6863" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { className: "archv-wtag archv-active", children: "\u6D3B\u52A8" }),
|
|
@@ -2719,7 +2822,7 @@ var SIDEBAR_AUG_CSS = `
|
|
|
2719
2822
|
.dsm-toast{position:fixed;bottom:20px;left:50%;transform:translateX(-50%);z-index:2147483601;background:Canvas;color:CanvasText;border:1px solid color-mix(in srgb,CanvasText 25%,transparent);padding:9px 16px;border-radius:999px;font-size:12px;box-shadow:0 8px 24px rgb(0 0 0/.25);max-width:min(92vw,460px);cursor:pointer}
|
|
2720
2823
|
.dsm-toast-long{border-radius:14px;text-align:left;line-height:18px}
|
|
2721
2824
|
.dsm-toast-err{background:#4A1D1D;color:#FFD9D9;border:1px solid var(--dsw-alias-state-error-primary)}
|
|
2722
|
-
.dsm-sub{position:fixed;z-index:1100;box-sizing:border-box;min-width:190px;max-width:320px;padding:4px;display:flex;flex-direction:column;gap:0;background:var(--dsw-specific-menu);border:1px solid var(--dsw-alias-border-inverted);border-radius:12px;box-shadow:var(--dsw-shadow-lv3)}
|
|
2825
|
+
.dsm-sub{position:fixed;z-index:1100;box-sizing:border-box;min-width:190px;max-width:320px;padding:4px;display:flex;flex-direction:column;gap:0;background:var(--dsw-specific-menu);backdrop-filter:var(--dsw-menu-backdrop-filter,blur(40px) saturate(150%));border:1px solid var(--dsw-alias-border-inverted);border-radius:12px;box-shadow:var(--dsw-shadow-lv3)}
|
|
2723
2826
|
.dsm-sub-loading,.dsm-sub-empty{font-size:12px;color:var(--dsw-alias-label-tertiary);padding:6px 10px}
|
|
2724
2827
|
.dsm-sub-err{font-size:12px;color:var(--dsw-alias-state-error-primary);padding:6px 10px}
|
|
2725
2828
|
.dsm-sub-item{display:flex;align-items:center;gap:8px;width:100%;min-height:36px;padding:6px 10px;border:none;border-radius:8px;background:transparent;cursor:pointer;font-size:13px;line-height:18px;color:var(--dsw-alias-label-primary);text-align:left}
|
|
@@ -2965,6 +3068,22 @@ function dsmTeardownSidebarAug() {
|
|
|
2965
3068
|
} catch (e) {
|
|
2966
3069
|
}
|
|
2967
3070
|
}
|
|
3071
|
+
try {
|
|
3072
|
+
document.querySelectorAll("[data-dsm-hidden]").forEach((row) => {
|
|
3073
|
+
row.style.display = "";
|
|
3074
|
+
row.removeAttribute("data-dsm-hidden");
|
|
3075
|
+
});
|
|
3076
|
+
document.querySelectorAll("[data-dsm-overflow-hidden], [data-dsm-overflow-base]").forEach((btn) => {
|
|
3077
|
+
const base = btn.getAttribute("data-dsm-overflow-base");
|
|
3078
|
+
if (base != null && btn.textContent !== base) btn.textContent = base;
|
|
3079
|
+
btn.style.display = "";
|
|
3080
|
+
btn.removeAttribute("data-dsm-overflow-hidden");
|
|
3081
|
+
btn.removeAttribute("data-dsm-overflow-base");
|
|
3082
|
+
btn.removeAttribute("data-dsm-overflow-write");
|
|
3083
|
+
btn.removeAttribute("data-dsm-overflow-ver");
|
|
3084
|
+
});
|
|
3085
|
+
} catch (e) {
|
|
3086
|
+
}
|
|
2968
3087
|
try {
|
|
2969
3088
|
document.querySelectorAll("[data-dsm-group-hidden]").forEach((owner) => {
|
|
2970
3089
|
owner.style.display = owner.dataset.dsmPrevDisplay || "";
|
|
@@ -3006,13 +3125,25 @@ function createSidebarAdapter() {
|
|
|
3006
3125
|
}
|
|
3007
3126
|
return out;
|
|
3008
3127
|
};
|
|
3128
|
+
const recognizeGroupQuiet = (row) => {
|
|
3129
|
+
if (disabled || !row || typeof row !== "object") return null;
|
|
3130
|
+
let f = findFiber(row);
|
|
3131
|
+
let guard = 0;
|
|
3132
|
+
while (f && guard++ < 300) {
|
|
3133
|
+
const props = f.memoizedProps;
|
|
3134
|
+
if (props && props.group && typeof props.group === "object") return props.group;
|
|
3135
|
+
f = f.return;
|
|
3136
|
+
}
|
|
3137
|
+
return null;
|
|
3138
|
+
};
|
|
3009
3139
|
return {
|
|
3010
3140
|
version: SIDEBAR_ADAPTER_VERSION,
|
|
3011
3141
|
get disabled() {
|
|
3012
3142
|
return disabled;
|
|
3013
3143
|
},
|
|
3014
3144
|
findFiber,
|
|
3015
|
-
recognize
|
|
3145
|
+
recognize,
|
|
3146
|
+
recognizeGroupQuiet
|
|
3016
3147
|
};
|
|
3017
3148
|
}
|
|
3018
3149
|
var sidebarAdapter = createSidebarAdapter();
|
|
@@ -3289,6 +3420,21 @@ function installSidebarSessionMenuAug() {
|
|
|
3289
3420
|
function installSidebarStatusDots() {
|
|
3290
3421
|
if (typeof document === "undefined") return;
|
|
3291
3422
|
const DOT = "data-dsm-dot";
|
|
3423
|
+
const DSM_HIDDEN_ATTR = "data-dsm-hidden";
|
|
3424
|
+
const GROUP_UNIT_ATTR = "data-dsm-group-hidden";
|
|
3425
|
+
const DSM_OVERFLOW_BASE = "data-dsm-overflow-base";
|
|
3426
|
+
const DSM_OVERFLOW_WRITE = "data-dsm-overflow-write";
|
|
3427
|
+
const DSM_OVERFLOW_VER = "data-dsm-overflow-ver";
|
|
3428
|
+
const DSM_OVERFLOW_HIDDEN = "data-dsm-overflow-hidden";
|
|
3429
|
+
let overflowDebugged = false;
|
|
3430
|
+
const debugOverflowOnce = (msg) => {
|
|
3431
|
+
if (overflowDebugged) return;
|
|
3432
|
+
overflowDebugged = true;
|
|
3433
|
+
try {
|
|
3434
|
+
console.debug("[dsh-sessions-manager] \u5C55\u5F00\u8BA1\u6570\uFF1A" + msg);
|
|
3435
|
+
} catch (e) {
|
|
3436
|
+
}
|
|
3437
|
+
};
|
|
3292
3438
|
if (!document.querySelector("style[data-dsm=aug]")) {
|
|
3293
3439
|
const s = document.createElement("style");
|
|
3294
3440
|
s.dataset.dsm = "aug";
|
|
@@ -3319,36 +3465,200 @@ function installSidebarStatusDots() {
|
|
|
3319
3465
|
};
|
|
3320
3466
|
const manualUnread = dsmLoadManual();
|
|
3321
3467
|
const titleBaselines = /* @__PURE__ */ new WeakMap();
|
|
3322
|
-
|
|
3323
|
-
|
|
3468
|
+
const setGroupHidden = (scope, hidden) => {
|
|
3469
|
+
if (hidden) {
|
|
3470
|
+
if (!scope.hasAttribute(GROUP_UNIT_ATTR)) {
|
|
3471
|
+
scope.dataset.dsmPrevDisplay = scope.style.display || "";
|
|
3472
|
+
scope.setAttribute(GROUP_UNIT_ATTR, "");
|
|
3473
|
+
}
|
|
3474
|
+
if (scope.style.display !== "none") scope.style.display = "none";
|
|
3475
|
+
return;
|
|
3476
|
+
}
|
|
3477
|
+
if (!scope.hasAttribute(GROUP_UNIT_ATTR)) return;
|
|
3478
|
+
const prev = scope.dataset.dsmPrevDisplay || "";
|
|
3479
|
+
if (scope.style.display !== prev) scope.style.display = prev;
|
|
3480
|
+
scope.removeAttribute(GROUP_UNIT_ATTR);
|
|
3481
|
+
delete scope.dataset.dsmPrevDisplay;
|
|
3482
|
+
};
|
|
3483
|
+
const isShownWithin = (el, stopAt) => {
|
|
3484
|
+
let node = el;
|
|
3485
|
+
while (node && node !== stopAt) {
|
|
3486
|
+
if (node.style && node.style.display === "none") return false;
|
|
3487
|
+
if (node.hasAttribute && (node.hasAttribute(GROUP_UNIT_ATTR) || node.hasAttribute(DSM_HIDDEN_ATTR))) return false;
|
|
3488
|
+
node = node.parentElement;
|
|
3489
|
+
}
|
|
3490
|
+
return true;
|
|
3491
|
+
};
|
|
3492
|
+
function dsmSyncEmptyGroups(purgedNow) {
|
|
3493
|
+
let rows = null;
|
|
3324
3494
|
try {
|
|
3325
|
-
|
|
3495
|
+
rows = document.querySelectorAll('[role="treeitem"][data-row-key^="workspace:"]');
|
|
3326
3496
|
} catch (e) {
|
|
3327
3497
|
return;
|
|
3328
3498
|
}
|
|
3329
|
-
if (!
|
|
3330
|
-
|
|
3331
|
-
|
|
3332
|
-
|
|
3333
|
-
|
|
3334
|
-
|
|
3335
|
-
|
|
3336
|
-
|
|
3337
|
-
const
|
|
3338
|
-
|
|
3339
|
-
|
|
3340
|
-
|
|
3341
|
-
|
|
3499
|
+
if (!rows || !rows.length) return;
|
|
3500
|
+
const purged = purgedNow instanceof Set ? purgedNow : /* @__PURE__ */ new Set();
|
|
3501
|
+
let hiddenIds = null;
|
|
3502
|
+
const hiddenIdSet = () => {
|
|
3503
|
+
if (hiddenIds) return hiddenIds;
|
|
3504
|
+
hiddenIds = /* @__PURE__ */ new Set();
|
|
3505
|
+
if (dsmTrashIds) for (const id of dsmTrashIds) hiddenIds.add(id);
|
|
3506
|
+
for (const id of purged) hiddenIds.add(id);
|
|
3507
|
+
for (const [id, info] of dsmLineage.entries()) if (info && info.empty) hiddenIds.add(id);
|
|
3508
|
+
return hiddenIds;
|
|
3509
|
+
};
|
|
3510
|
+
rows.forEach((row) => {
|
|
3511
|
+
try {
|
|
3512
|
+
const scope = row.parentElement;
|
|
3513
|
+
if (!scope || scope === document.body) return;
|
|
3514
|
+
if (typeof scope.getAttribute !== "function" || scope.getAttribute("role")) return;
|
|
3515
|
+
let rendered = 0;
|
|
3516
|
+
for (const el of scope.children) {
|
|
3517
|
+
if (el === row || !el.getAttribute) continue;
|
|
3518
|
+
if (el.getAttribute("role") !== "treeitem") continue;
|
|
3519
|
+
if (!(el.getAttribute("data-row-key") || "").startsWith("session:")) continue;
|
|
3520
|
+
if (el.hasAttribute(DSM_HIDDEN_ATTR)) continue;
|
|
3521
|
+
rendered++;
|
|
3522
|
+
}
|
|
3523
|
+
if (rendered > 0) {
|
|
3524
|
+
setGroupHidden(scope, false);
|
|
3525
|
+
return;
|
|
3526
|
+
}
|
|
3527
|
+
for (const nested of scope.querySelectorAll('[data-row-key^="workspace:"]')) {
|
|
3528
|
+
if (nested === row) continue;
|
|
3529
|
+
if (!isShownWithin(nested, scope)) continue;
|
|
3530
|
+
setGroupHidden(scope, false);
|
|
3531
|
+
return;
|
|
3342
3532
|
}
|
|
3343
|
-
|
|
3344
|
-
|
|
3345
|
-
|
|
3346
|
-
|
|
3347
|
-
owner.removeAttribute("data-dsm-group-hidden");
|
|
3348
|
-
delete owner.dataset.dsmPrevDisplay;
|
|
3533
|
+
const group = sidebarAdapter.recognizeGroupQuiet(row);
|
|
3534
|
+
const sessions = group && Array.isArray(group.sessions) ? group.sessions : null;
|
|
3535
|
+
setGroupHidden(scope, aliveSessionCount(sessions, hiddenIdSet()) === 0);
|
|
3536
|
+
} catch (e) {
|
|
3349
3537
|
}
|
|
3350
3538
|
});
|
|
3351
3539
|
}
|
|
3540
|
+
const OVERFLOW_SIGS = /* @__PURE__ */ new WeakMap();
|
|
3541
|
+
const overflowSignature = (scope, btn, purgedNow) => {
|
|
3542
|
+
let n = 0;
|
|
3543
|
+
let firstKey = "";
|
|
3544
|
+
let lastKey = "";
|
|
3545
|
+
for (const el of scope.children) {
|
|
3546
|
+
if (el === btn || !el.getAttribute) continue;
|
|
3547
|
+
const k = el.getAttribute("data-row-key") || "";
|
|
3548
|
+
if (!k.startsWith("session:")) continue;
|
|
3549
|
+
if (el.hasAttribute(DSM_HIDDEN_ATTR)) continue;
|
|
3550
|
+
n++;
|
|
3551
|
+
if (!firstKey) firstKey = k;
|
|
3552
|
+
lastKey = k;
|
|
3553
|
+
}
|
|
3554
|
+
return n + "|" + firstKey + "|" + lastKey + "|" + (btn.textContent || "") + "|" + (btn.style.display || "") + "|" + (dsmTrashIds ? dsmTrashIds.size : -1) + "|" + purgedNow.size + "|" + dsmLineage.size;
|
|
3555
|
+
};
|
|
3556
|
+
function dsmSyncOverflowLabels(purgedNow) {
|
|
3557
|
+
let buttons = null;
|
|
3558
|
+
try {
|
|
3559
|
+
buttons = document.querySelectorAll('[data-row-key^="overflow:"]');
|
|
3560
|
+
} catch (e) {
|
|
3561
|
+
return;
|
|
3562
|
+
}
|
|
3563
|
+
if (!buttons || !buttons.length) return;
|
|
3564
|
+
try {
|
|
3565
|
+
buttons.forEach((btn) => {
|
|
3566
|
+
const scope = btn.parentElement;
|
|
3567
|
+
if (!scope || !scope.children) return;
|
|
3568
|
+
const sig = overflowSignature(scope, btn, purgedNow);
|
|
3569
|
+
if (OVERFLOW_SIGS.get(btn) === sig) return;
|
|
3570
|
+
const key = (btn.getAttribute("data-row-key") || "").slice("overflow:".length);
|
|
3571
|
+
let wsRow = null;
|
|
3572
|
+
for (const el of scope.children) {
|
|
3573
|
+
if (el.getAttribute && el.getAttribute("data-row-key") === "workspace:" + key) {
|
|
3574
|
+
wsRow = el;
|
|
3575
|
+
break;
|
|
3576
|
+
}
|
|
3577
|
+
}
|
|
3578
|
+
const group = wsRow ? sidebarAdapter.recognizeGroupQuiet(wsRow) : null;
|
|
3579
|
+
const nodes = group && Array.isArray(group.sessions) ? group.sessions : null;
|
|
3580
|
+
if (!nodes) {
|
|
3581
|
+
restoreOverflowButton(btn);
|
|
3582
|
+
OVERFLOW_SIGS.set(btn, overflowSignature(scope, btn, purgedNow));
|
|
3583
|
+
return;
|
|
3584
|
+
}
|
|
3585
|
+
const ids = /* @__PURE__ */ new Set();
|
|
3586
|
+
for (const node of nodes) {
|
|
3587
|
+
if (!node || node.blank) continue;
|
|
3588
|
+
const id = node.id != null ? String(node.id) : "";
|
|
3589
|
+
if (!id) continue;
|
|
3590
|
+
if (dsmTrashIds && dsmTrashIds.has(id) || purgedNow.has(id)) continue;
|
|
3591
|
+
const li = dsmLineage.get(id);
|
|
3592
|
+
if (li && li.empty) continue;
|
|
3593
|
+
ids.add(id);
|
|
3594
|
+
}
|
|
3595
|
+
const rendered = [];
|
|
3596
|
+
for (const el of scope.children) {
|
|
3597
|
+
if (el === btn || !el.getAttribute) continue;
|
|
3598
|
+
if (el.getAttribute("role") !== "treeitem") continue;
|
|
3599
|
+
const k = el.getAttribute("data-row-key") || "";
|
|
3600
|
+
if (!k.startsWith("session:")) continue;
|
|
3601
|
+
rendered.push({ id: k.slice("session:".length), pluginHidden: el.hasAttribute(DSM_HIDDEN_ATTR) });
|
|
3602
|
+
}
|
|
3603
|
+
if (!nodes.length || !ids.size && rendered.length) {
|
|
3604
|
+
restoreOverflowButton(btn);
|
|
3605
|
+
OVERFLOW_SIGS.set(btn, overflowSignature(scope, btn, purgedNow));
|
|
3606
|
+
return;
|
|
3607
|
+
}
|
|
3608
|
+
const renderedVisible = countRenderedVisible(rendered, ids);
|
|
3609
|
+
const more = remainingRows(ids.size, renderedVisible);
|
|
3610
|
+
applyOverflowPlan(btn, more, "\u53EF\u89C1 " + ids.size + " / \u5DF2\u6E32\u67D3 " + renderedVisible);
|
|
3611
|
+
OVERFLOW_SIGS.set(btn, overflowSignature(scope, btn, purgedNow));
|
|
3612
|
+
});
|
|
3613
|
+
} catch (e) {
|
|
3614
|
+
try {
|
|
3615
|
+
console.debug("[dsh-sessions-manager] \u5C55\u5F00\u8BA1\u6570\u6821\u51C6\u8DF3\u8FC7\uFF1A" + (e && e.message));
|
|
3616
|
+
} catch (e2) {
|
|
3617
|
+
}
|
|
3618
|
+
}
|
|
3619
|
+
}
|
|
3620
|
+
function applyOverflowPlan(btn, more, detail) {
|
|
3621
|
+
const raw = btn.textContent || "";
|
|
3622
|
+
const ver = String(SIDEBAR_ADAPTER_VERSION);
|
|
3623
|
+
const fresh = btn.getAttribute(DSM_OVERFLOW_VER) === ver;
|
|
3624
|
+
const last = fresh ? btn.getAttribute(DSM_OVERFLOW_WRITE) : null;
|
|
3625
|
+
let baseline = fresh ? btn.getAttribute(DSM_OVERFLOW_BASE) : null;
|
|
3626
|
+
if (baseline == null || raw !== last) baseline = raw;
|
|
3627
|
+
btn.setAttribute(DSM_OVERFLOW_BASE, baseline);
|
|
3628
|
+
btn.setAttribute(DSM_OVERFLOW_VER, ver);
|
|
3629
|
+
const bm = baseline.match(/(\d[\d,]*)/);
|
|
3630
|
+
const upstream = bm ? Number(bm[1].replace(/,/g, "")) : null;
|
|
3631
|
+
if (more != null && upstream != null && upstream > 0 && more > upstream) {
|
|
3632
|
+
more = upstream;
|
|
3633
|
+
debugOverflowOnce((detail || "") + "\uFF0C\u8D85\u8FC7\u4E0A\u6E38\u8BA1\u6570 " + upstream + "\uFF0C\u5DF2\u6309\u4E0A\u6E38\u8BA1\u6570\u6536\u655B");
|
|
3634
|
+
}
|
|
3635
|
+
const plan = overflowPlan(baseline, more);
|
|
3636
|
+
if (plan.hide) {
|
|
3637
|
+
if (btn.style.display !== "none") btn.style.display = "none";
|
|
3638
|
+
if (!btn.hasAttribute(DSM_OVERFLOW_HIDDEN)) btn.setAttribute(DSM_OVERFLOW_HIDDEN, "");
|
|
3639
|
+
btn.setAttribute(DSM_OVERFLOW_WRITE, baseline);
|
|
3640
|
+
return;
|
|
3641
|
+
}
|
|
3642
|
+
if (btn.hasAttribute(DSM_OVERFLOW_HIDDEN)) {
|
|
3643
|
+
btn.style.display = "";
|
|
3644
|
+
btn.removeAttribute(DSM_OVERFLOW_HIDDEN);
|
|
3645
|
+
}
|
|
3646
|
+
if (plan.changed) {
|
|
3647
|
+
if (btn.textContent !== plan.text) btn.textContent = plan.text;
|
|
3648
|
+
btn.setAttribute(DSM_OVERFLOW_WRITE, plan.text);
|
|
3649
|
+
} else {
|
|
3650
|
+
if (btn.textContent !== baseline) btn.textContent = baseline;
|
|
3651
|
+
btn.setAttribute(DSM_OVERFLOW_WRITE, baseline);
|
|
3652
|
+
}
|
|
3653
|
+
}
|
|
3654
|
+
function restoreOverflowButton(btn) {
|
|
3655
|
+
const verbatim = btn.getAttribute(DSM_OVERFLOW_BASE);
|
|
3656
|
+
if (verbatim != null && btn.textContent !== verbatim) btn.textContent = verbatim;
|
|
3657
|
+
if (btn.hasAttribute(DSM_OVERFLOW_HIDDEN)) {
|
|
3658
|
+
btn.style.display = "";
|
|
3659
|
+
btn.removeAttribute(DSM_OVERFLOW_HIDDEN);
|
|
3660
|
+
}
|
|
3661
|
+
}
|
|
3352
3662
|
const paint = () => {
|
|
3353
3663
|
if (sidebarAdapter.disabled) return;
|
|
3354
3664
|
const activeId = activeRowId();
|
|
@@ -3379,6 +3689,7 @@ function installSidebarStatusDots() {
|
|
|
3379
3689
|
const purged = purgedNow;
|
|
3380
3690
|
if (dsmTrashIds && dsmTrashIds.has(id) || purged.has(id)) {
|
|
3381
3691
|
if (row.style.display !== "none") row.style.display = "none";
|
|
3692
|
+
if (row.getAttribute(DSM_HIDDEN_ATTR) !== "trash") row.setAttribute(DSM_HIDDEN_ATTR, "trash");
|
|
3382
3693
|
const d = row.querySelector("[" + DOT + "]");
|
|
3383
3694
|
if (d) d.remove();
|
|
3384
3695
|
dsmDropSubList(row, id);
|
|
@@ -3401,12 +3712,14 @@ function installSidebarStatusDots() {
|
|
|
3401
3712
|
}
|
|
3402
3713
|
if (hideLineage) {
|
|
3403
3714
|
if (row.style.display !== "none") row.style.display = "none";
|
|
3715
|
+
if (row.getAttribute(DSM_HIDDEN_ATTR) !== "empty") row.setAttribute(DSM_HIDDEN_ATTR, "empty");
|
|
3404
3716
|
const d = row.querySelector("[" + DOT + "]");
|
|
3405
3717
|
if (d) d.remove();
|
|
3406
3718
|
dsmDropSubList(row, id);
|
|
3407
3719
|
return;
|
|
3408
3720
|
}
|
|
3409
3721
|
if (row.style.display === "none") row.style.display = "";
|
|
3722
|
+
if (row.hasAttribute(DSM_HIDDEN_ATTR)) row.removeAttribute(DSM_HIDDEN_ATTR);
|
|
3410
3723
|
if (!isEmpty && li && li.parentSession && li.origin !== "subagent") {
|
|
3411
3724
|
const parentTitle = dsmAuthoritativeTitles.get(li.parentSession);
|
|
3412
3725
|
const tip = parentTitle ? "\u5206\u652F\u4E8E\uFF1A" + parentTitle : "\u5206\u652F\u4F1A\u8BDD\uFF08\u70B9\u51FB\u67E5\u770B\u6765\u6E90\u4F1A\u8BDD\uFF09";
|
|
@@ -3533,7 +3846,8 @@ function installSidebarStatusDots() {
|
|
|
3533
3846
|
}
|
|
3534
3847
|
dot.style.background = color;
|
|
3535
3848
|
});
|
|
3536
|
-
dsmSyncEmptyGroups();
|
|
3849
|
+
dsmSyncEmptyGroups(purgedNow);
|
|
3850
|
+
dsmSyncOverflowLabels(purgedNow);
|
|
3537
3851
|
};
|
|
3538
3852
|
dsmRepaintDots = paint;
|
|
3539
3853
|
const paintToast = (msg, kind) => {
|